Repository navigation
fix(tui): cancel buffered submissions on shutdown [AI-assisted] - #117331
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 7:50 AM ET / 11:50 UTC. ClawSweeper reviewWhat this changesThe PR makes the TUI’s buffered-submit coalescer cancel pending input during shutdown and moves the slow local PTY smoke from a source-loader path to the exact-head built CLI artifact. Merge readinessThe patch has a coherent owner-boundary repair, focused unit and real-PTY coverage, and no concrete correctness or security finding. It remains open because it carries the protected Priority: P2 Review scores
Verification
How this fits togetherThe TUI editor sends input through a short coalescing window before chat, command, or local-shell handling. Shutdown begins from Ctrl+D and other exit paths, then stops the backend and terminal; this change makes the coalescer part of that teardown boundary so delayed input cannot re-enter the TUI after exit begins. flowchart LR
A[Terminal input] --> B[TUI editor]
B --> C[Submit coalescer]
C --> D[Chat command or shell submit]
E[Ctrl+D or exit request] --> F[Shutdown owner]
F --> C
F --> G[Backend and terminal teardown]
H[Built CLI PTY smoke] --> I[CI build-artifacts job]
Decision needed
Why: The functional repair and supplied real-behavior proof are strong, but the protected Before merge
Agent review detailsSecurityNone. PR surfaceSource +41, Tests +118, Docs 0, Config +12, Other +1. Total +172 across 12 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the coalescer as the single owner of buffered-submit cancellation, approve the patch after the built-artifact PTY lane passes on this exact head, and retain the focused source-level and real-PTY regression tests. Do we have a high-confidence way to reproduce the issue? Yes. The supplied current-main real-PTY regression has a deterministic path: force a 500 ms submit window, submit text, wait for capture, then press Ctrl+D before expiry; source inspection confirms current main lacks the coalescer disposal boundary. Is this the best way to solve the issue? Yes. Disposing the coalescer at the shutdown owner is narrower and safer than adding downstream guards because it cancels the authoritative pending timer and rejects post-shutdown submissions before transport teardown begins. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2d545c16c37d. 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
History |
|
Land-ready proof for exact head
No known proof gap remains. Already-running |
|
Merged via squash.
|
…claw#117331) * fix(tui): cancel buffered submissions on shutdown * refactor(tui): preserve callable submit coalescer * test(tui): run local PTY smoke against built CLI
Closes #117329
What Problem This Solves
Fixes an issue where Terminal.app and iTerm users who pressed Ctrl+D immediately after submitting TUI input could have shutdown stall while the short paste-coalescing buffer still owned the submitted text.
It also repairs the real-local PTY proof path that blocked this PR and current
main: the CI test launched a CLI-shaped child with rawnode --import tsx, so a cold first turn could spend longer than the watchdog linking the combined agent runtime before reaching the mocked provider. That path contradicted the repository's CLI execution contract and made the TUI shard cache-dependent.Why This Change Was Made
The submit coalescer now owns an idempotent disposal boundary that cancels pending buffered input and refuses future submissions. TUI shutdown disposes that owner before transport and terminal teardown, so no delayed callback can re-enter chat, command, or local-shell submission after exit begins.
The real-local PTY smoke now runs the exact-head built CLI from the dist-owning
build-artifactsjob. Source-level fake-backend and Gateway PTY coverage remains. Test-owned PTY cleanup retains output until exit, escalates only the spawned process tree when graceful shutdown expires, removes explicitly cleared inherited environment variables, and releases the mock server and temporary state even when setup or teardown fails.Cancellation policy for a
!shell command that already started remains a separate product/lifecycle decision and is unchanged.User Impact
Ctrl+D now exits cleanly even when it lands inside Terminal/iTerm's coalescing window. Buffered text is retired instead of remaining eligible to dispatch after shutdown starts, while normal submissions, commands, session transitions, and active-run shutdown behavior stay unchanged.
CI now proves the real local TUI against the built product rather than a cold source loader. This removes the repeated 300-second no-output failures without increasing timeouts, weakening assertions, or prewarming caches.
Evidence
ab4c74b0971138ca8d77944ba4649cf2081b9873.d585c0c1ec4999cbdafeffee0c0fb56ae9bd5d74; 49/50 PTY tests passed and the new clause alone failed by timing out while waiting for exit.checks-node-compact-small-2; the latter stalled twice for the full 300-second no-output deadline.tbx_01kyygr382542q437cc6c2w6kc.pnpm build: passed.core, coreTests, testRoot, docs, toolingchanged gate passed: formatting, threetsgolanes, focused core/script lint, dead-code scans, dependency/SDK/boundary guards, max-lines/env ratchets, database-first, import-cycle, sidecar, webhook, and pairing checks.pnpm docs:list: passed; CI and test-reference docs describe the new proof owner.patch is correct, confidence 0.98).@earendil-works/pi-tui0.82.1 source was inspected directly: the editor clears before invokingonSubmit, and the callable function-with-property coalescer shape remains valid.mainthrough4e47c4cabf8f2901ec781b59d059999211398813has no overlapping TUI, CLI, embedded-agent, provider, auth, or PTY-harness changes; GitHub reports the branch mergeable.+21/-3. The remaining delta is test/CI/docs infrastructure. Live PR size:+302/-130across 12 files.Release-note context: TUI Ctrl+D shutdown now cancels Terminal/iTerm buffered submissions before they can dispatch.
AI-assisted: yes. I directly reviewed the coalescer, shutdown owner, pinned
pi-tuisubmit behavior, built/source PTY boundaries, test cleanup lifecycle, exact before/after evidence, and final branch diff. A sanitized agent transcript was not included because it was not explicitly approved.