diff --git a/apps/code/forge.config.ts b/apps/code/forge.config.ts index af4ba91e7..e25896cb1 100644 --- a/apps/code/forge.config.ts +++ b/apps/code/forge.config.ts @@ -219,6 +219,12 @@ const config: ForgeConfig = { icon: "./build/app-icon.png", categories: ["Development"], bin: "PostHog Code", + // Declare the custom URL scheme handler in the generated .desktop file + // so desktop integration registers x-scheme-handler/posthog-code and + // OAuth callbacks (posthog-code://) can route back to the AppImage. + // The deb/rpm makers get this via sharedLinuxOptions; without it, + // AppImage users cannot complete login. See sharedLinuxOptions.mimeType. + mimeType: ["x-scheme-handler/posthog-code"], }, }), new MakerDeb({ diff --git a/apps/code/src/main/platform-adapters/electron-app-lifecycle.ts b/apps/code/src/main/platform-adapters/electron-app-lifecycle.ts index 94e645be5..be1bf2e97 100644 --- a/apps/code/src/main/platform-adapters/electron-app-lifecycle.ts +++ b/apps/code/src/main/platform-adapters/electron-app-lifecycle.ts @@ -29,6 +29,12 @@ export class ElectronAppLifecycle implements IAppLifecycle { } public registerDeepLinkScheme(scheme: string): void { + // NOTE: setAsDefaultProtocolClient's optional `path`/`args` are Windows-only + // and ignored on Linux/macOS. On Linux, registration relies on the packaged + // .desktop file declaring `MimeType=x-scheme-handler/` so desktop + // integration can route the scheme — see forge.config.ts (the AppImage, + // deb, and rpm makers all set `mimeType`). Passing an AppImage exec path + // here would be a no-op, so it is intentionally omitted. app.setAsDefaultProtocolClient(scheme); } }