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 --- abi/term.zig | 56 ++++++++++++++++++++++++++++++-------------------------- abi/wire.zig | 5 ++++- 2 files changed, 34 insertions(+), 27 deletions(-) (limited to 'abi') diff --git a/abi/term.zig b/abi/term.zig index d6c48f96..31f155e8 100644 --- a/abi/term.zig +++ b/abi/term.zig @@ -13,22 +13,19 @@ const CellStyle = plain.CellStyle; /// A terminal: its emulator, its parse and what is kept beside it. pub const State = opaque {}; -/// Where the view and the cursor are, in rows counted from the top of the -/// history: `total` rows, the view's top at `offset`, `len` of them shown. -/// All zero without a terminal. +/// How much history there is and where the cursor is, in rows counted from +/// the top of the history: `total` rows, the last `len` of them the active +/// area (the program's screen). All zero without a terminal. Where a view +/// of it stands is the view's, not the terminal's (a `place`: the row its +/// top shows, or null on the output; core/panes.zig `scrolled_to`). pub const Grid = struct { total: usize = 0, - offset: usize = 0, len: usize = 0, - /// The cursor, in cells of the active area (the history's last `len` - /// rows). + /// The cursor, in cells of the active area. cursor_x: u16 = 0, cursor_y: u16 = 0, /// The program shows the cursor (DECTCEM). cursor_visible: bool = false, - /// The view's top row while it is scrolled to one, null while it - /// follows the output. - view: ?usize = null, /// Its grid's width. cols: u16 = 0, }; @@ -211,6 +208,8 @@ pub const PaintedRow = struct { /// `rows_of[v]` is the body row its view's row `v` shows on, null for one /// not shown. pub const ImagesAt = struct { + /// The view's place (`Grid`): the rows it shows. + place: ?usize, pane: u8, serial: u32, tx: u16, @@ -239,8 +238,6 @@ pub const EchoCell = struct { cp: u21, input: bool, style: u32 }; pub const Parts = struct { reply: []const u8 = "", reply_dropped: u32 = 0, - /// The view's top row, counted from the top of the history. - view: usize = 0, phase: Prompt.Phase = .none, started: u32 = 0, prompts: u32 = 0, @@ -293,8 +290,8 @@ pub const Ops = struct { gpa: *const fn (s: *const State) std.mem.Allocator, // ---- the dump and the digest (`Term.State`'s walk hooks) ---- - /// Its screen into the replay digest (`view`: where its view is too). - digest: *const fn (s: *const State, h: *std.hash.Wyhash, view: bool) void, + /// Its screen into the replay digest. + digest: *const fn (s: *const State, h: *std.hash.Wyhash) void, /// What the dump keeps of it beside its emulator. parts: *const fn (s: *const State) Parts, /// Its emulator as the dump keeps it (ghostty's snapshot); `slim`: its @@ -309,16 +306,19 @@ pub const Ops = struct { /// now on (the core's: a recorded answer). media: *const fn (read: Media) void, - // ---- output and view ---- + // ---- output and size ---- /// One read of its program's output (`Told` says where the tracked - /// rows went). - feed: *const fn (s: *State, bytes: []const u8, track: []const i32, rows: []i32, erased: []bool) Told, + /// rows went), every view's `places` carried through it (`resize`). + feed: *const fn (s: *State, bytes: []const u8, track: []const i32, rows: []i32, erased: []bool, places: []?usize) Told, // A null handle: what a pane without a terminal is told (all zero). grid: *const fn (s: ?*const State) Grid, - viewTo: *const fn (s: *State, at: ?usize) void, - scroll: *const fn (s: *State, delta: i32) void, - follow: *const fn (s: *State) void, - resize: *const fn (s: *State, cols: u16, rows: u16) void, + /// Its grid reflowed, every view's place (`Grid`) carried through it as + /// ghostty carries a view of its own: on its row while rows come below, + /// up by the rows the history drops above it, at the history's top when + /// its own row goes, on the output once it falls into the active area + /// or the screen is reset. A function of the bytes and sizes it was + /// given: the same places on every side. + resize: *const fn (s: *State, cols: u16, rows: u16, places: []?usize) void, cellPixels: *const fn (s: *State, w: u32, h: u32) void, replies: *const fn (s: *State) []const u8, @@ -328,6 +328,8 @@ pub const Ops = struct { wheel: *const fn (s: *State, last: *?Parts.Coordinate, buf: *[64]u8, turn: MouseButton, col: u16, row: u16, mods: MouseMods) ?[]const u8, paste: *const fn (s: ?*const State, text: []u8) [3][]const u8, modes: *const fn (s: ?*const State) Modes, + /// The cursor keys a click at its row `row` (from the top of its + /// history), column `col` of the text shown types at the prompt. promptMoves: *const fn (s: *State, row: i32, col: i32) ?Moves, // ---- prompt and commands ---- @@ -339,7 +341,8 @@ pub const Ops = struct { scrollback: *const fn (s: ?*State, gpa: std.mem.Allocator) error{ OutOfMemory, WriteFailed }![]const u8, scrollbackLen: *const fn (s: ?*State) usize, textRows: *const fn (s: *State, alloc: std.mem.Allocator, scratch: std.mem.Allocator) TextError!Rows, - viewport: *const fn (s: *State, arena: std.mem.Allocator, cut: bool) TextError![]const []const u8, + /// The rows a view at `place` (`Grid`) shows, as text. + viewport: *const fn (s: *State, arena: std.mem.Allocator, cut: bool, place: ?usize) TextError![]const []const u8, /// Its rows `first` and the `count` after it (from the top of its /// history) as text, a prompt's own cells cut off: `arena`'s. editRows: *const fn (s: *State, arena: std.mem.Allocator, first: usize, count: usize) (TextError || error{ NoRow })![]const []const u8, @@ -358,10 +361,11 @@ pub const Ops = struct { spanColor: *const fn (f: *Filter, color: Color, is_bg: bool) Color, // ---- draw ---- - /// Its view's rows, `rows.len` of them, `cols` cells each, into - /// `cells`: each cell's style in the theme's colours (through the - /// filter when `filtered`), its bytes and width. - paint: *const fn (s: *State, ink: *const Ink, palette: *FilterPalette, filtered: bool, first: u16, cols: u16, cells: []Painted, rows: []PaintedRow) void, + /// The rows a view at `place` (`Grid`) shows from its row `first`, + /// `rows.len` of them, `cols` cells each, into `cells`: each cell's + /// style in the theme's colours (through the filter when `filtered`), + /// its bytes and width. + paint: *const fn (s: *State, ink: *const Ink, palette: *FilterPalette, filtered: bool, place: ?usize, first: u16, cols: u16, cells: []Painted, rows: []PaintedRow) void, /// Its kitty images over the body's rows, appended to `out` (`gpa`'s; /// what it keeps to draw them is its own allocator's), and their /// placeholder cells blanked in `frame` (`frame_cols` wide). @@ -380,7 +384,7 @@ pub const Ops = struct { /// file, with its rule: a new one fails its test until it is listed. pub const replicated = [_][]const u8{ "open", "close", "revive", "digest", "parts", "snapshot", "load", "reload", - "media", "feed", "grid", "viewTo", "scroll", "follow", "resize", "replies", + "media", "feed", "grid", "resize", "replies", "key", "mouse", "wheel", "paste", "modes", "promptMoves", "prompt", "commandOutput", "endOutputHere", "scrollback", "scrollbackLen", "textRows", "viewport", "editRows", "promptCut", "page", "filter", "spanColor", "hasImages", diff --git a/abi/wire.zig b/abi/wire.zig index 8f7a7bdb..46e51645 100644 --- a/abi/wire.zig +++ b/abi/wire.zig @@ -10,6 +10,9 @@ const pardes = @import("core"); const config = @import("pardes_options"); const build_info = @import("build_info"); +/// 31: where a view stands in a terminal's history is the view's: a pane's +/// `scrolled_to` (and its share's in each view) in the dump and the digest, +/// the emulator's own view out of both (its `Parts.view` gone); /// 30: the terminals' one road: the screen-state messages are retired (a /// replica's `screen_ack`, 0x04, and the session's `screen`, 0x06: gaps), /// a welcome says no road (its `bytes` byte gone), and a pane's @@ -59,7 +62,7 @@ const build_info = @import("build_info"); /// part B); 14: the hello names a session and /// carries the semantics hash, and a ping is answered (phase 5's /// groundwork); 13: the frames went (phase 3). -pub const version: u16 = 30; +pub const version: u16 = 31; /// The terminal's build and the window's step alike (`semantics`). const family = switch (config.platform) { -- cgit v1.3 From c607dc14502a6956bdfa3575bc7363514a7abeb4 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 22 Nov 2026 18:11:38 -0300 Subject: wire: a replica's semantics hash takes what pardes changes in its dependencies (pardes-term-join-10, item 2; the note's "what cannot be made impossible"): `wire.semantics` hashed every dependency's pin but not build/patches.zig's edits nor the files they append nor uucode_config.zig, which an unstamped build has no commit to stand for, and which change how a core steps for the same bytes (ghostty's page size, so how many rows its history drops at once; a kitty medium's read; mvzr's budget; the Unicode tables ghostty measures widths by): build/core.zig `patchesHash` reads them at configure time (each file's name and text, xor-ed: no order) into `build_info.patches`, which `semantics` formats in; the failing run first: on the base, a comment appended to build/patches/mvzr_budget.zig left `pardes --version`'s semantics at f5f5b4aa40343313 both ways; with this change c5df65c0a926efab became 39ea20fc4149cc6b (logs/item2.sum); still not in the hash, on purpose: ghostty's optimize mode (build/core.zig:518, Debug builds it safe; Debug and ReleaseSafe sides of one session stay allowed, the upgrade rows between the two builds are that guard) and its SIMD (:517, off for a Darwin target built elsewhere: a scalar and a vector path must agree, ghostty's own tests); and pardes's own terminal module (its history cap, kitty limits) stands only in a stamped commit (the ponytail above `semantics`) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- abi/wire.zig | 10 ++++++---- build/core.zig | 33 +++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 8 deletions(-) (limited to 'abi') diff --git a/abi/wire.zig b/abi/wire.zig index 46e51645..55a08909 100644 --- a/abi/wire.zig +++ b/abi/wire.zig @@ -74,8 +74,10 @@ const family = switch (config.platform) { /// its own, and one of another build is refused. The protocol, the release /// and commit, the platform and build options, every dependency's content /// hash (grammars, the terminal emulator, Unicode), the walker codec's assumptions -/// (pointer width, byte order) and the tape's shape (tape.shape: what each -/// input and each answer of the host's is laid out as). Not the OS: a Linux +/// (pointer width, byte order), the tape's shape (tape.shape: what each +/// input and each answer of the host's is laid out as) and what pardes +/// changes in its dependencies (build_info.patches: the patches' text, the +/// Unicode tables' configuration). Not the OS: a Linux /// client of a FreeBSD session is the main case, and what differs there is /// the host's, taped, in a shape every OS shares (an error by its name, a /// stat as fs.OsStat). Nor the build mode: a Debug build steps as a @@ -96,12 +98,12 @@ pub const semantics: u64 = blk: { // 11 KB) joined on, not formatted: formatting them at comptime was 5 % // of a compile of the core. break :blk std.hash.Wyhash.hash(0, std.fmt.comptimePrint( - "wire {d}\npardes {s} {s}\n{s} grammars true {} {} {} workspace_tag {} sources {}\nusize {d} {t}\n", + "wire {d}\npardes {s} {s}\n{s} grammars true {} {} {} workspace_tag {} sources {}\nusize {d} {t}\npatches {x}\n", .{ version, build_info.version, build_info.commit orelse "unstamped", family, g != .none, g != .none, g == .full, config.workspace_tag, config.embed_sources, - @sizeOf(usize), builtin.cpu.arch.endian(), + @sizeOf(usize), builtin.cpu.arch.endian(), build_info.patches, }, ) ++ build_info.deps ++ "\n" ++ pardes.tape.shape); }; diff --git a/build/core.zig b/build/core.zig index 63b4a5e9..e8150843 100644 --- a/build/core.zig +++ b/build/core.zig @@ -94,18 +94,43 @@ pub fn options(b: *std.Build, cfg: ShellConfig, c: Core, pdf: bool) *std.Build.S } /// `build_info`: the version, and the commit, change and time a stamped -/// build was made from (see `stamp_commit`, read at configure time), and -/// every dependency's hash. -pub fn buildInfo(b: *std.Build, cfg: ShellConfig) *std.Build.Step.Options { +/// build was made from (see `stamp_commit`, read at configure time), every +/// dependency's hash, and what pardes changes in them (`patchesHash`). +pub fn buildInfo(b: *std.Build, io: std.Io, cfg: ShellConfig) *std.Build.Step.Options { const o = b.addOptions(); o.addOption([]const u8, "version", display_version); o.addOption(?[]const u8, "commit", cfg.commit); o.addOption(?[]const u8, "change", cfg.change); o.addOption(?[]const u8, "built", cfg.built); o.addOption([]const u8, "deps", deps_text); + o.addOption(u64, "patches", patchesHash(b, io)); return o; } +/// The text of every edit pardes makes to a fetched dependency +/// (build/patches.zig's tables and the files they append, build/patches/) +/// and of the Unicode tables' configuration (uucode_config.zig), hashed: a +/// dependency's pin is in `deps`, but what pardes changes in it is this +/// tree's, which an unstamped build has no commit to stand for, and it +/// changes how a core steps (ghostty's page size: how many rows its +/// history drops at once; a kitty medium's read; a regex's budget), so it +/// is a replica's semantics too (abi/wire.zig `semantics`). +fn patchesHash(b: *std.Build, io: std.Io) u64 { + var h: u64 = 0; + for ([_][]const u8{ "build/patches.zig", "uucode_config.zig" }) |sub| + h ^= std.hash.Wyhash.hash(0, configureRead(b, io, b.root, sub, 1 << 20) catch @panic(sub)); + var dir = b.root.root_dir.handle.openDir(io, "build/patches", .{ .iterate = true }) catch @panic("open build/patches"); + defer dir.close(io); + var it = dir.iterate(); + // Each file by its name and text, in whatever order the directory + // lists them: an xor of each one's hash. + while (it.next(io) catch @panic("read build/patches")) |e| { + const sub = b.pathJoin(&.{ "build/patches", e.name }); + h ^= std.hash.Wyhash.hash(std.hash.Wyhash.hash(0, e.name), configureRead(b, io, b.root, sub, 1 << 20) catch @panic(sub)); + } + return h; +} + fn vendoredThemes(b: *std.Build, io: std.Io) []const []const u8 { var names: std.ArrayList([]const u8) = .empty; var dir = b.root.root_dir.handle.openDir(io, "vendor/themes", .{ .iterate = true }) catch @panic("open vendor/themes"); @@ -593,7 +618,7 @@ pub fn assemble(b: *std.Build, c: struct { .optimize = optimize, .cloud9 = cloud9, .cfg = c.shell_cfg, - .info = buildInfo(b, c.shell_cfg), + .info = buildInfo(b, io, c.shell_cfg), .zstd = zstd, .image = image_addon.root_module, .pdf = pdf_built.module, -- cgit v1.3