From b1fb4242c0ab52767df1b8e155edcf2692f37873 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 23 Nov 2026 18:00:35 -0300 Subject: scroll: a view's top is a line and a row within that line's own wrapped rows, and a scroll moves it by rows (P62, round 3, on the layer's new model where the `Changes` layer's lines are lines of the buffer): a wheel's notch, the glide, PageDown/PageUp, zj/zk, Ctrl-d/u, zt/zz/zb and the margin (`scroll_off` now ROWS) go a row at a time through a line wrapped over many rows and through a long description line of the layer, where the base jumped all of a wrapped line's rows at once (the user, 2026-11-23: "the scroll view jumps around near deleted lines on the diff view"; one-row deleted lines were cured by the layer's second step, a wrapped one was not): TESTS FIRST: core/jj.zig "a view scrolls by rows through a line wrapped over 12 rows and a change's description wrapped over several (a line of the layer): ..." (a notch is one row down the whole text and back, the notches the text's rows exactly; PageDown/PageUp a page of rows; zj/zk one; a held j and k keep the cursor's row `scroll_off` rows inside the body) failing on the base at notch 21 (line 20's 12 rows crossed at once), and "a client wheels its session's view a row a notch into a change's description wrapped over several rows ..., agreeing at every notch; a client joined over that view loads its row"; kept from round 1: core/replica.zig's join over a view scrolled into a wrapped line (with a rollback and a dump) and the explorer of a view's rows (30 seeds), dev/gui's glide a row a notch; THE CHANGE, taken from pardes-row-scroll (`xrxmqlnw`) and -2 (`xxzmwnvq`) without their ghost-row "blocks" (a block is now just a line's own rows): `File.State.scroll_row` and `views.PaneView.scroll_row` in the generic walk (digested, dumped, copied; a dump of 34 loads at its lines' first rows), the wire 35; core/File.zig `Top`, `rowIn`/`rowWalked` (a line's rows as fillBody wraps them, `guideOf` shared), `rowOf`, `lineRows`, `top`/`setTop`, `walkRows`/`walkKnown`, `rowsTo`, `rowsOf` (off the map where it holds the line), `mapFresh`, `scrollRows`, `shownRows` (the geometry laid out first), `show` (a cursor's or a result's row inside the band, the line's rows whole when they fit), `textRowLine`, fillBody's skip to the top's row walked once a geometry (`Pane.top_skip`, derived), the geometry's key with `scroll_row` and stored as what the map was made from; the one-row fact `State.widest` (`Widest`, an upper bound kept by the index's own vector passes `countLines`/`fillLines`) so a view whose lines are each one row walks nothing (`oneRow`: line arithmetic, checked against the walk in Debug); `fitEnd` a vector of printable ASCII at a time; the callers in rows: panes.zig `scrollBy(tab, delta)` and `ensureCursorVisible` (a file's through `File.show`), the wheel and the rail and the edge scroll (mouse.zig), Ctrl-d/u (normal.zig `halfPageMove`), zt/zz/zb, Ctrl-f/b and PgUp/PgDn (Text.zig `scrollViewMove`), Look's reveal and centring, Places' `goTo`/`restore`, Query's `showCurrent`/`caretTo`, the frames' `Region.row` and the glide (dev/glide.zig, the window's `topOf`); test/perf.zig's checks by (line, row) and its seek at a line's first row; Debug in the workspace: core-test 963/1129 (166 skipped), shell-test 1172/1175 (3 skipped) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/replica.zig | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) (limited to 'core/replica.zig') diff --git a/core/replica.zig b/core/replica.zig index 57dd4eed..f62cd629 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -4491,6 +4491,160 @@ test "bytes: a client's wheel over a terminal is its own view's: applied at once try std.testing.expect(placeIn(b.r.core(), b.r.view, id).? < back); } +test "a view's top is a line and a row of its block: a client's wheel into a line wrapped over rows moves it a row a notch, the session agrees through a rollback, and a dump keeps the row" { + const gpa = std.testing.allocator; + var text: std.ArrayList(u8) = .empty; + defer text.deinit(gpa); + // Line 3 is 60 words: four rows at this width. + for (0..40) |i| if (i == 3) { + for (0..60) |w| try text.print(gpa, "w{d:0>3} ", .{w}); + try text.append(gpa, '\n'); + } else try text.print(gpa, "line {d}\n", .{i}); + const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host()); + defer a.deinit(); + const was = Stepping.begin(&a.t, null); + _ = try a.core.setTestFile(text.items); + was.end(); + _ = try a.unit(0, 0); + const id = a.core.view().active; + // A client joined from the session's dump: the text is in it. + const r = try joinedNow(a, 1, 0); + defer r.deinit(); + const rect = a.core.view().rects[id]; + const notch: pardes.Event = .{ .mouse = .{ .button = .wheel_down, .kind = .press, .col = rect.x + 10, .row = rect.y + 5 } }; + // Three notches to line 3's first row, two into its block. + for (0..5) |_| { + const m = try gpa.dupe(u8, try r.input(notch)); + defer gpa.free(m); + r.confirm(try a.take(m)); + r.settle(); + try agrees(a, r); + } + for ([_]*Pardes{ a.core, r.core() }) |core| { + try std.testing.expectEqual(@as(usize, 3), core.panes[id].?.file.?.scroll); + try std.testing.expectEqual(@as(u32, 2), core.panes[id].?.file.?.scroll_row); + } + // A notch of the client's on top of the session's own key (one that + // leaves the view be): the copy put back, the notch applied over it. + const again = try gpa.dupe(u8, try r.input(notch)); + defer gpa.free(again); + r.confirm(try a.local(.{ .key = .{ .cp = pardes.Key.escape } })); + r.settle(); + r.confirm(try a.take(again)); + r.settle(); + try agrees(a, r); + try std.testing.expectEqual(@as(u32, 3), r.core().panes[id].?.file.?.scroll_row); + // A client joining over the view scrolled into the block has the row. + const late = try joinedNow(a, 2, 0); + defer late.deinit(); + try agrees(a, late); + try std.testing.expectEqual(@as(u32, 3), late.core().panes[id].?.file.?.scroll_row); + // The client's view keys, each after the session drew (its geometry + // made for the frame; the client's is not): what a key reads of the + // body's rows is made of the state alone (the soak's divergence at a + // Ctrl-b, before File.shownRows laid the geometry out first). + var arena: std.heap.ArenaAllocator = .init(gpa); + defer arena.deinit(); + for ([_]pardes.Key{ .{ .cp = 'b', .ctrl = true }, .{ .cp = 'f', .ctrl = true }, .{ .cp = 'd', .ctrl = true }, .{ .cp = 'u', .ctrl = true }, .{ .cp = 'e', .ctrl = true } }) |k| { + for (0..3) |_| { + { + const drew = Stepping.begin(&a.t, null); + defer drew.end(); + _ = try a.core.render(arena.allocator()); + } + const m = try gpa.dupe(u8, try r.input(.{ .key = k })); + defer gpa.free(m); + r.confirm(try a.take(m)); + r.settle(); + try agrees(a, r); + } + } + // A session's dump keeps the row. + const bytes = try pardes.dump.dumpBytes(a.core); + defer gpa.free(bytes); + const loaded = try pardes.dump.load(gpa, .{ .cols = 80, .rows = 24 }, bytes, null); + defer loaded.deinit(); + try std.testing.expectEqual(walk.digest(Pardes, a.core), walk.digest(Pardes, loaded)); + try std.testing.expectEqual(a.core.panes[id].?.file.?.scroll_row, loaded.panes[id].?.file.?.scroll_row); +} + +test "a text's views under random orders of the session's and a client's keys, wheels and draws, keys of the session's between a client's and its confirm (rollbacks): every side agrees (an explorer of a view's rows)" { + const gpa = std.testing.allocator; + var text: std.ArrayList(u8) = .empty; + defer text.deinit(gpa); + // Lines of one row and of several (wrapped at 80 columns). + for (0..120) |i| if (i % 7 == 3) { + for (0..20 + i % 40) |w| try text.print(gpa, "w{d:0>3} ", .{w}); + try text.append(gpa, '\n'); + } else try text.print(gpa, "line {d}\n", .{i}); + const keys = [_]pardes.Key{ + .{ .cp = 'j', .text = "j" }, .{ .cp = 'k', .text = "k" }, + .{ .cp = 'w', .text = "w" }, .{ .cp = 'b', .text = "b" }, + .{ .cp = 'b', .ctrl = true }, .{ .cp = 'f', .ctrl = true }, + .{ .cp = 'd', .ctrl = true }, .{ .cp = 'u', .ctrl = true }, + .{ .cp = 'G', .text = "G" }, .{ .cp = 'z', .text = "z" }, + .{ .cp = 't', .text = "t" }, .{ .cp = 'i', .text = "i" }, + .{ .cp = 'x', .text = "x" }, .{ .cp = pardes.Key.escape }, + .{ .cp = '/', .text = "/" }, .{ .cp = pardes.Key.enter }, + }; + for (0..view_orders) |seed| { + const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host()); + defer a.deinit(); + const was = Stepping.begin(&a.t, null); + _ = try a.core.setTestFile(text.items); + was.end(); + _ = try a.unit(0, 0); + const id = a.core.view().active; + const r = try joinedNow(a, 1, 0); + defer r.deinit(); + const opened = try a.openView(1); + r.view = opened.view; + r.confirm(opened.unit); + r.settle(); + try agrees(a, r); + var prng: std.Random.DefaultPrng = .init(seed); + const rand = prng.random(); + var arena: std.heap.ArenaAllocator = .init(gpa); + defer arena.deinit(); + for (0..150) |_| { + const rect = a.core.views[r.view].?.rects[id]; + const at = .{ .col = rect.x + 10, .row = rect.y + rect.h / 2 }; + const ev: pardes.Event = switch (rand.uintLessThan(u8, 10)) { + 0 => .{ .mouse = .{ .button = .wheel_down, .kind = .press, .col = at.col, .row = at.row } }, + 1 => .{ .mouse = .{ .button = .wheel_up, .kind = .press, .col = at.col, .row = at.row } }, + else => .{ .key = keys[rand.uintLessThan(usize, keys.len)] }, + }; + if (rand.boolean()) { + const drew = Stepping.begin(&a.t, null); + defer drew.end(); + _ = arena.reset(.retain_capacity); + _ = try a.core.render(arena.allocator()); + } + if (rand.uintLessThan(u8, 4) == 0) _ = r.draw(.{ .ctx = null, .f = null }); + if (rand.uintLessThan(u8, 3) == 0) { + // The session's own key, then nothing of the client's. + r.confirm(try a.local(.{ .key = keys[rand.uintLessThan(usize, keys.len)] })); + r.settle(); + } else { + const m = try gpa.dupe(u8, try r.input(ev)); + defer gpa.free(m); + // Sometimes the session's own key first: the client's + // applied at once is rolled back and replayed. + if (rand.uintLessThan(u8, 3) == 0) { + r.confirm(try a.local(.{ .key = keys[rand.uintLessThan(usize, keys.len)] })); + r.settle(); + } + r.confirm(try a.take(m)); + r.settle(); + } + agrees(a, r) catch |err| { + std.debug.print("seed {d}: diverged\n", .{seed}); + return err; + }; + } + } +} + /// Seeds of the explorer below a run of the suite takes; 3,000 were run /// once (reports/pardes-term-join-10.md). const view_orders = 30; -- cgit v1.3 From 4e28df7f8e02ceec66a9d62ca75f8ec006e26d7c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 24 Nov 2026 05:28:45 -0300 Subject: layout: a view's geometry is read back as its session holds it, never laid out again at a load, and held to its screen (walk.zig `.within`): a dump whose rect or column is off its screen is REFUSED, the field named: RUN FIRST (the soak, `replicas -- --clients 5`, Debug): `rpplxwst` ALONE diverged 124 at rtt 30 (225 clients parted at their first unit after a join, `addon pdf: its state after view is not the session's (it breaks PA_PLAIN)` and `the tape's answer to addon is short`; then 532 keys into the pdf's pane stopped at `a key into a kind's pane`, the kind distrusted; the witness's replay past a divergence panicked, `integer overflow` in Core.advanceInner), `pardes-merge67` 0 at 30, 80 and 207 ms; THE CAUSE: a join opens its client a view (views.zig `open`: the live one's screen and columns, NO rects: laid out at that view's first input), and rpplxwst's load (dump.zig `afterLoad`) laid every view out again, so the client had rects for its own view the session had not, told its plain kinds a view the session never told them (Kind.zig `step`, `viewOf`), and parted at the session's next step; a join's dump is the session: THE FIX: `rects`, `col_x`, `col_w` back in the digest, the dump and the copy as merge67 had them, `afterLoad`'s relayout gone (and walk.zig `pastHeld`'s pass over a derived buffer with it), and where a value read back may be is declared beside the field: `replica.within` (a predicate of the struct by the entry's place in the field, as far as its length says), checked with the indexes (`heldIndexes`) in all three decoders (a tape's `decode`, a byte dump's and an image's `holdTo`): `View.rects` on its screen (`onScreen`: x + w <= screen_w, y + h <= screen_h, as the layout pass puts every one, and a view not laid out yet has empty ones), a column's edge with its width (`columnOnScreen`, declared on `col_w`), refused in words (`Core.View.rects[0] is not within Core.View.onScreen: refused`), never clamped (a clamped rect is a state no session had); `cols` stays held to `ncol` (a column past `ncol` is a dropped one's, which the index rule would read); TESTS FIRST: replica.zig "a client joins with its session's geometry as the session holds it ..." (a plain kind keeping the rows its view was told; on pardes-load-index: `expected 0, found 5`, the joined view's rect, and without that line `the tape's answer to addon is short (tape byte 241, in tick)`), dump.zig "a view's geometry is read back as the session holds it, never laid out again; a rect or a column off its screen is refused, the field named" (the fuzz's restore seed 589: a pane 534 rows tall on a 24-row screen; a column 900 wide; a column's edge at 900), walk.zig's index test gains an entry not where it may be (`S.edges[1] is not within`, a tape, a dump and an image) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/Core.zig | 23 ++++++++++++++++++---- core/dump.zig | 59 ++++++++++++++++++++++++++++++++++---------------------- core/replica.zig | 39 +++++++++++++++++++++++++++++++++++++ core/walk.zig | 55 +++++++++++++++++++++++++++++++++++++--------------- 4 files changed, 133 insertions(+), 43 deletions(-) (limited to 'core/replica.zig') diff --git a/core/Core.zig b/core/Core.zig index b2f96886..6c981adf 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -87,16 +87,18 @@ const Pardes = @This(); /// One client's view of the session (views.zig): its screen and layout, /// its focus, its pointer and gestures, its jumps, its key prefixes. pub const View = struct { - /// Its geometry (`rects`, `col_x`, `col_w`) is the layout pass's over - /// its columns and screen: never dumped, laid out again at a load - /// (dump.afterLoad), as a resize lays it out. pub const replica = .{ .len = .{ .{ "leader_keys", "leader_n" }, .{ "cols", "ncol" }, .{ "col_x", "ncol" }, .{ "col_w", "ncol" } }, - .derived = .{ "rects", "col_x", "col_w" }, // What its keyboard is on: a pane there; window mode's outline and // a kind's press and hover, slots; its screen, a grid a frontend // sizes (walk.zig `.index`). .index = .{ .{ "active", Pardes, "focusPanes" }, .{ "window_pick", Pardes, "panes" }, .{ "kind_grab", Pardes, "panes" }, .{ "kind_hover", Pardes, "panes" }, .{ "screen_w", "grids" }, .{ "screen_h", "grids" } }, + // Its geometry, read back as the session holds it (a view opened + // and not laid out yet has none, on a join's client too, whose + // kinds are told its views as the session's are): on its screen, + // a pane's rect and a column's `col_x` with its width (walk.zig + // `.within`). + .within = .{ .{ "rects", "onScreen" }, .{ "col_w", "columnOnScreen" } }, }; /// A view's slot in `Pardes.views`, as it crosses the core's edge: an /// entry's argument or answer, the wire's welcome. A type of its own, @@ -221,6 +223,19 @@ pub const View = struct { return n >= 1 and n <= max_grid; } pub const max_grid = 4096; + + /// Pane slot `id`'s rect on the screen, where the layout pass puts + /// every one (a frame is the screen's cells: one past it, drawn, is a + /// cell outside the frame). + pub fn onScreen(v: *const View, id: usize) bool { + const r = v.rects[id]; + return @as(u32, r.x) + r.w <= v.screen_w and @as(u32, r.y) + r.h <= v.screen_h; + } + + /// Column `c` on the screen: its left edge and its width. + pub fn columnOnScreen(v: *const View, c: usize) bool { + return @as(u32, v.col_x[c]) + v.col_w[c] <= v.screen_w; + } }; gpa: std.mem.Allocator, diff --git a/core/dump.zig b/core/dump.zig index 9dcc076e..b4561ae2 100644 --- a/core/dump.zig +++ b/core/dump.zig @@ -143,14 +143,6 @@ pub fn dumpExit(p: *Pardes) !void { /// view showed in a dump made before the layer's lines were the buffer's /// (wire 31 and older: a view's bit, no lines), its lines in it (jj.loaded). fn afterLoad(p: *Pardes) void { - // Each view laid out again over its columns and its screen, as a resize - // lays it out: its geometry is derived, never read (View.replica). - const live = p.live; - for (p.views, 0..) |slot, k| if (slot != null) { - p.live = @intCast(k); - layout.compute(p); - }; - p.live = live; for (p.panes) |slot| if (slot) |pane| if (pane.file) |*f| { const text = pardes.panes.File.fileText(f, p.scratch.allocator()) catch continue; f.context.reload(p.tree_sitter_gpa, f.path, text, f.revision); @@ -1036,24 +1028,45 @@ test "a dump keeps the session's settings, and a restore applies them" { try std.testing.expect(!restored.settings.wrap); } -test "a view's geometry is laid out again at a load, never read: a pane's rect past its screen in a dump is the layout's after it" { - // The fuzz's restore road, seed 589: an image whose pane 0 said 534 - // rows on a 24-row screen, drawn: surface.zig's `at` asserted. +test "a view's geometry is read back as the session holds it, never laid out again; a rect or a column off its screen is refused, the field named" { const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); defer p.deinit(); - const want = p.view().rects[0]; - p.view().rects[0].h = 534; - p.view().col_w[0] = 900; - const dumped = try dumpBytes(p); - defer gpa.free(dumped); - p.view().rects[0] = want; - const q = try load(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }, dumped, null); - defer q.deinit(); - try std.testing.expectEqual(want, q.view().rects[0]); - try std.testing.expectEqual(@as(u16, 80), q.view().col_w[0]); - _ = q.frame_arena.reset(.retain_capacity); - _ = try q.render(q.frame_arena.allocator()); + // Not what the layout pass would make of its columns (a view opened + // and not laid out yet has no rects at all): as the session has it. + p.view().rects[0].h -= 1; + const held = p.view().rects[0]; + inline for (.{ byteDump, dumpBytes }) |dumpOf| { + const bytes = try dumpOf(p); + defer gpa.free(bytes); + const q = try load(gpa, p.opts, bytes, null); + defer q.deinit(); + try std.testing.expectEqual(held, q.view().rects[0]); + } + // The fuzz's restore road, seed 589: an image whose pane 0 said 534 + // rows on a 24-row screen, drawn: surface.zig's `at` asserted. + const Off = struct { at: *u16, to: u16, why: []const u8 }; + for ([_]Off{ + .{ .at = &p.view().rects[0].h, .to = 534, .why = "View.rects[0] is not within" }, + .{ .at = &p.view().col_w[0], .to = 900, .why = "View.col_w[0] is not within" }, + // A column's edge is held with its width. + .{ .at = &p.view().col_x[0], .to = 900, .why = "View.col_w[0] is not within" }, + }) |off| { + const was = off.at.*; + off.at.* = off.to; + defer off.at.* = was; + inline for (.{ byteDump, dumpBytes }) |dumpOf| { + const bytes = try dumpOf(p); + defer gpa.free(bytes); + var notes: std.ArrayList(u8) = .empty; + defer notes.deinit(gpa); + try std.testing.expectError(error.BadDump, load(gpa, p.opts, bytes, ¬es)); + std.testing.expect(std.mem.indexOf(u8, notes.items, off.why) != null) catch |err| { + std.debug.print("refused, but not by {s}: {s}\n", .{ off.why, notes.items }); + return err; + }; + } + } } test "a dump whose index names no view or pane there is refused, the field named; a top past its text is its last line; a key's replay is not dumped" { diff --git a/core/replica.zig b/core/replica.zig index 46320fea..4126972a 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -6615,6 +6615,45 @@ test "a kind's place moved in a step of another view's: a replica's key that rea try agrees(a, r); } +/// Placed, plain (PA_PLAIN): a client runs it, and its state is the rows +/// its last view was told. +const Viewed = struct { + const pa = pardes.Kind.c; + const words = [_]pa.pa_word{std.mem.zeroInit(pa.pa_word, .{ .name = "Viewed", .opens = 1, .doc = "the rows its view was told" })}; + const ops = std.mem.zeroInit(pardes.Kind.Ops, .{ + .head = std.mem.zeroInit(pa.pa_head, .{ .size = @sizeOf(pa.pa_head), .abi = pardes.Kind.abi, .name = "viewed".* ++ @as([10]u8, @splat(0)), .version = 1, .exts = "", .flags = pa.PA_PLAIN, .words = &words, .nwords = 1 }), + .open = Placed.open, + .paint = Placed.paint, + .view = Placed.view, + }); +}; + +test "a client joins with its session's geometry as the session holds it: the view opened for it, not laid out yet, is not laid out in the client either, and a plain kind is told the same views on both" { + // The soak's (test/replicas.zig): a client parted at its first unit + // after its join, `addon pdf: its state after view is not the + // session's`: it had laid every view out at its load, its own new one + // too, which the session lays out at that view's first input. + const gpa = std.testing.allocator; + const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host()); + defer a.deinit(); + var words: [64]pardes.Kind.LoadedWord = undefined; + const viewed = pardes.Kind.loadedOf(&Viewed.ops, "/x/viewed.so", @splat(7), &words); + _ = try a.local(.{ .addon = .{ .op = .load, .pane = .at(0), .kind = &viewed } }); + _ = try a.local(.{ .command = "Viewed" }); + const kid = a.core.view().active; + const joined = (try a.join(1, null)).?; + defer gpa.free(joined.dump); + const r = try Replica.initDump(gpa, 1, joined.view, joined.dump, .{ .cols = 80, .rows = 24 }); + defer r.deinit(); + try std.testing.expect(r.loaded(joined.digest)); + try runsHere(r, kid, &Viewed.ops); + try std.testing.expectEqual(a.core.views[joined.view].?.rects[kid], r.core().views[joined.view].?.rects[kid]); + // The session's own step tells the kind each view whose facts changed. + r.confirm(try a.local(.tick)); + r.settle(); + try agrees(a, r); +} + /// A kind whose every key asks a job, for the job tokens' test. const Jobber = struct { const pa = pardes.Kind.c; diff --git a/core/walk.zig b/core/walk.zig index 25e4bdc3..51b0a384 100644 --- a/core/walk.zig +++ b/core/walk.zig @@ -249,8 +249,6 @@ const Past = struct { name: []const u8, says: usize, holds: usize }; /// its own. fn pastHeld(comptime T: type, v: *const T, held: ?*const [pairs(T)]usize) ?Past { inline for (0..comptime pairs(T)) |i| { - // A buffer no dump carries (derived) is made again, not read. - if (comptime excluded(T, T.replica.len[i][0])) continue; const buffer = @field(v, T.replica.len[i][0]); const holds = if (comptime @typeInfo(@TypeOf(buffer)) == .array) (if (held) |h| @min(h[i], buffer.len) else buffer.len) else buffer.len; const says = lengthIn(v, T.replica.len[i][1]); @@ -276,6 +274,10 @@ fn pastHeld(comptime T: type, v: *const T, held: ?*const [pairs(T)]usize) ?Past // // Its last place, a function of the struct (`fn (*const T) usize`), // // or its first and last (`[2]usize`). // .place = .{ .{ "scroll", "lastLine" } }, +// // Where each of its entries (as far as its length says) may be, +// // a predicate of the struct by the entry's place in the field +// // (`fn (*const T, usize) bool`): a view's rects on its screen. +// .within = .{ .{ "rects", "onScreen" } }, // // What a load that left one of its things out (another build's // // pane) does to what names it (`fn (*T) void`), before its indexes // // are held. @@ -286,18 +288,20 @@ fn pastHeld(comptime T: type, v: *const T, held: ?*const [pairs(T)]usize) ?Past // the disk) is held to them where its fields end, beside its lengths // (`pastHeld`), every declaration of every type at once: an index that names // none is REFUSED, its field named (the dump is not the session: the view, -// the pane it names is not there); a place past its thing's last is that -// LAST (the session is there, its view a line off). A field that names a -// slot by its type (`Pane.Id`, `View.Id`) and says nothing is a compile -// error (`checkSlots`); a bare integer that does is found by reading, as -// the lengths' were, until it is typed as its slot. +// the pane it names is not there), and so is an entry that is not where it +// may be (no session's: a rect past its screen); a place past its thing's +// last is that LAST (the session is there, its view a line off). A field +// that names a slot by its type (`Pane.Id`, `View.Id`) and says nothing is +// a compile error (`checkSlots`); a bare integer that does is found by +// reading, as the lengths' were, until it is typed as its slot. fn declared(comptime T: type, comptime kind: []const u8) usize { return if (@hasDecl(T, "replica") and @hasField(@TypeOf(T.replica), kind)) @field(T.replica, kind).len else 0; } -/// An index read back that names none of what it says it indexes. -const Unnamed = struct { holder: []const u8, name: []const u8, says: usize, of: []const u8 }; +/// An index read back that names none of what it says it indexes, or +/// (`within`) the entry `says` of a field that is not where it may be. +const Unnamed = struct { holder: []const u8, name: []const u8, says: usize, of: []const u8, within: bool = false }; /// What an index field says, as a number: an integer, an optional one's (null /// names nothing), a slot's enum's (`Pane.Id`). @@ -395,6 +399,11 @@ fn heldIndexes(comptime T: type, v: *T) ?Unnamed { if (comptime d.len == 2) if (firstUnnamed(T, v, d[0], T, v, d[1])) |i| return .{ .holder = @typeName(T), .name = d[0], .says = i, .of = @typeName(T) ++ "." ++ d[1] }; } + inline for (0..comptime declared(T, "within")) |k| { + const d = T.replica.within[k]; + for (0..heldOf(T, v, d[0])) |i| if (!@field(T, d[1])(v, i)) + return .{ .holder = @typeName(T), .name = d[0], .says = i, .of = @typeName(T) ++ "." ++ d[1], .within = true }; + } inline for (comptime heldIn(T)) |U| if (visit(T, v, U, T, v, 0)) |bad| return bad; return null; } @@ -461,7 +470,10 @@ fn holdTo(l: anytype, comptime T: type, out: *T, held: *const [pairs(T)]usize, d } if (comptime @hasDecl(T, "replica")) if (comptime @hasField(@TypeOf(T.replica), "left_out")) if (l.dropped != dropped) @field(T, T.replica.left_out)(out); if (heldIndexes(T, out)) |bad| { - l.note("{s}.{s} says {d}, which names none of {s}: refused", .{ bad.holder, bad.name, bad.says, bad.of }); + if (bad.within) + l.note("{s}.{s}[{d}] is not within {s}: refused", .{ bad.holder, bad.name, bad.says, bad.of }) + else + l.note("{s}.{s} says {d}, which names none of {s}: refused", .{ bad.holder, bad.name, bad.says, bad.of }); return error.BadDump; } } @@ -499,10 +511,11 @@ fn checkAnnotations(comptime T: type) void { continue; } inline for (@field(T.replica, kind)) |entry| { - const pair = comptime std.mem.eql(u8, kind, "len") or std.mem.eql(u8, kind, "alloc") or std.mem.eql(u8, kind, "index") or std.mem.eql(u8, kind, "place"); + const held = comptime std.mem.eql(u8, kind, "index") or std.mem.eql(u8, kind, "place") or std.mem.eql(u8, kind, "within"); + const pair = comptime held or std.mem.eql(u8, kind, "len") or std.mem.eql(u8, kind, "alloc"); const name = if (pair) entry[0] else entry; if (!@hasField(T, name)) @compileError("walk: " ++ @typeName(T) ++ " annotates no field " ++ name); - if (comptime std.mem.eql(u8, kind, "index") or std.mem.eql(u8, kind, "place")) { + if (held) { const H = if (entry.len >= 3) entry[1] else T; const what = if (entry.len >= 3) entry[2] else entry[1]; if (entry.len == 4) if (!@hasField(T, entry[3])) @compileError("walk: " ++ @typeName(T) ++ " counts its span by no field " ++ entry[3]); @@ -3146,7 +3159,7 @@ test "a length past what its buffer holds is refused where it is read back (a ta try std.testing.expectError(error.BadDump, get.get(Room, (try Get.member(root, "room")).?)); } -test "an index read back that names none of its things is refused, its field named, in a tape, a dump and an image; a place past its thing's last is that last" { +test "an index read back that names none of its things is refused, its field named, in a tape, a dump and an image, and so is an entry not where it may be; a place past its thing's last is that last" { const S = struct { const Self = @This(); const Inner = struct { @@ -3161,10 +3174,14 @@ test "an index read back that names none of its things is refused, its field nam slot: ?u16 = null, scroll: u32 = 0, inner: [2]?*Inner = @splat(null), - pub const replica = .{ .index = .{ .{ "live", "there" }, .{ "slot", "things" } }, .place = .{.{ "scroll", "last" }} }; + edges: [2]u8 = @splat(0), + pub const replica = .{ .index = .{ .{ "live", "there" }, .{ "slot", "things" } }, .place = .{.{ "scroll", "last" }}, .within = .{.{ "edges", "inside" }} }; pub fn there(s: *const Self, i: usize) bool { return i < s.things.len and s.things[i] != null; } + pub fn inside(s: *const Self, i: usize) bool { + return s.edges[i] < 8; + } pub fn last(_: *const Self) usize { return 9; } @@ -3200,7 +3217,13 @@ test "an index read back that names none of its things is refused, its field nam v.inner[1] = &bad_list; break :blk v; } }, + .{ "S.edges[1] is not within", blk: { + var v = good; + v.edges = .{ 7, 8 }; + break :blk v; + } }, }; + const n_bad = bad.len; var notes: std.ArrayList(u8) = .empty; // A dump. @@ -3239,14 +3262,14 @@ test "an index read back that names none of its things is refused, its field nam pub fn run(ctx: @This(), cursor: *Mem.Cursor(.read_write)) !void { const map = try Mem.HashMap(.read_write).init(cursor.*); try ctx.put.member(map, "good", S, ctx.good); - inline for (0..4) |i| try ctx.put.member(map, std.fmt.comptimePrint("bad{d}", .{i}), S, &ctx.bad[i][1]); + inline for (0..n_bad) |i| try ctx.put.member(map, std.fmt.comptimePrint("bad{d}", .{i}), S, &ctx.bad[i][1]); } }{ .put = &put, .good = &good, .bad = &bad }); var get: Get = .init(a); defer get.deinit(); const root = db.rootCursor().readOnly(); try std.testing.expectEqual(@as(u32, 9), (try get.get(S, (try Get.member(root, "good")).?)).scroll); - inline for (0..4) |i| { + inline for (0..n_bad) |i| { get.notes.clearRetainingCapacity(); try std.testing.expectError(error.BadDump, get.get(S, (try Get.member(root, std.fmt.comptimePrint("bad{d}", .{i}))).?)); try std.testing.expect(std.mem.indexOf(u8, get.notes.items, bad[i][0]) != null); -- cgit v1.3 From 9ebe0ab174b25d488dfbf20a9b9d9827fc564b6c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 24 Nov 2026 05:49:28 -0300 Subject: replica: `may_wait` lists the two stops the soaks saw that no row held, each a read of what only the session has: `a key into a kind's pane` (a key to a kind this client does not run, no library for it here or not PA_PLAIN: its state the session's, as "a replica with no code for a kind whose state is not plain ... its keys go to the authority" has it; on `.addon`, which the walk does not stand in, as the kinds' other rows) and `jj` (jj run in the session's tree: `At `, a file at a revision; a Look at a change id, its patch; `Diff a..b`: what the session's repository holds, its disk, as `resolve` and `read_file` are); the walk walks `At @-` (walk_samples), which stops at `jj` on a file's pane and a directory's, so the row is held to a stop it names (the shell-test walk's stale check passes with it, 12/12); WHERE EACH WAS SEEN: the first only after a divergence (the geometry fault, the change before: a client that found the pdf break PA_PLAIN distrusts it and joins again without its code, then every key into its pane stops there: 532 in rpplxwst's soak), none in a soak with the fix; the second on main's soaks (pair-14, link-3, merge65's release soak: a client's Enter, `\r`, stopped at `jj`), whose path to a jj site is not named here (Enter on a word that reads as a change id, in a scratch and in a file, stopped nowhere in a probe) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/replica.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'core/replica.zig') diff --git a/core/replica.zig b/core/replica.zig index 4126972a..182d25c2 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -7365,12 +7365,16 @@ const may_wait = [_]Wait{ .{ .what = "DumpThemes", .on = .any, .stop = "the authority's own state", .why = "the theme files written" }, // A +Preview's text is read from the session's disk. .{ .what = "Search *", .on = .any, .stop = "preview", .why = "a +Preview's file, from the session's disk" }, + // jj run in the session's tree (jj.zig `show`, `diffChange`, + // `diffPair`): what its repository holds, the session's disk. + .{ .what = "At *", .on = .any, .stop = "jj", .why = "a file at a revision, asked of the session's repository" }, // A kind's own state on the session (a PDF's document): asking it. .{ .what = "*", .on = .addon, .stop = "a kind's search", .why = "a search in a kind's pane: its own state, the session's" }, .{ .what = "*", .on = .addon, .stop = "a kind's address", .why = "a place in a kind's pane (`Look doc.pdf:3`): its own state" }, .{ .what = "*", .on = .addon, .stop = "a kind's close", .why = "a kind's pane closed: its state let go on the session" }, .{ .what = "*", .on = .addon, .stop = "a kind's word", .why = "a word to a kind (a key it takes as one): its own state" }, .{ .what = "*", .on = .addon, .stop = "a kind's open", .why = "a kind's pane opened (`Life`): its state made on the session" }, + .{ .what = "*", .on = .addon, .stop = "a key into a kind's pane", .why = "a key to a kind this client does not run (no library for it here, or not PA_PLAIN): its state the session's" }, } ++ (if (pardes.builtins.capabilities.font_picker) [_]Wait{ // A window's view's words, which a terminal's build has too: a window // client of its session runs them. @@ -7426,7 +7430,7 @@ const walk_samples = [_]struct { []const u8, []const u8 }{ .{ "Msg", "hi" }, .{ "ThemeFile", "t.zon" }, .{ "Edit", "s/a/b/" }, .{ "Mini", "x" }, .{ "Find", "x" }, .{ "Grep", "x" }, .{ "Rename", "x" }, .{ "WsSymbols", "x" }, .{ "Theme", "acme" }, .{ "Font", "Mono 12" }, .{ "TaglineSize", "100" }, .{ "WindowOpacity", "100" }, - .{ "MessageLinger", "1000" }, .{ "InactiveDim", "0" }, .{ "GripWidth", "100" }, + .{ "MessageLinger", "1000" }, .{ "InactiveDim", "0" }, .{ "GripWidth", "100" }, .{ "At", "@-" }, }; fn keyName(buf: []u8, k: pardes.Key) []const u8 { -- cgit v1.3 From e332c4c300bd39ba9b2da797391e37ddebda5319 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 24 Nov 2026 06:03:39 -0300 Subject: soak: a join's dump that loads as another session says the fields it differs by, as a client's join says them (replica.fromDump's words: `loadDiffers` made pub): the coordinator's merge67b release soak had 'seed 3 rtt 207 ms: client 3's dump loaded as another session' and no field (1 in 12 seed-runs), not reproduced yet Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/replica.zig | 2 +- test/replicas.zig | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'core/replica.zig') diff --git a/core/replica.zig b/core/replica.zig index 182d25c2..48cb1838 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -3100,7 +3100,7 @@ fn loadAgain(gpa: Allocator, j: *Joined, have: ?*Have, why: []u8, session: []con /// The fields a replica loaded from the join's dump `bytes` has other than /// the session as it dumped them (the digest a field at a time the dump /// ends with: dump.joinParts), named in `out`. -fn loadDiffers(r: *Replica, bytes: []const u8, out: []u8) []const u8 { +pub fn loadDiffers(r: *Replica, bytes: []const u8, out: []u8) []const u8 { const want = pardes.dump.joinParts(r.gpa, bytes) orelse return "(the dump names no field) "; defer r.gpa.free(want); var arena: std.heap.ArenaAllocator = .init(r.gpa); diff --git a/test/replicas.zig b/test/replicas.zig index 3aa9263e..cd0a3459 100644 --- a/test/replicas.zig +++ b/test/replicas.zig @@ -1986,7 +1986,9 @@ const Soak = struct { rp.echo.now = m.at * 1000; if (!rp.loaded(cl.digest)) { s.totals.unequal += 1; - std.debug.print("seed {d} rtt {d} ms: client {d}'s dump loaded as another session\n", .{ s.r.seed, s.r.rtt_ms, m.who }); + // The fields it differs by, as a client's join says them (replica.fromDump). + var named: [400]u8 = undefined; + std.debug.print("seed {d} rtt {d} ms: client {d}'s dump loaded as another session: {s}differs\n", .{ s.r.seed, s.r.rtt_ms, m.who, replica.loadDiffers(rp, m.bytes, &named) }); } cl.live = m.gen; var j: replica.Joined = .{ .fd = cl.cfd, .pid = 0, .client = cl.id, .view = cl.view, .gmtoff = 0, .dump = &.{} }; -- cgit v1.3 From 4ae132650106242a5130aad5230c4f429bf02b29 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 24 Nov 2026 14:43:18 -0300 Subject: replica, gui, tui: the clock a session's pump reads after its wait is held only while a client's post waits for it (Peers.heldNow, which both shells' clocks call), so a wait that ran out always reads the clock and its step meets the deadline it waited for: a window's session showing a PDF with a client attached stepped ~700 times a second with nobody typing, each step a unit every client replayed (the multi-client line's "a PDF in a window's session floods every client"); RUN (an instrumented Debug build, the window's loop offscreen with no test mode, a terminal client; .scratch reorg/pardes-idle-flood/runs/probe): the client's view of the PDF (pane 1, view 1: 78x9, 8x16, glyphs) owed to the kind from its join on (Kind.wake: now, so nextWake a frame on), and 2247 of 2268 pumps 'mail_only true, mail false, wait ran out', the clock read after each the one held at the join (1.302 s while the real one ran to 2.93 s), so advance never reached the deadline, the view was never told, and the next wait was 1 ms: for ever; THE CAUSE: dev/gui/gui.zig guiNow held the clock after any wait whose `mail_only` was still set, and waitInput sets it at a wait's start and clears it only for an event that is not a replica's wake or a queue message: a wait that ran out (SDL_WaitEventTimeout false, waitDetached's too) took no post and still held the clock; a terminal's session never did (its wait ends in a .wake event, tui.zig apply clears it); THE FIX: Peers.heldNow (core/replica.zig): held only when the wait took nothing else (the shell's `mail_only`), a client is attached (`recording`), a post waits to be taken (`mail`, set by post, cleared at the boundary) and the clock has started; gui.zig guiNow and tui.zig clockNow call it (their own copies of the rule gone), so no shell's wait can hold the clock without a post; TEST FIRST: test/panes.zig "a PDF shown and a client's view its kind was not told: the session's next pump, its wait run out with nobody typing, tells it, and nothing is owed after; a client's post waiting holds the clock" (on the base's rule, the same function without `mail`: fails at panes.zig:4120, the view still owed after the pump); test/daemon.py --client-idle on this build: the window's loop 7 boundaries and 8 units with a PDF against the text alone's 5 and 6 (4871 and 4872 on the base), the test surface 223 against 207 (388 against 206), the terminal's 8 against 5; a user hit it: every window's session with a client attached and a deadline owed (a PDF's view, a message's linger, a Life's tick, a look's hover) stepped and sent a unit a millisecond until someone typed in the window Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/replica.zig | 12 ++++++++ dev/gui/gui.zig | 7 ++--- dev/tui/tui.zig | 7 ++--- test/panes.zig | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 8 deletions(-) (limited to 'core/replica.zig') diff --git a/core/replica.zig b/core/replica.zig index 829972c2..875a7828 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -1911,6 +1911,18 @@ pub const Peers = struct { return n; } + /// The time the session's pump reads after its wait, when that wait + /// took a client's post and nothing else (`only_mail`, the shell's word + /// for its wait): the core's clock as it stands, so the pump's unit + /// moves nothing a client's speculation stands on; null otherwise (the + /// shell's clock). Held only while a post waits (`mail`): a wait that + /// ran out took none, and the pump after it is the one its deadline + /// asked for (a window's wait that ran out was held, 2026-11-24: a + /// deadline never met, the session stepped a millisecond for ever). + pub fn heldNow(ps: *const Peers, core: *const Pardes, only_mail: bool) ?u64 { + return if (only_mail and ps.recording and ps.mail.load(.acquire) and core.clock.started) core.clock.now_ns else null; + } + pub fn post(ps: *Peers, note: Note) void { ps.lock.lockUncancelable(ps.io); if (note == .join and ps.upgrading.load(.monotonic)) { diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig index 9ea813fc..8fd8c24c 100644 --- a/dev/gui/gui.zig +++ b/dev/gui/gui.zig @@ -2457,9 +2457,8 @@ const Shell = struct { /// of their own with no window here; the session loop's /// (runtime/session.zig), a client's none. peers: *replica.Peers, - /// This wait took only a replica's post (its input, its join): the pump - /// after it reads no new time, so it moves nothing the replicas' - /// speculations stand on (tui.zig's `mail_only`). + /// This wait took nothing but a replica's post, if one (its input, its + /// join): the pump after one reads no new time (Peers.heldNow). mail_only: bool = false, waited: bool = false, /// With replica clients, a wait takes one person's input (tui.zig @@ -3167,7 +3166,7 @@ fn guiNow(ctx: ?*anyopaque) u64 { const s = shellOf(ctx); if (s.waited) { s.waited = false; - if (s.mail_only and s.peers.count() > 0 and s.core.clock.started) return s.core.clock.now_ns; + if (s.peers.heldNow(s.core, s.mail_only)) |held| return held; } return s.test_clock orelse s.paced_ns orelse c.SDL_GetTicksNS(); } diff --git a/dev/tui/tui.zig b/dev/tui/tui.zig index e2cdd2fa..312a0846 100644 --- a/dev/tui/tui.zig +++ b/dev/tui/tui.zig @@ -1240,9 +1240,8 @@ const Shell = struct { /// The session's replica clients (core/replica.zig), on sockets: the /// session loop's (runtime/session.zig); a client's, none. peers: *replica.Peers, - /// This wait took only a replica's post (its input, its join): the - /// pump after it reads no new time, so it moves nothing the replicas' - /// speculations stand on (a replica takes such a unit as is). + /// This wait took nothing but a replica's post, if one (its input, its + /// join): the pump after one reads no new time (Peers.heldNow). mail_only: bool = false, waited: bool = false, /// This wait's steps so far, and the input held for the next (`split`). @@ -1321,7 +1320,7 @@ const Shell = struct { const s = of(ctx); if (s.waited) { s.waited = false; - if (s.mail_only and s.peers.count() > 0 and s.core.clock.started) return s.core.clock.now_ns; + if (s.peers.heldNow(s.core, s.mail_only)) |held| return held; } return s.test_clock orelse @intCast(std.Io.Clock.awake.now(s.io).nanoseconds); } diff --git a/test/panes.zig b/test/panes.zig index bd39beba..28a3b256 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -4047,6 +4047,90 @@ const PdfAddon = struct { } } + /// A session's loop with nobody typing: each wait runs out at its + /// deadline, and the clock read after it is the shells' (Peers.heldNow, + /// as gui.zig `guiNow` and tui.zig `clockNow` read it: a wait that took + /// nothing else, `only_mail`). + const Idle = struct { + now: u64 = std.time.ns_per_s, + waited: bool = false, + core: ?*Pardes = null, + peers: pardes.replica.Peers = .{ .gpa = std.testing.allocator, .io = std.testing.io }, + + const vtable: pardes.Host.VTable = .{ + .wait_input = wait, + .now = clock, + .watched = host_vtable.watched, + .job = host_vtable.job, + }; + + fn wait(ctx: ?*anyopaque, timeout_ms: u32) void { + const h: *Idle = @ptrCast(@alignCast(ctx.?)); + h.now += @as(u64, timeout_ms) * std.time.ns_per_ms; + h.waited = true; + } + + fn clock(ctx: ?*anyopaque) u64 { + const h: *Idle = @ptrCast(@alignCast(ctx.?)); + if (!h.waited) return h.now; + h.waited = false; + return h.peers.heldNow(h.core orelse return h.now, true) orelse h.now; + } + }; + + test "a PDF shown and a client's view its kind was not told: the session's next pump, its wait run out with nobody typing, tells it, and nothing is owed after; a client's post waiting holds the clock" { + // 2026-11-24: a window's session showing a PDF, a client attached, + // stepped ~700 times a second with nobody typing: the client's view + // owed to the kind (Kind.wake: now), a wait of a millisecond that + // ran out, and the clock after it held as if a client had posted + // (gui.zig guiNow: its wait's `mail_only` is cleared by an event, + // and one that ran out had none), so no step met the deadline. + if (!addons.has_pdf) return error.SkipZigTest; + const R = pardes.replica; + var idle: Idle = .{}; + defer idle.peers.deinit(); + const a = try R.Authority.init(std.testing.allocator, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, .{ .ctx = &idle, .vtable = &Idle.vtable }); + defer a.deinit(); + idle.core = a.core; + const Land = struct { + a: *R.Authority, + fn step(l: @This(), ev: pardes.Event) !void { + _ = try l.a.local(ev); + } + }; + const id = try opened(a, Land{ .a = a }); + const slot = a.core.panes[id].?.addon.?; + // A client attached (units go to it), its view sized by its input: + // a client's step tells no kind (17.2), so its view is owed. + idle.peers.recording = true; + const k = (try a.openView(2)).view; + const was = pardes.tape.on; + pardes.tape.on = &a.t; + const bytes = try pardes.dump.byteDump(a.core); + pardes.tape.resync(&a.t); + pardes.tape.on = was; + defer a.core.gpa.free(bytes); + const win = try R.Replica.initDump(std.testing.allocator, 2, k, bytes, .{ .cols = 80, .rows = 24 }); + defer win.deinit(); + _ = try a.take(try win.input(.{ .resize = .{ .cols = 80, .rows = 24 } })); + try std.testing.expect(pardes.Kind.viewOwed(a.core, slot, id)); + // ONE pump, nobody typing: its wait runs out at the wake, the step + // it asked for tells the view, and nothing is owed after. + a.pump(); + try std.testing.expect(!pardes.Kind.viewOwed(a.core, slot, id)); + try std.testing.expect((pardes.Kind.wake(a.core) orelse std.math.maxInt(u64)) > a.core.clock.now_ns); + // A client's post waiting (its input, its join): the pump before + // the boundary takes it reads the clock as it stands. + const at = a.core.clock.now_ns; + idle.now += std.time.ns_per_s; + idle.peers.mail.store(true, .release); + a.pump(); + try std.testing.expectEqual(at, a.core.clock.now_ns); + idle.peers.mail.store(false, .release); + a.pump(); + try std.testing.expectEqual(idle.now, a.core.clock.now_ns); + } + test "a PDF pane whose file changes on disk opens again from it at its page, its fit kept" { if (!addons.has_pdf) return error.SkipZigTest; const gpa = std.testing.allocator; -- cgit v1.3