Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

getViewport() returns corrupted data when viewport spans multiple pages

Đang mở
#139 2 bình luận 0 reaction 1 người được giao Xem trên GitHub

@ThomasK33 đang làm issue này rồi.

Từ ngày 26/6/2026.

  • #177 của @ThomasK33 — đang mở

Đánh giá

Issue này chưa được đánh giá.

Mô tả

accepted bug triage:done
Description

renderStateGetViewport in the WASM build resolves the viewport top-left position independently for each row using pages.pin(.active). When the viewport spans multiple internal pages, this per-row resolution can produce inconsistent results, leading to corrupted viewport data.

Additionally, scrollbackLimit is passed as a line count but Terminal.init() interprets max_scrollback as bytes, causing the scrollback buffer to be much smaller than intended and making the page-spanning condition occur more frequently.

Symptoms
  • getScrollbackLength() drops unexpectedly (e.g., 498 → 269) after repeated writes
  • getViewport() returns rows with content from different terminal lines merged together
  • Both getViewport() and getLine() return the same wrong data
  • Corruption frequency depends on column width:
    • cols=80: OK
    • cols=120: CORRUPT
    • cols=130: CORRUPT
    • cols=140: OK
    • cols=160: scrollback drops but viewport may appear OK (merge lands on empty rows)
Root cause

The native Ghostty renderer reads cell data from cached row pins in RenderState.row_data (built during update()), which guarantees consistent page resolution across all viewport rows. The WASM renderStateGetViewport instead calls pages.pin(.active) per-row, which can resolve to different pages inconsistently when the viewport straddles a page boundary.

Reproduction
  1. Create a terminal at cols=130, rows=39, scrollback=10000
  2. Repeatedly write ~68 lines of escape-heavy output (SGR 256-color, truecolor, attributes)
  3. After ~8 repetitions, call getScrollbackLength() and getViewport()
  4. Scrollback length will drop and/or viewport rows will contain merged content
Expected behavior

getViewport() should return consistent, correct row data regardless of internal page layout. scrollbackLimit should be interpreted consistently between the JS config and WASM init.

Fix

Draft PR with fix and regression tests: #133

Ngôn ngữ chính
TypeScript
Star
3k
Fork
188
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của coder/ghostty-web

Tất cả issue của coder/ghostty-web

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.