Skip to content

fix(infinity-agent-cli): don't eat scrollback when a resize races the re-anchor cursor query - #89

Open
shadaj wants to merge 1 commit into
mainfrom
sandbox-5c18c70b-5b5d-4cee-90a3-933c3ade71e3
Open

fix(infinity-agent-cli): don't eat scrollback when a resize races the re-anchor cursor query#89
shadaj wants to merge 1 commit into
mainfrom
sandbox-5c18c70b-5b5d-4cee-90a3-933c3ade71e3

Conversation

@shadaj

@shadaj shadaj commented Jul 29, 2026

Copy link
Copy Markdown
Member

When the terminal is resized continuously (e.g. dragging a pane divider in
Zed), the terminal keeps reflowing while the viewport's re-anchor cursor
query (CSI 6n) is in flight. Acting on the stale reply re-saved the anchor
too high (a growing reflow pulls scrollback rows down, moving the true anchor
with them) and the subsequent clear-from-anchor-down erased the tail of the
assistant output.

  • InlineViewport::re_anchor now re-checks the terminal size after every
    cursor-query round-trip and, if the geometry moved again, absorbs the new
    resize and re-queries until stable
  • InlineViewport::draw runs re_anchor before computing any
    geometry-dependent values (frame area, ideal viewport position), so a draw
    that absorbs a raced resize is fully consistent with the newest geometry
  • Regression test tui_resize_race.rs reproduces the race with a TermOut
    interposer that resizes the emulator right after answering the cursor
    query (before the fix, 6 of 30 output lines were erased)
  • Test harness: TuiHarness::spawn_with_term allows spawning the TUI
    against a caller-provided TermOut and event channel

… re-anchor cursor query

When the terminal is resized continuously (e.g. dragging a pane divider in
Zed), the terminal keeps reflowing while the viewport's re-anchor cursor
query (`CSI 6n`) is in flight. Acting on the stale reply re-saved the anchor
too high (a growing reflow pulls scrollback rows down, moving the true anchor
with them) and the subsequent clear-from-anchor-down erased the tail of the
assistant output.

* `InlineViewport::re_anchor` now re-checks the terminal size after every
  cursor-query round-trip and, if the geometry moved again, absorbs the new
  resize and re-queries until stable
* `InlineViewport::draw` runs `re_anchor` before computing any
  geometry-dependent values (frame area, ideal viewport position), so a draw
  that absorbs a raced resize is fully consistent with the newest geometry
* Regression test `tui_resize_race.rs` reproduces the race with a `TermOut`
  interposer that resizes the emulator right after answering the cursor
  query (before the fix, 6 of 30 output lines were erased)
* Test harness: `TuiHarness::spawn_with_term` allows spawning the TUI
  against a caller-provided `TermOut` and event channel

Co-authored-by: Infinity 🤖 <infinity@hydro.run>
PR: #89
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 29, 2026

Copy link
Copy Markdown

Deploying infinity with  Cloudflare Pages  Cloudflare Pages

Latest commit: acf5e0f
Status: ✅  Deploy successful!
Preview URL: https://fff4e7ca.infinity-dc7.pages.dev
Branch Preview URL: https://sandbox-5c18c70b-5b5d-4cee-9.infinity-dc7.pages.dev

View logs

@shadaj
shadaj marked this pull request as ready for review July 29, 2026 21:59
@shadaj
shadaj requested a review from MingweiSamuel July 29, 2026 21:59
@shadaj
shadaj force-pushed the sandbox-5c18c70b-5b5d-4cee-90a3-933c3ade71e3 branch from a4fb040 to acf5e0f Compare August 4, 2026 19:02
@shadaj
shadaj requested a review from a team August 4, 2026 19:02
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