Skip to content

feat(session): project a replayed transcript for a session we do not own - #690

Merged
mohitranka merged 1 commit into
mainfrom
feat/child-session-view
Sep 15, 2026
Merged

mohitranka merged 1 commit into
mainfrom
feat/child-session-view

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

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-session change reviewable on its own.

Why a replay, and why not open_session

An 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_session constructs 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, which crates/forge-tui/src never has.

Replaying the journal is a second reader, which is what WAL does license. Journal::open (crates/forge-durable/src/lib.rs:280) plus replay (:793) already returns ReplayState.messages — "the ordered active conversation reconstructed from journal events".

The missing seam

TranscriptSnapshot has private fields and exactly one constructor, capture(&AgentSession), so a replay had no way to become the thing the transcript pane renders. from_messages is that seam:

let state = journal.replay(child_session_id).await?;
self.transcript_view = TranscriptSnapshot::from_messages(state.messages, revision);

Two properties are load-bearing, and they are documented on the constructor rather than left for the caller to trip over:

  • events is empty, because TurnEvents 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.
  • revision is the caller's and must differ from the snapshot it replaces. The conversation render cache keys on session_id and revision (ConversationRenderKey); reusing the parent's revision would serve the parent's rendered lines for the child.

Notes for the reviewer

  • No forge-durable dependency was added to forge-session for testing: the durable crate already has thorough replay coverage (replay_restores_ordered_conversation_and_reset_context and friends), and the replay→projection seam belongs with the consumer. The end-to-end assertion lands with the TUI change.
  • from_messages currently 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 -- --check clean.
  • cargo clippy --package forge-session --all-targets --locked -- -D warnings clean.
  • New 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.

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.
@mohitranka
mohitranka merged commit 6809d05 into main Sep 15, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant