Severity: MEDIUM (performance)
Status: ✅ FIXED
Files: src/server/render.zig:483-651, src/grid.zig:58-62
renderContent always iterates all w × h cells, comparing each against last_cells — even when only one row changed. On an 80×24 terminal that’s ~1920 comparisons/frame; on a 200×60 display ~12000; and the pane merge stage (renderAll, render.zig:183-249) does the same for every dirty pane.
GridLine has a dirty: bool field with doc note that “no production code reads this yet” (grid.zig:58-62), so the flag carries tested copy semantics (see #477 “Deliberately kept”) but gives the render loop no skip benefit.
Make row dirtiness drive the diff: when scrolling/editing, mark only affected GridLines dirty in the pane screen; the render loop skips rows whose line is not dirty (a per-line cell-hash check for the ones that are). This turns the diff from O(rows × cols) into O(changed_rows × cols) in the common case (single-line cursor advance, one status-cell change).
The scroll-aware mapping of the dirty flag was called out in #477 as the reason it was left unused — this bug is that follow-up, scoped to line-granular skipping.
Wired GridLine.dirty into the render pipeline as the line-granular signal,
using the comparison-based mapping #477 flagged as missing:
renderAll merge stage (src/server/render.zig) compares each merged
cell while compositing and sets merged_line.dirty only when content
actually changes — this covers scrolled/moved content, since position
changes show up as cell differences. Border painting and
pane-border-format writes mark their lines dirty.renderContent skips lines whose flag is clean (only while the last_cells
diff is active) and clears the flag after processing the row.force_clear, the size-mismatch baseline reset inside renderContent, and
the new Server.invalidateClientDiff helper (replacing the two raw
@memset(last_cells) failure paths) mark every merged line dirty, so a skip
can never hide a forced full repaint.Tests: a direct renderContent second frame re-emits only the changed row,
and a two-frame renderAll against a persistent merged screen + last_cells
repaints row 5 without re-emitting row 0’s unchanged text.
Verified: zig build test -Doptimize=ReleaseFast — 1012/1012 tests pass.