summaryrefslogtreecommitdiff
path: root/core/panes.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/panes.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/panes.zig')
-rw-r--r--core/panes.zig30
1 files changed, 15 insertions, 15 deletions
diff --git a/core/panes.zig b/core/panes.zig
index dd36839a..7ea479b9 100644
--- a/core/panes.zig
+++ b/core/panes.zig
@@ -716,7 +716,7 @@ pub const Pane = struct {
// A replica's emulator is what the authority's deltas make it; what
// pardes keeps over it moves as the authority's feed told it.
if (tape.screenReplica()) {
- if (has_positions and pane.followRows(state, bytes)) if (paneIdOf(p, pane)) |id| p.setMessage(id, positions_lost);
+ if (has_positions and pane.followRows(state, bytes)) if (paneIdOf(p, pane)) |id| p.setMessage(.at(id), positions_lost);
return;
}
// Sticky bottom, as every other terminal does it: output drags the
@@ -728,7 +728,7 @@ pub const Pane = struct {
Term.cellPixels(state, p.view().cell_pixels.w, p.view().cell_pixels.h);
if (!has_positions) {
_ = Term.feed(state, bytes, &.{}, &.{}, &.{});
- } else if (pane.followRows(state, bytes)) if (paneIdOf(p, pane)) |id| p.setMessage(id, positions_lost);
+ } else if (pane.followRows(state, bytes)) if (paneIdOf(p, pane)) |id| p.setMessage(.at(id), positions_lost);
p.shell_rows.markStale(pane);
if (pane.body.mode == .tty and at_bottom) pane.followOutput();
}
@@ -1078,7 +1078,7 @@ pub const Pane = struct {
// failure is worth the pane.
if (pane.command_pages) {
pane.command_pages = false;
- if (status == 0) return p.removePane(id, null) catch |err| p.reportError(id, "close", err);
+ if (status == 0) return p.removePane(id, null) catch |err| p.reportError(.at(id), "close", err);
}
var buf: [16]u8 = undefined;
const code = if (status) |n| std.fmt.bufPrint(&buf, "{d}", .{n}) catch unreachable else "?"; // an exit status fits 16
@@ -1350,8 +1350,8 @@ pub fn newScratchBelow(p: *Pardes, from_id: usize) void {
/// A scratch for New (`.scratch`) or 9P's pane/new (`.fs`).
pub fn newScratchFor(p: *Pardes, from_id: usize, kind: layout.NewPane) void {
- const free = p.freeSlot() orelse return p.reportError(from_id, "New", error.NoPaneSlots);
- _ = newScratch(p, from_id, free, kind) catch |err| return p.reportError(from_id, "New", err);
+ const free = p.freeSlot() orelse return p.reportError(.at(from_id), "New", error.NoPaneSlots);
+ _ = newScratch(p, from_id, free, kind) catch |err| return p.reportError(.at(from_id), "New", err);
layout.placeNew(p, from_id, from_id, free, kind);
}
@@ -1529,7 +1529,7 @@ pub fn startPrompt(p: *Pardes, pane: *Pane, t: *Text, request: union(enum) {
// directory for the name to be typed onto.
const dir = if (request == .save) paneDir(pane) else "";
const slash: []const u8 = if (request == .save and (dir.len == 0 or dir[dir.len - 1] != '/')) "/" else "";
- const answer = std.mem.concat(p.gpa, u8, &.{ marker, dir, slash }) catch |err| return p.reportError(p.view().active, "prompt", err);
+ const answer = std.mem.concat(p.gpa, u8, &.{ marker, dir, slash }) catch |err| return p.reportError(.at(p.view().active), "prompt", err);
// The keyboard comes back to the text answered for; a prompt for
// the body takes it out of a tag or header.
switch (t.what) {
@@ -1584,7 +1584,7 @@ test "owned cwd preserves long paths aliases and failed updates" {
var path: [3072]u8 = @splat('d');
path[0] = '/';
for (1..12) |i| path[i * 256] = '/';
- p.setCwd(0, &path);
+ p.setCwd(.at(0), &path);
try std.testing.expectEqualStrings(&path, pane.cwdSlice());
try std.testing.expect(pane.cwdSlice().ptr != &path);
const original = pane.cwdSlice();
@@ -1609,15 +1609,15 @@ test "owned cwd preserves long paths aliases and failed updates" {
const current = pane.cwdSlice();
allocator.fail_index = allocator.alloc_index;
- p.setCwd(0, "/replacement");
+ p.setCwd(.at(0), "/replacement");
try std.testing.expectEqual(current.ptr, pane.cwdSlice().ptr);
try std.testing.expectEqualStrings(&path, pane.cwdSlice());
try std.testing.expect(std.mem.indexOf(u8, pane.msg[0..pane.msg_len], "out of memory") != null);
allocator.fail_index = std.math.maxInt(usize);
- p.setCwd(0, "/replacement");
+ p.setCwd(.at(0), "/replacement");
try std.testing.expectEqualStrings("/replacement", pane.cwdSlice());
const allocations = allocator.allocations;
- p.setCwd(0, "/replacement");
+ p.setCwd(.at(0), "/replacement");
try std.testing.expectEqual(allocations, allocator.allocations);
pane.clearCwd();
try std.testing.expect(pane.cwd == .none);
@@ -1678,8 +1678,8 @@ test "owned cwd column close allocates every copy before removing any pane" {
var allocator = std.testing.FailingAllocator.init(std.testing.allocator, .{});
const p = try Pardes.init(allocator.allocator(), .{ .shells = 3, .cols = 100, .rows = 30 });
defer p.deinit();
- p.setCwd(0, "/first");
- p.setCwd(1, "/second");
+ p.setCwd(.at(0), "/first");
+ p.setCwd(.at(1), "/second");
const first_child = try p.newDocPane(3);
const second_child = try p.newDocPane(4);
first_child.cwd = .{ .inherited = p.panes[0].? };
@@ -1706,7 +1706,7 @@ test "owned cwd EOF failure retains the pane and Del retries its close" {
var allocator = std.testing.FailingAllocator.init(std.testing.allocator, .{});
const p = try Pardes.init(allocator.allocator(), .{ .tty_only = true });
defer p.deinit();
- p.setCwd(0, "/exited");
+ p.setCwd(.at(0), "/exited");
const parent = p.panes[0].?;
p.newScratchBelow(0);
const child = p.panes[p.view().active].?;
@@ -1800,7 +1800,7 @@ test "New opens an empty scratch below the caller, inheriting its directory" {
while (p.nextEffect()) |_| {}
const source: usize = 2; // the right column; active starts in the left
- p.setCwd(source, "/tmp/pardes-scratch-dir");
+ p.setCwd(.at(source), "/tmp/pardes-scratch-dir");
const source_col = layout.findPane(p, source).?.col;
try std.testing.expect(p.executeBuiltinLine(source, "New"));
@@ -1814,7 +1814,7 @@ test "New opens an empty scratch below the caller, inheriting its directory" {
try std.testing.expectEqual(@as(usize, 0), np.file.?.content.len);
// its directory is a LIVE link to the opener, not a snapshot taken at New
try std.testing.expectEqualStrings("/tmp/pardes-scratch-dir", Pardes.paneDir(np));
- p.setCwd(source, "/tmp/pardes-moved");
+ p.setCwd(.at(source), "/tmp/pardes-moved");
try std.testing.expectEqualStrings("/tmp/pardes-moved", Pardes.paneDir(np));
try p.removePane(source, null);
p.sync();