Support deep-link protocol registration for AppImage builds#2743
Merged
Conversation
…ork stack OAuth token exchange and refresh run in the Electron main process, where the global `fetch` is Node's undici. undici ignores the system proxy and certificate configuration that Chromium honours, so on some Linux setups (e.g. behind a proxy or with a custom trust store) token exchange failed with a bare "fetch failed" even though the renderer's API calls — which already go through Chromium — succeeded. Add an `IHttpClient` platform port backed by Electron's `net.fetch` (Chromium networking) and inject it into `OAuthService`, so main-process requests behave like the renderer's. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aMsqBjTdturnFTpnTsD1f
…m's network stack" This reverts commit 7b91a4d.
The AppImage build never registered the posthog-code:// protocol handler, so after OAuth at us.posthog.com the browser couldn't hand the posthog-code://callback?code=... redirect back to the app — users had to create the .desktop file and run xdg-mime by hand. app.setAsDefaultProtocolClient is a no-op for AppImages: there is no installed .desktop file for xdg to point at, and the AppImage mount path (/tmp/.mount_*) changes every launch. On AppImage builds we now write a desktop entry to the user applications dir with Exec pointing at the stable $APPIMAGE path and register it as the default handler for each scheme (mirroring the manual xdg-mime default step). Also declare the scheme in the maker's bundled .desktop entry so AppImage integrators (e.g. AppImageLauncher) pick it up. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aMsqBjTdturnFTpnTsD1f
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
Prompt To Fix All With AIFix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
apps/code/src/main/utils/linux-appimage-protocol.test.ts:62-80
**Prefer parameterised tests for `isAppImage`**
The three cases here — `(linux, APPIMAGE set) → true`, `(linux, APPIMAGE missing) → false`, `(darwin, APPIMAGE set) → false` — all exercise the same predicate with different `(platform, envVar, expected)` inputs, which is the canonical use case for `it.each`. As a single table-driven test it would be easier to extend with new platforms and avoids the repeated `setPlatform` / `process.env` setup boilerplate.
### Issue 2 of 2
apps/code/src/main/services/deep-link/service.ts:55-59
**Dead `.catch()` — `registerAppImageSchemes` never rejects**
`registerAppImageSchemes` swallows every failure path internally: `runXdg` always resolves (warnings are logged, errors are not re-thrown), and the `writeFileSync` / `mkdirSync` catch block returns rather than throwing. The `.catch()` here can therefore never fire, making it a superfluous part. The `void` plus `.catch(log.error)` pattern is idiomatic only when the callee can reject — if you want to surface any future errors here, the callee's error handling would need to change too.
```suggestion
if (isAppImage()) {
void registerAppImageSchemes(schemes);
}
```
Reviews (1): Last reviewed commit: "fix(deep-links): register posthog-code:/..." | Re-trigger Greptile |
- Parameterise isAppImage tests with it.each over (platform, env, expected) - Drop dead .catch() on registerAppImageSchemes (it never rejects) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
Reviews (2): Last reviewed commit: "fix linxu build image target" | Re-trigger Greptile |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Linux AppImage-specific deep-link protocol registration so OAuth callbacks (e.g. posthog-code://callback?...) can be handed back to the app even when no system .desktop file is installed.
Changes:
- Introduces an AppImage runtime helper that writes a user-scoped
.desktopentry (Exec →$APPIMAGE), stages an icon, updates desktop DB, and registersx-scheme-handler/*viaxdg-mime. - Updates
DeepLinkServiceto register all active schemes (dev/prod + legacy) and trigger AppImage registration best-effort on AppImage builds. - Updates Forge AppImage maker config to include
x-scheme-handler/posthog-code, and adjusts the Linux docker build script target mapping.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/code/src/main/utils/linux-appimage-protocol.ts | Adds AppImage detection + .desktop/xdg-mime registration utilities. |
| apps/code/src/main/utils/linux-appimage-protocol.test.ts | Adds unit tests for AppImage scheme registration and desktop entry generation. |
| apps/code/src/main/services/deep-link/service.ts | Collects schemes consistently and triggers AppImage-specific registration. |
| apps/code/scripts/build-linux-docker.sh | Maps friendly maker targets to Forge maker names for Linux container builds. |
| apps/code/forge.config.ts | Declares deep-link MIME handler for AppImage .desktop generation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
16d5e02 to
0e61eb1
Compare
charlesvien
approved these changes
Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
AppImage builds lack an installed
.desktopfile, soapp.setAsDefaultProtocolClient()(which points xdg at one) is a no-op. This breaks OAuth callbacks: the browser cannot handposthog-code://callback?...back to the app after authentication.Changes
Added AppImage-specific protocol registration that mirrors manual
xdg-mime defaultsetup:New module
linux-appimage-protocol.ts: Detects AppImage runtime (APPIMAGEenv var), builds freedesktop.desktopentries pointing at the stable$APPIMAGEpath, stages the app icon to a persistent location, and registers URL schemes viaxdg-mime.Updated
DeepLinkService: Collects all schemes (dev/prod, legacy) and callsregisterAppImageSchemes()on AppImage builds. Failures are best-effort and do not block startup.Updated
forge.config.ts: Declaredx-scheme-handler/posthog-codein the bundled.desktopentry so AppImage integrators (e.g., AppImageLauncher) register the handler at install time.The solution is defensive: it only runs on Linux with
APPIMAGEset, handles missing xdg utilities gracefully, and does not interfere with non-AppImage builds.How did you test this?
linux-appimage-protocol.test.ts) covering:isAppImage()detection on Linux with/withoutAPPIMAGE.desktopentry generation with correct Exec path and MIME typesxdg-mime defaultregistrationexecFileto verify correct paths and command sequences without side effectshttps://claude.ai/code/session_014aMsqBjTdturnFTpnTsD1f