Skip to content

fix(renderer): flush queued view before insert above - #1741

Open
yanmxa wants to merge 1 commit into
charmbracelet:mainfrom
yanmxa:agent/flush-before-insert-above
Open

fix(renderer): flush queued view before insert above#1741
yanmxa wants to merge 1 commit into
charmbracelet:mainfrom
yanmxa:agent/flush-before-insert-above

Conversation

@yanmxa

@yanmxa yanmxa commented Jul 23, 2026

Copy link
Copy Markdown

Summary

  • flush the latest queued inline View before insertAbove calculates scroll geometry
  • propagate a flush failure instead of inserting scrollback against stale renderer state
  • add a regression test that verifies the current frame is rendered before the committed block

Root cause

render only queues the latest View; the frame ticker flushes it asynchronously. Println can therefore reach insertAbove after the model has produced a shorter view but before that view has reached the terminal.

At that point, insertAbove uses the previous cellbuf and cursor geometry. Rows from the stale managed frame can then be moved into native scrollback and remain there permanently.

Flushing at the renderer boundary keeps the queued view, cellbuf, terminal output, and the subsequent scroll calculation on the same frame.

Fixes #1736.

Downstream regression and integration coverage: genai-io/san#401

Testing

  • go test ./...
  • go test -race ./...

Signed-off-by: Meng Yan <yanmxa@gmail.com>
@yanmxa
yanmxa marked this pull request as ready for review July 23, 2026 15:13
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.

v2: no way to sync tea.Println/insertAbove with the frame flush (stale frame row welded into scrollback)

1 participant