summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 04:59:03 -0300
committerGabriel Schneider <[email protected]>2026-11-10 05:34:09 -0300
commitf30dfdb3d5546195a69f8046ded9acc669882b8d (patch)
treeb8f4ff5648683aeda6d8b820d68ca4b326933289 /src
parent60d4db7046f5cfe130eedbc9dabad680373e3e94 (diff)
downloadpardes-f30dfdb3d5546195a69f8046ded9acc669882b8d.tar.gz
pardes-f30dfdb3d5546195a69f8046ded9acc669882b8d.zip
kind: a view's facts (Kind.viewOf) count its bands as Messages.bands makes them from what a dump keeps (the pane's messages and prompt, the view's leader, rect and tag rows), never the derived copy a step or a park left in Pane.notices or Pane.pv, which a client joined from a dump has not: its kind was told other rows than the session's and the join diverged (`digest N differs in panes pane M.addon`); collectNotices makes the live view's from the same function
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src')
-rw-r--r--src/Kind.zig5
-rw-r--r--src/Messages.zig25
-rw-r--r--src/replica.zig23
3 files changed, 41 insertions, 12 deletions
diff --git a/src/Kind.zig b/src/Kind.zig
index d3feed96..6d4caec6 100644
--- a/src/Kind.zig
+++ b/src/Kind.zig
@@ -702,8 +702,11 @@ pub fn viewOf(p: *const Pardes, k: u8, id: usize) c.pa_view {
const pane = p.panes[id] orelse return out;
const r = v.rects[id];
// The live view's share of the pane is in its own fields, another's parked.
- const collapsed, const tag_rows, const notices = if (k == p.live) .{ pane.collapsed, pane.tag_rows, pane.notices.span() } else .{ pane.pv[k].collapsed, pane.pv[k].tag_rows, pane.pv[k].notices.span() };
+ const collapsed, const tag_rows = if (k == p.live) .{ pane.collapsed, pane.tag_rows } else .{ pane.pv[k].collapsed, pane.pv[k].tag_rows };
if (collapsed) return out;
+ // Its bands made again, never the copy a step or a park left: they are
+ // derived, so a client joined from a dump has none.
+ const notices = pardes.Messages.bands(p, v, pane, tag_rows, r, id).span();
const th = p.theme();
const rgb = struct {
fn f(x: [3]u8) u32 {
diff --git a/src/Messages.zig b/src/Messages.zig
index f5767857..f400df54 100644
--- a/src/Messages.zig
+++ b/src/Messages.zig
@@ -454,7 +454,7 @@ pub fn reportFailure(p: *Pardes, id: usize, text: []const u8) void {
/// so it does not paint under them, and the paint pass so it can stack
/// them instead of letting the last one win the row.
pub fn collectNotices(p: *Pardes, pane: *Pane, r: Rect, id: usize) void {
- collectBands(p, pane, r, id);
+ pane.notices = bands(p, p.view(), pane, pane.tag_rows, r, id);
// Each band's chip at the right edge, as wide as its own text and a
// blank cell either side, the pane's width at most: a click finds it
// whether or not a frame has drawn it. An overlay over the body's top
@@ -470,26 +470,28 @@ pub fn collectNotices(p: *Pardes, pane: *Pane, r: Rect, id: usize) void {
}
}
-fn collectBands(p: *Pardes, pane: *Pane, r: Rect, id: usize) void {
- pane.notices.len = 0;
- if (r.w <= config.GUTTER or r.h <= pane.tag_rows) return;
+/// The bands pane `id` shows in view `v`, over `r` below its `tag_rows`:
+/// the live view's each step, and any view's for its kind's facts
+/// (Kind.viewOf), made from what a dump keeps (the bands are derived).
+pub fn bands(p: *const Pardes, v: *const Pardes.View, pane: *const Pane, tag_rows: u16, r: Rect, id: usize) Pane.Notices {
+ var n: Pane.Notices = .{};
+ if (r.w <= config.GUTTER or r.h <= tag_rows) return n;
// Oldest message line on top, so lines already up do not move when a
// new one lands under them; when rows run out the oldest go first.
- for (pane.msg_older[0..pane.msg_older_len], 0..) |line, i| pane.notices.pushAt(.older, @intCast(i), line.slot);
- if (pane.msg_len > 0) pane.notices.pushAt(.message, 0, pane.msg_slot);
- if (id == p.view().active and p.view().prefix == .leader) pane.notices.push(.leader);
+ for (pane.msg_older[0..pane.msg_older_len], 0..) |line, i| n.pushAt(.older, @intCast(i), line.slot);
+ if (pane.msg_len > 0) n.pushAt(.message, 0, pane.msg_slot);
+ if (id == v.active and v.prefix == .leader) n.push(.leader);
// Del's question shows once its delay is up: answered before that, it
// was never there.
const del_waiting = pane.prompt == .del_side and pane.question_due_ns > p.clock.now_ns;
- if (pane.promptText()) |text| if (text.len > 0 and !del_waiting) pane.notices.push(.prompt);
+ if (pane.promptText()) |text| if (text.len > 0 and !del_waiting) n.push(.prompt);
// A pane only has so many rows to give. When they do not all fit the
// LAST ones survive, because the prompt is last and it is the one
// carrying the cursor: a prompt you cannot see is a prompt you type
// into blind. A two-row pane spends its only body row on one notice,
// which is what the single shared row used to do anyway.
- const room: u8 = @intCast(@min(@as(u16, Pane.Notices.max), r.h - pane.tag_rows));
- const n = &pane.notices;
- if (n.span() <= room) return;
+ const room: u8 = @intCast(@min(@as(u16, Pane.Notices.max), r.h - tag_rows));
+ if (n.span() <= room) return n;
// Too short for the gaps: close them up in screen order, and if even
// that does not fit, the top bands go.
var i: usize = 1;
@@ -508,6 +510,7 @@ fn collectBands(p: *Pardes, pane: *Pane, r: Rect, id: usize) void {
n.row[k] = @intCast(k);
}
n.len -= @intCast(drop);
+ return n;
}
test "errors are said in words, and a ZON failure names its line" {
diff --git a/src/replica.zig b/src/replica.zig
index 0b22f8b2..dd6f34bc 100644
--- a/src/replica.zig
+++ b/src/replica.zig
@@ -4383,3 +4383,26 @@ test "a replica's word that opens a kind's pane with no file waits for the autho
try agrees(a, r);
try std.testing.expect(r.core().panes[r.core().view().active].?.addon != null);
}
+
+test "a client joined from a dump tells a kind each view's facts as the session does, the live one's and another's" {
+ const gpa = std.testing.allocator;
+ const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host(), false);
+ defer a.deinit();
+ var words: [64]pardes.Kind.LoadedWord = undefined;
+ const placed = pardes.Kind.loadedOf(&Placed.ops, "/x/placed.so", @splat(7), &words);
+ _ = try a.local(.{ .addon = .{ .op = .load, .pane = 0, .kind = &placed } });
+ _ = try a.local(.{ .command = "Placed" });
+ // A message in its pane: a band over its body, in each view.
+ _ = try a.local(.{ .command = "Placed x" });
+ // The second client's view laid out by an input of its own, then the
+ // first's resized: its kind told at the session's next step of its own.
+ _ = try a.openView(2);
+ var buf: [256]u8 = undefined;
+ _ = try a.take(try inputOf(&buf, 2, 1, .{ .resize = .{ .cols = 80, .rows = 24 } }));
+ _ = try a.take(try inputOf(&buf, 1, 1, .{ .resize = .{ .cols = 80, .rows = 20 } }));
+ const joiner = try joinedNow(a, 3, 1);
+ defer joiner.deinit();
+ try std.testing.expectEqual(digestOf(a), joiner.digest());
+ joiner.confirm(try a.local(.tick));
+ try agrees(a, joiner);
+}