From 76b493ef40a02931eb86805aa30040a594b72ec8 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 18:54:04 -0300 Subject: kinds #41, the soak's stale tty screen (7a's two blank rows of a PDF's text layer, seed 2): a kind's frame whose row count changed sent the rows it kept at their place as hashes the peer held, while the peer's Shadow of the new size started from blank cells, so those rows stayed blank until they moved; a row is held now only at the same size, and a test sizes a frame up and down and finds its first row each time Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/screen_state.zig | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/screen_state.zig') diff --git a/src/screen_state.zig b/src/screen_state.zig index 7be7d0d2..6b12f9eb 100644 --- a/src/screen_state.zig +++ b/src/screen_state.zig @@ -1522,7 +1522,8 @@ pub fn encodeShadow(gpa: std.mem.Allocator, sent: *ShadowSent, f: *const Kind.Fr try w.writeByte(pointer); for (hashes.items, 0..) |h, y| { try w.writeInt(u64, h, .little); - const held = sent.cols == f.cols and y < sent.hashes.items.len and sent.hashes.items[y] == h; + // Held only at the same size: a peer's Shadow of another starts afresh. + const held = sent.cols == f.cols and sent.hashes.items.len == f.rows and sent.hashes.items[y] == h; try w.writeByte(@intFromBool(!held)); if (!held) for (f.cells[y * f.cols ..][0..f.cols]) |*c| { try w.writeAll(&c.text); @@ -1556,6 +1557,28 @@ pub fn encodeShadow(gpa: std.mem.Allocator, sent: *ShadowSent, f: *const Kind.Fr return true; } +test "a pane of a kind's frame a row taller or shorter is drawn whole at its peer, never a row it let go" { + const gpa = std.testing.allocator; + var cells: [2 * 3]Cell = @splat(std.mem.zeroes(Cell)); + cells[0] = .{ .text = "a".* ++ @as([7]u8, @splat(0)), .fg = 1, .bg = 2, .attrs = 0, .len = 1, .flags = Kind.c.PA_PAINTED }; + var f: Kind.Frame = .{ .cells = &cells, .cols = 2, .rows = 2 }; + var sent: ShadowSent = .{}; + defer sent.deinit(gpa); + var blobs: Blobs = .{}; + const sh = try gpa.create(Shadow); + sh.* = .{}; + defer sh.deinit(gpa); + var out: std.Io.Writer.Allocating = .init(gpa); + defer out.deinit(); + for ([_]u16{ 2, 3, 2 }) |rows| { + f.rows = rows; + out.clearRetainingCapacity(); + try std.testing.expect(try encodeShadow(gpa, &sent, &f, 0, &out.writer)); + _ = try sh.apply(gpa, out.written(), 1, &blobs); + try std.testing.expectEqualStrings("a", sh.cells[0].text[0..1]); + } +} + test "a pane of a kind crosses as its frame, a row the peer holds as its hash, a raster by key after its strips over what it shows" { const gpa = std.testing.allocator; var cells: [3 * 2]Cell = @splat(std.mem.zeroes(Cell)); -- cgit v1.3