Repository navigation
feat(session): project a replayed transcript for a session we do not own - #690
Merged
Merged
Conversation
Groundwork for viewing a background subagent's own session, so the operator can read what it actually did rather than infer it from a label. The child owns that session and may still be writing to it, so the TUI must not open a second runtime against it: `open_session` *constructs* a runtime, it does not merely read, and a second owner of a journal a subagent is writing to is not something WAL licenses. Replaying the journal is a second reader, which is exactly what WAL does license — `Journal::open` plus `replay` already returns `ReplayState.messages`, the ordered active conversation reconstructed from events. What was missing is the seam: `TranscriptSnapshot` has private fields and only `capture(&AgentSession)`, so a replay had no way to become the thing the pane renders. `from_messages` is that seam, and it is deliberately the whole change — the TUI consumer follows separately. Two properties are load-bearing and documented on the constructor rather than left for the caller to discover: - `events` is empty, because `TurnEvent`s are not replayed. The view shows the conversation without the live activity rows the owning session carries, which is the right trade for a view that cannot act. - `revision` is the caller's, and must differ from the snapshot it replaces. The conversation render cache keys on revision, so reusing the parent's would serve the parent's rendered lines for the child. Tests: a replayed transcript carries its messages, no events, and the caller's revision; and an in-flight child with no assistant message yet projects to an empty transcript rather than panicking.
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.
Groundwork for P5: viewing a background subagent's own session, so the operator can read what it did rather than infer it from a label. This is the enabling seam only; the TUI consumer follows separately, which keeps the
forge-sessionchange reviewable on its own.Why a replay, and why not
open_sessionAn earlier version of this plan called for
open_session(SessionTarget::Resume(child))→capture→ drop. That is wrong, and worth stating so nobody re-derives it:open_sessionconstructs a runtime, it does not merely read. Pointing it at a running child would open a second owner of a journal the subagent is still writing — which is not what the WAL finding licenses. It also needs a&Config, whichcrates/forge-tui/srcnever has.Replaying the journal is a second reader, which is what WAL does license.
Journal::open(crates/forge-durable/src/lib.rs:280) plusreplay(:793) already returnsReplayState.messages— "the ordered active conversation reconstructed from journal events".The missing seam
TranscriptSnapshothas private fields and exactly one constructor,capture(&AgentSession), so a replay had no way to become the thing the transcript pane renders.from_messagesis that seam:Two properties are load-bearing, and they are documented on the constructor rather than left for the caller to trip over:
eventsis empty, becauseTurnEvents are not replayed. The view shows the conversation without the live activity rows the owning session carries — the right trade for a view that cannot act.revisionis the caller's and must differ from the snapshot it replaces. The conversation render cache keys onsession_idand revision (ConversationRenderKey); reusing the parent's revision would serve the parent's rendered lines for the child.Notes for the reviewer
forge-durabledependency was added toforge-sessionfor testing: the durable crate already has thorough replay coverage (replay_restores_ordered_conversation_and_reset_contextand friends), and the replay→projection seam belongs with the consumer. The end-to-end assertion lands with the TUI change.from_messagescurrently has no caller in-tree. That is deliberate — it is the agreed first step — but it is worth knowing before reviewing.Verification
cargo fmt --all -- --checkclean.cargo clippy --package forge-session --all-targets --locked -- -D warningsclean.