Skip to content

fix: auto-register Linux .desktop file with %u to unblock OAuth callback#1625

Open
Rene0422 wants to merge 1 commit into
eigent-ai:mainfrom
Rene0422:fix/linux-protocal-handler-auth-hang
Open

fix: auto-register Linux .desktop file with %u to unblock OAuth callback#1625
Rene0422 wants to merge 1 commit into
eigent-ai:mainfrom
Rene0422:fix/linux-protocal-handler-auth-hang

Conversation

@Rene0422

Copy link
Copy Markdown

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 (as the reporter did) 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:

[info] second-instance [
'/opt/eigent-0.0.89/bin/squashfs-root/eigent',
'--allow-file-access-from-files',
... // no eigent:// URL here
]

So handleProtocolUrl is never called and the token never reaches the renderer.

Fix.

  • New electron/main/utils/linuxProtocol.ts — on every packaged Linux launch, writes a self-managed eigent-protocol-handler.desktop into ~/.local/share/applications/ with Exec="<path>" %u and MimeType=x-scheme-handler/eigent;, then refreshes update-desktop-database and xdg-mime default. Prefers $APPIMAGE so the registration survives AppImage version bumps; falls back to process.execPath. Skipped in dev mode since the existing dev branch of setupProtocolHandlers handles that case.
  • 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.
  • electron-builder.json — adds MimeType=x-scheme-handler/eigent; to the AppImage's bundled .desktop entry so appimaged-managed installs pick up the association at install time.

Testing Evidence (REQUIRED)

  • I have included human-verified testing evidence in this PR.
  • This PR includes frontend/UI changes, and I attached screenshot(s) or screen recording(s).
  • No frontend/UI changes in this PR.

Verification performed:

  • npm run type-check passes (exit 0).
  • npm run dev produces clean Vite bundles for dist-electron/main and dist-electron/preload.
  • Manual: on Fedora 43 / XFCE4 reproducing the reporter's setup, the app now writes ~/.local/share/applications/eigent-protocol-handler.desktop with Exec="<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.

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Contribution Guidelines Acknowledgement

@Douglasymlai Douglasymlai added bug Something isn't working frontend labels Jul 3, 2026
@Douglasymlai

Copy link
Copy Markdown
Contributor

Hi @Rene0422 could you help resolve the conflicts?

Once they’re resolved, I can move this forward to the review process.

@Rene0422
Rene0422 force-pushed the fix/linux-protocal-handler-auth-hang branch from 3a4d9e9 to a180d18 Compare July 4, 2026 03:02
@Rene0422

Rene0422 commented Jul 4, 2026

Copy link
Copy Markdown
Author

Hi @Rene0422 could you help resolve the conflicts?

Once they’re resolved, I can move this forward to the review process.

@Douglasymlai I've fixed conflicts. Please check it and update the process.

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

2 participants