summaryrefslogtreecommitdiff
path: root/core/views.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-19 16:41:27 -0300
committerGabriel Schneider <[email protected]>2026-11-19 18:42:47 -0300
commit78d94c4a62ec3f4039a475b637ff6a60649fde52 (patch)
tree92b7d29d43bd1f563291db3aa1ab4b90ba55824a /core/views.zig
parentd0e36bb453526af64349a4eb2335b86c94bea56d (diff)
downloadpardes-78d94c4a62ec3f4039a475b637ff6a60649fde52.tar.gz
pardes-78d94c4a62ec3f4039a475b637ff6a60649fde52.zip
core: the entries that take or answer a slot take and answer its type (P21, pardes-ids change 2): a pane's slot is `Pane.Id` in the twelve entries that took it, six as `usize` (setCwd, acknowledgeShell, setMessage, setStatus, reportError, noteLateFailure) and six as `u8` (readerFailed, shellFailed, restartFailed, saveFailed, reloadWatchedFile, File.deleted), and in what adoptShell answers (`?Pane.Id`); a view's slot is `View.Id` in closeView, leaveView, awayView, rejoinView and the hand-written toView (its `to_view` variant is `Pardes.View.Id` now, and its replay arm unchanged) and in what openView answers (`?View.Id`); the tape's other variants follow their inners' types with no edit (`Args`); each inner converts where its body indexes (`id.index()`), passes the id itself to another entry, and the core's own code stays integers; every caller converts at its own line, `p.reportError(.at(id), ..)` (the decl literal of the parameter's type), 514 calls in 56 files written by a script that refuses any path outside the workspace (`.scratch/sketch/reorg/pardes-ids/wrap.py`), 46 `.index()`; nothing the compiler caught was a pane's slot passed as a view's or the reverse: what it caught were a script's wrong guesses (Editor.reportError(err) and macos.zig's own reloadWatchedFile, same names, undone) and the integers a view's id met (views.zig's tests, replica.zig's Authority and Peers.join, host_io's Adoption); in files another agent is in, each conversion on the line that was there: core/Kind.zig 5 lines, core/Addon.zig 4, core/replica.zig 23 (Authority.openView and join, closeView/toView/awayView/rejoinView/leaveView calls, Peers.join's `openView`, tests), test/replicas.zig 1; the tape's records are smaller (a `usize` is a byte in six inputs) and its shape moves, so the semantics word moves, 313a99190b93a8c5 -> c47ecf638b3f4b9f; test/perf.zig untouched (its harness id does not move); the Mac: runtime/macos.zig 16 call lines, abi/pardes.h unchanged; 581 lines changed in 56 files, no line added. Gate (load 4 to 28: a drat build and other agents' gates beside): tui core-test 841/984 (143 skipped), shell-test 1020/1023, term-test 15/15, pane-test 183/184, kitty-test 45/45, behaviour-test 275/275 and --replay 20 seeds of 70 steps, 0 failures, process-test lspcomplete and lspcompletemoved (the base's), gui unit-test 1618/1622 (BaselineHarnessMismatch, the base's); replicas --clients 5 (TMPDIR /tmp/claude-1000/ids, alternated with the base twice, both pass both times): diverged 0, unequal 0 at rtt 30, 80, 207, deltas checked/wrong 1811/0, 1838/0, 1715/0, quiet checks 567/0, 650/0, 544/0, stops not on may_wait 0 (its corpus-through-a-client scene fails at step 21 as on the base with that TMPDIR); two earlier runs of this tree under a load of 10 to 28 ended in a leak of Places' compiled regex (Places.derive from Query.produce) and one rtt-207 run in an assertion in mouse.kindMouse's clamp during a client's speculation, the leak not seen in the eight runs of this tree after them (the full soak, each rtt alone, single seeds), the assertion not in the two full runs after it, and neither in three full runs of the base (by reading neither touches a slot: in the report); daemon.py plain, --far, --games, --window-clients, --upgrade both ways against pardes-tree's base prefix pass; test/cross_replay.py (tui records, gui replays): 27 digests agree in each of three replicas; rollback-bench runs; the macOS library for Linux and aarch64-macos and the FreeBSD cross-build build; frames (gpu/ids-2 against tree1) 77/77 byte-identical in Debug, unit-test 1618/1622 there too, perfab corpus2x -0.059% (session noise 0.134%, threshold 0.4%), pictures identical in all 10 runs, perfops 97 counts within 0.1% (largest image-frame on longline +0.0274%), key-down on medium 10,040,104 -> 10,039,959 an operation (-0.0014%), render on medium 11,455,764 -> 11,455,707 (-0.0005%)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/views.zig')
-rw-r--r--core/views.zig52
1 files changed, 26 insertions, 26 deletions
diff --git a/core/views.zig b/core/views.zig
index ee061964..a8bf8e60 100644
--- a/core/views.zig
+++ b/core/views.zig
@@ -579,25 +579,25 @@ test "each view has its own cursor and scroll, and an edit in one is in the othe
const text = try numbered(gpa, 200);
defer gpa.free(text);
const pane = try p.setTestFile(text);
- try testing.expectEqual(@as(?u8, 1), p.openView());
+ try testing.expectEqual(@as(?View.Id, .at(1)), p.openView());
cursorTo(p, pane, 119);
const scrolled = pane.file.?.scroll;
try testing.expect(scrolled > 0);
// The other view is where the session was when it came.
- p.toView(1);
+ p.toView(.at(1));
try testing.expectEqual(@as(i32, 0), pane.body.cur_row);
try testing.expectEqual(@as(usize, 0), pane.file.?.scroll);
typeKeys(p, "ix");
escape(p);
try testing.expectEqual(Text.Mode.normal, pane.body.mode);
- p.toView(0);
+ p.toView(.at(0));
try testing.expectEqual(@as(i32, 119), pane.body.cur_row);
try testing.expectEqual(scrolled, pane.file.?.scroll);
try testing.expect(std.mem.startsWith(u8, pane.file.?.content, "xline 1\n"));
// Its mode is its own: insert here leaves the other in normal.
typeKeys(p, "i");
try testing.expectEqual(Text.Mode.insert, pane.body.mode);
- p.toView(1);
+ p.toView(.at(1));
try testing.expectEqual(Text.Mode.normal, pane.body.mode);
}
@@ -614,7 +614,7 @@ test "each view has its own layout and focus over the same panes" {
const made = p.view().active;
try testing.expect(made != 0);
try testing.expectEqual(ncol + 1, p.view().ncol);
- p.toView(0);
+ p.toView(.at(0));
try testing.expectEqual(ncol, p.view().ncol);
try testing.expectEqual(@as(usize, 0), p.view().active);
try testing.expect(layout.findPane(p, made) == null);
@@ -663,15 +663,15 @@ test "a terminal shown at two sizes takes the size of the view that typed into i
p.update(.{ .key = .{ .cp = Key.right } });
try testing.expect(term.cols > small[0] and term.rows > small[1]);
const big = .{ term.cols, term.rows };
- p.toView(0);
+ p.toView(.at(0));
p.sync();
try testing.expectEqual(big, .{ term.cols, term.rows });
p.update(.{ .key = .{ .cp = Key.right } });
try testing.expectEqual(small, .{ term.cols, term.rows });
// That view gone, the one left sizes it.
p.toView(k);
- p.closeView(0);
- try testing.expectEqual(k, p.live);
+ p.closeView(.at(0));
+ try testing.expectEqual(k.index(), p.live);
try testing.expectEqual(big, .{ term.cols, term.rows });
}
@@ -691,18 +691,18 @@ test "a view closing leaves the others as they were" {
typeKeys(p, "xy");
p.toView(a);
cursorTo(p, pane, 70);
- p.toView(0);
+ p.toView(.at(0));
cursorTo(p, pane, 10);
const ncol = p.view().ncol;
// The live one closing: the session goes into another.
p.toView(b);
p.closeView(b);
- try testing.expect(p.live != b);
+ try testing.expect(p.live != b.index());
try testing.expectEqual(@as(usize, 2), count(p));
p.toView(a);
try testing.expectEqual(@as(i32, 70), pane.body.cur_row);
- p.closeView(0);
- try testing.expectEqual(a, p.live);
+ p.closeView(.at(0));
+ try testing.expectEqual(a.index(), p.live);
try testing.expectEqual(ncol, p.view().ncol);
// The last stays.
p.closeView(a);
@@ -749,7 +749,7 @@ test "a client's view kept for its rejoin: through an Upgrade's dump, each clien
defer p.deinit();
_ = try p.setTestFile("one\ntwo\n");
// Two clients, each a pane of its own in its own view.
- const ks: [2]u8 = .{ p.openView().?, p.openView().? };
+ const ks: [2]View.Id = .{ p.openView().?, p.openView().? };
var made: [2]usize = undefined;
for (ks, &made) |k, *m| {
p.toView(k);
@@ -767,7 +767,7 @@ test "a client's view kept for its rejoin: through an Upgrade's dump, each clien
const q = try pardes.dump.load(gpa, opts, bytes, null);
defer q.deinit();
for (ks, made, 0..) |k, m, i| {
- try testing.expect(isAway(q, k));
+ try testing.expect(isAway(q, k.index()));
try testing.expect(q.rejoinView(k));
q.toView(k);
try testing.expectEqual(m, q.view().active);
@@ -776,10 +776,10 @@ test "a client's view kept for its rejoin: through an Upgrade's dump, each clien
}
try testing.expect(!q.rejoinView(ks[0]));
// A client that never comes back: its view goes when a join has no room.
- p.toView(0);
- try testing.expectEqual(@as(?u8, 3), p.openView());
+ p.toView(.at(0));
+ try testing.expectEqual(@as(?View.Id, .at(3)), p.openView());
try testing.expectEqual(ks[0], p.openView());
- try testing.expect(!isAway(p, ks[0]) and isAway(p, ks[1]));
+ try testing.expect(!isAway(p, ks[0].index()) and isAway(p, ks[1].index()));
}
test "drawing another view leaves the live one as it was, to the digest" {
@@ -793,10 +793,10 @@ test "drawing another view leaves the live one as it was, to the digest" {
p.toView(k);
cursorTo(p, pane, 60);
typeKeys(p, "dd");
- p.toView(0);
+ p.toView(.at(0));
cursorTo(p, pane, 95);
const before = pardes.walk.digest(Pardes, p);
- _ = try drawOne(p, k, .{ .ctx = null, .f = null });
+ _ = try drawOne(p, k.index(), .{ .ctx = null, .f = null });
try testing.expectEqual(@as(u8, 0), p.live);
try testing.expectEqual(before, pardes.walk.digest(Pardes, p));
p.toView(k);
@@ -812,9 +812,9 @@ test "a view drawn while another is live keeps its own cursors" {
p.toView(k);
p.update(.{ .key = .{ .cp = 'C', .text = "C" } });
try testing.expectEqual(@as(u16, 1), pane.body.nsel);
- p.toView(0);
+ p.toView(.at(0));
const before = pardes.walk.digest(Pardes, p);
- _ = try drawOne(p, k, .{ .ctx = null, .f = null });
+ _ = try drawOne(p, k.index(), .{ .ctx = null, .f = null });
try testing.expectEqual(before, pardes.walk.digest(Pardes, p));
p.toView(k);
try testing.expectEqual(@as(u16, 1), pane.body.nsel);
@@ -831,7 +831,7 @@ test "a view not live keeps its place in a text another view edits" {
p.toView(k);
cursorTo(p, pane, 100);
const scrolled = pane.file.?.scroll;
- p.toView(0);
+ p.toView(.at(0));
// Three lines put above it, one taken below it.
typeKeys(p, "xyppp");
cursorTo(p, pane, 150);
@@ -862,7 +862,7 @@ test "a terminal shown in a view shorter than it keeps its cursor in sight" {
p.update(.{ .output = .{ .pane = @intCast(id), .bytes = out.items } });
// Sized for the tall view, it fits there whole: nothing is passed over.
try testing.expectEqual(@as(u16, 0), term.pan);
- p.toView(0);
+ p.toView(.at(0));
p.sync();
try testing.expectEqual(rows, term.rows);
try testing.expect(term.pan > 0);
@@ -897,7 +897,7 @@ test "a session's dump keeps its views: loaded, each where it was; revived for o
cursorTo(p, pane, 119);
p.toView(k);
p.update(.{ .command = "Newcol" });
- p.toView(0);
+ p.toView(.at(0));
p.toView(k);
cursorTo(p, pane, 30);
const ncol = p.view().ncol;
@@ -910,7 +910,7 @@ test "a session's dump keeps its views: loaded, each where it was; revived for o
defer gpa.free(again);
try testing.expectEqualSlices(u8, bytes, again);
const lp = loaded.panes[id].?;
- loaded.toView(0);
+ loaded.toView(.at(0));
try testing.expectEqual(@as(i32, 119), lp.body.cur_row);
try testing.expectEqual(ncol - 1, loaded.view().ncol);
loaded.toView(k);
@@ -923,7 +923,7 @@ test "a session's dump keeps its views: loaded, each where it was; revived for o
try testing.expectEqual(@as(u8, 0), one.live);
try testing.expectEqual(ncol, one.view().ncol);
try testing.expectEqual(@as(i32, 30), one.panes[id].?.body.cur_row);
- try testing.expectEqual(@as(?u8, 1), one.openView());
+ try testing.expectEqual(@as(?View.Id, .at(1)), one.openView());
}
test "a pane's id and a view's id are two types: neither is taken for the other, nor for an integer" {