From 4475a3c8bcd2f37b4e1f3c4e3acc217b05c78bc8 Mon Sep 17 00:00:00 2001 From: "posthog[bot]" <206114724+posthog[bot]@users.noreply.github.com> Date: Fri, 12 Jun 2026 04:51:50 +0000 Subject: [PATCH] fix(linux): register posthog-code scheme handler in AppImage builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The MakerAppImage config omitted the `mimeType` option that the deb/rpm makers get via `sharedLinuxOptions`, so the generated AppImage `.desktop` file never declared `x-scheme-handler/posthog-code`. Without it, desktop integration can't route the OAuth callback (`posthog-code://callback`) back to the app and login times out, fully blocking AppImage users. Add `mimeType: ["x-scheme-handler/posthog-code"]` to the AppImage maker so the `.desktop` file declares the handler, matching deb/rpm. Also document, where `setAsDefaultProtocolClient` is called, that its `path`/`args` parameters are Windows-only and ignored on Linux — Linux relies on the packaged `.desktop` MimeType — so a future change doesn't try to "fix" AppImage routing by passing an exec path there (a no-op). Generated-By: PostHog Code Task-Id: f86f368b-dc7b-4da3-ba21-997a04b794ff --- apps/code/forge.config.ts | 6 ++++++ .../src/main/platform-adapters/electron-app-lifecycle.ts | 6 ++++++ 2 files changed, 12 insertions(+) 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); } }