From 8e850e6c923dcd84b7a5483f73377bd192b94a2b Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 22 Nov 2026 17:55:03 -0300 Subject: terminals: where a view stands in a terminal's history is the view's, not the emulator's (pardes-term-join-10, item 1; the note's point 3, the coordinator's choice): `Pane.scrolled_to` (core/panes.zig), a per-view field (views.zig `pane_fields`, `PaneView`: in the rollback copy, the digest and the dump, each view's own), the row its top shows or null on the output, written only by a step (`scrollBy`, `followOutput`), and carried with every open view's through each write of the emulator that moves rows, once, in the confirmed unit's apply, on every side alike (`Term.feed`/`Term.resize` take the places; core/term/terminal.zig `carry`/`carried` pin each place's row on the primary screen and read the pin back: up by the rows the history drops, 0 when its own row goes, null in the active area or after a reset: a function of the fed bytes); the draw reads the rows from the view's place (`viewport`, `paint`, `ImagesAt.place`, terminal.zig `shown`), and ghostty's own viewport is never moved, read, digested or dumped (`Grid.offset`/`view`, `Parts.view` and the digest's offset gone): two clients no longer scroll one viewport (the new views.zig test failed on the base, `expected 80, found 77`), and a speculation's scroll is in the copy, so `putViews`, the view half of `keepViews` (now `keepSerials`), `viewTo`/`scroll`/`follow` (ops, wrappers, bodies), the Debug screen hash's view exclusion, `reflow`'s column-0 cure and `feedOutput`'s follow-after-read are deleted, and S1's `calls` lists no view write (the rows `viewTo`, `scroll`, `follow` gone); tests: the two-view test (with a dump), the place at the history's cap (`setMaxBytes(1)`), a 300-seed fuzz of the carried place against ghostty's own pinned view, a client's wheel over a shared terminal through output and a rollback, round 6's order explorer (30 seeds a run); the wire at 31 (abi/wire.zig, test/daemon.py `WIRE`): an installed build's dump loads with every view on the output; IN THE WORKSPACE core-test 912/1072 (160 skipped), shell-test 1114/1117 (3 skipped), term-test 16/16, kitty-test 45/45, pane-test 181/182, behaviour-test 275/275, --replay 275/275, process-test 0 of 146 failed, as pairs 0 of 146; gui unit-test 1707/1711, its one error BaselineHarnessMismatch (every base's) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/echo.zig | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'core/echo.zig') diff --git a/core/echo.zig b/core/echo.zig index 93b877b8..b1200ca2 100644 --- a/core/echo.zig +++ b/core/echo.zig @@ -237,7 +237,7 @@ pub const Echo = struct { fn predict(e: *Echo, pane: *Pane, kind: Kind, seq: u32) bool { const state = pane.terminal orelse return false; const g = Term.grid(state); - if (Term.modes(state).alternate or g.offset + g.len < g.total or !g.cursor_visible) return false; + if (Term.modes(state).alternate or pane.termTop() + g.len < g.total or !g.cursor_visible) return false; const top = e.tops[e.pane]; const cur: Cursor = e.cursor orelse .{ .x = g.cursor_x, .row = top + g.cursor_y, .seq = 0 }; if (cur.row < top or cur.row - top >= g.len or e.n == max) return false; @@ -457,17 +457,18 @@ pub const Echo = struct { const top = e.tops[id]; // Off a prompt, the trust is inferred: underlined, as mosh does. const flag = !atPrompt(pane); + const shown = pane.termTop(); const at = struct { - fn f(sb_: @TypeOf(sb), pan: u16, h: u16, top_: u64, row: u64) ?u16 { + fn f(sb_: @TypeOf(sb), shown_: usize, pan: u16, h: u16, top_: u64, row: u64) ?u16 { if (row < top_ or row - top_ >= sb_.len) return null; const screen_row = sb_.total - sb_.len + (row - top_); - if (screen_row < sb_.offset + pan) return null; - const y = screen_row - sb_.offset - pan; + if (screen_row < shown_ + pan) return null; + const y = screen_row - shown_ - pan; return if (y < h) @intCast(y) else null; } }.f; for (e.cells[0..e.n]) |cell| { - const y = at(sb, pane.pan, body_h, top, cell.row) orelse continue; + const y = at(sb, shown, pane.pan, body_h, top, cell.row) orelse continue; if (cell.x >= tw) continue; const dst = s.at(tx + cell.x, body_y + y); // Typed text continues the text before it (mosh's heuristic). @@ -484,7 +485,7 @@ pub const Echo = struct { } if (!active or pane.focus != .body) return; const cur = e.cursor orelse return; - const y = at(sb, pane.pan, body_h, top, cur.row) orelse return; + const y = at(sb, shown, pane.pan, body_h, top, cur.row) orelse return; if (cur.x < tw) s.cursor = .{ .x = tx + cur.x, .y = body_y + y }; } }; -- cgit v1.3