Skip to content

fix: use cached row pins for WASM viewport rendering#133

Draft
darrinm wants to merge 2 commits into
coder:mainfrom
darrinm:fix/viewport-cached-row-pins
Draft

fix: use cached row pins for WASM viewport rendering#133
darrinm wants to merge 2 commits into
coder:mainfrom
darrinm:fix/viewport-cached-row-pins

Conversation

@darrinm
Copy link
Copy Markdown

@darrinm darrinm commented Feb 24, 2026

Summary

  • Replace per-row pages.pin(.active) calls in renderStateGetViewport with cached row pins from RenderState.row_data, matching how the native renderer reads cell data
  • Fix scrollback_limit to properly convert line counts to bytes (matching Terminal.init's expected units)
  • Add Page imports needed for the bytes-per-line calculation

The per-row approach independently resolved the viewport top-left position for every row, which could produce inconsistent results when the viewport spanned multiple pages. Using the cached pins (built during update()) matches the native renderer's approach and avoids this class of issues.

Test plan

  • bun test lib/iris-repro-final.test.ts — scrollback and viewport regression tests pass
  • bun test lib/iris-repro-fix-verify.test.ts — scrollback drop verification passes
  • bun test — full suite passes

🤖 Generated with Claude Code

darrinm and others added 2 commits February 23, 2026 20:49
Replace per-row pages.pin(.active) calls in renderStateGetViewport with
cached row pins from RenderState.row_data, matching how the native
renderer reads cell data. This avoids inconsistent top-left resolution
when the viewport spans multiple pages.

Also fixes scrollback_limit to properly convert line counts to bytes
(matching Terminal.init's expected units) and adds Page imports needed
for the bytes-per-line calculation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
diegosouzapw added a commit to diegosouzapw/ghostty-web that referenced this pull request May 24, 2026
)

Ports fixes for upstream issues coder#138 and coder#139:

Issue coder#139 (viewport corruption when viewport spans multiple pages):
- renderStateGetViewport: replace per-row pages.pin(.active) calls with
  cached row pins from RenderState.row_data, matching the native renderer.
  Independent per-row pin resolution produced inconsistent results across
  page boundaries.
- terminal_new_with_config: convert scrollback_limit from line count to
  bytes using page layout calculation (Terminal.init expects bytes, not
  lines). This makes the page-spanning condition much less frequent.

Issue coder#138 (stale cell data visible after scroll with default cursor style):
- cursorDownScroll in Screen.zig: make row clearing unconditional. The old
  check `if (bg_color != .none)` skipped clearing when cursor style was
  default (after ESC[0m), leaving stale cells from reused page memory
  visible on empty lines.

Inspired by: coder#133
Inspired by: coder#134

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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