Repository navigation
fix: let local TUI /auth sign in to providers again - #200605
Conversation
|
🦞👀 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: blocked before merge. What this changesRuns built-in provider login inside the local TUI, refreshes active credentials, and completes cancellation and resource cleanup during shutdown. Example: Run /auth github-copilot after a completed local TUI chat turn.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this PR repairs current local TUI sign-in failures and addresses both maintainer-reported shutdown defects; no actionable code findings remain. Reviewed head: Before merge
FindingsNone. Agent review detailsHow this fits togetherThe local TUI holds state ownership and drives the embedded agent; provider login saves credentials through shared persistence, publishes them into the active runtime, and returns control to chat. flowchart TD
A[Local TUI] --> B[Shared provider login]
B --> C[Credential persistence]
C --> D[Active credential snapshot]
D --> E[Embedded model request]
A --> F[Shutdown owner]
F --> G[Prepared model retirement]
G --> H[Database and worker cleanup]
Technical reviewBest possible solution: Land the existing-owner sign-in and shutdown repair after the approved current-head workflows satisfy required CI. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the competing process ownership and stale credential-publication paths, corroborated by supplied failure controls; this read-only review executed no target code. Is this the best way to solve the issue? The patch fixes the responsible boundaries directly by reusing shared login, persistence, snapshot publication, and ordered cleanup instead of adding another state owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d0f826bea860. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +40, Tests +120, Docs +2. Total +162 across 16 files. Added test files: 0. View PR surface stats
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. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 HistoryReview history (4 earlier review cycles)
Reviewed November 27, 2026, 1:41 AM ET / 06:41 UTC (Revision 5). |
|
@clawsweeper re-review Added the requested sanitized product terminal capture directly to the PR body under Captured terminal evidence (2026-11-18). It was freshly recorded from the built CLI at unchanged head The capture shows cancellation, successful retry, resumed chat, and the final authentication prompt before SIGTERM. The matching scenario passed in 9.205 s and verifies credential persistence, next-request credential use, unchanged model selection, and exit code 0. The synthetic-provider/local-model scope and redaction details are stated alongside the capture. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Please review |
|
🦞👀 Re-review progress:
|
The child-process login could not acquire gateway state ownership while the TUI held it, so /auth failed before the post-login refresh ever ran. Run the login in-process through the TUI's own state owner (sharing the embedded runtime), matching the approved openclaw#200605 shape. The post-login republish still goes through the module-scoped secrets-layer binding (refreshRuntimeAuthProfileStoreAfterLogin), so the persisted store is re-observed and republished into the active runtime generation without relying on an external file event. The prepared-model-runtime lifetimes key is exposed so CLI cleanup releases model generations backed by native workers, letting the TUI exit on SIGTERM while an auth prompt is open. Regression: the built-CLI PTY scenario now exercises cancellation, retry, credential entry, and a resumed request carrying the new credential for both an inline API key and a store-backed token. Co-Authored-By: nebulacoder-v8.0 <[email protected]>
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.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@jtmyershp thanks again for the detailed reports in #200558 and #201751. This PR fixes both and is waiting for maintainer review. One part is still unverified: my runs used a synthetic provider and token, so GitHub Copilot's real device-code sign-in wasn't covered. If you have a few minutes, could you try the PR head (
A short reply is enough: whether it worked, or where it failed with the error text (for example, |
|
@ArcueidMP Sorry for the delay, and thank you for everything you've done so far! I built and tested PR head Everything worked end-to-end without restarting the TUI:
Redacted terminal excerpt |
|
@jtmyershp Thanks! This was the one check I couldn't run myself: the real GitHub Copilot device-code sign-in. Your run covers both reports. Sign-in finished in-process with no state-ownership conflict (#200558), and signing in again after a completed turn kept working on the same model without the materialization error (#201751). Nothing more is needed from you; the PR is now waiting for maintainer review. |
|
I reproduced two shutdown bugs on c156520 that need fixing before merge. Aborting the local TUI while a credential save is waiting still lets the save go through with no cancellation guard and report success. Also, in runtime-cleanup-scope.ts, if closing the prepared model runtime rejects, the SQLite, native worker, and Postgres pool cleanup after it gets skipped. |
Pass the local shutdown guard to the credential writer so a pending save cannot replace an existing profile after cancellation. Retire prepared models as a separate ordered CLI disposer so a rejected model close still allows shared resources to drain.
|
@clawsweeper re-review Both shutdown cases reported on |
|
🦞👀 Re-review progress:
|
|
Thanks for catching these. Both are fixed in d2e80ad:
|
* commit 'fd681ab8786e062045fa5ec6261b1b06f60832eb': (2115 commits) fix: keep doctor --fix pending checks from creating SQLite sidecars (#206485) fix(ci): update iOS screenshot reducer gate (#206497) fix: keep chat photo previews sharp within their byte limits (#206461) fix: let agents use short Workboard card IDs fix(tui): run provider sign-in in the local TUI (#200605) improve(config): reduce repeated directory checks for larger agent rosters (#206494) perf(test): reuse the Periphery producer workflow snapshot (#189681) fix(ci): keep locale assets within the installed package budget (#206492) fix: preserve failed Apple chat messages across partial history pages (#205404) improve: avoid merging unrelated settings for agent directory lookups (#206489) fix: show typing while a queued follow-up turn runs (#201920) fix: stop 2026-11-17 main Git checkouts from half-switching on a schema update (#206341) refactor(codex): centralize native completion delivery (#206447) fix(subagents): finish claimed stops after session rotation (#206405) fix: let owners fork a chat with exec after a subagent or exec completion (#206483) test(cli): gate agent --local cold-start processes and workers (#206466) perf(ci): skip baseline inventory when line-cap debt is empty (#189909) refactor(test): share core process-result fixtures (#174149) refactor(ci): reuse canonical budget flag parsing (#189480) fix: recover Codex chats after oversized requests (#206475) ...
* commit 'fd681ab8786e062045fa5ec6261b1b06f60832eb': (923 commits) fix: keep doctor --fix pending checks from creating SQLite sidecars (#206485) fix(ci): update iOS screenshot reducer gate (#206497) fix: keep chat photo previews sharp within their byte limits (#206461) fix: let agents use short Workboard card IDs fix(tui): run provider sign-in in the local TUI (#200605) improve(config): reduce repeated directory checks for larger agent rosters (#206494) perf(test): reuse the Periphery producer workflow snapshot (#189681) fix(ci): keep locale assets within the installed package budget (#206492) fix: preserve failed Apple chat messages across partial history pages (#205404) improve: avoid merging unrelated settings for agent directory lookups (#206489) fix: show typing while a queued follow-up turn runs (#201920) fix: stop 2026-11-17 main Git checkouts from half-switching on a schema update (#206341) refactor(codex): centralize native completion delivery (#206447) fix(subagents): finish claimed stops after session rotation (#206405) fix: let owners fork a chat with exec after a subagent or exec completion (#206483) test(cli): gate agent --local cold-start processes and workers (#206466) perf(ci): skip baseline inventory when line-cap debt is empty (#189909) refactor(test): share core process-result fixtures (#174149) refactor(ci): reuse canonical budget flag parsing (#189480) fix: recover Codex chats after oversized requests (#206475) ...
Run built-in provider sign-in under the local TUI's existing state owner and refresh saved credentials for the next message on the selected model. Cancel pending credential writes during shutdown and retire prepared model runtimes before draining shared state. (cherry picked from commit a8f3e66)
Run built-in provider sign-in under the local TUI's existing state owner and refresh saved credentials for the next message on the selected model. Cancel pending credential writes during shutdown and retire prepared model runtimes before draining shared state.
Run built-in provider sign-in under the local TUI's existing state owner and refresh saved credentials for the next message on the selected model. Cancel pending credential writes during shutdown and retire prepared model runtimes before draining shared state. Release adaptation: Extend the existing inline login options and pass the abort signal to Clack. Keep stable relogin identity, persistence checks, and error propagation; omit the upstream type split, node auth surface, and failure formatter. Retain the upstream in-process login, runtime snapshot refresh, orderly model-runtime disposal, and external Codex login path. Follow-ups: No later changes in the pinned main range touch the production owners. (cherry picked from commit a8f3e66) Co-authored-by: RomneyDa <[email protected]>
* perf(agents): prepare fallback rate-limit routes with model snapshots Reuse configured fallback models within the admitted config snapshot and share provider handles across configured normalization hooks. Preserve cold resolution for standalone or mismatched snapshots and reload route facts with their owning snapshot. * fix(agents): preserve static model selection during fallback preparation Skip projection for agents without configured fallbacks. Match the production plugin-runtime scope in fallback benchmarks and regressions so both variants use the same retained registry. (cherry picked from commit 2b58c8e) Companion audit: #201632 is selected to preserve registry and metadata ownership for the fallback hot path. #200605, #203901, #203095 and #202618 make independent TUI, custody, module separation and model listing changes; none is required by this port. Co-authored-by: RomneyDa <[email protected]>

Closes #200558
Closes #201751
What Problem This Solves
In
openclaw tui --local, built-in provider login started a child process that tried to take the state lock already held by the TUI. The login could fail before the provider prompt opened.A second failure appeared once login could finish. After the TUI had completed a chat turn, saving a protected token left the existing session with its previous credentials. The next message failed locally with
secret reference was not materialized by the active runtime. GitHub Copilot uses this storage path by default.User Impact
Users can sign in from the local TUI and send the next message with the new credential and the same model, including after an earlier chat turn. Cancelling returns to the TUI. Quitting with a sign-in prompt open cancels it. If a replacement credential is still waiting to be written, the previous credential stays in place. External Codex sign-in continues through
codex login.Why This Change Was Made
Built-in login runs under the TUI's existing state owner and uses the shared login flow's refresh callback to publish credentials into the embedded runtime. A fresh session prepares its credentials on its first turn. An active session refreshes its existing provider snapshot before chat resumes. A queued credential write checks the TUI's cancellation signal after it acquires the profile lock.
The shutdown comparison exposed a second lifetime to release. A prepared model generation held a plugin source capture, which kept its native resource broker alive after command cleanup. The executable waits for model retirement to settle before closing the shared database and native workers. If model retirement fails, it reports the error and continues with shared-state cleanup. Borrowed command invocations leave that process-wide lifetime with their caller.
Evidence
I reproduced both shutdown failures reported on
c156520b8b4and repeated the same checks ond2e80ad2129. Shutdown reportThe two original built-CLI PTY scenarios also passed. Both the inline key and the protected
tokenRefreached the next model request on the original model, and both processes exited normally on SIGTERM. The original reporter independently verified real GitHub Copilot device-code sign-in and reauthentication after a completed turn onc156520b8b4. Reporter's Linux runRedacted shutdown probe output, checks and replay on
d2e80ad2129The held-lock probe used the built local TUI and a synthetic provider. The cleanup probe used the compiled CLI cleanup scope, a real SQLite handle, an owned native worker, and an isolated PostgreSQL pool endpoint.
The two committed regressions failed against the previous production code and passed with this fix. In total, 79 focused tests in eight files passed, in addition to the two built-CLI PTY scenarios on Node 24.22.1 and the pinned OpenClaw Bun runtime. The QA runtime build, core and affected test typechecks, scoped lint, formatting and
git diff --checkpassed. Local autoreview covered the complete PR diff from265577c4c15to the tree committed asd2e80ad2129and reported no actionable P0–P2 findings. Queued credential regression · Cleanup regressionEarlier sign-in, recovery and SIGTERM evidence on
c156520b8b4After integrating #203394 from
main(265577c4c15), I rebuiltc156520b8b4and ran the local TUI in a real Linux PTY. With either an inline API key or a protected token, the next model request used the new credential and the original model. For the protected case, a completed chat turn preceded sign-in and the profile on disk contained only a store-backedtokenRef. The provider and loopback model were synthetic. The GitHub-hosted device-code exchange was outside these runs. Committed PTY scenariosBoth cases covered cancellation, retry, and SIGTERM at a new sign-in prompt. Both processes exited normally within the existing four-second limit. A separate run surfaced an expired device code and displayed the provider-specific retry command in the TUI. Two isolated Gateway tests exercised node access for both credential-only and app-guided sign-in.
Terminal excerpts and focused validation on
c156520b8b4These are ordered excerpts from the built CLI. Terminal controls, redraws, masked input and host-specific identifiers have been omitted.
From delivery of the final SIGTERM to exit_group(0), Linux recorded 282 ms for the inline key and 294 ms for the protected token. Both exit codes were 0 with no terminating signal.
The built-CLI cases passed with the pinned OpenClaw Bun runtime on this commit and with Node 24.22.1 on the identical staged source tree. Another 165 tests in 10 files passed, including Gateway node access, CLI recovery, command cleanup and prompt stability. The QA runtime build, core and commands-test typechecks, scoped formatting and lint, and
git diff --checkpassed. Local autoreview covered the complete PR diff from265577c4c15to the staged tree committed asc156520b8b4and reported no actionable P0–P2 findings.Original failure controls and the November 18–19 terminal captures
eceb208abea, local built-in logina7273a36e2b, protected login after a completed turntokenRef. The next message produced the reported local error and zero new model requests.SIGTERMwith a new sign-in prompt open6feedfb9b51, inline API key and warm-session protected tokenOn
6feedfb9b51, all 250 focused tests across 12 files passed. The two built-CLI auth scenarios passed under Node 24.21.0 and the pinned Bun runtime. The QA runtime build, production and affected test typechecks, scoped lint and formatting, staged line-cap check, andgit diff --checkpassed. Independent local review of the staged PR range found no P0–P2 issues.Terminal capture on
6feedfb9b51Redacted terminal excerpts and signal observations
The excerpts below retain the order of observed product output. Terminal controls, repeated redraws, masked input, local paths, and the credential owner identifier have been omitted.
Protected login after one completed turn on the previous PR head
Inline API key on commit
6feedfb9b51fe185c7adea67d171cd41fabd8fb3Protected token after one completed turn on the updated commit
On the updated commit, a Linux syscall trace measured 247 ms and 265 ms from the final
SIGTERMtoexit_group(0)for the inline and protected cases, respectively. The PTY runner also checked the process exit status and the absence of a terminating signal in each case. The wire and storage checks are runner assertions.Earlier API-key terminal capture (2026-11-18)
This earlier replay used the clean commit
a7273a36e2b9a1c4797af193a9421d8e7f803015, with the product PTY stream captured through the existingOPENCLAW_TUI_PTY_MIRROR_PATHhook. The driver launches the builtopenclaw.mjs tui --localin its own PTY and uses the embedded backend. The API-key provider and local HTTP model endpoint are synthetic, as in the reported reproduction.Result: passed, 9.205 s for the scenario and 53.400 s wall time including worker preparation. The terminal capture shows cancellation, successful retry, resumed chat returning
LOCAL_AUTH_RESPONSE, and another authentication prompt. At that last prompt the driver sends SIGTERM; the scenario verifies that the TUI exits with code 0.The same passing committed scenario also checks the persisted credential digest against the entered value, verifies that the default model stays unchanged, and checks that the subsequent model request carries the new credential. These are test assertions; the block below is the captured terminal stream plus the corresponding runner output.
Sanitized product terminal capture and matching runner output
Replay the normal sign-in PTY scenarios
pnpm build qaRuntime OPENCLAW_TUI_PTY_INCLUDE_LOCAL=1 OPENCLAW_TUI_PTY_USE_BUILT_CLI=1 \ node scripts/run-vitest.mjs run --config test/vitest/vitest.tui-pty.config.ts \ src/tui/tui-pty-local.e2e.test.ts \ -t 'authenticates a manifest-discovered provider' --maxWorkers=1