Skip to content

Fix transcript render retention for long TUI sessions#4841

Open
cexll wants to merge 1 commit into
can1357:mainfrom
cexll:fix/issue-4820-transcript-retention
Open

Fix transcript render retention for long TUI sessions#4841
cexll wants to merge 1 commit into
can1357:mainfrom
cexll:fix/issue-4820-transcript-retention

Conversation

@cexll

@cexll cexll commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Compact finalized transcript head rows after they enter native scrollback so JS render state no longer retains committed history rows indefinitely
  • Keep committed compacted blocks classified as committed for removal safety checks
  • Bound the Markdown render cache by approximate rendered size so very large renders are not retained as normal cache entries

Fixes #4820.

Tests

  • bun test packages/coding-agent/test/modes/components/transcript-container.test.ts packages/tui/test/markdown.test.ts
  • bun run check in packages/coding-agent
  • bun run check in packages/tui

@github-actions github-actions Bot added the vouched Passed the vouch gate label Jul 8, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 044d0863ad

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

if (segment === undefined) continue;
segment.startRow -= dropRows;
}
this.#compactedChildStart = dropUntil;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve compacted transcript rows for full repaints

When this advances #compactedChildStart, subsequent render() calls start walking children from that index, so the compacted prefix is no longer available in the rendered frame. That only works while the terminal's native scrollback still contains those rows; on a non-multiplexer resize settle the TUI explicitly requests a full repaint that clears scrollback (packages/tui/src/tui.ts:3295), and reset-display paths do the same, but the transcript can now replay only the retained tail. After a long session has compacted history, any such resize/reset permanently drops the compacted transcript rows from the terminal history instead of re-emitting the full transcript.

Useful? React with 👍 / 👎.

@RensTillmann

Copy link
Copy Markdown
Contributor

I built on this approach in #5239 and kept the original attribution. The replacement adds a NativeScrollbackReplay hook invoked before destructive full paints, allowing TranscriptContainer to rehydrate compacted children for resize/reset replay and then resume compaction on the next frame. It includes an engine-level regression covering the P1 history-loss case, plus the transcript and Markdown cache tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouched Passed the vouch gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Long resumed TUI sessions retain excessive JSC/WebKit footprint and block event loop during transcript/render work

2 participants