From 9991a90aae7f4591e63e5ecb0ab2467a348ed54e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 13:18:42 -0300 Subject: kinds #22, a kind's frame as its tick left it: a step that ticks a kind paints it once for the live view (Kind.repaint) before its tag is laid out, where the tag took what the frame before the tick placed and the next input's step another (a replica's guess of that input, the last step's tag, missed: 13 of the 30 ms cell's 14 visible rollbacks), so a pane of a kind's tag has its art words from its first step (the fake and pdf addon scripts' windows a row shorter), and an input's step sends each client what it made of a kind's pane after its unit, not at the next pump (a terminal client looked at the frame from before its own key's tick, the text layer missing from its view) Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/panes.zig | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'test') diff --git a/test/panes.zig b/test/panes.zig index 15eca652..d16de109 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -3917,6 +3917,75 @@ const PdfAddon = struct { try std.testing.expect(r.stats.stopped >= 1); } + test "the tag a step lays out for a PDF's pane is of the frame its tick left, not the frame before it" { + 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 land: Land = .{ .a = a }; + const id = try opened(a, land); + const slot = a.core.panes[id].?.addon.?; + // A view without graphics: the page's text layer, no picture. + try std.testing.expect(std.mem.indexOf(u8, slot.told.slice(), "petscii") == null); + // A window's: its tick lays the pages out as pictures and asks + // for them; the step their answers land in ticks it again, and its + // tag says what that tick placed, as the next step's will (a + // replica's guess of its next input is the tag this step laid out). + try land.step(.{ .frontend = .{ .windowed = true, .native_images = true } }); + try jobs(a.core, land); + try std.testing.expect(slot.placed); + try std.testing.expect(std.mem.indexOf(u8, slot.told.slice(), "petscii") != null); + } + + test "a PDF's pane in a window's view and a terminal's in turn: each one's step lays its tag out as its frame shows it" { + 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(); + // A terminal's client on the session's view, a window's on its own. + const tty = try R.Replica.init(gpa, 1, try a.unit(0, 0), false); + defer tty.deinit(); + const Land = struct { + a: *R.Authority, + fn step(l: @This(), ev: pardes.Event) !void { + _ = try l.a.local(ev); + } + }; + const land: Land = .{ .a = a }; + const id = try opened(a, land); + const slot = a.core.panes[id].?.addon.?; + 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(gpa, 2, k, bytes, .{ .cols = 80, .rows = 24 }); + defer win.deinit(); + _ = try a.take(try win.input(.{ .frontend = .{ .windowed = true, .native_images = true } })); + try jobs(a.core, land); + try std.testing.expect(std.mem.indexOf(u8, slot.told.slice(), "petscii") != null); + for (0..2) |_| { + // The terminal's key: its view's tick, the page's text layer. + _ = try a.take(try tty.input(.{ .key = .{ .cp = 'j', .text = "j" } })); + try jobs(a.core, land); + try std.testing.expect(std.mem.indexOf(u8, slot.told.slice(), "petscii") == null); + // The window's: the pages as pictures again, in its tag at once. + _ = try a.take(try win.input(.{ .key = .{ .cp = 'j', .text = "j" } })); + try std.testing.expect(std.mem.indexOf(u8, slot.told.slice(), "petscii") != null); + try jobs(a.core, land); + } + } + 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