summaryrefslogtreecommitdiff
path: root/core/Core.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-24 05:28:45 -0300
committerGabriel Schneider <[email protected]>2026-11-24 05:49:28 -0300
commit4e28df7f8e02ceec66a9d62ca75f8ec006e26d7c (patch)
treeeeee707f41a480fdcf038179ff1a527105b620c1 /core/Core.zig
parentda985ae98180c2394ccdf48cf8bdf5bd85873c2f (diff)
downloadpardes-4e28df7f8e02ceec66a9d62ca75f8ec006e26d7c.tar.gz
pardes-4e28df7f8e02ceec66a9d62ca75f8ec006e26d7c.zip
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 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/Core.zig')
-rw-r--r--core/Core.zig23
1 files changed, 19 insertions, 4 deletions
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,