fix(runtime): preserve agent session capture during quit#243
fix(runtime): preserve agent session capture during quit#243forketyfork merged 2 commits intomainfrom
Conversation
Issue: Quitting Architect with multiple active agent sessions could miss resume IDs because trailing PTY output arrived after sessions were marked dead, and shutdown debug tail logging printed control-heavy terminal data into the launcher shell. Solution: Keep draining PTY output for spawned sessions even after process exit so late bytes are still processed. Add a bounded post-worker drain-until-quiet pass before UUID extraction to capture trailing shutdown output deterministically. Remove raw terminal-tail debug logging to avoid control-sequence noise in the launcher shell while retaining concise capture diagnostics.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 81f4a212b2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
This PR fixes a shutdown edge case where agent resume UUIDs could be missed during quit by continuing to drain PTY output after process exit and performing a bounded “drain-until-quiet” pass before UUID extraction.
Changes:
- Keep
SessionState.processOutput()active for spawned sessions even when marked dead, allowing post-exit PTY bytes to be processed/captured. - Add a bounded post-worker quit-capture drain loop (poll + quiet-window + max-window) before extracting UUIDs.
- Remove noisy “terminal tail” debug logging during quit teardown and update the architecture ADR to reflect the new drain behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/session/state.zig |
Adjusts output-drain gating so quit capture can continue after session exit; adds a small unit test for the gating helper. |
src/app/runtime.zig |
Adds bounded post-worker output draining before UUID extraction; removes control-heavy debug tail logging; adds unit tests for drain stopping conditions. |
docs/ARCHITECTURE.md |
Updates ADR-014 to document post-exit drain behavior and the bounded drain-until-quiet pass. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address PR review comment: #243 (comment) Limit post-exit output draining to sessions with active quit capture, and treat PTY EIO as terminal EOF during reads. This preserves quit-time UUID capture while avoiding runtime failures when dead sessions are polled in normal loops.
Issue
When quitting Architect with multiple active agent sessions, some Claude resume IDs were not captured. The shutdown path could mark sessions as dead before draining all trailing PTY output, so late
claude --resume <uuid>lines were sometimes missed.Issue linkage is not included for this hotfix-path change; linkage will be added during mandatory cleanup.
Solution
This change keeps PTY output processing enabled for spawned sessions even after process exit, so late bytes can still flow into quit capture.
It also adds a bounded post-worker drain-until-quiet pass before UUID extraction. That extra drain window captures trailing shutdown output without making quit unbounded.
Finally, it removes raw terminal-tail debug logging that emitted control-heavy text into the launcher shell and made debugging noisy.
Test plan