Skip to content

fix(auth): clear deleted account selections and support account recovery - #157745

Merged
stevenlee-oai merged 4 commits into
mainfrom
dev/stevenlee/siwc-reconnect-selection
Sep 25, 2026
Merged

stevenlee-oai merged 4 commits into
mainfrom
dev/stevenlee/siwc-reconnect-selection

Conversation

@stevenlee-oai

@stevenlee-oai stevenlee-oai commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Removing a provider credential left model defaults and conversations pointing at its old profile ID. Signing in again could work until switching models restored the deleted selection. Recovery also failed to offer an already connected shared account.

User Impact

  • Credential lifecycle: Explicit deletion releases the removed credential from affected agent model defaults, conversation selections, fallback state, and queued follow-ups. Model choices stay intact. Scoped cleanup preserves independent accounts in other agents and concurrent reconnects; partial removal restores surviving references.
  • Account recovery: Older stale selections can use an existing saved or shared account. Gateway verification must succeed before changing the agent default. The chooser matches the model's credential owner, even when a display card groups different login systems.
  • Composer account freshness: Auth publications refresh the mounted composer's account identity. Account choices reload from the updated catalog selection, so reconnecting or changing accounts no longer leaves the composer showing a generic sign-in label or stale choices.
  • Provider navigation: The Chat and New Conversation gears open that provider's settings for the source agent. Explicit connect actions still open setup.

Why This Change Was Made

The existing deletion, session-write, and shared-auth request owners now drive cleanup, recovery, and mounted UI refresh.

Sign-in alone remains save-only. Expiry and temporary inventory gaps do not clear account selections. Personal account ownership and credential storage formats are unchanged.

Evidence

  • Composer regression reproduced the old fallback label after an auth event, then passed with the fix. The bundled browser file passes all 15 tests (25.83s including UI build; new scenario 1.61s), including updated account choices; six existing stale-response guards pass (6.42s wrapper).
  • 161 focused tests passed across credential removal, OAuth peers, queued work, and account-recovery UI. New regressions reproduce the deletion/model-switch bug and both reconnect races before the fix.
  • Browser recovery scenario passed using the bundled UI with a mock Gateway (screenshots below).
  • Core/UI production types and all core test type graphs passed; changed-file formatting and lint passed. Storage, import-cycle, unused-export, and auth-boundary guards also passed.
  • Independent P0–P2 review of the composer refresh update: no actionable findings. Broader-PR review comments are outside this update.

Browser evidence uses synthetic accounts and a mock Gateway. No new live OAuth/inference run or native Mac retest is claimed. Existing setup activation tests cover verification and configuration; lifecycle regressions use real credential and session databases.

Known follow-up: the existing OpenAI usage widget invokes Codex subscription usage for SIWC profiles, producing a public-API-route error. Its refresh icon refreshes usage statistics; it is not an OAuth renewal control.

Existing shared account recovery (synthetic browser proof)

Existing shared account can be selected

Verified account selected

Inspected before/after screenshots (synthetic accounts)
Flow Before After
Removed account No account recovery action Choose a replacement account
Composer gear Unexpected new-connection dialog Provider settings for the source agent

Replacement account selection:

Explicit replacement selection

Mobile replacement selection

Composer refresh after an external auth publication (synthetic accounts, mock Gateway)
Before fix After fix
Generic account label after auth changes Replacement email and updated account choices

@clawsweeper

clawsweeper Bot commented Sep 25, 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.

@stevenlee-oai
stevenlee-oai marked this pull request as ready for review September 25, 2026 00:12
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 25, 2026, 2:02 AM ET / 06:02 UTC (Revision 3).

ClawSweeper review

What this changes

The branch clears deleted account references from model defaults, sessions, and queued replies, adds saved-account recovery and provider settings navigation in the Control UI, and refreshes the chat composer after auth changes.

Merge readiness

⛔ Blocked before merge - 5 items remain

Current main does not provide the requested recovery behavior. The latest head still has two previously reported edge cases that block a safe merge.

Priority: P1
Reviewed head: d2f0d8bbec7d87ee70ce0784ce6f66d80bdaf8e3

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The branch has useful UI evidence and focused lifecycle coverage, but two concrete recovery defects remain.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The maintainer-author proof gate does not apply. Inspected synthetic browser screenshots show the common Control UI recovery flow, and the PR reports real SQLite lifecycle tests; neither establishes recovery from an unreadable existing session store. Persisted-state compatibility remains insufficient for that case.
Patch quality 🦐 gold shrimp (3/6) 2 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-author proof gate does not apply. Inspected synthetic browser screenshots show the common Control UI recovery flow, and the PR reports real SQLite lifecycle tests; neither establishes recovery from an unreadable existing session store. Persisted-state compatibility remains insufficient for that case.
Evidence reviewed 8 items Recovery still depends on a sign-in method: The new recovery action opens the provider picker, but that picker creates groups only from login options or quick API-key setup; it never creates a group from saved profiles alone.
Methodless provider capability is supported: The Gateway test expects a GitHub Copilot capability with neither a UI login option nor quick API-key setup, establishing the capability shape the recovery picker must handle.
Unreadable session store after removal: Session cleanup throws when an existing database cannot be read. The command calls this cleanup after credential removal and has no pending-cleanup record or restoration path.
Findings 2 actionable findings [P2] Offer saved accounts without requiring a sign-in method
[P2] Keep session cleanup recoverable after credential deletion
Security None None.

How this fits together

OpenClaw's credential removal command updates saved credentials, agent settings, and conversation selections. The Control UI reads Gateway account status and asks the Gateway to verify a replacement before selecting it for an agent.

flowchart LR
  A[Saved credentials] --> B[Credential removal]
  B --> C[Agent model settings]
  B --> D[Sessions and queued replies]
  C --> E[Gateway account status]
  E --> F[Control UI recovery]
  F --> G[Verified account selection]
Loading

Before merge

  • Offer saved accounts without requiring a sign-in method (P2) - The new recovery button opens loginProviders, which creates provider groups only from loginOptions or quick API-key setup. A provider can have a compatible saved profile and neither method, as the Gateway capability test demonstrates, so the picker has no group and never shows “Use this account.” Build recovery groups from compatible saved profiles too.
  • Keep session cleanup recoverable after credential deletion (P2) - An unreadable existing session database throws here after the credential has already been removed. Its stored account override is left behind, while a second logout cannot find the deleted profile to resume cleanup. Preserve a retryable cleanup path or prevent deletion before this failure can strand the session.
  • Resolve merge risk (P1) - Recovery still offers no usable replacement choice when a provider has a saved compatible account but no advertised Control UI sign-in method.
  • Resolve merge risk (P1) - If an existing session database is unreadable after credential deletion, its old account selections remain and the removal cannot be retried through the same logout path.
  • Complete next step (P2) - Expose compatible saved accounts without requiring a login method, and establish a retryable outcome for an unreadable existing session database after credential deletion.

Findings

  • [P2] Offer saved accounts without requiring a sign-in method — ui/src/pages/model-providers/login-controller.ts:163-166
  • [P2] Keep session cleanup recoverable after credential deletion — src/sessions/auth-profile-removal.ts:46-53
Agent review details

Security

None.

PR surface

Source +793, Tests +1149, Docs 0. Total +1942 across 38 files.

View PR surface stats
Area Files Added Removed Net
Source 22 882 89 +793
Tests 15 1213 64 +1149
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 38 2096 154 +1942

Review metrics

Metric Value Why it matters
Source and test growth source +793 net lines; tests +1,149 net lines The growth covers credential, session, and UI owners, making the remaining recovery cases important to settle before merge.

Merge-risk options

Maintainer options:

  1. Repair both recovery paths (recommended)
    Offer methodless saved accounts in the picker and preserve a retryable outcome when an existing session store cannot be read after deletion.
  2. Pause the branch
    Hold the PR if the credential and session owners cannot provide a safe recovery path within this change.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Cover recovery with a saved compatible account whose provider has no login option or quick-key method; make unreadable existing-session cleanup recoverable after credential deletion and prove the retry on persisted state.

Technical review

Best possible solution:

Make deletion recoverable across credential and session owners, and build recovery choices from compatible saved accounts independently of sign-in methods.

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

Yes. Current-main source supports a pinned-account deletion and model-switch reproduction path; this read-only review did not execute it.

Is this the best way to solve the issue?

No. The branch uses the relevant credential and Gateway owners, but methodless saved accounts remain unreachable and post-deletion session cleanup lacks recovery.

Full review comments:

  • [P2] Offer saved accounts without requiring a sign-in method — ui/src/pages/model-providers/login-controller.ts:163-166
    The new recovery button opens loginProviders, which creates provider groups only from loginOptions or quick API-key setup. A provider can have a compatible saved profile and neither method, as the Gateway capability test demonstrates, so the picker has no group and never shows “Use this account.” Build recovery groups from compatible saved profiles too.
    Confidence: 0.95
  • [P2] Keep session cleanup recoverable after credential deletion — src/sessions/auth-profile-removal.ts:46-53
    An unreadable existing session database throws here after the credential has already been removed. Its stored account override is left behind, while a second logout cannot find the deleted profile to resume cleanup. Preserve a retryable cleanup path or prevent deletion before this failure can strand the session.
    Confidence: 0.92

Overall correctness: patch is incorrect
Overall confidence: 0.91

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1976a166443f.

Labels

Label changes:

  • add merge-risk: 🚨 session-state: A failed post-deletion session read can leave persisted account selections tied to a removed credential.
  • remove proof: sufficient: Current real behavior proof status is not_applicable, not sufficient.

Label justifications:

  • P1: Deleting an account can leave an agent's account recovery or conversation selection broken for affected users.
  • merge-risk: 🚨 auth-provider: The new replacement flow can fail to offer an existing compatible credential when its provider has no UI sign-in method.
  • merge-risk: 🚨 session-state: A failed post-deletion session read can leave persisted account selections tied to a removed credential.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The maintainer-author proof gate does not apply. Inspected synthetic browser screenshots show the common Control UI recovery flow, and the PR reports real SQLite lifecycle tests; neither establishes recovery from an unreadable existing session store. Persisted-state compatibility remains insufficient for that case.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The maintainer-author proof gate does not apply. Inspected synthetic browser screenshots show the common Control UI recovery flow, and the PR reports real SQLite lifecycle tests; neither establishes recovery from an unreadable existing session store. Persisted-state compatibility remains insufficient for that case.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs ui/src/pages/model-providers/model-providers-page.recovery.test.ts.
  • [P1] node scripts/run-vitest.mjs src/commands/models/auth-api-key.test.ts.
  • [P1] node scripts/run-vitest.mjs src/auto-reply/reply/queue/state.test.ts.
  • [P1] git diff --check.

What I checked:

  • Recovery still depends on a sign-in method: The new recovery action opens the provider picker, but that picker creates groups only from login options or quick API-key setup; it never creates a group from saved profiles alone. (ui/src/pages/model-providers/login-controller.ts:165, d2f0d8bbec7d)
  • Methodless provider capability is supported: The Gateway test expects a GitHub Copilot capability with neither a UI login option nor quick API-key setup, establishing the capability shape the recovery picker must handle. (src/gateway/server-methods/models-auth-status.test.ts:849, d2f0d8bbec7d)
  • Unreadable session store after removal: Session cleanup throws when an existing database cannot be read. The command calls this cleanup after credential removal and has no pending-cleanup record or restoration path. (src/sessions/auth-profile-removal.ts:51, d2f0d8bbec7d)
  • Deletion precedes session cleanup: The removal command invokes session cleanup in its finalization path after the credential owner has reported removal; a later cleanup error cannot be retried by logging out the now-missing profile. (src/commands/models/auth-logout.ts:308, d2f0d8bbec7d)
  • Prior findings remain on unchanged code: The prior completed review raised saved-account recovery without a sign-in method and post-deletion session recoverability. Neither affected file changed between its reviewed head and this head. (d2f0d8bbec7d)
  • Visual proof inspected: The prepared before/after images show the common recovery prompt and a shared-account choice with synthetic accounts. They do not exercise a methodless provider or an unreadable session database. (d2f0d8bbec7d)

Likely related people:

  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • stevenlee-oai: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Cover saved-account recovery when the provider advertises no Control UI sign-in method.
  • Prove a recoverable outcome when an affected existing session database is unreadable after deletion.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-25T00:35:49.236Z sha 823c535 :: blocked before merge. :: [P2] Filter recovery accounts by credential owner
  • reviewed 2026-09-25T01:42:53.820Z sha 66a7f28 :: blocked before merge. :: [P2] Show saved accounts without requiring a sign-in method | [P2] Keep session cleanup recoverable after credential deletion

@stevenlee-oai stevenlee-oai changed the title fix(ui): recover removed accounts and open provider settings fix(auth): clear deleted account selections and support account recovery Sep 25, 2026
@stevenlee-oai

Copy link
Copy Markdown
Contributor Author

Codex: addressed the credential-owner finding in 66a7f28e289. Recovery now matches each profile's auth provider to the selected model's auth provider, independently of display-card grouping. Mixed MiniMax and CN-alias regressions fail before the fix and pass afterward. Existing inherited/shared accounts can also be selected through the same verified activation flow.

This update additionally repairs the deletion lifecycle: confirmed removal clears affected model, conversation, fallback, and queued references while preserving models, independent same-ID agent credentials, and concurrent reconnects. Real SQLite regressions cover delete/reconnect/model-switch and both session/queue reconnect races. Expiry and transient inventory gaps do not clear selections.

Validation: 161 focused tests, bundled-UI browser recovery with a mock Gateway, production and test type checks, formatting/lint, and independent P0–P2 review passed. Updated screenshots and scope details are in the PR description. No new live OAuth/inference or Mac retest is claimed.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: d2f0d8bbec7d87ee70ce0784ce6f66d80bdaf8e3
  • Maintainer: @stevenlee-oai
  • Repository role: maintain

These security sensitive changes were made:

  • src/agents/auth-profiles/oauth-refresh-peers.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/profiles.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui commands Command implementations agents Agent runtime and tooling size: XL labels Sep 25, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. labels Sep 25, 2026
@stevenlee-oai
stevenlee-oai merged commit 0125ffa into main Sep 25, 2026
229 of 236 checks passed
@stevenlee-oai
stevenlee-oai deleted the dev/stevenlee/siwc-reconnect-selection branch September 25, 2026 06:18
vincentkoc added a commit that referenced this pull request Sep 25, 2026
…4-prep

* commit '8fe893da516ebdc817692fb2d272e27bc3c88376': (31 commits)
  fix(test): wait for reload admission before restart polling (#157964)
  refactor(mattermost): reuse DM retry option selection (#157800)
  chore(i18n): refresh native locales (#157850)
  perf(sessions): reuse current participants across transcript appends (#157622)
  refactor(signal): share pending transport migration results (#157777)
  fix(tui): open model pickers without waiting for the Gateway (#157839)
  fix(gateway): apply config despite delayed file notifications (#157906)
  fix(auth): clear deleted account selections and support account recovery (#157745)
  fix: plugin reloads lose tool results and strand subagent settlement (#157339)
  fix(gateway): avoid preview errors during worker metadata updates (#157943)
  refactor(diffs): reuse native promisify for compression (#157835)
  fix(models): keep current choices on the first picker page (#157869)
  fix(plugins): retain existing quarantine across unrelated reloads (#157907)
  fix(openai): prioritize ChatGPT sign-in and clarify auth choices (#157792)
  chore(ui): refresh control ui locales (#157955)
  fix(ui): refresh connected accounts after auth changes (#157950)
  fix(scripts): avoid redundant npm version process in package checks (#157809)
  refactor(usage): capture hosted pricing once per operation (#157838)
  refactor(ui): share slash-command failure results (#157649)
  fix(cron): announce runs miss the channel's formatting rules (#157877)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 26, 2026
…ery (openclaw#157745)

* fix(ui): recover removed accounts and open provider settings

* fix(ui): use the narrowed provider route snapshot

* fix(auth): release deleted account selections across agents and sessions

* fix(ui): refresh composer accounts after auth changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui commands Command implementations docs Improvements or additions to documentation merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant