Skip to content

fix(desktop): show a ChatGPT sign-in that is still running when Settings opens again - #151

Merged
X-iZhang merged 1 commit into
mainfrom
fix/desktop-signin-state
Nov 27, 2026
Merged

X-iZhang merged 1 commit into
mainfrom
fix/desktop-signin-state

Conversation

@X-iZhang

@X-iZhang X-iZhang commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

What & why

Follow-up to #144.

  • A ChatGPT sign-in outlives the Settings row. Leaving Settings (or the setup wizard's step) while a sign-in ran and coming back, or reloading the window, showed "Not signed in" with an enabled "Sign in with ChatGPT" and no Cancel; pressing it joined the running sign-in and opened its page again, and the sign-in's answer (for example port 1455 in use) was lost. The bridge's chatgpt gets two members, isSigningIn() and waitForSignIn() (the running sign-in's end, or null at once when none runs; it opens nothing), answered only for the UI's own origin. When the row mounts it asks both and shows a running sign-in with its waiting button and Cancel, then takes its answer the way a sign-in started there does. An app without the two members keeps today's row.
  • A login whose output stays open is answered after it exits. When EvoSci login chatgpt --json exited without a terminal line while a child process kept its output open, the sign-in was answered only at the app's 330 s limit, and every new sign-in joined it until then. The output is now read for at most 5 s after the exit; the run then answers cancelled after a cancel, else internal_error, and keeps a terminal line that arrives within those 5 s.

Known limits:

  • A sign-in that ends while no Settings row is shown still loses its answer; the next row shows the state the settings report.
  • A row that opens again shows "Sign in with ChatGPT" for one round trip to the app before it shows the running sign-in; a click there joins it and opens its page again.
  • A row that opens again does not know that a sign-out is waiting on the app's question; Sign out there answers that the app is busy.
  • A child of the login that keeps its output open may also keep port 1455; the next sign-in then reports the port in use.

Manual testing

Must be tested against a real backend (EvoSci deploy, port 6174) — a green build is not enough.

  • npm run lint && npm run format:check && npm run build all green
  • Started the backend → configured the Deployment URL → chat works
  • The feature(s) touched here were verified to work (Workspace / Skills / Memory / theme / chat …)
  • Significant changes re-tested against the production build (npm run build && npm start; dev and standalone behave differently)

Test steps / screenshots

Desktop app from this branch (npm run build at the root, then cd desktop && npm start), core 0.4.4. A real ChatGPT account is needed for the rows marked ★. Tested on macOS: every row passes, and after row 4 a saved ChatGPT plan answered a chat. Rows 1 to 3 were also run in a scripted Electron session against the released core; with the WebUI's hook from main, rows 1 to 3 fail there (the row shows Sign in, and the login keeps port 1455).

# Where Do Expect
1 Settings › Model, OpenAI Choose ChatGPT plan, Sign in with ChatGPT, leave the browser page open; close Settings with the gear, open it again, choose ChatGPT plan "Finish signing in in your browser…" and Cancel; the browser page did not open again
2 Same Reload the window (View › Reload) instead of the gear The same
3 The row from 1 or 2 Cancel "Sign in with ChatGPT", no message; lsof -iTCP:1455 shows nothing
4 ★ The row from 1 or 2 Finish signing in in the browser "Signed in · Plus" and Sign out
5 ★ Fresh setup wizard, key step OpenAI → ChatGPT plan → Sign in with ChatGPT → Back → Next → ChatGPT plan The waiting button and Cancel; finishing in the browser signs in and Next is enabled

Checklist

  • Self-tested, no obvious regressions
  • Requested at least one teammate for peer review

Merging ≠ shipping: releases are handled solely by the maintainer. A published release reaches users without a core release: EvoScientist v0.3.6+ picks up the newest version in its supported range (v0.3.6: >=0.3,<0.4; v0.3.7 and v0.3.8: >=0.3,<0.5; v0.4.0: >=0.4,<0.6; v0.4.1+: >=0.5,<0.6), and older versions run @latest.

Summary by CodeRabbit

  • New Features
    • The sign-in screen can now detect an in-progress ChatGPT sign-in and wait for its result when you return to the page, avoiding a duplicate sign-in attempt.
  • Bug Fixes
    • Sign-in status and results are handled more reliably when the login process exits before its output closes, including cancellations and delayed completion events.

…ngs opens again

The bridge's chatgpt gets isSigningIn() and waitForSignIn(), so a
Settings row or wizard step opened again during a sign-in shows its
waiting button and Cancel and takes its answer. A login that exits
while a child keeps its output open is answered 5 s after the exit
instead of at the 330 s limit.
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The desktop sign-in run now limits post-exit output reading. The desktop bridge adds methods to check for and await an active sign-in, and the Settings view can observe and adopt that sign-in.

Changes: ChatGPT sign-in flow

Layer / File(s) Summary
Bound post-exit output reading
desktop/src/chatgpt.ts, desktop/src/chatgpt.test.ts
The sign-in run waits up to SIGN_IN_STOP_MS for output after process exit. If output stays open, it settles with an exit-derived result. Tests cover cancellation, terminal events during the wait, and output kept open by a child process.
Expose sign-in status and outcome
desktop/src/app.ts, desktop/src/main.ts, desktop/src/preload.ts, src/lib/desktop.ts, desktop/README.md, desktop/src/app.test.ts, src/lib/desktop.test.ts
App adds UI-origin-gated status and wait methods. IPC and preload expose them, and the desktop adapter handles optional bridge methods and normalizes their results. Tests cover origin checks and bridge responses.
Adopt an active sign-in in Settings
src/app/hooks/useChatgptSignIn.ts, src/test/setupView.test.tsx
The hook observes active desktop sign-ins, waits for their results, and refreshes settings. It ignores stale results after newer sign-in or sign-out actions. Tests cover remounts, cancellation, and status-check races.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Settings as Settings view
  participant Hook as useChatgptSignIn
  participant Bridge as ChatGPT desktop bridge
  participant App as App
  participant Run as Active sign-in
  Settings->>Hook: Mount sign-in controls
  Hook->>Bridge: isSigningIn()
  Bridge->>App: Query status with sender origin
  App-->>Bridge: Return running status
  Hook->>Bridge: waitForSignIn()
  Bridge->>App: Request active sign-in outcome
  App->>Run: Read signIn.done
  Run-->>App: Return sign-in outcome
  App-->>Bridge: Return outcome
  Bridge-->>Hook: Resolve wait
  Hook->>Settings: Refresh settings and update phase
Loading

Possibly related PRs

Suggested reviewers: jfilipiuk, din0s

Merge Risk: Minimal · up to 4a466

This change lets a reopened Settings row or wizard step rejoin a running ChatGPT sign-in, and it bounds the wait for sign-in output after the login process exits to 5 seconds. No concrete defects were found, and apps without the new bridge methods keep the existing behavior. The merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: a ChatGPT sign-in that is still running is shown when Settings reopens. The changeset adds chatgpt.isSigningIn() and chatgpt.waitForSignIn() bridge methods, a row that…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: a ChatGPT sign-in that is still running is shown when Settings reopens. The changeset adds chatgpt.isSigningIn() and chatgpt.waitForSignIn() bridge methods, a row that reconnects to a running sign-in on mount, and tests for these paths. The title also uses the fix(desktop) prefix. The changeset also changes the post-exit output read window (5 seconds, then cancelled or internal_error), which the title does not mention. That is a secondary change, so the title remains a fair summary.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1da0b8e7-e909-4db9-989d-0fe87989cebe
Commits

Reviewing files that changed from the base of the PR and between 822a42e and 4a4663b.

Files selected for processing: 11

  • desktop/README.md
  • desktop/src/app.test.ts
  • desktop/src/app.ts
  • desktop/src/chatgpt.test.ts
  • desktop/src/chatgpt.ts
  • desktop/src/main.ts
  • desktop/src/preload.ts
  • src/app/hooks/useChatgptSignIn.ts
  • src/lib/desktop.test.ts
  • src/lib/desktop.ts
  • src/test/setupView.test.tsx

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@X-iZhang
X-iZhang merged commit 6e7e74d into main Nov 27, 2026
15 checks passed
@X-iZhang
X-iZhang deleted the fix/desktop-signin-state branch November 27, 2026 09:35
@X-iZhang X-iZhang mentioned this pull request Nov 27, 2026
2 of 3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant