Skip to content

fix(client): keep an evicted transcript evicted on later steps - #56751

Open
shreyanshj10 wants to merge 1 commit into
anomalyco:devfrom
shreyanshj10:evicted-transcript-refill
Open

shreyanshj10 wants to merge 1 commit into
anomalyco:devfrom
shreyanshj10:evicted-transcript-refill

Conversation

@shreyanshj10

@shreyanshj10 shreyanshj10 commented Oct 18, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #56737

Type of change

  • Bug fix

What does this PR do?

Retention evicts a family's transcript when it falls out of the recent-three set, but a later session.step.started for that family went straight into message.update, which lazily recreates the per-session message array. A background session that keeps running therefore rebuilds a full transcript behind the retention decision, one assistant message per step, and the next recompute does not evict it again because the family is already in the excluded map.

session.step.started is the only handler that appends an assistant row from an event; everything that streams into that row afterwards (text, reasoning, tools, step.ended) already drops its edit when the row is missing. So I record the sessions eviction dropped and have that one handler skip them until a transcript read puts the session back. A read is where the history comes from anyway, so nothing is lost: reopening the session hydrates it from the server as before, and the current session streams normally.

The issue asks for the policy for an excluded but still-running family to be explicit, so to be clear about the one I picked: its heavy assistant transcript stays excluded until the session is read again, and the light marker rows are unchanged. I kept the markers because session.model.selected already guards itself on a loaded transcript and test/solid-eviction.test.ts expects the others (agent-switched) to keep mirroring live state after an eviction. If you would rather exclude those too it is a one-line move of the same guard into message.update, plus that assertion.

How did you verify your code works?

Added a case to packages/tui/test/context/session-retention.test.ts that views four root sessions with no kept tabs and a limit of 3, then delivers a complete step (session.step.started, session.text.started, session.text.delta) for the evicted family and updates its metadata: its transcript stays empty. Without the change it holds one assistant message with its text. The same test then reopens that session and sends another step, to confirm a current session still gets its message and text.

In packages/tui: bun test test/context/session-retention.test.ts. In packages/client: bun test test/solid-eviction.test.ts test/solid-data.test.ts test/solid-inbox-race.test.ts test/solid-compaction.test.ts test/solid-pending-status.test.ts. Plus bun run check at the root.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #56736

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks sound. I ran the #56737 reproduction against both checkouts. On the base, an evicted session's transcript grows by one full assistant message per background step, and a later metadata update doesn't evict it again. With this change it stays empty, and after the session is reopened its history reloads and new steps stream normally. Your new test fails on the base and passes here. The client tests and the packages/tui session retention tests pass, and type checks are clean in both packages.

Public API: unchanged (the new tracking is internal to createData).

I also checked the edge cases: a step that starts while a reopened session's history is still loading is dropped, but the base already loses it in that case, so it isn't a regression. Every session in an evicted family gets marked, and sessions with a queued outgoing message are never evicted, so they never get the mark. No blocking concerns.

Related: #56736

This branch has not been deployed

No deployments
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.

tui: new background steps refill transcripts of already-evicted session families

1 participant