Skip to content

fix: report saved credentials and auth refresh failures - #144436

Merged
obviyus merged 1 commit into
mainfrom
feat/models-login-results
Sep 10, 2026
Merged

obviyus merged 1 commit into
mainfrom
feat/models-login-results

Conversation

@obviyus

@obviyus obviyus commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #136257, #144181.

What Problem This Solves

Fixes an issue where private-chat login reported completion after saving credentials even when the Gateway rejected authentication refresh or could not be reached. Settings-write failures also hid that credentials were already saved.

Why This Change Was Made

The login result carries refresh outcomes and saved-credential state. The shared login runtime owns completion and failure wording for generic chat and native Telegram while retaining cancellation, session switching and delivery behavior.

User Impact

Users receive accurate saved-credential and recovery guidance after partial success. Successful refresh keeps existing retry guidance. No configuration or permission change.

Consumers: generic chat and native Telegram render the shared login outcome.

Evidence

Producer and presentation regressions failed before the fix; 106 focused tests passed. Five real Telegram recordings verified acknowledged, rejected and unreachable refresh, rejected settings, and failure before save. Credentials were checked before and after each result. Synthetic login credentials were used; external authentication was not proved.

@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram commands Command implementations size: M maintainer Maintainer-authored PR labels Sep 10, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 10, 2026, 5:59 PM ET / 21:59 UTC.

ClawSweeper review

What this changes

The PR makes private-chat login replies distinguish saved credentials from Gateway refresh or provider-settings failures, using shared wording for Telegram and other chat surfaces.

Merge readiness

⛔ Blocked before merge - 1 item remains

This remains a useful, bounded fix: current main still loses the refresh outcome before presenting login completion. No blocking defect was found in the introduced changes.

Priority: P2
Reviewed head: b6f7b82836dc074ccd01db88fa6cd1795808a15a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with relevant regression coverage and recorded real-channel observations.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The recorded final-head Telegram Test Server observations exercise the normal login producer and native command across five save/refresh outcomes, with credential readback and corresponding replies; this supports the changed reporting behavior without claiming vendor OAuth coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The recorded final-head Telegram Test Server observations exercise the normal login producer and native command across five save/refresh outcomes, with credential readback and corresponding replies; this supports the changed reporting behavior without claiming vendor OAuth coverage.
Evidence reviewed 9 items Introduced production changes: The pinned merge-base comparison carries the existing refresh outcome through fresh and imported login results and replaces the existing post-save settings error with a typed error retaining its message and cause.
Current main still needs the fix: Current main selects completion wording from session-switch success alone and catches all login failures with the same generic message. The shared runtime also lacks refresh-result validation and outcome formatters.
Release comparison: The latest release contains shared-runtime blob 35954c6b39708e43c2300012e70ad2e527bc989e, the same pre-change blob identified by the introduced diff; that runtime does not carry the new outcome handling.
Findings None None.
Security None None.

How this fits together

OpenClaw’s provider-login owner saves credentials, applies settings, and requests Gateway auth refresh. Chat adapters use its result to update the session’s selected profile and tell the user whether login is ready or needs recovery.

flowchart TD
  A[Private chat login] --> B[Owner admission and login flow]
  B --> C[Save provider credentials]
  C --> D[Apply provider settings]
  D --> E[Refresh Gateway auth]
  E --> F[Adopt session profile]
  D --> G[Shared outcome wording]
  E --> G
  F --> G
  G --> H[Chat completion or recovery reply]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +50, Tests +240. Total +290 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 5 81 31 +50
Tests 4 289 49 +240
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 370 80 +290

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +50 net lines; tests +240 net lines Production growth carries typed outcome facts and centralizes wording; most growth protects failure and partial-success behavior.

Stored data model

Persistent data-model change detected: unknown-data-model-change: extensions/telegram/src/bot-native-command-login.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep login outcome facts in the existing producer and use one shared presentation owner without changing credential storage, defaults, or session-adoption policy.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: a successful credential save followed by failed Gateway refresh still reaches unconditional completion wording on current main. No runtime reproduction was executed in this review.

Is this the best way to solve the issue?

Yes. Propagating the existing refresh result and preserving the typed post-save failure fixes the reporting boundary without introducing another login or persistence implementation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4c32e1eab744.

Labels

Label changes:

  • add P2: This repairs misleading login completion and recovery messages for bounded post-save failures.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The recorded final-head Telegram Test Server observations exercise the normal login producer and native command across five save/refresh outcomes, with credential readback and corresponding replies; this supports the changed reporting behavior without claiming vendor OAuth coverage.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The recorded final-head Telegram Test Server observations exercise the normal login producer and native command across five save/refresh outcomes, with credential readback and corresponding replies; this supports the changed reporting behavior without claiming vendor OAuth coverage.
  • add proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The changed Telegram completion and recovery replies are directly observable on the Test Server.

Label justifications:

  • P2: This repairs misleading login completion and recovery messages for bounded post-save failures.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The recorded final-head Telegram Test Server observations exercise the normal login producer and native command across five save/refresh outcomes, with credential readback and corresponding replies; this supports the changed reporting behavior without claiming vendor OAuth coverage.
  • proof: sufficient: Contributor real behavior proof is sufficient. The recorded final-head Telegram Test Server observations exercise the normal login producer and native command across five save/refresh outcomes, with credential readback and corresponding replies; this supports the changed reporting behavior without claiming vendor OAuth coverage.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The changed Telegram completion and recovery replies are directly observable on the Test Server.

Evidence

What I checked:

Likely related people:

  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • arthurlacoste: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@obviyus

obviyus commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator Author

The stored-data migration flag is a false positive at b6f7b82836dc074ccd01db88fa6cd1795808a15a.

  • In extensions/telegram/src/bot-native-command-login.ts, the updateSessionStoreEntry call, admission comparisons, and returned patch remain unchanged. It still writes the same authProfileOverride, authProfileOverrideSource, and authProfileOverrideCompactionCount fields. The changed local boolean selects reply wording after that existing operation.
  • authRefresh carries an existing outcome in an in-process login result. ProviderAuthConfigApplyError is an in-memory error; neither is written into credential, session, or configuration storage. No schema, table, stored key, migration, or protocol version changes.
  • The runtime subpath is explicitly private-local. Both bundled callers move together; no supported external serialized contract changes.
  • Final-head Telegram readback proves the existing store remains usable across success and partial failure. The existing session-adoption and concurrency tests remain covered. Fresh exact-head local review independently found no compatibility, code, or security defect and rated the five-outcome behavior proof sufficient.

Comparison: git diff 00a859634fbf259b8de773a8f116aeb5094070b9 b6f7b82836dc074ccd01db88fa6cd1795808a15a -- extensions/telegram/src/bot-native-command-login.ts src/commands/models/auth.ts src/plugin-sdk/provider-auth-login-flow-runtime.ts src/shared/provider-auth-result.ts.

No data migration or additional source revision is needed for this reporting-only change.

@obviyus
obviyus merged commit 39b671d into main Sep 10, 2026
192 checks passed
@obviyus
obviyus deleted the feat/models-login-results branch September 10, 2026 22:08
@obviyus

obviyus commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator Author

Completed the focused follow-up to #144181.

Proof: Five real Telegram Test Server /login codex recordings cover successful refresh, rejected refresh, unreachable Gateway, saved credentials with rejected settings, and failure before save. Ordered credential readback, reply timing, zero inference, and cleanup passed. The fixture uses synthetic provider authentication.

  • Bug: Chat could report login ready after refresh failed, or hide a saved credential behind a generic settings-failure message.
  • Fix: The login owner returns the actual refresh result; generic chat and Telegram share outcome presentation and preserve session-switch failures.
Before After
Rejected refresh followed by “login complete.” Saved-credential notice with recovery guidance.
Settings failure looked like authentication never completed. Saved credentials and unapplied settings are reported separately.

106 targeted tests passed. The final built head also passed the three selected CLI/callback checks. Fresh exact-head ClawSweeper review found no code or security defects and rated behavior proof sufficient.

All exact-head checks passed. The guarded dry run and merge both exited 0; merge commit: 39b671dc74158f088adde3b4415de4547a0c902b. The required Co-authored-by: Ayaan Zaidi <[email protected]> trailer is verified.

The hosted migration classifier's flag was reconciled from the unchanged storage writers and fields. The local exact-head review cleared compatibility, security, and product proof. This merge used the normal guarded path without a CI or owner-review exception.

obviyus added a commit that referenced this pull request Sep 10, 2026
## Problem

Models sign-in also runs model setup, which can activate a provider's starter model. Bare `/login` starts OpenAI device authentication before the user chooses a provider.

## Solution

Add credential-only provider login in Models and one shared provider menu for chat. Plugins declare optional login choices in their manifests. Core resolves provider and method choices and produces existing command buttons or copyable commands. Bare `/login` always asks for a provider, even when only one is available. API-key and local setup methods remain available through explicit provider commands. `/login codex` retains its device-code flow.

The credential-only flow uses the shared persistence and auth-refresh owner from merged #144181. It preserves the selected model, restrictions, concurrent settings and existing account pins. Models publishes the saved credential through the current Gateway context. Cancellation locks at the real persistent-effect boundary; confirmed saves remain visible through later errors. Caller authority is checked at credential and session commits, and disconnected clients cannot finish pending login. Qualified choices reject stale or ambiguous plugin owners. Leaving Models closes its wizard input through the existing close operation and waits for admission to settle. This uses optional `closeInput` on `wizard.cancel`; ordinary cancellation still refuses to interrupt a protected save. Separate pending requests keep page disposal independent of an outstanding Cancel response.

The final conflict resolution also preserves the shared refresh outcomes from merged #144436: rejected or unreachable refresh reports saved credentials with recovery guidance. One shared error module carries saved-credential and settings-write failure facts, and the provider-neutral runtime owns completion/failure wording for both chat paths.

Channels render core-owned command actions. Provider-neutral recovery replaces the old OpenAI-specific recovery path. OpenAI, MiniMax and xAI declare their supported credential-only choices; methods requiring starter discovery retain setup.

## Impact

- No new configuration keys or database schema.
- Optional metadata preserves setup for plugins that omit it.
- Connecting a provider does not activate its default model.
- Chat selection rechecks current owner permission and availability.

## Evidence

Original baseline: `d35cefd9b7013e2a2fced8cf16b631a6ee476d45`. Integrated base after #144181: `7d2296e3339d1a9689ee020b102ba7c9a765e229`. The later required conflict resolution integrates #144436 at `39b671dc74158f088adde3b4415de4547a0c902b`.

- Real Telegram Test Server baseline: bare `/login` issued a device code before selection. Candidate: provider buttons, second method menu, synthetic device code, saved result and rejection of a stale qualified selection. Telegram transport and user actions are real; provider credentials are synthetic.
- Real Gateway baseline: `models.authLogin` was unknown. Candidate: saved fixture credential with the same default model and restrictions.
- Independent public-client checks cover singleton webchat selection, wrong-connection denial, unavailable choices, disconnect rejection and positive connected-owner completion. An existing CLI setup flow with omitted metadata still saves credentials and honors explicit `--set-default`.
- Integrated public-client cancellation proof: cancelling before save leaves no credential; cancelling after profile visibility while a provider note is pending returns running, and acknowledging the note produces the saved terminal result. A public settings edit during login survives; the saved profile appears without restarting the Gateway.
- Browser captures show Connect, explicit provider selection, the sign-in URL/code and saved result with the selected model unchanged. Captures were inspected.
- Current integrated focused Vitest: 243 passing tests across the auth producer and choice resolution, shared login runtime, core chat, native Telegram, Gateway wizard ownership, Models UI and the CLI sibling. Earlier retained checks cover method ordering, setup, MiniMax/xAI and provider recovery. The Telegram fixture cleanup preserves all test names, parameter rows and assertions; its 25 cases pass after cleanup.
- Page-disposal regression: the original Gateway kept waiting after a saved note, and the original Models page left the wizard unsettled on removal. The correction passes 33 Gateway and 49 UI tests, including disposal during a pending Cancel and a second login on the same connection. Fresh real-Gateway proof rejects a peer disposal, preserves the saved credential, returns truthful closure status, and immediately admits the same owner’s next login.
- Focused lint, assertion safety, runtime build and whitespace checks pass. Full typechecking and full CI run on GitHub.

This extracts Auth C+E from #136257 and replaces closed #142943. Auth A was merged before integration; its implementation was not copied into this branch.

## Deletion and rewrite ledger

`src/auto-reply/codex-login-recovery.ts` moved to `src/auto-reply/provider-login-recovery.ts`. Its `buildCodexLoginRecovery`, `CodexLoginRecoveryEvidence`, and `CodexLoginRecovery` symbols moved to `buildProviderLoginRecovery` (`:23`), `ProviderLoginRecoveryEvidence` (`:5`), and `ProviderLoginRecovery` (`:11`). The fixed OpenAI/Codex recovery action is replaced by the shared provider menu. No recovery test definition was deleted; the nine renamed or parameterized definitions are mapped below against head `73cfa4b319b9640a6711b2dc8e871d9ff4aea035`.

| Removed test name | Disposition | New test name and location |
| --- | --- | --- |
| `adds Codex login recovery to raw forwarded refresh failures` | **behavior moved** | `adds provider login recovery to raw forwarded refresh failures` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:51` |
| `keeps Codex login recovery actionable on Control UI turns` | **behavior moved** | `keeps provider login recovery actionable on Control UI turns` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:72` |
| `preserves Codex login recovery in known failure payloads` | **behavior moved** | `preserves provider login recovery in known failure payloads` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:118` |
| `keeps disabled OpenAI OAuth profiles actionable on later turns` | **behavior moved**; original OpenAI row retained, xAI and MiniMax rows added | `keeps disabled %s OAuth profiles actionable on later turns` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:228` |
| `does not offer Codex login for $label` | **behavior moved**; API-key and transient OAuth negative rows retained, provider-name-only negative row added | `does not offer provider login for $label` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:277` |
| `keeps non-OpenAI OAuth refresh failures on provider-specific terminal guidance` | **behavior moved and expanded**; terminal guidance retained, shared login action added | `adds provider login while retaining non-OpenAI terminal guidance` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:289` |
| `turns returned OpenAI refresh failures into Codex login recovery` | **behavior moved**; original OpenAI row retained, xAI and MiniMax rows added | `turns returned %s refresh failures into provider login recovery` — `src/agents/embedded-agent-runner/run/payloads.errors.test.ts:121` |
| `adds Codex login recovery to OpenAI OAuth refresh failures` | **behavior moved** | `adds provider login recovery to OpenAI OAuth refresh failures` — `src/cron/service.failure-alert.test.ts:845` |
| `does not offer Codex login for non-OAuth authentication failures` | **behavior moved** | `does not offer provider login for non-OAuth authentication failures` — `src/cron/service.failure-alert.test.ts:884` |

The obsolete provider restriction in `buildCodexLoginRecovery` is intentionally removed: typed non-OpenAI OAuth failures now receive the shared action while keeping their provider-specific terminal repair command. The old `/login codex` recovery presentation becomes `/login`; explicit `/login codex` remains supported. Typed OAuth evidence, negative authentication cases, private profile handling, and complete recovery-presentation assertions remain covered.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Sep 11, 2026
…144568)

## What Problem This Solves

Fixes an issue where users preparing a provider through Gateway setup received a raw config-changed error after saving credentials if another config edit occurred during login. The unrelated edit survived, but the provider settings were not applied and the error did not explain that the credential was already saved.

## Why This Change Was Made

CLI login and Gateway preparation now share one config writer. It applies only the provider's changes to the latest authored config, merges model rows by ID, rejects conflicting or invalid edits, and uses the existing saved-credential/settings-failure error. Pending plugin-install records remain with their existing commit owner.

The setup path no longer binds publication to the snapshot taken before login. Strict snapshot checks remain for migration promotion and verified setup operations that require them. Credential persistence, cancellation, and default-model policy retain their existing owners.

## User Impact

Unrelated edits made while provider setup waits for input survive, and setup can complete. If settings cannot be applied, setup explains that credentials were saved and retains the config owner's recovery guidance.

## Evidence

- Reproduced on main `a321595f496e5a95d2bd0ffe81f7a080b4fcdfc8` through the shipped Gateway client: start preparation, edit an unrelated setting while the provider key prompt waits, then complete. Before: raw config-changed error with credential saved. After: setup completes with the edit and credential retained.
- Real config-directory permission failure: before, config-only error despite a saved credential; after, explicit saved-credential/settings-failure message. Used isolated state and synthetic credentials.
- 45 targeted Gateway setup tests and 55 CLI auth tests pass. The three original new regressions fail on main. Added protection for a config that becomes invalid during login.
- Focused lint, formatting, line-count and assertion checks pass. Full type checks run in GitHub CI.

Related: #144181, #144436. No changes to the credential replacement paths under #144524.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 11, 2026
)

Related: openclaw#136257
Follows: openclaw#144181

## What Problem This Solves

Users running `/login codex` in private chat could receive “login complete” after credentials were saved even when the Gateway rejected the auth refresh or could not be reached. A failed provider-settings write after credential storage instead appeared as an ordinary login failure.

## Why This Change Was Made

The login owner now carries its existing refresh outcome through fresh and imported login results. A lightweight typed error preserves the saved-credential fact when applying provider settings fails, including the original CLI message and cause.

The existing shared login runtime validates the result and owns completion and failure wording for generic chat and native Telegram. Both callers retain their admission, cancellation, device-code delivery, session-adoption and terminal-delivery owners. A failed session switch remains visible alongside a failed refresh.

## User Impact

- Successful refresh keeps the existing retry guidance.
- Rejected or unreachable refresh says credentials were saved and gives recovery guidance.
- A failed provider-settings write is distinguished from a failure before credentials were saved.
- This adds no configuration key, protocol change, permission change, provider menu or live OAuth behavior.

## Evidence

- Baseline `19250eca`: five producer regressions and two refresh-presentation cases in each chat surface fail before the fix.
- 106 focused tests pass: producer 55, generic chat 26, native Telegram 22, owner pairing callback 1, shipped CLI integration 2. The final rebase preserves the contribution; the callback and CLI cases also pass on `b6f7b82836dc`.
- Formatting, focused lint, assertion and size ratchets, normal commit hooks, the final build and built Telegram startup check pass on Testbox.
- Real Telegram Test Server baseline: `/login codex` receives an actual rejected refresh, then incorrectly says “login complete.”

Five independent real-Telegram recordings pass on the final built head, each with ordered before/after credential readback, zero inference, and verified cleanup:

| Outcome | Observed result | Sent message ID |
| --- | --- | --- |
| Refresh acknowledged | Completion follows the actual Gateway acknowledgment; credential remains saved. | 13852737536 |
| Refresh rejected | Saved-credential notice and recovery guidance follow the actual rejection. | 13856931840 |
| Gateway unreachable | Saved-credential notice explains the missing Gateway application. | 13861126144 |
| Provider settings rejected | Credential remains saved; invalid settings are rejected; the reply preserves both facts. | 13865320448 |
| Failure before save | Ordinary failure reply; credential store remains empty. | 13869514752 |

The channel fixture uses a synthetic provider credential through the normal login producer and the real native Telegram command. It does not claim live vendor OAuth or inference. Full event files retain sent message IDs, timestamps and ordering; identity and private-path redactions are recorded with hashes. Earlier heartbeat-contaminated and unordered-snapshot recordings remain disclosed as failed or limited evidence.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 11, 2026
…#144329)

## Problem

Models sign-in also runs model setup, which can activate a provider's starter model. Bare `/login` starts OpenAI device authentication before the user chooses a provider.

## Solution

Add credential-only provider login in Models and one shared provider menu for chat. Plugins declare optional login choices in their manifests. Core resolves provider and method choices and produces existing command buttons or copyable commands. Bare `/login` always asks for a provider, even when only one is available. API-key and local setup methods remain available through explicit provider commands. `/login codex` retains its device-code flow.

The credential-only flow uses the shared persistence and auth-refresh owner from merged openclaw#144181. It preserves the selected model, restrictions, concurrent settings and existing account pins. Models publishes the saved credential through the current Gateway context. Cancellation locks at the real persistent-effect boundary; confirmed saves remain visible through later errors. Caller authority is checked at credential and session commits, and disconnected clients cannot finish pending login. Qualified choices reject stale or ambiguous plugin owners. Leaving Models closes its wizard input through the existing close operation and waits for admission to settle. This uses optional `closeInput` on `wizard.cancel`; ordinary cancellation still refuses to interrupt a protected save. Separate pending requests keep page disposal independent of an outstanding Cancel response.

The final conflict resolution also preserves the shared refresh outcomes from merged openclaw#144436: rejected or unreachable refresh reports saved credentials with recovery guidance. One shared error module carries saved-credential and settings-write failure facts, and the provider-neutral runtime owns completion/failure wording for both chat paths.

Channels render core-owned command actions. Provider-neutral recovery replaces the old OpenAI-specific recovery path. OpenAI, MiniMax and xAI declare their supported credential-only choices; methods requiring starter discovery retain setup.

## Impact

- No new configuration keys or database schema.
- Optional metadata preserves setup for plugins that omit it.
- Connecting a provider does not activate its default model.
- Chat selection rechecks current owner permission and availability.

## Evidence

Original baseline: `f1881c4f376edf3229e669c189cbd2f4a453a3ea`. Integrated base after openclaw#144181: `872107b561da08e74f1402e03d724136fc521ae6`. The later required conflict resolution integrates openclaw#144436 at `1f2227f786967da4b4bd3662501df6ea0003d2c3`.

- Real Telegram Test Server baseline: bare `/login` issued a device code before selection. Candidate: provider buttons, second method menu, synthetic device code, saved result and rejection of a stale qualified selection. Telegram transport and user actions are real; provider credentials are synthetic.
- Real Gateway baseline: `models.authLogin` was unknown. Candidate: saved fixture credential with the same default model and restrictions.
- Independent public-client checks cover singleton webchat selection, wrong-connection denial, unavailable choices, disconnect rejection and positive connected-owner completion. An existing CLI setup flow with omitted metadata still saves credentials and honors explicit `--set-default`.
- Integrated public-client cancellation proof: cancelling before save leaves no credential; cancelling after profile visibility while a provider note is pending returns running, and acknowledging the note produces the saved terminal result. A public settings edit during login survives; the saved profile appears without restarting the Gateway.
- Browser captures show Connect, explicit provider selection, the sign-in URL/code and saved result with the selected model unchanged. Captures were inspected.
- Current integrated focused Vitest: 243 passing tests across the auth producer and choice resolution, shared login runtime, core chat, native Telegram, Gateway wizard ownership, Models UI and the CLI sibling. Earlier retained checks cover method ordering, setup, MiniMax/xAI and provider recovery. The Telegram fixture cleanup preserves all test names, parameter rows and assertions; its 25 cases pass after cleanup.
- Page-disposal regression: the original Gateway kept waiting after a saved note, and the original Models page left the wizard unsettled on removal. The correction passes 33 Gateway and 49 UI tests, including disposal during a pending Cancel and a second login on the same connection. Fresh real-Gateway proof rejects a peer disposal, preserves the saved credential, returns truthful closure status, and immediately admits the same owner’s next login.
- Focused lint, assertion safety, runtime build and whitespace checks pass. Full typechecking and full CI run on GitHub.

This extracts Auth C+E from openclaw#136257 and replaces closed openclaw#142943. Auth A was merged before integration; its implementation was not copied into this branch.

## Deletion and rewrite ledger

`src/auto-reply/codex-login-recovery.ts` moved to `src/auto-reply/provider-login-recovery.ts`. Its `buildCodexLoginRecovery`, `CodexLoginRecoveryEvidence`, and `CodexLoginRecovery` symbols moved to `buildProviderLoginRecovery` (`:23`), `ProviderLoginRecoveryEvidence` (`:5`), and `ProviderLoginRecovery` (`:11`). The fixed OpenAI/Codex recovery action is replaced by the shared provider menu. No recovery test definition was deleted; the nine renamed or parameterized definitions are mapped below against head `73cfa4b319b9640a6711b2dc8e871d9ff4aea035`.

| Removed test name | Disposition | New test name and location |
| --- | --- | --- |
| `adds Codex login recovery to raw forwarded refresh failures` | **behavior moved** | `adds provider login recovery to raw forwarded refresh failures` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:51` |
| `keeps Codex login recovery actionable on Control UI turns` | **behavior moved** | `keeps provider login recovery actionable on Control UI turns` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:72` |
| `preserves Codex login recovery in known failure payloads` | **behavior moved** | `preserves provider login recovery in known failure payloads` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:118` |
| `keeps disabled OpenAI OAuth profiles actionable on later turns` | **behavior moved**; original OpenAI row retained, xAI and MiniMax rows added | `keeps disabled %s OAuth profiles actionable on later turns` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:228` |
| `does not offer Codex login for $label` | **behavior moved**; API-key and transient OAuth negative rows retained, provider-name-only negative row added | `does not offer provider login for $label` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:277` |
| `keeps non-OpenAI OAuth refresh failures on provider-specific terminal guidance` | **behavior moved and expanded**; terminal guidance retained, shared login action added | `adds provider login while retaining non-OpenAI terminal guidance` — `src/auto-reply/reply/agent-runner-execution-auth-failures.test.ts:289` |
| `turns returned OpenAI refresh failures into Codex login recovery` | **behavior moved**; original OpenAI row retained, xAI and MiniMax rows added | `turns returned %s refresh failures into provider login recovery` — `src/agents/embedded-agent-runner/run/payloads.errors.test.ts:121` |
| `adds Codex login recovery to OpenAI OAuth refresh failures` | **behavior moved** | `adds provider login recovery to OpenAI OAuth refresh failures` — `src/cron/service.failure-alert.test.ts:845` |
| `does not offer Codex login for non-OAuth authentication failures` | **behavior moved** | `does not offer provider login for non-OAuth authentication failures` — `src/cron/service.failure-alert.test.ts:884` |

The obsolete provider restriction in `buildCodexLoginRecovery` is intentionally removed: typed non-OpenAI OAuth failures now receive the shared action while keeping their provider-specific terminal repair command. The old `/login codex` recovery presentation becomes `/login`; explicit `/login codex` remains supported. Typed OAuth evidence, negative authentication cases, private profile handling, and complete recovery-presentation assertions remain covered.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 11, 2026
…penclaw#144568)

## What Problem This Solves

Fixes an issue where users preparing a provider through Gateway setup received a raw config-changed error after saving credentials if another config edit occurred during login. The unrelated edit survived, but the provider settings were not applied and the error did not explain that the credential was already saved.

## Why This Change Was Made

CLI login and Gateway preparation now share one config writer. It applies only the provider's changes to the latest authored config, merges model rows by ID, rejects conflicting or invalid edits, and uses the existing saved-credential/settings-failure error. Pending plugin-install records remain with their existing commit owner.

The setup path no longer binds publication to the snapshot taken before login. Strict snapshot checks remain for migration promotion and verified setup operations that require them. Credential persistence, cancellation, and default-model policy retain their existing owners.

## User Impact

Unrelated edits made while provider setup waits for input survive, and setup can complete. If settings cannot be applied, setup explains that credentials were saved and retains the config owner's recovery guidance.

## Evidence

- Reproduced on main `c073aed1cfd1ae78c62b1920e76456b595e26950` through the shipped Gateway client: start preparation, edit an unrelated setting while the provider key prompt waits, then complete. Before: raw config-changed error with credential saved. After: setup completes with the edit and credential retained.
- Real config-directory permission failure: before, config-only error despite a saved credential; after, explicit saved-credential/settings-failure message. Used isolated state and synthetic credentials.
- 45 targeted Gateway setup tests and 55 CLI auth tests pass. The three original new regressions fail on main. Added protection for a config that becomes invalid during login.
- Focused lint, formatting, line-count and assertion checks pass. Full type checks run in GitHub CI.

Related: openclaw#144181, openclaw#144436. No changes to the credential replacement paths under openclaw#144524.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram commands Command implementations maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant