Repository navigation
refactor(auth): one owner for provider sign-in failures, paste and recovery - #203394
Conversation
Folds 445eec06e0f5: ctx.nodes for provider sign-in through the Gateway. Co-authored-by: obviyus <[email protected]>
ProviderAuthFailure { reason, recovery, providerDetail?, retryAfterMs? } with
core-owned recovery, exported from plugin-sdk/provider-auth. One paste parser in
the SDK (parseOAuthAuthorizationInput with expected state and sign-in page);
parseOAuthCallbackInput and the hex generateOAuthState alias are gone. Loopback
and Gateway-origin refusals keep the sign-in open. Wizard error results carry
the failure reason. One renderer per surface: CLI prints the login command,
chat says /login or Open Models, later turns render the refresh fence as a new
login with a Sign in button. Folds 95efffea64ec minus singleUse.
Co-authored-by: obviyus <[email protected]>
Folds f50bf78c24dc (pasted-address field) and ff4cf89eff2e (show only the error), and drops the remaining sign-in note appends. A typed failure shows its sentence and one action: Retry this step, Start sign-in again, Open settings, or wait/admin text. Co-authored-by: obviyus <[email protected]>
Folds 02e1463f74ff core parts: pickAuthMethod owns id, label and the shipped --device-code alias (auth-method-pick.ts is gone). Removes unreachable and single-use auth.ts paths, the test-only providerConfigNormalizer hook, the platform split file and duplicate default-model and env-var lookups. Co-authored-by: obviyus <[email protected]>
The chat sign-in flow no longer rechecks owner authority before every message, URL, device code and write; cancellation still stops delivery. Removes the runLoginFlow test hook and the re-validation of its own typed result. The chat renderer keeps the provider's reason. Co-authored-by: obviyus <[email protected]>
Folds 02e1463f74ff OpenAI/xAI/Codex parts (merged device-code choices, 404 fallback). OpenAI and xAI throw ProviderAuthFailure; the error rewriter, double prints and catch-block notes are gone; device code exchanges through the token runtime; the plugin TLS probe is gone (core doctor owns it). Co-authored-by: obviyus <[email protected]>
Chutes, OpenRouter, MS Teams, Google Meet, Copilot, MiniMax, Radius and Anthropic use the SDK paste parser and throw ProviderAuthFailure. Copilot no longer reports a denied or expired code as success. OpenRouter's private parser and loopback are gone. Co-authored-by: obviyus <[email protected]>
Co-authored-by: obviyus <[email protected]>
A browser refusal at the loopback or Gateway-origin callback kept the sign-in open but the Control UI never said why. The refusal (and a busy callback port before the paste fallback) now reaches the open step with its typed reason: the waiting dialog shows it with Reopen browser tab as the primary action, and the paste dialog shows it under the field. Co-authored-by: obviyus <[email protected]>
The login recovery hint carried literal markdown (**Sign in**) that error surfaces show verbatim, the Control UI turn notice had no cause and so no action, and the composer banner pointed at /models, /help and model setup. The hint is plain text, the lifecycle terminal names the provider and an auth failure so the notice offers Open Models, and the auth-failed banner offers the same action. Co-authored-by: obviyus <[email protected]>
Codex app-server auth errors, the Codex Hosted Search setup note, the spark unknown-model hint, the sign-in scope note shown by chat /login, the saved profile collision error, the account-link input error, the auth-profile failover chat reply and the default loopback success page named CLI commands or a terminal that Control UI and chat users do not have. Co-authored-by: obviyus <[email protected]>
…rors Co-authored-by: obviyus <[email protected]>
Co-authored-by: obviyus <[email protected]>
Co-authored-by: obviyus <[email protected]>
…covery OpenClaw-Publication: edd9445b-4d05-87be-ad06-889408f1ae7e
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. What this changesThis PR centralizes provider sign-in failures and pasted callbacks, adds recovery actions, and combines OpenAI Codex sign-in methods. Example: A user denies Google consent while signing in from Models.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 5 items remain Keep this PR open: the maintainer-approved recovery improvements are useful, but patch-caused test and validation failures need repair before merge. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherProvider plugins perform authentication; shared SDK and Gateway owners validate callbacks and carry failure reasons to Control UI, chat, and CLI renderers. flowchart LR
A[Control UI chat or CLI] --> B[Gateway sign-in admission]
B --> C[Provider authentication plugin]
C --> D[OAuth provider]
D --> E[Shared callback and paste validation]
E --> F[Typed failure or credentials]
F --> A
Technical reviewBest possible solution: Retain the shared failure and parser owners, repair the affected consumer tests and validation gates, and verify the approved sign-in changes across an upgrade. Do we have a high-confidence way to reproduce the issue? Current-main failure renderers and callback settlement establish the reported behavior, and supplied before/after screenshots demonstrate the consent-denial case without a reviewer-run reproduction. Is this the best way to solve the issue? Shared failure classification, callback parsing, and surface-specific rendering fit the existing owners; the approved direction should remain while consumer tests and enforced gates are repaired. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a28f2117181c. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfacePR surface statistics unavailable: the file list is incomplete. Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 21, 2026, 10:30 PM ET / November 22, 2026, 03:30 UTC. |
- Keep the chat sign-in runLoginFlow seam so Telegram tests stay on the public SDK. - Narrow the Chutes token-exchange catch, document the one failure-shape assertion. - Paste sign-in reuses the shared row/stack layout; only a compact badge is new CSS. - Update stale tests and ratchet baselines; drop the matrix group that asserted a helper instead of the Control UI; record the measured test-line growth. Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: 67abf2b0-86d7-8d0b-9f88-352402c04c22
Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: 15729543-6d65-8fc1-81af-7ab9757e5657
|
Landed as a30bdf3. Provider sign-in failures now have one core owner: a typed reason, one recovery action per surface, and one shared paste parser. Recoverable mistakes keep the attempt open, and Control UI and chat no longer show CLI commands. Proof: the 31-case failure matrix fails on main and passes here, CI is green, the local ClawSweeper review is clean, and the before/after screenshots are above. |
Merge upstream main after openclaw#203394. Keep provider recovery messages and Gateway node access in the shared sign-in flow while the local TUI retains prompt cancellation and credential refresh.
## What Problem This Solves A user signs in to a provider (for example "Sign in with Google (Gemini)") from Models in the Control UI on a phone or a laptop. The dialog asks them to approve access in the browser and paste back the address of the page it opened. While they are on the provider's page, the Control UI socket drops, or the phone discards and reloads the tab. When they come back, the dialog is gone and they must start the sign-in again. On a phone this happens almost every time, so remote Gateways (VPS, Docker, phone) could not finish a provider sign-in. This is older than #203394: the same repro fails on `15e5f7596fac` (the parent of #203394) and on current `main`. `models.authLogin` has closed its sign-in when the starting socket closes since #171526 / #183777. ## User Impact User impact: leaving the Control UI tab during a provider sign-in no longer loses it. After a reconnect, the same step comes back with the address the user already typed. After a reload in the same browser, the same sign-in dialog reopens (the paste field is empty again: the one-time code is not stored in the browser). Pasting the address then finishes the sign-in as before. - If the Gateway no longer has the sign-in (Gateway restart, 25-minute timeout, or a newer sign-in replaced it), the reopened dialog says "This sign-in session ended" instead of disappearing. - A sign-in nobody watches no longer blocks other setup: a new sign-in from the same user or device replaces it, and so does anyone's once every connection that showed it is gone. While someone is still on the sign-in (including after a resume), another user's start stays "already in progress", as today. - Known and out of scope: MCP server sign-in (`mcp.authLogin`) and runtime setup still end when their socket closes. ## Why This Change Was Made One owner on each side, no new store, timer or config: - **Gateway:** `models.authLogin` now uses the same session contract as first-run provider sign-in (`openclaw.setup.auth.start`): the session outlives its socket and is reached again by its session id; the starter's retained grant still stops it when the device is revoked or downgraded. The existing per-owner replacement for provider sign-in now also covers `models.authLogin`, and it replaces a predecessor only when every connection that started or read it (`wizard.next`/`status`/`cancel`) is closed, so an abandoned tab cannot hold setup admission for 25 minutes. It no longer requires the replacement to use the same provider/agent/workspace: a user who starts another sign-in has abandoned the first one. - **Control UI:** the Models login suspends its wizard when the socket drops and resumes the same session on reconnect (same agent and recovery scope only), using the runner's existing `suspend`/`resume`. The typed value follows the model-setup draft rule, which keeps it through the reconnect. The existing activation record (`openclaw.modelSetup.pendingActivation.v1`, HMAC-bound to this browser's device key and credentials) now also records a Models sign-in, and a reloaded Models page reopens it with `restore`/`resume`. First-run setup ignores these records. The sign-in's choice, mode and recovery move into one sibling module (`login-sign-in.ts`); `login-controller.ts` stays at its line cap. A reopened sign-in also takes precedence over a provider picker the page's `?connect=1` route opened. ## Evidence Base side (reproduction, before the change): scratch Gateway on the same commit as this PR's base and on `15e5f7596fac`, remote (tailnet) Control UI in headless mobile Chromium, Gemini OAuth plugin, Google sign-in page blocked: | Scenario | `15e5f7596fac` (before #203394) | `main` base | This PR | |---|---|---|---| | Start sign-in, type the address, go offline 25 s, come back | no dialog | no dialog | same step, typed address kept | | Start sign-in, type the address, reload the page | provider picker, no paste field | provider picker, no paste field | same dialog, paste field shown | | After reconnect, paste an address with a made-up code | n/a | n/a | "Google rejected this sign-in (invalid_grant)": the resumed step reached the plugin and Google | | | Before (`main`) | After (this PR) | |---|---|---| | Socket drops, user comes back |  |  | | Page reloads |  |  | After the reconnect, a made-up code reaches Google:  Regression tests: - `src/gateway/server-methods/models-auth-login.test.ts` (red on base: 4 failed): the sign-in survives its socket, the returning operator reads the same step on a new socket, another owner stays busy while a returning connection (or any other reader, such as a second tab) is still open and replaces it once all are gone, and browser sign-in still stops on cancel. - `ui/src/e2e/model-provider-login-recovery.e2e.test.ts` (reload cases red on base): Models page with a mocked Gateway; reload of `?connect=1` reopens the step on the same session instead of the picker; a socket drop during the reloaded page's restore still reopens the sign-in after reconnect; a reload that finds no session says the sign-in ended, once (the next reload shows the picker); a reconnect keeps the step and typed address on the same session without a new start or a cancel (this one also passes on base: the base UI already rereads after a quick reconnect, and the base failure was the Gateway closing the session). - `ui/src/e2e/provider-browser-login-leave.real-gateway.e2e.test.ts`: real Gateway with a browser-callback provider fixture; start sign-in → socket drops → reconnect → approve → "ready"; and start → reload → approve → "ready". Green here; on the base build checkout its fixture never reached the login form, so its base side is covered by the live runs above instead. Removed tests that asserted the removed behavior: `models.authLogin` closing on disconnect, and same-owner sign-ins staying busy when the provider, agent, workspace, model target or native catalog setting differs. Review: local ClawSweeper round 1 found that a reload's restore deferred by a transient config or connection failure never retried; fixed in this head (it retries on the next connection or config change) with the socket-drop test above, red when the retry is removed. Round 2 found that a resumed sign-in could be replaced by another owner because only the starting socket counted; every open reader now counts (a later check found that a second tab's drop must not count as abandonment), with the Gateway test above. Not covered locally: the SQLite worker ratchet in `pnpm check:changed` runs out of heap on this host (it scans all source files; this change touches no database code). The other changed-lane checks pass. `model-providers-page.usage.test.ts` fails intermittently in the batched Models UI run: 2/5 runs on this branch and 3/5 on the base, same files. ## Merge danger Two-way door: a revert restores close-on-disconnect. No config, schema, protocol or stored Gateway state changes. The browser activation record keeps its format and gains one record kind. Blast radius if wrong: provider sign-in from Models and Model setup (a sign-in could be resumed by the wrong tab, or a new sign-in could replace another user's abandoned one), and first-run activation recovery that shares the record. Co-authored-by: Ayaan Zaidi <[email protected]>
…covery (openclaw#203394) ## What Problem This Solves Fixes: provider sign-in failures end the attempt with the wrong reason, raw provider errors, or a terminal command, when consent is denied, a wrong or unrelated address is pasted, the callback port is busy, a device code expires or is denied, the network drops during the token exchange, or a saved sign-in is rejected later. Each provider plugin, the Control UI wizard, the chat `/login` flow and the CLI decided and worded these failures separately. The same failure looked different on every surface, and most of them told Control UI and chat users to run a CLI command. ## User Impact User impact: a failed sign-in now names the cause in one plain sentence and offers one recovery action on every surface. - **Recoverable mistakes keep the attempt open.** Consent denied (Gateway-origin and loopback callbacks), a wrong-state paste, a pasted sign-in page and a pasted `error=` redirect show the reason under the field. The user fixes it without starting over. - **Terminal failures offer Start sign-in again.** Code expired, code denied, network failure and `invalid_grant` end with Close and **Start sign-in again**, instead of only Close. - **Paste is visible by default.** The paste field is open when the browser step starts. A busy callback port says so (`The sign-in callback could not start because its port is in use.`). - **OpenAI Codex login is one method.** It starts with a device code (works on local and remote Gateways). When the device-code endpoint is not available (404), it falls back to browser sign-in by itself, instead of failing with "use ChatGPT OAuth instead". This replaces the separate browser-first and device-code choices. - **No terminal commands in Control UI or chat text.** The CLI keeps its own renderer, which prints `openclaw models auth login …`. - **A rejected saved sign-in has one recovery in chat.** The reply says to send `/login <provider>`, and the composer banner offers **Open Models** instead of contradicting it. Compatibility: - Retired auth choice ids still resolve through `deprecatedChoiceIds`: `openai-device-code` (shipped in v2026.5.12) and `xai-device-code` (shipped in v2026.5.19). The `--device-code` and `--method` CLI flags are kept. - The Plugin SDK changes are additive only (see Evidence). The deprecated `OAuthAuthorizationInput` type is kept. - The Gateway wizard protocol gets one optional `reason` field on a step and on an error result. Older clients ignore it, because wizard results are not validated on the client. A newer CLI against an older Gateway gets no `reason` and prints the plain message, as before. ## Why This Change Was Made One owner now decides sign-in failures: - `ProviderAuthFailure` carries a typed reason. Its recovery (`retry`, `wait`, `admin`) is derived from the reason in one place. - Provider plugins throw typed failures instead of formatting their own text. - The wizard session carries the reason to clients on progress updates and on the terminal result. The Control UI and chat render it with the one recovery action, and the CLI renders it with its command. - One shared SDK parser validates pasted callback addresses for every provider, so state checks and the error messages are the same everywhere. - Gateway provider sign-in gets `ctx.nodes` for paired-node access, so plugins do not reach into core internals. - `/login` authority is checked once, when the flow starts. Production code in the sign-in scope is smaller than on `main` (−305 lines). The superseded per-plugin failure formatting, the separate OpenAI authorization and preflight runtimes, MiniMax's own OAuth runtime and the duplicate auth-method matchers are removed. Danger: two-way door. A revert restores the previous text and flows. No stored state, config or schema changes. The blast radius is provider sign-in in the Control UI, chat `/login` and the CLI, for the bundled providers that sign in (OpenAI, Codex, xAI, OpenRouter, Chutes, LM Studio, MiniMax, GitHub Copilot) and for external plugins that use the provider-auth SDK, such as Gemini. ## Evidence **Failure matrix** (`src/plugins/provider-auth-failure.matrix.test.ts`, 31 cases: each failure × surface, plus refusal and paste cases): every case fails on `main` 8b61bc2 and passes on this branch. (The run on `main` had 39/39 failing; 8 of them were a helper-only group that was later removed, because the Control UI tests cover that path.) **Gates at the PR head:** - Tests: 87 in-scope test files across 22 Vitest shards pass, including the matrix. - Type checks: `tsgo:core`, `tsgo:core:test`, `tsgo:extensions` and `tsgo:ui` pass. - `ui:i18n:verify` and `protocol:check` pass. The protocol check includes the Swift and Kotlin contract checks. - oxlint is clean. - `ocx build --dts` and the packed release smoke (`scripts/release-check.ts`) pass. - Test-line growth above the 400-line allowance (+161) is recorded in `config/test-lines-allocations/203394-provider-sign-in-failure-owner.txt`: the matrix replaces per-plugin failure-text tests that this PR deletes. - The paste layout reuses the shared `.row`/`.stack` layout. The only new CSS is one compact-badge rule, within the Control UI CSS budget. **Line counts in the sign-in scope** (physical lines): | Class | main | this PR | Change | |---|---|---|---| | Production | 18093 | 17788 | **−305** | | Tests | 17250 | 17647 | +397 | **Plugin SDK API diff** (no entrypoint added or removed, no export removed). The declared additions are: - `ProviderAuthFailure`, plus its reason and recovery types. - `ctx.nodes` on the Gateway provider sign-in context (approved by the maintainer). - The shared paste parser for callback addresses. - An optional `reason` on `WizardProgress.update(message, reason?)`, `WizardSession.pushProgress` and the local OAuth callback `onProgress`. This optional parameter is why the diff tool marks 50 more exports that reach `WizardPrompter` as affected. **CLI commands in sign-in text.** All 35 earlier hits are classified: - Fixed (reaches the Control UI or chat), with the surface-neutral text now used: - the Codex auth bridge and the web-search setup note - the OpenAI unknown-model hint - the chat `/login` opener scope note - the Control UI save error for a profile that is already in use - the loopback callback page ("Return to the terminal") - the account-link RPC error - the auth-profile failover chat reply - the LM Studio key error - the shared `agentDir` config error - Kept, because they are CLI-only: doctor, onboarding, the TUI, CLI usage errors, the llama-cpp CLI setup and the CLI renderer. **Telegram `/login openai`, code denied** (real Telegram Test Server, stub device-code provider): - Before: `OpenAI login did not complete. Send /login openai/openai-device-code to try again.`, plus a separate "OAuth help" FAQ message, which was then edited. - After: `OpenAI: The sign-in code was denied. Send /login openai/openai to try again.` The FAQ message is gone. **Control UI, before (main) and after (this PR).** Captured on scratch Gateways with the real Gemini and OpenAI plugins. - Real provider endpoints were used for the expired device code (`auth.openai.com`, 15 minutes) and for `invalid_grant` (Google). - Consent redirects were simulated on the real callback URL. - Network drops and denials were stubbed through a proxy. No tokens, emails, real codes or live state appear in the images. Visible codes and state values are synthetic. | Case | Before | After | |---|---|---| | Consent denied (Gemini, Gateway callback) |  |  | | Consent denied, callback page |  |  | | Consent denied (OpenAI loopback) |  |  | | Wrong-state paste |  |  | | Busy callback port |  |  | | Device code expired (real, 15 min) |  |  | | Network drop at token exchange |  |  | | `invalid_grant` (real Google) |  |  | | Saved sign-in rejected later (chat) |  |  | | Paste success after three bad pastes (same attempt; ends on the known profile collision, see follow-ups) | — |  | **Local review:** a ClawSweeper local review of the PR head found the patch correct, with 0 findings. **Follow-ups (not in this PR):** - One shared device-code poller for providers that poll their own device codes. - A core chat text step, so chat sign-ins do not need provider-specific text. - Three chat-reachable diagnostics still use CLI wording: the provider auth recovery hint used by embedded-runner diagnostics, the failover re-auth command in fallback summaries, and the `openclaw configure` pattern in the failover user copy. - **Start sign-in again** in the waiting dialog, for the browser step. - The auth-profile collision on save is still an untyped error. - A few removal candidates were kept because their callers are unclear; they need a separate audit. Co-authored-by: Ayaan Zaidi <[email protected]>
…law#203478) ## What Problem This Solves A user signs in to a provider (for example "Sign in with Google (Gemini)") from Models in the Control UI on a phone or a laptop. The dialog asks them to approve access in the browser and paste back the address of the page it opened. While they are on the provider's page, the Control UI socket drops, or the phone discards and reloads the tab. When they come back, the dialog is gone and they must start the sign-in again. On a phone this happens almost every time, so remote Gateways (VPS, Docker, phone) could not finish a provider sign-in. This is older than openclaw#203394: the same repro fails on `160a2ebf64d5` (the parent of openclaw#203394) and on current `main`. `models.authLogin` has closed its sign-in when the starting socket closes since openclaw#171526 / openclaw#183777. ## User Impact User impact: leaving the Control UI tab during a provider sign-in no longer loses it. After a reconnect, the same step comes back with the address the user already typed. After a reload in the same browser, the same sign-in dialog reopens (the paste field is empty again: the one-time code is not stored in the browser). Pasting the address then finishes the sign-in as before. - If the Gateway no longer has the sign-in (Gateway restart, 25-minute timeout, or a newer sign-in replaced it), the reopened dialog says "This sign-in session ended" instead of disappearing. - A sign-in nobody watches no longer blocks other setup: a new sign-in from the same user or device replaces it, and so does anyone's once every connection that showed it is gone. While someone is still on the sign-in (including after a resume), another user's start stays "already in progress", as today. - Known and out of scope: MCP server sign-in (`mcp.authLogin`) and runtime setup still end when their socket closes. ## Why This Change Was Made One owner on each side, no new store, timer or config: - **Gateway:** `models.authLogin` now uses the same session contract as first-run provider sign-in (`openclaw.setup.auth.start`): the session outlives its socket and is reached again by its session id; the starter's retained grant still stops it when the device is revoked or downgraded. The existing per-owner replacement for provider sign-in now also covers `models.authLogin`, and it replaces a predecessor only when every connection that started or read it (`wizard.next`/`status`/`cancel`) is closed, so an abandoned tab cannot hold setup admission for 25 minutes. It no longer requires the replacement to use the same provider/agent/workspace: a user who starts another sign-in has abandoned the first one. - **Control UI:** the Models login suspends its wizard when the socket drops and resumes the same session on reconnect (same agent and recovery scope only), using the runner's existing `suspend`/`resume`. The typed value follows the model-setup draft rule, which keeps it through the reconnect. The existing activation record (`openclaw.modelSetup.pendingActivation.v1`, HMAC-bound to this browser's device key and credentials) now also records a Models sign-in, and a reloaded Models page reopens it with `restore`/`resume`. First-run setup ignores these records. The sign-in's choice, mode and recovery move into one sibling module (`login-sign-in.ts`); `login-controller.ts` stays at its line cap. A reopened sign-in also takes precedence over a provider picker the page's `?connect=1` route opened. ## Evidence Base side (reproduction, before the change): scratch Gateway on the same commit as this PR's base and on `160a2ebf64d5`, remote (tailnet) Control UI in headless mobile Chromium, Gemini OAuth plugin, Google sign-in page blocked: | Scenario | `160a2ebf64d5` (before openclaw#203394) | `main` base | This PR | |---|---|---|---| | Start sign-in, type the address, go offline 25 s, come back | no dialog | no dialog | same step, typed address kept | | Start sign-in, type the address, reload the page | provider picker, no paste field | provider picker, no paste field | same dialog, paste field shown | | After reconnect, paste an address with a made-up code | n/a | n/a | "Google rejected this sign-in (invalid_grant)": the resumed step reached the plugin and Google | | | Before (`main`) | After (this PR) | |---|---|---| | Socket drops, user comes back |  |  | | Page reloads |  |  | After the reconnect, a made-up code reaches Google:  Regression tests: - `src/gateway/server-methods/models-auth-login.test.ts` (red on base: 4 failed): the sign-in survives its socket, the returning operator reads the same step on a new socket, another owner stays busy while a returning connection (or any other reader, such as a second tab) is still open and replaces it once all are gone, and browser sign-in still stops on cancel. - `ui/src/e2e/model-provider-login-recovery.e2e.test.ts` (reload cases red on base): Models page with a mocked Gateway; reload of `?connect=1` reopens the step on the same session instead of the picker; a socket drop during the reloaded page's restore still reopens the sign-in after reconnect; a reload that finds no session says the sign-in ended, once (the next reload shows the picker); a reconnect keeps the step and typed address on the same session without a new start or a cancel (this one also passes on base: the base UI already rereads after a quick reconnect, and the base failure was the Gateway closing the session). - `ui/src/e2e/provider-browser-login-leave.real-gateway.e2e.test.ts`: real Gateway with a browser-callback provider fixture; start sign-in → socket drops → reconnect → approve → "ready"; and start → reload → approve → "ready". Green here; on the base build checkout its fixture never reached the login form, so its base side is covered by the live runs above instead. Removed tests that asserted the removed behavior: `models.authLogin` closing on disconnect, and same-owner sign-ins staying busy when the provider, agent, workspace, model target or native catalog setting differs. Review: local ClawSweeper round 1 found that a reload's restore deferred by a transient config or connection failure never retried; fixed in this head (it retries on the next connection or config change) with the socket-drop test above, red when the retry is removed. Round 2 found that a resumed sign-in could be replaced by another owner because only the starting socket counted; every open reader now counts (a later check found that a second tab's drop must not count as abandonment), with the Gateway test above. Not covered locally: the SQLite worker ratchet in `pnpm check:changed` runs out of heap on this host (it scans all source files; this change touches no database code). The other changed-lane checks pass. `model-providers-page.usage.test.ts` fails intermittently in the batched Models UI run: 2/5 runs on this branch and 3/5 on the base, same files. ## Merge danger Two-way door: a revert restores close-on-disconnect. No config, schema, protocol or stored Gateway state changes. The browser activation record keeps its format and gains one record kind. Blast radius if wrong: provider sign-in from Models and Model setup (a sign-in could be resumed by the wrong tab, or a new sign-in could replace another user's abandoned one), and first-run activation recovery that shares the record. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes: provider sign-in failures end the attempt with the wrong reason, raw provider errors, or a terminal command, when consent is denied, a wrong or unrelated address is pasted, the callback port is busy, a device code expires or is denied, the network drops during the token exchange, or a saved sign-in is rejected later.
Each provider plugin, the Control UI wizard, the chat
/loginflow and the CLI decided and worded these failures separately. The same failure looked different on every surface, and most of them told Control UI and chat users to run a CLI command.User Impact
User impact: a failed sign-in now names the cause in one plain sentence and offers one recovery action on every surface.
error=redirect show the reason under the field. The user fixes it without starting over.invalid_grantend with Close and Start sign-in again, instead of only Close.The sign-in callback could not start because its port is in use.).openclaw models auth login …./login <provider>, and the composer banner offers Open Models instead of contradicting it.Compatibility:
deprecatedChoiceIds:openai-device-code(shipped in v2026.5.12) andxai-device-code(shipped in v2026.5.19). The--device-codeand--methodCLI flags are kept.OAuthAuthorizationInputtype is kept.reasonfield on a step and on an error result. Older clients ignore it, because wizard results are not validated on the client. A newer CLI against an older Gateway gets noreasonand prints the plain message, as before.Why This Change Was Made
One owner now decides sign-in failures:
ProviderAuthFailurecarries a typed reason. Its recovery (retry,wait,admin) is derived from the reason in one place.ctx.nodesfor paired-node access, so plugins do not reach into core internals./loginauthority is checked once, when the flow starts.Production code in the sign-in scope is smaller than on
main(−305 lines). The superseded per-plugin failure formatting, the separate OpenAI authorization and preflight runtimes, MiniMax's own OAuth runtime and the duplicate auth-method matchers are removed.Danger: two-way door. A revert restores the previous text and flows. No stored state, config or schema changes. The blast radius is provider sign-in in the Control UI, chat
/loginand the CLI, for the bundled providers that sign in (OpenAI, Codex, xAI, OpenRouter, Chutes, LM Studio, MiniMax, GitHub Copilot) and for external plugins that use the provider-auth SDK, such as Gemini.Evidence
Failure matrix (
src/plugins/provider-auth-failure.matrix.test.ts, 31 cases: each failure × surface, plus refusal and paste cases): every case fails onmain2c47390 and passes on this branch. (The run onmainhad 39/39 failing; 8 of them were a helper-only group that was later removed, because the Control UI tests cover that path.)Gates at the PR head:
tsgo:core,tsgo:core:test,tsgo:extensionsandtsgo:uipass.ui:i18n:verifyandprotocol:checkpass. The protocol check includes the Swift and Kotlin contract checks.ocx build --dtsand the packed release smoke (scripts/release-check.ts) pass.config/test-lines-allocations/203394-provider-sign-in-failure-owner.txt: the matrix replaces per-plugin failure-text tests that this PR deletes..row/.stacklayout. The only new CSS is one compact-badge rule, within the Control UI CSS budget.Line counts in the sign-in scope (physical lines):
Plugin SDK API diff (no entrypoint added or removed, no export removed). The declared additions are:
ProviderAuthFailure, plus its reason and recovery types.ctx.nodeson the Gateway provider sign-in context (approved by the maintainer).reasononWizardProgress.update(message, reason?),WizardSession.pushProgressand the local OAuth callbackonProgress. This optional parameter is why the diff tool marks 50 more exports that reachWizardPrompteras affected.CLI commands in sign-in text. All 35 earlier hits are classified:
/loginopener scope noteagentDirconfig errorTelegram
/login openai, code denied (real Telegram Test Server, stub device-code provider):OpenAI login did not complete. Send /login openai/openai-device-code to try again., plus a separate "OAuth help" FAQ message, which was then edited.OpenAI: The sign-in code was denied. Send /login openai/openai to try again.The FAQ message is gone.Control UI, before (main) and after (this PR). Captured on scratch Gateways with the real Gemini and OpenAI plugins.
auth.openai.com, 15 minutes) and forinvalid_grant(Google).No tokens, emails, real codes or live state appear in the images. Visible codes and state values are synthetic.
invalid_grant(real Google)Local review: a ClawSweeper local review of the PR head found the patch correct, with 0 findings.
Follow-ups (not in this PR):
openclaw configurepattern in the failover user copy.