Repository navigation
feat(tui): read a background subagent's own session - #692
Merged
Merged
Conversation
`→` on a background task row now shows that subagent's session — what it actually did, rather than an inference from a label — and `←` returns. Read-only by construction. The child owns that session and may still be writing to it, so this replays its journal instead of opening a second runtime: the `open_session` route builds a runtime, which would make this TUI a second *owner* of a session a subagent is writing to. Replaying is a second *reader*, which is what the durable store's WAL mode permits. The TUI never holds a second `AgentSession`, so there is no ownership question, no second writer, and nothing to unwind on the way out. The chain is `Journal::open` + `replay` (already used by `session_title_hint`, which is the same read-only shape) -> `forge_core::session_messages` -> `forge_session::replayed_transcript` -> the pane's existing `TranscriptSnapshot`. Each step is a thin pass-through, so the projection rule lives in one place. Details that are load-bearing: - The child's revision must differ from the one it replaces. The conversation render cache keys on `session_id` *and* revision, and unsticking either would put the parent's rendered lines behind the child's transcript. - Leaving restores the parent's `TranscriptSnapshot` rather than re-capturing it, so the return trip is a restore and the parent's revision stays intact. - The composer hint carries the read-only notice, and the composer refuses input while the view is open — the hint alone would be a promise the TUI cannot keep. Tests: opening shows the child's own conversation with a distinct revision and the read-only hint, and `←` restores the parent's snapshot exactly; a shell task is refused with a reason rather than opening an empty view; and the composer does not take a character while the view is open.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
→on a background task row now shows that subagent's own session — what it actually did, rather than an inference from a label — and←returns. This is P5a; the smaller half of P5.Read-only by construction
The child owns that session and may still be writing to it, so this replays its journal instead of opening a second runtime. The
open_sessionroute — which an earlier version of this plan called for — constructs a runtime, which would make this TUI a second owner of a session a subagent is writing to. Replaying is a second reader, which is what the durable store's WAL mode (SqliteJournalMode::Wal,forge-durable/src/lib.rs:292) permits.The TUI therefore never holds a second
AgentSession: no ownership question, no second writer, and nothing to unwind on the way out.The chain
Each step is a thin pass-through, so the projection rule lives in one place.
session_title_hintwas the precedent — sameJournal::open+replay, "independent of any liveAgentSession(no tools/model/governance needed)" — so this adds a sibling rather than a new mechanism.Details that are load-bearing
ConversationRenderKeykeys onsession_idand revision; reusing the parent's would put the parent's rendered lines behind the child's transcript.TranscriptSnapshotrather than re-capturing it, so the return trip is a restore and the parent's revision stays intact.Notes for the reviewer
eventsis empty in the child view.TurnEvents are not replayed, so it shows the conversation without the live activity rows the owning session carries. Documented onfrom_messages.read-only · viewing explore · ← to return) rather than chrome above the transcript, and the view does not refresh as a live child writes. Both are worth doing; neither is needed for the view to be correct rather than stale-by-design.→from the strip reaches the same view without inventing rows for sessions the TUI does not own.Verification
cargo fmt --all -- --checkclean;cargo clippy --package forge-core --package forge-session --package forge-tui --all-targets --locked -- -D warningsclean.←restores the parent's snapshot exactly; a shell task is refused with a reason rather than opening an empty view; the composer does not take a character while the view is open.app::tests::taskssandbox failures are unchanged and pass on CI.