Repository navigation
fix(tui): exit cleanly during local auth - #126476
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 19, 2026, 7:39 PM ET / 23:39 UTC. ClawSweeper reviewWhat this changesThe PR gives the local TUI ownership of its foreground authentication child so shutdown terminates that child and does not restart the suspended interface. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessThe lifecycle owner is a coherent repair and its PTY test exercises the real TUI process, but this review cannot complete the repository-required direct Codex CLI contract check because the required sibling source checkout is unavailable. Likely related people: steipete (high), vincentkoc (medium). Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherThe local terminal UI starts provider authentication as a foreground child process, then resumes after authentication completes. Terminal loss, signals, and embedded-backend shutdown flow through the TUI exit path and must also stop that child. flowchart LR
A[User starts local auth] --> B[Terminal UI]
B --> C[Foreground auth process]
D[Signal or backend shutdown] --> B
B --> E[Auth child owner]
E --> C
C --> F[Child exits]
F --> G[Terminal UI exits or resumes]
Decision needed
Why: The TUI branch directly invokes Before merge
Agent review detailsSecurityNone. PR surfaceSource +96, Tests +209. Total +305 across 7 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the single auth-child lifecycle owner, then verify the exact Codex Do we have a high-confidence way to reproduce the issue? Yes, from source: current main starts local auth without retaining that child for Is this the best way to solve the issue? Unclear: the dedicated lifecycle owner is the cleanest visible repair and preserves the existing error contract, but the required direct Codex CLI source check could not be completed here. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1762f43a34c5. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Maintainer landing-gate resolution:
Proceeding with the repository-native landing workflow. |
|
Merged via squash.
|
What Problem This Solves
Fixes an issue where users running the local TUI
/authflow could leave the foreground auth process alive—and keep the TUI process from exiting—when shutdown was requested by SIGTERM, SIGHUP, terminal loss, or the embedded backend.Why This Change Was Made
The local TUI now owns the exact foreground auth child for its full lifetime. Shutdown sends a graceful signal and then a bounded force signal only while that same child remains active. POSIX keeps direct-PID signaling because the auth child intentionally shares the TUI foreground process group; Windows uses the existing
taskkill /Tpath so.cmdwrappers cannot strand descendants. The suspended TUI also no longer restarts after exit has begun.The separate local
!shell process path remains unchanged because it has different piped-output and process-tree semantics.User Impact
Local TUI sessions now exit cleanly during an in-progress auth flow instead of hanging or orphaning the Codex/OpenClaw auth process. Auth flows that finish normally still restore the TUI and continue working.
Evidence
Before the fix, a real PTY reproduction started
/auth openai, sent SIGTERM directly to the TUI, and observed both processes still alive 750 ms later.After the fix:
node scripts/run-vitest.mjs src/tui/tui-auth-child.test.ts src/tui/tui.local-auth.test.ts src/tui/tui-pty-local-test-support.test.ts— 13 tests passed across 3 files / 2 shards.node scripts/run-vitest.mjs run --config test/vitest/vitest.tui-pty.config.ts src/tui/tui-auth-child-pty.e2e.test.ts— 2 real-PTY tests passed, covering exit-during-auth child termination and normal auth completion/TUI resume.node scripts/check-changed.mjs -- src/tui/tui-auth-child.ts src/tui/tui-auth-child.test.ts src/tui/tui-auth-child-pty.e2e.test.ts src/tui/tui-pty-local-test-support.test.ts src/tui/tui-pty-test-support.ts src/tui/tui.ts test/vitest/vitest.tui-pty.config.ts— all required type, lint, format, import-cycle, dead-export, and policy checks passed.git diff --check— passed.Direct dependency-contract inspection confirmed that
codex loginremains one blocking foreground CLI process (../codex/codex-rs/cli/src/main.rsand../codex/codex-rs/cli/src/login.rs), so detaching it would violate the intended terminal/job-control model.Production LOC: +127/-33 (net +94), establishing the missing exact-child lifecycle owner. Tests/test support/tooling: +211/-0.