From d1d5d3cfb18841604bba2057eeb3598f729b4475 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 02:56:53 -0300 Subject: 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 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/replica.zig | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/replica.zig') diff --git a/src/replica.zig b/src/replica.zig index 6de125bd..40353d89 100644 --- a/src/replica.zig +++ b/src/replica.zig @@ -437,7 +437,7 @@ pub const Screens = struct { pp.shadow.deinit(x.s.gpa); pp.shadow.serial = pane.serial; } - const r = p.rects[id]; + const r = p.view().rects[id]; const cols = r.w -| pardes.config.GUTTER; const rows = (r.h -| pane.tag_rows) -| pane.notices.span(); if (cols == 0 or rows == 0) continue; @@ -990,7 +990,7 @@ pub const Replica = struct { // and applied again over each delta while it waits (`screen`), so // what the authority's unit confirms read the emulator its step // read (the deltas come before it). - const keyboard = if (c.panes[c.active]) |pane| pane.terminal != null else false; + const keyboard = if (c.panes[c.view().active]) |pane| pane.terminal != null else false; c.update(in.event); c.step(); p.terminal = r.t.screen_state and (keyboard or r.t.touched); @@ -3087,7 +3087,7 @@ test "a delta applied under a speculation outlives its rollback: the terminal st } else return error.NoShell; // Typing goes to the text pane under the shell (the host's write of // `active`, taped). - a.core.active = for (a.core.panes, 0..) |slot, id| { + a.core.view().active = for (a.core.panes, 0..) |slot, id| { if (slot) |pane| if (pane.file != null) break id; } else return error.NoTextPane; r.confirm(try a.local(.{ .focus = true })); @@ -3170,7 +3170,7 @@ test "a closed terminal brought back on a screen-state replica: its emulator on const shell: u8 = for (a.core.panes, 0..) |slot, id| { if (slot) |pane| if (pane.isTerminal()) break @intCast(id); } else return error.NoShell; - a.core.active = shell; + a.core.view().active = shell; r.confirm(try a.local(.{ .command = "Del" })); try std.testing.expectEqual(@as(usize, 1), a.core.store.closed.items.len); var line: [32]u8 = undefined; @@ -3195,7 +3195,7 @@ test "a view that sized a terminal closing leaves nothing queued: the others' re defer r1.deinit(); const r2 = try Replica.init(gpa, 2, first, true); defer r2.deinit(); - a.core.active = for (a.core.panes, 0..) |slot, id| { + a.core.view().active = for (a.core.panes, 0..) |slot, id| { if (slot) |pane| if (pane.isTerminal()) break id; } else return error.NoShell; const opened = try a.openView(2); @@ -3243,7 +3243,7 @@ test "a terminal sized again by a client's key: the step reads the grid it had, const shell: u8 = for (a.core.panes, 0..) |slot, id| { if (slot) |pane| if (pane.isTerminal()) break @intCast(id); } else return error.NoShell; - a.core.active = shell; + a.core.view().active = shell; // History the replica holds as holes, of lines a narrow grid wraps in // two, which a wider one unwraps. var line: [96]u8 = undefined; @@ -3345,7 +3345,7 @@ test "pardes's own keys over a terminal's history apply at once: its view moves const shell: u8 = for (a.core.panes, 0..) |slot, id| { if (slot) |pane| if (pane.isTerminal()) break @intCast(id); } else return error.NoShell; - a.core.active = shell; + a.core.view().active = shell; r.confirm(try a.local(.{ .focus = true })); var line: [64]u8 = undefined; for (0..200) |i| a.output(.{ .output = .{ .pane = shell, .bytes = try std.fmt.bufPrint(&line, "history line {d}\r\n", .{i}) } }); @@ -3801,7 +3801,7 @@ test "a replica joined after a pane closed: the session's jump to it, its Panes _ = try a.local(.{ .command = try std.fmt.bufPrint(&line, "Look {s}/build.zig.zon", .{dir}) }); _ = try a.local(.{ .command = "Del" }); try std.testing.expectEqual(@as(usize, 1), a.core.store.closed.items.len); - try std.testing.expect(a.core.jumps.n > 1); + try std.testing.expect(a.core.view().jumps.n > 1); // What another window of the user's wrote to the store, which the // session read (src/variants_test.zig's case, the variant hunt's). a.core.recent.opened(a.core.recentGpa(), try std.fmt.bufPrint(&line, "{s}/build.zig", .{dir})); @@ -3928,7 +3928,7 @@ test "a client that diverged joins again for its view: kept for it meanwhile, it old.confirm(opened.unit); var buf: [256]u8 = undefined; old.confirm(try a.take(try inputOf(&buf, 2, 1, .{ .command = "New" }))); - const made = a.core.active; + const made = a.core.view().active; // Its bye says it joins again: its view is kept, as every replica keeps it. var was = Stepping.begin(&a.t, null); a.core.awayView(opened.view); @@ -3948,7 +3948,7 @@ test "a client that diverged joins again for its view: kept for it meanwhile, it defer gpa.free(u); old.confirm(u); back.confirm(u); - try std.testing.expectEqual(made, a.core.active); + try std.testing.expectEqual(made, a.core.view().active); try std.testing.expect(pardes.layout.findPane(a.core, made) != null); try agrees(a, old); try agrees(a, back); @@ -4055,7 +4055,7 @@ test "a step that reads a terminal's rows as the core keeps them sends a new cli const shell: u8 = for (a.core.panes, 0..) |slot, id| { if (slot) |pane| if (pane.isTerminal()) break @intCast(id); } else return error.NoShell; - a.core.active = shell; + a.core.view().active = shell; var line: [64]u8 = undefined; for (0..60) |i| a.output(.{ .output = .{ .pane = shell, .bytes = try std.fmt.bufPrint(&line, "line {d} of the shell's history\r\n", .{i}) } }); const out = try gpa.dupe(u8, (try a.pending()).?); -- cgit v1.3