From e0ed81fc02b7fcf9f20f9be1c0080bd1339d80fb Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 12:19:03 -0300 Subject: kinds #21, a PDF across replicas: a pane of a kind's frame crosses within the wire's bound (encodeShadow takes a budget and leaves out a raster past it, where a 17 MB page in a 110-column window ended every client's link and every join's after), a join's dump keeps a kind's tag words and selection (SlotRecord tail and selection, which only Kind.reopen made: a joiner's tag wrapped another way and it diverged on tag_rows at each join), and a speculation whose step would tick a kind waits for the session's unit (Kind.step's rule, read only) where it guessed no tick and rolled back, every visible rollback of the 30 ms soak cell Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/panes.zig | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) (limited to 'test/panes.zig') diff --git a/test/panes.zig b/test/panes.zig index 7592742c..15eca652 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -3835,6 +3835,88 @@ const PdfAddon = struct { try std.testing.expect(r.diverged == null); } + /// A session with design.pdf open in a pane of the addon, its pages + /// rendered; `land` takes each of its units. + fn opened(a: *pardes.replica.Authority, land: anytype) !usize { + var words: [64]pardes.Kind.LoadedWord = undefined; + var why: pardes.Kind.Buf(160) = .{}; + const lib = pardes.Addon.readLoaded(pdf_lib, &words, &why); + try land.step(.{ .addon = .{ .op = .load, .pane = 0, .kind = &lib } }); + var buf: [4096]u8 = undefined; + const real = try std.Io.Dir.cwd().realPathFile(std.testing.io, "docs/design.pdf", &buf); + var line: [4200]u8 = undefined; + try land.step(.{ .command = try std.fmt.bufPrint(&line, "Look {s}", .{buf[0..real]}) }); + for (0..3) |_| { + try land.step(.tick); + try jobs(a.core, land); + } + return for (a.core.panes, 0..) |slot, i| { + if (slot) |pane| if (pane.addon != null) break i; + } else error.NoPdfPane; + } + + test "a client that joins a session with a PDF open has its pane's tag words and selection as the session has them" { + if (!addons.has_pdf) return error.SkipZigTest; + const R = pardes.replica; + const gpa = std.testing.allocator; + const a = try R.Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, .{ .vtable = &host_vtable }, false); + defer a.deinit(); + 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.?; + slot.gpa.free(slot.selection); + slot.selection = try slot.gpa.dupe(u8, "a word it selected"); + // The dump a join is sent (Peers.join's), as the session makes it. + 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 r = try R.Replica.initDump(gpa, 2, 0, bytes, .{ .cols = 80, .rows = 24 }); + defer r.deinit(); + try std.testing.expect(r.loaded(pardes.tape.digestOf(a.core))); + var arena: std.heap.ArenaAllocator = .init(gpa); + defer arena.deinit(); + const theirs = r.core().panes[id].?; + try std.testing.expectEqualStrings(try pardes.tagline.tagText(a.core, arena.allocator(), a.core.panes[id].?), try pardes.tagline.tagText(r.core(), arena.allocator(), theirs)); + try std.testing.expectEqualStrings("a word it selected", theirs.addon.?.selection); + r.confirm(try a.local(.{ .key = .{ .cp = 'j', .text = "j" } })); + if (r.diverged) |w| std.debug.print("diverged: {s}\n", .{w}); + try std.testing.expect(r.diverged == null); + } + + test "a client's input whose session step ticks a PDF's pane waits for that step, never guessed and rolled back" { + if (!addons.has_pdf) return error.SkipZigTest; + const R = pardes.replica; + const gpa = std.testing.allocator; + const a = try R.Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, .{ .vtable = &host_vtable }, false); + defer a.deinit(); + const r = try R.Replica.init(gpa, 1, try a.unit(0, 0), false); + defer r.deinit(); + const Land = struct { + a: *R.Authority, + r: *R.Replica, + fn step(l: @This(), ev: pardes.Event) !void { + l.r.confirm(try l.a.local(ev)); + } + }; + _ = try opened(a, Land{ .a = a, .r = r }); + const guessed = r.stats.mispredicted; + // Its window resized: the pane's view moves, and the session's + // step ticks its kind, which only the session runs. + r.confirm(try a.take(try r.input(.{ .resize = .{ .cols = 100, .rows = 30 } }))); + r.settle(); + try std.testing.expect(r.diverged == null); + try std.testing.expectEqual(guessed, r.stats.mispredicted); + try std.testing.expect(r.stats.stopped >= 1); + } + 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