Repository navigation
fix: close task terminals after completion - #121070
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
2c5d240 to
836965b
Compare
|
Codex review: needs changes before merge. Reviewed August 9, 2026, 10:44 AM ET / 14:44 UTC. ClawSweeper reviewWhat this changesThis PR replaces session-name-based terminal cleanup with private task-ID ownership so completed tasks close their own PTYs while persistent conversation and connection terminals remain open. Merge readiness⛔ Blocked by patch quality or review findings - 7 items remain Keep this PR open: two prior P1 lifecycle blockers remain on the current head, so task terminals can still escape completion cleanup. Priority: P1 Review scores
Verification
How this fits togetherAgent tasks open terminals through the terminal tool, and the Gateway observes task completion to tear down task-owned PTYs. The terminal manager also emits viewer exit events and must handle both registered and still-opening sessions. flowchart LR
A[Agent task run] --> B[Terminal tool]
B --> C[Terminal manager]
A --> D[Task registry]
D --> E[Gateway task completion]
E --> C
C --> F[PTY closure and viewer exit]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +9, Tests -2. Total +7 across 6 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Bind terminals through the exact active run ID and make task completion abort matching pending opens before they can register. Do we have a high-confidence way to reproduce the issue? Yes, from source: two active tasks sharing a child session leave a terminal unbound, and a task terminalizing during a deferred backend spawn registers a PTY after cleanup. Is this the best way to solve the issue? No: task IDs are a better boundary than session-key syntax, but the implementation must use the already-available active run ID and cover pending opens. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against fc9905edb2b8. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
ccf4ea7 to
38c5bde
Compare
58df17a to
4f6c5db
Compare
|
Merged via squash.
|
* fix(gateway): bind terminals to task owners * fix(tasks): use task access seam for terminal ownership * refactor(gateway): keep terminal task binding private * refactor(gateway): preserve terminal manager contract
Related: #121055
What Problem This Solves
Fixes an issue where terminals opened by a task could remain alive after that task completed when its agent session key did not use a recognized cron, subagent, or ACP naming pattern. Those leaked PTYs kept the Gateway's active-work blocker set non-empty after otherwise successful tasks.
This follows #121055 after independent source-blind validation found that a generic CLI task still leaked both of its terminals.
Why This Change Was Made
Terminal ownership now records the exact active task ID at creation time. Task lifecycle cleanup closes only terminals carrying that task ID, while normal conversation terminals and connection-owned terminals remain persistent. Ambiguous shared-session cases stay conversation-scoped rather than guessing ownership.
The repair replaces session-key syntax inference with the task registry's authoritative ownership relationship. Production code is +34/-25 (net +9); the added lines keep task binding private while preserving the existing public terminal-manager contract.
User Impact
When a terminal task finishes, all terminals that task opened are closed and attached viewers receive
terminal.exit. Unrelated normal-chat and browser-attached terminals continue running.Evidence
de5ada41e23b(implementation rebased as6a3faee59616): running-task retention, exact task-owned cleanup, normal-chat persistence, connection-owned persistence, viewer exit delivery, and PTY drain.terminal-tool, Gateway task subscriptions, and terminal task lifecycle (tbx_01kzk9b03srt4t78d3ehrhqw40; run 31314398390).tbx_01kzkcfpte5rp4fk3kwkwpeyxq; run 31316755916).git diff --checkpassed on the current shape.