Skip to content

fix: Linux AppImage OAuth auth hang (#1525) - #1788

Open
carlosjarenom wants to merge 3 commits into
eigent-ai:mainfrom
carlosjarenom:fix/1525-linux-auth-desktop
Open

fix: Linux AppImage OAuth auth hang (#1525)#1788
carlosjarenom wants to merge 3 commits into
eigent-ai:mainfrom
carlosjarenom:fix/1525-linux-auth-desktop

Conversation

@carlosjarenom

Copy link
Copy Markdown
Contributor

Related Issue

Closes #1525

Description

Fixes the Linux auth hang where login stalls at "Logging in......." after the OAuth provider redirects back via `eigent://auth/callback?token=...`.

Root Cause

On Linux, `app.setAsDefaultProtocolClient` only invokes `xdg-mime default` against a `.desktop` file that must already exist — it does not create one. AppImage builds ship no such file, and users who author their own frequently omit the `%u/%U` field code. Without `%u`, `xdg-open` drops the `eigent://` URL before launching the app. The running instance's `second-instance` event then fires with a URL-less argv, so `handleProtocolUrl` is never called and the token never reaches the renderer.

Fix (3 changes)

  1. New: `electron/main/utils/linuxProtocol.ts` — On every packaged Linux launch, writes a self-managed `eigent-protocol-handler.desktop` to `~/.local/share/applications/` with `Exec="" %u` and `MimeType=x-scheme-handler/eigent;`, then runs `update-desktop-database` and `xdg-mime default`. Prefers `$APPIMAGE` so registration survives AppImage version bumps; falls back to `process.execPath`. Skipped in dev mode (existing dev branch handles that). Re-registers on `second-instance` without URL (self-heal).

  2. `electron/main/index.ts` — Wires the helper into `setupProtocolHandlers()`, and re-runs registration if `second-instance` fires on Linux without a URL so stale desktop files self-heal on the next login attempt.

  3. `electron-builder.json` — Adds `mimeTypes: ["x-scheme-handler/eigent"]` to the Linux AppImage config so `appimaged`-managed installs pick up the association at install time.

Testing Evidence

  • `npm run type-check` passes (exit 0)
  • `npm run dev` produces clean Vite bundles for dist-electron/main and dist-electron/preload
  • Manual verification: on Fedora 43 / XFCE4 reproducing the reporter's setup, the app now writes `~/.local/share/applications/eigent-protocol-handler.desktop` with `Exec="" %u`. Triggering `xdg-open 'eigent://auth/callback?token=test'` against the running app delivers the URL into the `second-instance` argv and `handleProtocolUrl` fires `auth-token-received`, completing login.

Checklist

Carlos added 2 commits July 19, 2026 12:43
- Add linuxProtocol.ts: writes ~/.local/share/applications/eigent-protocol-handler.desktop
  with Exec="<path>" %u and MimeType=x-scheme-handler/eigent; on every packaged Linux launch
- Integrate in setupProtocolHandlers() and second-instance handler (self-heal)
- Add mimeTypes to electron-builder.json for AppImage bundled .desktop

Closes eigent-ai#1525
Comment thread electron/main/utils/linuxProtocol.ts Fixed
Incomplete string escaping: backslashes in executable path were not escaped,
which could lead to shell interpretation issues in the .desktop file.
Escapes both backslashes and double quotes now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Auth process hangs with "Logging in......." message

3 participants