Skip to content

fix(tui): a Host-started Turn in /side makes the copied parent transcript visible again #3881

Description

@Astro-Han

What happened

A TUI side conversation is a Session copy that carries the parent's transcript. The driver hides it by recording #hiddenTranscriptThroughTurnId and filtering every transcript it hands the runner through visibleTranscriptMessages(). One path skips that filter.

packages/cli/src/runtime-host-session-driver.ts:1155 builds the attached Turn for a Host-started Turn with the raw opened.messages:

const turn = {
  sessionId,
  turnId,
  events: opened.channel.eventsForTurn(turnId),
  messages: opened.messages,   // unfiltered
  summary: projectSessionCatalogSummary(configuration.session),
} satisfies MakaAttachedSessionTurn;

Every sibling applies the filter — switchSession at line 563, the transcript-replacement subscriptions at lines 251 and 1243 — so this is the one gap rather than a deliberate exception.

packages/cli/src/pi-tui-runner.ts then replaces the visible transcript with exactly those messages when it adopts the attached Turn, so the parent conversation the user opened /side to get away from reappears in full.

Expected: /side shows only what happened inside the side conversation, on this path as on the others.

How to reproduce

  1. Start the TUI on a Session that already has several Turns.
  2. Run /side to open a side conversation.
  3. Confirm the transcript is empty, as intended.
  4. Cause a Host-started Turn to arrive on the side Session — the reattach path at runtime-host-session-driver.ts:1155, e.g. reconnecting while a Turn is running there.
  5. The transcript is replaced with the copied parent transcript.

Deterministic once step 4 is reached; the difficulty is arranging a Host-started Turn rather than a client-started one.

Environment

Logs, screenshots, or additional context

Found while reviewing #3803; not attributable to that PR — git log -S puts both the unfiltered messages: opened.messages and the runner's transcript replacement before its base commit.

The fix is to route this path through the same filter the siblings use:

messages: visibleTranscriptMessages(opened.messages, this.#hiddenTranscriptThroughTurnId),

Worth landing after #3760, which is open against the same two files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions