diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-22 20:21:32 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-22 20:21:32 -0300 |
| commit | 3f250d0f963f375d699f11ffc02b07f2e2cbbbee (patch) | |
| tree | 4e5a1f577fd3dd247f3643d979868347524ce703 /test | |
| parent | 34e2d82a322bd3767a8ec62b3a4c0894399e8c04 (diff) | |
| parent | c607dc14502a6956bdfa3575bc7363514a7abeb4 (diff) | |
| download | pardes-3f250d0f963f375d699f11ffc02b07f2e2cbbbee.tar.gz pardes-3f250d0f963f375d699f11ffc02b07f2e2cbbbee.zip | |
integration (a base for the terminals' next round, not yet the gathered line): the viewport in the view and the patches in the semantics hash on merge58 with the terminal put back: pardes-raw-tty (`muwnrqro`, on pardes-merge58: a TERM that reaches a session while it leaves its terminal no longer leaves it raw: `Killed.disarm` puts the cooked modes back itself, `leave` calls it last) and pardes-term-join-10's two changes (`xktusoyq` on `qtxssxyk`, on pardes-term-join-9: where a view stands in a terminal's history is the view's (`Pane.scrolled_to`), carried once a confirmed write that moves rows, the wire at 31; build/patches hashed into a replica's semantics); no conflict; core-test 917/1077 (160 skipped), shell-test 1119/1122, pane-test 182/183, term-test 16/16; NOT gated whole: the viewport's gate had one perf count over its budget ("terminal on all" +0.235%), which the next round brings down before this is the gathered line (2026-11-22)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test')
| -rw-r--r-- | test/daemon.py | 2 | ||||
| -rw-r--r-- | test/kitty.zig | 8 | ||||
| -rw-r--r-- | test/panes.zig | 14 | ||||
| -rw-r--r-- | test/perf.zig | 2 | ||||
| -rw-r--r-- | test/replicas.zig | 19 | ||||
| -rw-r--r-- | test/terminal.zig | 6 |
6 files changed, 24 insertions, 27 deletions
diff --git a/test/daemon.py b/test/daemon.py index 9e0047e5..9c0252e5 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -301,7 +301,7 @@ class Replica: """A replica's connection (abi/wire.zig): length-prefixed messages, a tag byte and a little-endian u32 length. It is a near client: its first word after the hello says so.""" - WIRE = 30 + WIRE = 31 def __init__(self, path, timeout=10): self.path, self.timeout = path, timeout diff --git a/test/kitty.zig b/test/kitty.zig index 76d97421..22b62fb2 100644 --- a/test/kitty.zig +++ b/test/kitty.zig @@ -641,14 +641,14 @@ test "kitty: an image follows its text when the shell scrolls, resizes and reflo try std.testing.expectEqual(o.y + 2, (try r.placesOf(10))[0].dst.y); // A narrower pane reflows the text; the image stays on its row. const pane = r.pane(0); - pane.resizeGrid(40, pane.rows); + pane.resizeGrid(0, 40, pane.rows); const text = try pardes.Term.scrollback(pane.terminal, r.frame.allocator()); var row: usize = 0; var lines = std.mem.splitScalar(u8, text, '\n'); while (lines.next()) |line| : (row += 1) if (std.mem.startsWith(u8, line, "marker")) break; const drawn = try r.placesOf(10); try std.testing.expectEqual(@as(usize, 1), drawn.len); - const viewport_top: usize = pardes.Term.grid(pane.terminal).offset; + const viewport_top: usize = pane.termTop(); try std.testing.expectEqual(o.y + @as(u16, @intCast(row - viewport_top)), drawn[0].dst.y); } @@ -1167,7 +1167,7 @@ fn fuzzRun(seed: u64, steps: usize, trace: bool) !bool { r.p.update(.{ .resize = .{ .cols = cols, .rows = rows, .cell_pixels = .{ .w = 1 + rng.uintLessThan(u16, 30), .h = 1 + rng.uintLessThan(u16, 60) } } }); r.drain(); }, - 1 => r.pane(0).resizeGrid(1 + rng.uintLessThan(u16, 120), 1 + rng.uintLessThan(u16, 40)), + 1 => r.pane(0).resizeGrid(0, 1 + rng.uintLessThan(u16, 120), 1 + rng.uintLessThan(u16, 40)), 2, 3 => { const drawn = try r.places(); if (trace) std.debug.print(" {d} places, {d} placements, {d} images\n", .{ drawn.len, r.placementCount(0), r.storage(0).images.count() }); @@ -1224,7 +1224,7 @@ test "kitty: scrolled back by pardes, an image shows on its row; scrolled forwar r.feed(0, &nl); try std.testing.expectEqual(@as(usize, 0), (try r.placesOf(20)).len); // Back to the top of the history: the marker row is the body's first. - pardes.Term.scroll(pane.terminal.?, -1000); + pane.scrollBy(-1000); const o = r.origin(0); const drawn = try r.placesOf(20); try std.testing.expectEqual(@as(usize, 1), drawn.len); diff --git a/test/panes.zig b/test/panes.zig index 7d0b6396..88209693 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -965,7 +965,7 @@ test "terminal overlay recoloring never materializes unrelated history" { _ = try p.render(frame.allocator()); try testing.expect(p.shell_rows.pane == null); - pane.ovl.?.row = @intCast(pardes.Term.grid(pane.terminal).offset); + pane.ovl.?.row = @intCast(pane.termTop()); p.gpa.free(pane.ovl.?.text); pane.ovl.?.text = try p.gpa.dupe(u8, "caf\xc3\xa9 \xe7\x95\x8c"); _ = frame.reset(.retain_capacity); @@ -994,8 +994,8 @@ test "terminal output keeps following new rows after scrollback eviction" { for (0..3) |phase| { if (phase > 0) { pane.body.mode = .normal; - pardes.Term.scroll(pane.terminal.?, -30); - try std.testing.expect(pages.scrollbar().offset < pages.scrollbar().total - pane.rows); + pane.scrollBy(-30); + try std.testing.expect(pane.termTop() < pages.scrollbar().total - pane.rows); pardes.keys.enterTty(p, 0); } for (phase * 20_000..(phase + 1) * 20_000) |n| { @@ -1008,7 +1008,7 @@ test "terminal output keeps following new rows after scrollback eviction" { try std.testing.expect(evictions > phase); try std.testing.expect(pages.page_size <= pages.limits.max(.bytes)); const sb = pages.scrollbar(); - try std.testing.expectEqual(sb.total - pane.rows, sb.offset); + try std.testing.expectEqual(sb.total - pane.rows, pane.termTop()); const full = try pardes.Term.scrollback(pane.terminal, gpa); defer gpa.free(full); var last_buf: [16]u8 = undefined; @@ -2686,14 +2686,14 @@ const TerminalTests = struct { p.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } }); } p.shell_rows.stale = true; - pardes.Term.scroll(pane.terminal.?, -20); + pane.scrollBy(-20); // ONE buffer line standing in for SIX shell rows: everything below slides // UP five, so the last rows of the body resolve past the viewport's bottom // edge. `PageList.pin` answers for those rows anyway — it walks down the // pagelist, not the viewport — so without a bound of its own this pass // painted the scrollback's colours onto rows the text pass left blank. - const anchor: i32 = @intCast(pardes.Term.grid(pane.terminal).offset); + const anchor: i32 = @intCast(pane.termTop()); pane.ovl = .{ .row = anchor, .rows = 6, .text = try p.gpa.dupe(u8, "one") }; p.shell_rows.stale = true; @@ -2958,7 +2958,7 @@ const TerminalTests = struct { // a buffer whose covered span STRADDLES the viewport top is an ordinary // state. tty mode does not apply the buffer, so it must not be moved by one // either — and `surfRow`/`gridRow` are not inverses across that span. - const anchor: i32 = @intCast(pardes.Term.grid(pane.terminal).offset); + const anchor: i32 = @intCast(pane.termTop()); pane.ovl = .{ .row = anchor - 1, .rows = 4, .text = try p.gpa.dupe(u8, "one\ntwo") }; p.shell_rows.stale = true; _ = frame.reset(.retain_capacity); diff --git a/test/perf.zig b/test/perf.zig index e9ee43d7..30e15dcc 100644 --- a/test/perf.zig +++ b/test/perf.zig @@ -1138,7 +1138,7 @@ fn measureTerminalSession(io: std.Io, mib: usize, reps: usize, json: bool) !void const begin = nowNs(); core.update(.{ .output = .{ .pane = .at(0), .bytes = update } }); pump(core); - const cursor_row = @as(i32, @intCast(pardes.Term.grid(pane.terminal).offset)) + @as(i32, pardes.Term.grid(pane.terminal).cursor_y); + const cursor_row = @as(i32, @intCast(pane.termTop())) + @as(i32, pardes.Term.grid(pane.terminal).cursor_y); pane.ovl.?.row = if (phase == 0) 0 else cursor_row - 1; pane.body.cur_row = pane.ovl.?.row; pane.body.cur_col = 0; diff --git a/test/replicas.zig b/test/replicas.zig index 90f7c10d..a68ce222 100644 --- a/test/replicas.zig +++ b/test/replicas.zig @@ -856,19 +856,18 @@ const Watchdog = struct { /// the untraced one. const Named = struct { const Parted = struct { c: usize, origin: u16, seq: u32, parts: []u64, terms: [pardes.MAX_PANES]Term }; - /// A terminal pane's: its screen's digest without its view and with - /// it, and where its view and cursor stand. - const Term = struct { content: u64 = 0, viewed: u64 = 0, grid: pardes.Term.Grid = .{} }; + /// A terminal pane's: its screen's digest, where the live view stands + /// in it (the pane's, `scrolled_to`), and its grid. + const Term = struct { content: u64 = 0, place: ?usize = null, grid: pardes.Term.Grid = .{} }; fn terms(p: *const pardes.Pardes) [pardes.MAX_PANES]Term { var out: [pardes.MAX_PANES]Term = @splat(.{}); for (p.panes, &out) |slot, *t| { - const state = (slot orelse continue).terminal orelse continue; + const pane = slot orelse continue; + const state = pane.terminal orelse continue; var a = pardes.walk.Hasher.init(0); - state.digestScreen(&a, false); - var b = pardes.walk.Hasher.init(0); - state.digestScreen(&b, true); - t.* = .{ .content = a.final(), .viewed = b.final(), .grid = pardes.Term.grid(state) }; + state.digest(&a); + t.* = .{ .content = a.final(), .place = pane.scrolled_to, .grid = pardes.Term.grid(state) }; } return out; } @@ -898,8 +897,8 @@ const Named = struct { const theirs = arena.allocator().create(pardes.tape.Parts) catch return; const want = pardes.tape.digestParts(rp.core(), theirs); w.print("seed {d} rtt {d} ms: client {d} names: at unit {d}/{d}, against the witness's replay: {s}\n", tag ++ .{ x.c + 1, u.origin, u.seq, pardes.tape.partsDiffer(x.parts, want, arena.allocator()) }) catch {}; - for (x.terms, terms(rp.core()), 0..) |a, b, id| if (a.viewed != b.viewed or a.content != b.content) { - w.print(" pane {d}'s terminal: content {s}, view {s}; the client's {any}; the witness's {any}\n", .{ id, if (a.content == b.content) "equal" else "DIFFERS", if (a.viewed == b.viewed) "equal" else "DIFFERS", a.grid, b.grid }) catch {}; + for (x.terms, terms(rp.core()), 0..) |a, b, id| if (a.place != b.place or a.content != b.content) { + w.print(" pane {d}'s terminal: content {s}, view {s}; the client's {any} at {?d}; the witness's {any} at {?d}\n", .{ id, if (a.content == b.content) "equal" else "DIFFERS", if (a.place == b.place) "equal" else "DIFFERS", a.grid, a.place, b.grid, b.place }) catch {}; }; }; } diff --git a/test/terminal.zig b/test/terminal.zig index 7e7106a1..bad70081 100644 --- a/test/terminal.zig +++ b/test/terminal.zig @@ -25,7 +25,6 @@ const close = Term.close; const grid = Term.grid; const modes = Term.modes; const prompt = Term.prompt; -const scroll = Term.scroll; const scrollback = Term.scrollback; const commandOutput = Term.commandOutput; const filterOf = emu.filterOf; @@ -110,7 +109,7 @@ test "document construction allocates only the pane and has inert terminal defau try std.testing.expectEqual(Term.Prompt{}, prompt(pane.terminal)); pane.scrollBy(100); pane.followOutput(); - pane.resizeGrid(80, 24); + pane.resizeGrid(0, 80, 24); try std.testing.expectEqual(Term.Grid{}, grid(pane.terminal)); try std.testing.expectEqualStrings("", try scrollback(pane.terminal, allocator)); try std.testing.expect(!failing.has_induced_failure); @@ -139,7 +138,7 @@ test "terminal state keeps parser fragments and sends emulator replies through i try std.testing.expectEqual(@as(u16, 0), state.reply_len); } -test "a terminal's dump restores the cells it drew, its history and where its view was" { +test "a terminal's dump restores the cells it drew and its history (where a view stands is the view's, dumped with its pane)" { const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }); defer p.deinit(); @@ -150,7 +149,6 @@ test "a terminal's dump restores the cells it drew, its history and where its vi var line: [16]u8 = undefined; pane.feedOutput(p, std.fmt.bufPrint(&line, "line {d}\r\n", .{i}) catch unreachable); } - scroll(pane.terminal.?, -5); const bytes = try pardes.walk.save(State, gpa, pane.terminal.?); defer gpa.free(bytes); var arena: std.heap.ArenaAllocator = .init(gpa); |
