summaryrefslogtreecommitdiff
path: root/src/tape.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 02:56:53 -0300
committerGabriel Schneider <[email protected]>2026-11-06 04:13:33 -0300
commitd1d5d3cfb18841604bba2057eeb3598f729b4475 (patch)
tree298c29ab8767852bf74eb86ad4d15acc4348f109 /src/tape.zig
parent33037ece5af9ae1c7048819bbbae3fc5e6fc4ade (diff)
downloadpardes-d1d5d3cfb18841604bba2057eeb3598f729b4475.tar.gz
pardes-d1d5d3cfb18841604bba2057eeb3598f729b4475.zip
client #1, the views indexed: a view's share of the session is Pardes.View (the ~42 fields views.fields named: size, cell metrics, columns, rects, focus, jumps, pointer, gestures, prefixes, frontend), one of Pardes.views[4] (null when closed), the live one views[live] through Pardes.view() (index field `view` renamed `live`); going into another view is the index plus the panes' shares, which stay swapped (park and unpark now move only Pane.pv); views.zig loses fields, Part over Pardes, Parked, kept, emptied and the session half of every copy, and a pane closing leaves every view's layout at once (views.gone, at the two places a slot is freed) instead of the serials each parked view kept; drawOne and within put the drawn view's own share back whole; the views are in the digest now (tape's per-field parts name views[k].field), so a fresh view's col_x/col_w default to zeros, not undefined; the dump keeps every open view in the core and the panes' shares of the others under `shares`; an image from before (live view as the core's own fields, the rest under `views`) loads them into views[] once; the ~2,400 references rewritten mechanically from the compiler's errors (p.active is p.view().active, `const v = p.view()` hoisted in 823 places), Kind.zig (4 lines) and addon_test.zig (3) among them, macos.zig by pattern (not compiled here); tape's watched host writes read the live view's frontend and active; perf.zig's accessor lines change its harness hash, the debug baselines re-keyed to it (their numbers the base's); no golden changes; gates: core-test 956/956 both, unit-test 1487/1488 tui and 1530/1531 gui, behaviour-test 248/248 both, pane-test 171/172, snap all 105 ok, process-test 0 of 37 failed tui, replicas ok
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/tape.zig')
-rw-r--r--src/tape.zig36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/tape.zig b/src/tape.zig
index 3752af54..d3e5558a 100644
--- a/src/tape.zig
+++ b/src/tape.zig
@@ -169,13 +169,22 @@ pub const shape = blk: {
var types: []const type = &.{ Input, []const u64, struct { u8, u64 } };
for (results) |R| types = types ++ .{R};
for (host_fns) |f| types = types ++ .{@typeInfo(@typeInfo(@typeInfo(@FieldType(VTable, f)).optional.child).pointer.child).@"fn".return_type.?};
- for (watched) |name| types = types ++ .{@FieldType(Pardes, name)};
+ for (watched) |name| types = types ++ .{Watched(name)};
break :blk walk.shape(types);
};
/// Fields a host writes straight into the core between its calls.
const watched = .{ "frontend", "present_skipped", "needs_frame", "quit", "active", "unattended" };
+/// Watched field `name` of `p`: the live view's, or the session's.
+fn watchedOf(p: *Pardes, comptime name: []const u8) *Watched(name) {
+ return if (comptime @hasField(Pardes.View, name)) &@field(p.view(), name) else &@field(p, name);
+}
+
+fn Watched(comptime name: []const u8) type {
+ return if (@hasField(Pardes.View, name)) @FieldType(Pardes.View, name) else @FieldType(Pardes, name);
+}
+
const Kind = enum(u8) { input, done, host, ret, set, digest };
/// A digest record's kind byte (replica.zig reads a unit's last).
pub const digest_kind: u8 = @backingInt(Kind.digest);
@@ -292,10 +301,10 @@ pub const Tape = struct {
fn noteWrites(t: *Tape) void {
const p = t.core orelse return;
inline for (watched, 0..) |name, i| {
- const now = walk.digest(@FieldType(Pardes, name), &@field(p, name));
+ const now = walk.digest(Watched(name), watchedOf(p, name));
if (now != t.seen[i]) {
t.seen[i] = now;
- const set: struct { u8, @FieldType(Pardes, name) } = .{ i, @field(p, name) };
+ const set: struct { u8, Watched(name) } = .{ i, watchedOf(p, name).* };
t.record(.set, @TypeOf(set), &set);
}
}
@@ -303,7 +312,7 @@ pub const Tape = struct {
fn seeFields(t: *Tape) void {
const p = t.core orelse return;
- inline for (watched, 0..) |name, i| t.seen[i] = walk.digest(@FieldType(Pardes, name), &@field(p, name));
+ inline for (watched, 0..) |name, i| t.seen[i] = walk.digest(Watched(name), watchedOf(p, name));
}
/// The host's functions go through the tape while it records, whoever
@@ -534,7 +543,7 @@ pub const Tape = struct {
}
const p = t.core orelse return;
inline for (watched, 0..) |name, i| if (i == which) {
- @field(p, name) = walk.decode(@FieldType(Pardes, name), r, t.arena.allocator()) catch return;
+ watchedOf(p, name).* = walk.decode(Watched(name), r, t.arena.allocator()) catch return;
};
}
@@ -645,13 +654,20 @@ const stream_fields = walk.fieldNames(pardes.Stream);
const pane_fields = walk.fieldNames(pardes.Pane);
const file_fields = walk.fieldNames(pardes.panes.File.State);
const places_fields = walk.fieldNames(pardes.panes.Places);
-const Parts = [pardes_fields.len + stream_fields.len + pardes.MAX_PANES * (2 + pane_fields.len + file_fields.len + places_fields.len)]u64;
+const view_fields = walk.fieldNames(Pardes.View);
+const Parts = [pardes_fields.len + stream_fields.len + pardes.views.max * view_fields.len + pardes.MAX_PANES * (2 + pane_fields.len + file_fields.len + places_fields.len)]u64;
/// The session's digest as one per field of the core's, its stream's, and
/// each pane's and its file's, so a divergence says where it is.
fn digestParts(p: *const Pardes, parts: *Parts) []const u64 {
var n = walk.fieldDigests(Pardes, p, parts[0..pardes_fields.len]).len;
n += walk.fieldDigests(pardes.Stream, &p.stream, parts[n..][0..stream_fields.len]).len;
+ for (&p.views) |*slot| if (slot.*) |*v| {
+ n += walk.fieldDigests(Pardes.View, v, parts[n..][0..view_fields.len]).len;
+ } else {
+ @memset(parts[n..][0..view_fields.len], 0);
+ n += view_fields.len;
+ };
for (p.panes, 0..) |slot, id| {
const pane = slot orelse continue;
parts[n] = id;
@@ -677,6 +693,14 @@ fn partsDiffer(got: []const u64, want: []const u64, a: std.mem.Allocator) []cons
said.print(a, "{s}{s} ", .{ if (i < pardes_fields.len) "" else "stream.", name }) catch {};
count += 1;
}
+ for (0..pardes.views.max) |k| for (view_fields) |name| {
+ if (i >= n) break;
+ if (got[i] != want[i]) {
+ said.print(a, "views[{d}].{s} ", .{ k, name }) catch {};
+ count += 1;
+ }
+ i += 1;
+ };
while (i + 2 <= n and count < 16) {
const id = got[i];
const has_file = got[i + 1] != 0;