The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): a click during the chooser check keeps its sign-in window
Austin Pickettc4c8e600b66a
diff --git a/apps/desktop/electron/oauth-login-window.test.ts b/apps/desktop/electron/oauth-login-window.test.tsindex b8bfe8138e8..6c174c407b0 100644--- a/apps/desktop/electron/oauth-login-window.test.ts+++ b/apps/desktop/electron/oauth-login-window.test.ts@@ -121,6 +121,33 @@ test('a revealed attempt stays open on the chooser for the user', async () => {expect(settled).toBe(false)})+test('a click that joins while the chooser check is pending keeps its window', async () => {+ const h = harness()++ let resolveCookie: (present: boolean) => void = () => {}++ h.deps.hasSessionCookie = () =>+ new Promise<boolean>(resolve => {+ resolveCookie = resolve+ })++ const attempt = h.start({ silent: true, background: true })+ let outcome = 'pending'++ void attempt.result.then(+ () => (outcome = 'resolved'),+ error => (outcome = `rejected: ${error.message}`)+ )++ h.windows[0].navigate(`${GATEWAY}/login`)+ attempt.reveal()+ resolveCookie(false)+ await vi.advanceTimersByTimeAsync(0)++ expect(h.windows[0].state).toMatchObject({ destroyed: false, shown: true })+ expect(outcome).toBe('pending')+})+test('a foreground silent sign-in reveals itself when auto-SSO does not finish', async () => {const h = harness()diff --git a/apps/desktop/electron/oauth-login-window.ts b/apps/desktop/electron/oauth-login-window.tsindex 36bc9215eca..8b0d05920f7 100644--- a/apps/desktop/electron/oauth-login-window.ts+++ b/apps/desktop/electron/oauth-login-window.ts@@ -137,7 +137,13 @@ export function startOauthLoginWindow<S>(// plus a slow poll for IdPs that finish via in-page JS.live.webContents.on('did-navigate', (_event: unknown, url?: string) => {if (hiddenRecovery && typeof url === 'string' && url.split(/[?#]/)[0] === chooserUrl) {- void deps.hasSessionCookie().then(present => finish(present ? null : new Error(SIGN_IN_REQUIRED)))+ // A click may join while the check is pending; reveal() clears+ // hiddenRecovery, and the user's window must survive that race.+ void deps.hasSessionCookie().then(present => {+ if (present || hiddenRecovery) {+ finish(present ? null : new Error(SIGN_IN_REQUIRED))+ }+ })return}@@ -164,10 +170,7 @@ export function startOauthLoginWindow<S>(}if (hiddenRecovery) {- deadlineTimer = setTimeout(- () => finish(new Error('Silent sign-in did not complete; sign-in required.')),- deadlineMs- )+ deadlineTimer = setTimeout(() => finish(new Error(SIGN_IN_REQUIRED)), deadlineMs)}// The user's click joined this flow: show this window (a second one would