Skip to content

feat(tui): keep the child session view live on the poll tick - #694

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

mohitranka merged 1 commit into
mainfrom
feat/child-view-live-refresh

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

P5b: the child session view no longer freezes. P5a (#692) opened it as a snapshot, so a live subagent's transcript stopped at the moment the operator pressed →. This re-reads the viewed child's journal on the existing poll_background_tasks tick while its task is non-terminal; a finished child keeps its final snapshot.

Guarded on the live handle, not the view

ChildSessionView now carries the task id, and the tick refreshes only while that task's status is non-terminal. The id comes from the background registry each tick, so a stale view can never point the refresh at the wrong journal.

Three quietness rules

Each is load-bearing, and each is documented at the call site:

  • Silent. The tick already updates the strip, which is the evidence; an unreadable journal must not knock a view the operator is still reading out from under them.
  • Swap only when the messages actually changed (length plus last content length), else every tick invalidates the render cache for nothing. An unchanged journal across a poll leaves the revision untouched — asserted in the test.
  • Never touches the conversation window. The operator may be reading an older page, and a refresh must not steal their place — asserted (scroll intact) in the test.

Notes for the reviewer

  • The change-detection is deliberately cheap (length + last content length), not a hash: it only has to decide whether to re-project, and a miss just costs one extra render-cache rebuild, never wrong content.
  • session_messages returning None for an unreadable journal is the same contract as session_title_hint — fall back, never fail the whole listing. The test plants a non-SQLite .db file to prove the read side, since Journal::open with create_if_missing makes a merely-missing file readable.
  • Still open after this: breadcrumb/header (header shows the parent's workspace/branch while the child runs in its own worktree) and the design-doc update.

Verification

  • cargo fmt --all -- --check clean; cargo clippy --package forge-tui --all-targets --locked -- -D warnings clean.
  • New tests pass; the three known local sandbox failures unchanged (pass on CI).

P5a opened the view as a snapshot, so a live subagent's transcript froze at
the moment the operator pressed `→`. This re-reads the viewed child's journal
on the existing `poll_background_tasks` tick while its task is non-terminal;
a finished child keeps its final snapshot.

Guarded on the live handle, not the view: `ChildSessionView` now carries the
task id, and the tick refreshes only while that task's status is non-terminal.
A stale view can never point the refresh at the wrong journal, because the id
comes from the background registry each tick.

Three quietness rules, each load-bearing:

- Silent. The tick already updates the strip, which is the evidence; an
  unreadable journal must not knock a view the operator is still reading out
  from under them.
- Swap only when the messages actually changed (length plus last content
  length), else every tick invalidates the render cache for nothing.
- Never touches the conversation window: the operator may be reading an older
  page, and a refresh must not steal their place.

Tests: an unchanged journal across a poll leaves the revision untouched (no
render-cache churn); ending the child keeps the view standing on its final
snapshot with scroll intact; and `session_messages` reads an unreadable
journal as `None` rather than an error, so one bad session cannot fail the
caller.
@mohitranka
mohitranka merged commit 89fe80c 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