Skip to content

Stage OpenAI OAuth credentials until setup validation - #707

Merged
TheGreatAxios merged 2 commits into
cl-7114-corbits-fails-after-openai-setup-writes-legacy-settingsfrom
cl-7115-stage-openai-oauth-credentials-until-setup-validation
Aug 28, 2026
Merged

Stage OpenAI OAuth credentials until setup validation#707
TheGreatAxios merged 2 commits into
cl-7114-corbits-fails-after-openai-setup-writes-legacy-settingsfrom
cl-7115-stage-openai-oauth-credentials-until-setup-validation

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Stages OpenAI OAuth tokens in memory and commits them only after setup validation succeeds.
  • Treats definitive OAuth scope and credential rejections as non-saveable and blocks Ctrl+S for those failures.

Verification

  • bun run check passes.
  • 116 targeted auth/TUI tests pass.

Fixes CL-7115

@linear-code

linear-code Bot commented Aug 28, 2026

Copy link
Copy Markdown

CL-7115

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review · Approve

OAuth credentials no longer become durable before setup validation succeeds.

No findings.

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review · Approve

Stages Codex/xAI OAuth tokens in memory after the PKCE exchange and commits them to the home auth store only when provider setup's scope probe passes (or the operator explicitly saves anyway); definitive scope/credential rejections block Ctrl+S.

No findings.

Notes

  • Conflicts textually with #706 in src/tui/provider-setup-submit.ts (git merge-tree --write-tree → CONFLICT): #706 rewrites the same OAuth-branch comment block, adds a providers[oauth.providerName] entry to the saveGlobalSettings call, and makes localSettingsFile: string | null. Resolution: keep await oauth.commit() ahead of saveGlobalSettings and add #706's providers spread. #705 merges clean and has no behavioral interaction (commit happens before settle(true), so the reload sees the profile).
  • Commits "Fix staged OAuth credential validation retries" and "Clean OAuth setup hygiene" amend code introduced earlier on this same branch (commit-retry logic, insufficient-scopeblocked rename). Squash them into the commits they fix; "Clean OAuth setup hygiene" is too vague to stand alone.
  • src/auth/oauth-scope-check.ts:76-80isDefinitiveRefreshAuthRejection matches /invalid_grant|revoked/i on the raw body, so a 400 without those words is treated as transient and save-anyway stays available. Consistent with the never-lock-out policy; noting for awareness.
  • Verified: no tokens reach settings.json (provider-setup-submit.ts:65-72 writes only defaultProvider + local selection; commit goes through saveCodexProfile/saveXaiProfilewriteAuthFile tmp+rename/0600, untouched); nothing on disk before commit(), so Ctrl+C/Esc/validation failure/deadline leave no orphan profile; refreshed staged tokens are the object commit saves (session.ts:60-62, provider-setup.ts:1379-1384, login.ts:61-75); Ctrl+S gate enforced in the key handler (provider-setup.ts:1714-1715), not just guidance text; no callers of startCodexLogin/startXaiLogin outside provider-setup.ts.
  • Checks: bun run typecheck, bun run lint (0 warnings on the 19 touched files), bun test src/auth/callback-page.test.ts src/auth/oauth-scope-check.test.ts src/auth/oauth/oauth.test.ts src/tui/provider-setup-submit.test.ts src/tui/provider-setup.test.ts (116 pass).

Ctrl+S save-anyway must not persist staged Codex/xAI credentials after
insufficient-scope or revoked refresh rejection. Transient refresh
failures stay inconclusive so existing save-anyway UX remains.
@TheGreatAxios
TheGreatAxios force-pushed the cl-7115-stage-openai-oauth-credentials-until-setup-validation branch from 56aced1 to 3efe315 Compare August 28, 2026 19:34
@TheGreatAxios
TheGreatAxios changed the base branch from main to cl-7114-corbits-fails-after-openai-setup-writes-legacy-settings August 28, 2026 19:35
@TheGreatAxios
TheGreatAxios merged commit eae0170 into main Aug 28, 2026
5 checks passed
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