Skip to content

feat(native): add managed ChatGPT setup and accounts - #129

Merged
rynfar merged 3 commits into
nativefrom
nw/126-chatgpt-setup
Nov 3, 2026
Merged

rynfar merged 3 commits into
nativefrom
nw/126-chatgpt-setup

Conversation

@rynfar

@rynfar rynfar commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Codex's native provider card and onboarding Agents step had only generic account/runtime controls. This ports managed ChatGPT setup, reconnect and multiple accounts into a shared native card, with operation-scoped install/sign-in sequencing, cancellation, handoff/import retry, masked emails and the connected-plan welcome.

Closes #126 (a slice of #81). CN-WELCOME and ST-PROVIDERS remain partial.

Web-path applicability:

Web source/path Native behavior
CodexSetupSection.tsx, .logic.ts Managed/existing CLI choice; install or update before authentication; progress, preparing/waiting/failed/cancelled/signed-in states; reconnect email; cancel owned work on close/environment change. Local native connections use the server callback.
Desktop client callback Native has no Electron callback bridge. Direct local setup lets the server receive the loopback callback.
Remote sign-in / handoff A reachable paired local environment receives the handoff subscription; the finished profile imports into the destination. Failed imports retry the in-memory profile. With no reachable helper, use client callback mode and the masked pasted-redirect form. SSH loopback transports count as remote.
Web-only desktop protocol handoff / browser return Native already stays in its Agents step while the browser is open. Return URLs preserve #agents:<environment>; native welcome links and a saved environment-specific resume also restore Agents. No Electron bridge/protocol helper is claimed.
AddCodexAccountDialog.tsx Personal name default, independent managed Codex instance, account-name copy and multiple-account warning. Settings embeds setup in the dialog; onboarding closes it, promotes the created card and starts setup when ready.
ChatGptAccountPicker.tsx, ChatGptConnectionButton.tsx Saved profiles in server order, first profile selected by default, different-account choice, branded Continue button.
ChatGptWelcomeCoordinator.tsx Connected-plan welcome in setup, acknowledged locally per environment/instance/account email. Native's current provider projection lacks profileId, so the identity falls back to email.
MultipleAccountsNote.tsx Same Codex multiple-account warning and FAQ destination.
WelcomeWizard.tsx Shared Codex welcome card, every Codex account, existing-CLI terminal path, another-account action, created-account promotion and Agents resume.

Verification obeys #126's hard boundary. No real OAuth/install/ChatGPT RPC, browser opening, real window, paid turn, clipboard operation, or real-data write was used. The account check read only the required Codex email metadata. Setup fixtures boot without a client and skip discovery, subscriptions, commands and URL opening; captures use the copied smoke native home. Transferred profiles have no Debug implementation, stay on the network task and are never persisted.

Validation:

  • cargo test --workspace (1,157 workspace tests; the focused GPUI test also passed during the preceding review); core state/payload tests and t3-client fake-server tests cover all three ChatGPT methods, null reconnect, auth/handoff decoding, install ordering, cancellation/late success, flow matching and in-memory import retry.
  • cargo clippy --workspace --all-targets -- -D warnings; snapshot-feature clippy and build.
  • Theme generation check, parity sync tests, conformance generation check and vp run check:changed native.

Local evidence (not uploaded, per factory rules):

  • Before: /private/tmp/native-126-evidence/before-settings.png, /private/tmp/native-126-evidence/before-agents.png.
  • After: /private/tmp/native-126-evidence/{settings,agents}-{signed-out,install-needed,waiting,reconnect,handoff,failed,multiple}.png.
  • Dialogs: /private/tmp/native-126-evidence/settings-{picker,add-account,welcome}.png. Focus/restore captures: settings-{picker,add-account}-{keyboard,escape}.png in that directory. Default mode: {settings,agents}-unmanaged.png; existing CLI auth: settings-existing-cli.png.
  • Fake-wire and gate logs: /private/tmp/native-126-verified-tests.log, /private/tmp/native-126-review-gate-tests.log, /private/tmp/native-126-review-gate-clippy.log, /private/tmp/native-126-review-changed.log.

Remaining gaps: T3 Connect/relay onboarding (#93), simultaneous multi-computer selection (CN-MULTI), ChatGPT usage (explicitly out of scope), profileId-based/global welcome coordination, managed CODEX_HOME/shadow-home fields (the projection is owned by another worker), and the pre-existing provider configuration/ACP Registry wizard gaps. Actual OAuth, callback receipt, installation and cross-server credential transfer are intentionally unverified against real servers.

Review fixes (all eight findings accepted):

  1. The default/unmanaged choice is independent of managed readiness. Auth/install observations mount only after managed mode is saved; the fake-server regression models the rejected observe-install guard.
  2. Authorization URLs are never rendered; the reconnect fixture includes an obviously fake id_token_hint and displays only safe page copy. The pre-fix PNG audit found zero token hints.
  3. Existing CLI Codex again uses the generic Account row, including sign-in/change/sign-out.
  4. Install start acknowledgements and later observations are distinct updates; stale idle, succeeded and active operations cannot replace ownership or retarget Cancel.
  5. Automatic setup remains requested while busy/unavailable and is consumed only when start accepts it.
  6. Agents resume accepts the registered t3code-native scheme.
  7. A nested modal key context traps Tab/Shift-Tab and restores the invoking focus; the GPUI TestWindow regression fails with the trap removed.
  8. Picker/welcome use the shared 512px DialogFrame and standard footer; Add account uses its 768px wizard sizing/bare footer. A compatible render_modal extension adds close-button and overlay-priority support without changing existing DialogFrame callers.

Rebased onto fork/native at c830714733. Regression red/green logs: /private/tmp/native-126-review-{red,core-red,default-red,green,focus-red-correct-stops,focus-green2}.log. Final native gate logs: /private/tmp/native-126-review-gate-*.log.

Cancellation re-review (both findings accepted), head 65e0ebee1995c036785202d15275bb8e19c8b454:

  1. Cancel clears the queued automatic setup request before terminal observations can trigger another install or sign-in. A fake-server regression drives cancelled and succeeded observations and asserts neither start method is dispatched.
  2. Cancel releases local install ownership while preserving the aborted task's serial guard. The core regression observes a different operation after cancellation and proves an old cancel reply cannot hide its progress or retarget Cancel.

Fresh waiting/reconnect captures for Settings and Agents pass the rendered-text assertion in scripts/assert-chatgpt-captures.swift: the safe sign-in page message is present and URLs/token hints are absent. Red/green cancellation logs: /private/tmp/native-126-cancel-{core,client}-{red,green}.log. Final gates: /private/tmp/native-126-cancel-gate-*.log, /private/tmp/native-126-cancel-changed.log; rendered assertions: /private/tmp/native-126-cancel-render-text.log. All required gates passed. fork/native remains c830714733, already the branch base.

Built with GPT-6.1 Sol in Codex

@rynfar
rynfar force-pushed the nw/126-chatgpt-setup branch from d1afe50 to b776760 Compare November 3, 2026 14:26
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