Skip to content

feat(login): let the desktop sign-in handoff continue in the browser - #2989

Open
Leeeon233 wants to merge 2 commits into
mainfrom
web-redirect-browser-button
Open

Leeeon233 wants to merge 2 commits into
mainfrom
web-redirect-browser-button

Conversation

@Leeeon233

@Leeeon233 Leeeon233 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Related issue

Problem / pressure

The browser page the desktop app opens for sign-in (/login?client_id=electron&state=…&code_challenge=…) offered only two exits: hand the browser session to the desktop app, or sign out to switch accounts. A user already signed in who would rather keep using Lody on the web had no way out — leaving meant closing the tab, and navigating Back could re-arm the automatic lody:// deep link.

Summary

  • Adds a secondary "Continue in browser" (在 Web 浏览器中使用) button to the Electron browser-handoff panel, between the primary desktop action ("Open Lody Desktop" / "Continue with this account") and "Use a different account", in both panel states.
  • The click performs the same bail-out as an account switch — account generation bump, handoff URL cleared, short-lived better-auth.electron cookie cleared — so an in-flight electron.transferUser is discarded instead of minting a handoff link or auto-opening lody:// after the user chose the web.
  • Navigation reuses the page's ordinary authenticated redirect path (prepareAuthenticatedRedirect → replaceLocation(getRedirectTarget())): login-hint cookie plus native session sync where needed, then window.location.replace to the validated redirect target or the app root. The existing browser session carries the user into the web app, and replace keeps the handoff page out of history so Back cannot re-arm the deep link.
  • Disabled only while an account switch is signing the browser out; enabled during an in-flight transfer, which is exactly when the exit is needed.
  • i18n: login.desktopHandoff.useWeb in en.json ("Continue in browser") and zh_CN.json ("在 Web 浏览器中使用"). Owning decision note updated in both languages.

Visual explanation

Before                             After
┌───────────────────────────┐      ┌───────────────────────────┐
│ Signed in as a@lody.ai    │      │ Signed in as a@lody.ai    │
│ [ Open Lody Desktop ]     │      │ [ Open Lody Desktop ]     │
│ [ Use a different acct ]  │      │ [ Continue in browser ] ←+ │
└───────────────────────────┘      │ [ Use a different acct ]  │
                                   └───────────────────────────┘

click → generation++ (in-flight transfer discarded)
      → replaceLocation(validated redirect target or "/")

Test plan

  • tests/electron-browser-login-handoff.test.tsx extended, 15 tests pass:
    • clicking "Continue in browser" navigates via replaceLocation("/") without calling transferUser;
    • the button stays available after the handoff link exists and retracts it;
    • a transfer resolving after the click produces no link and no lody:// navigation.
  • pnpm check (typecheck + all test suites) passed; pnpm format; pnpm run docs check passed.
  • Not verified on the deployed web app: a real-browser pass is still needed (/login?client_id=electron&… while signed in → 在 Web 浏览器中使用 → web workspace).

Generated with Devin

The browser page the desktop app opens (/login?client_id=electron...) only
offered handing the web session to the desktop app or switching accounts.
A signed-in user who would rather keep using Lody on the web had no way
out: leaving meant closing the tab, and navigating back could re-arm the
automatic deep link.

The handoff panel gains a secondary "Use in web browser" button between
the desktop action and "Use a different account". It bumps the account
generation like an account switch, so a transfer in flight is discarded
instead of opening the desktop app after the choice, then follows the
page's ordinary authenticated redirect - the validated redirect target
or the app root - through window.location.replace, which keeps the
handoff page out of history. Transfer, auto-open and switch-account
behavior is unchanged.

Generated with [Devin](https://devin.ai)

Model: SWE-2 Max

Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@Leeeon233
Leeeon233 marked this pull request as ready for review November 20, 2026 09:10
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T09:12:17.163180Z a53da9c Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Generated with [Devin](https://devin.ai)

Model: SWE-2 Max

Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant