summaryrefslogtreecommitdiff
path: root/core/ninep/ctl.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-19 18:35:16 -0300
committerGabriel Schneider <[email protected]>2026-11-19 20:24:14 -0300
commitbf351b62e8843a3d173cedeefa2dd0b8ef4b4392 (patch)
treeed415f31749669a36d5df304af4101f56e9fdd23 /core/ninep/ctl.zig
parent78d94c4a62ec3f4039a475b637ff6a60649fde52 (diff)
downloadpardes-bf351b62e8843a3d173cedeefa2dd0b8ef4b4392.tar.gz
pardes-bf351b62e8843a3d173cedeefa2dd0b8ef4b4392.zip
core, dev: what carries a slot across the core's edge carries its type (P21, pardes-ids change 3): `Pane.Id` in Event's six variants that carry a pane (output, eof, exited, file_changed, addon, job), in the fourteen effects that do (spawn, write, resize_pty, signal_pty, close_pty, start, save_file, save_text, lsp, watch, dump_themes, detach, addon, job), in the fourteen Host functions that take one (dev/Host.zig: adopt, upgrade, spawn, pty_write, pty_resize, pty_signal, close_pty, tty_taken, fg_name, kill_job, write_file, watch_file, dump_themes, job; tape.zig's Wrap follows with no edit), in the device messages that carry one into the core (the inbox's output and eof and the five reader functions that make them, dev/Lsp.zig's Request, host_io's Adoption and Adoptions.take, which hold what adoptShell answered); `View.Id` in abi/wire.zig's welcome.view (its bytes on the wire unchanged: one byte, hand-encoded, `.at(takeByte())`/`writeByte(view.index())`); every producer converts at its own line (`.pane = .at(id)`, a script that refuses any path outside the workspace, `fields.py`), every consumer where it indexes or compares (`o.pane.index()`), every Host implementer at its own first line (`fn spawn(ctx, id: pardes.Pane.Id, ..) { const pane = id.index(); ..}`: the terminal's 14, the window's 14, the Mac's 10, and the tests' hosts), and an id that went integer and back is passed through whole (`s.core.readerFailed(e.pane, err)`); the compiler caught no pane's slot passed as a view's or the reverse, only integers meeting the type; kept integers on purpose: KindJob.pane (core/Kind.zig, another agent's, reads it four times; converted at KindJob's and Effect's lines), the Watch table (file_watch: its last slot is the theme's, no pane), the hello's view and the replica's Peer/Joined/Replica views (core/replica.zig, another agent's), the C ABI's `pardes_watch_changed(uint8_t pane)` (abi/pardes.h unchanged; runtime/macos.zig converts at its Host functions); in files another agent is in, each conversion on the line that was there: core/Kind.zig 2 lines, core/Addon.zig 4, core/replica.zig 31 (the welcome's view, 3 test hosts, test literals), test/replicas.zig 12 (4 host functions with their first lines, 1 signature, the welcome's view, 5 literals); the tape's shape moves (Event is update's input), so the semantics word moves, c47ecf638b3f4b9f -> 38b5ae573b965550; test/perf.zig follows on 6 lines its Event and effect literals forced, so its harness id moves, be7cc504010471bc -> 1ed95030eb768eae (unit-test's perf check was BaselineHarnessMismatch already); 607 lines added, 562 deleted in 48 files. Gate (load 4 to 8): 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; hscroll failed once and passed on the runner's retry), gui unit-test 1618/1622 (BaselineHarnessMismatch, the base's); replicas --clients 5 (TMPDIR /tmp/claude-1000/ids): diverged 0, unequal 0 at rtt 30, 80, 207, deltas checked/wrong 1811/0, 1838/0, 1660/0, quiet checks 567/0, 650/0, 655/0, stops not on may_wait 0 (corpus through a client fails at step 21 as on the base with that TMPDIR); daemon.py plain, --far, --games, --window-clients, --upgrade both ways against pardes-tree's base prefix pass (the semantics words differ: the upgrade carries the session by its dump); 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-3 against tree1) 77/77 byte-identical in Debug, unit-test 1618/1622 there, perfab corpus2x -0.021% (session noise 0.036%, threshold 0.4%), pictures identical in all 10 runs, perfops 97 counts within 0.1% (largest image-frame on longline +0.0231%), key-down on medium 10,040,108 -> 10,039,990 an operation (-0.0012%), render on medium 11,455,765 -> 11,455,683 (-0.0007%), terminal on all +0.0030%
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/ninep/ctl.zig')
-rw-r--r--core/ninep/ctl.zig28
1 files changed, 14 insertions, 14 deletions
diff --git a/core/ninep/ctl.zig b/core/ninep/ctl.zig
index cf68fa76..302b916a 100644
--- a/core/ninep/ctl.zig
+++ b/core/ninep/ctl.zig
@@ -1282,7 +1282,7 @@ pub fn getFile(p: *Pardes, pane: *Pane, path: []const u8) GetError!void {
f.disk_newer_warned = false;
f.disk_gone = false;
f.on_disk = fs.localPath(path) != null;
- if (f.on_disk) p.emit(.{ .watch = .{ .pane = @intCast(id), .on = true } });
+ if (f.on_disk) p.emit(.{ .watch = .{ .pane = .at(id), .on = true } });
}
/// What Get and Edit's `e` fail with, as their callers say it (the 9P
@@ -1500,7 +1500,7 @@ test "a body write to a terminal is typed input, not a paste, even to a program
const term = for (p.panes, 0..) |slot, id| {
if (slot) |pane| if (pane.isTerminal()) break id;
} else return error.SkipZigTest;
- p.update(.{ .output = .{ .pane = @intCast(term), .bytes = "\x1b[?2004h" } });
+ p.update(.{ .output = .{ .pane = .at(term), .bytes = "\x1b[?2004h" } });
while (p.nextEffect()) |_| {}
const w = wr(p, Node.of(p.panes[term].?.serial, .body), "ls\n");
try testing.expectEqual(Status.ok, w.reply.status);
@@ -1513,7 +1513,7 @@ test "Save path of a file pane logs a save record naming that path" {
const serial = serialOf(p);
const saved = wr(p, Node.of(serial, .ctl), "Save /tmp/pardes-save-copy.txt\n");
try testing.expectEqual(Status.ok, saved.reply.status);
- p.perform(.{ .save_text = .{ .pane = 0, .serial = serial, .path = Pardes.SavePath.from("/tmp/pardes-save-copy.txt") } });
+ p.perform(.{ .save_text = .{ .pane = .at(0), .serial = serial, .path = Pardes.SavePath.from("/tmp/pardes-save-copy.txt") } });
var want: [64]u8 = undefined;
try testing.expect(th.logHas(p, try std.fmt.bufPrint(&want, "save {d} /tmp/pardes-save-copy.txt\n", .{serial})));
}
@@ -1590,7 +1590,7 @@ test "exec Save writes the named file through the host" {
const saved = wr(p, Node.of(serial, .exec), "Save\n");
try testing.expectEqual(Status.ok, saved.reply.status);
try testing.expect(saved.saved);
- p.perform(.{ .save_file = .{ .pane = 0 } });
+ p.perform(.{ .save_file = .{ .pane = .at(0) } });
try testing.expect(!pane_files.dirtyOf(pane));
try testing.expectEqualStrings(pane.file.?.content, p.fallback.get("/tmp/renamed.txt").?);
}
@@ -1990,7 +1990,7 @@ test "a terminal told the directory it already goes by logs no rename" {
const session = p.sessionDir();
p.setCwd(.at(term), session);
try testing.expect(!th.logHas(p, try std.fmt.bufPrint(&rec, "rename {d} ", .{p.panes[term].?.serial})));
- p.update(.{ .output = .{ .pane = @intCast(term), .bytes = "$ " } });
+ p.update(.{ .output = .{ .pane = .at(term), .bytes = "$ " } });
// Somewhere else is a rename.
p.setCwd(.at(term), "/usr");
try testing.expect(th.logHas(p, try std.fmt.bufPrint(&rec, "rename {d} /usr", .{p.panes[term].?.serial})));
@@ -2001,13 +2001,13 @@ test "a terminal with text typed at its prompt is never typed into: a look at it
defer p.deinit();
const term = p.paneBySerial(serialOf(p)).?;
p.setCwd(.at(term), "/tmp");
- p.update(.{ .output = .{ .pane = @intCast(term), .bytes = "\x1b]133;A;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07TYPED" } });
+ p.update(.{ .output = .{ .pane = .at(term), .bytes = "\x1b]133;A;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07TYPED" } });
while (p.nextEffect()) |_| {}
var count: usize = 0;
for (p.panes) |slot| count += @intFromBool(slot != null);
try testing.expectEqual(Status.ok, wr(p, @backingInt(tree.TopFile.look), "/tmp\n").reply.status);
var typed_into = false;
- while (p.nextEffect()) |effect| if (effect == .write and effect.write.pane == term) {
+ while (p.nextEffect()) |effect| if (effect == .write and effect.write.pane.index() == term) {
typed_into = true;
};
try testing.expect(!typed_into);
@@ -2016,7 +2016,7 @@ test "a terminal with text typed at its prompt is never typed into: a look at it
try testing.expectEqual(count + 1, after);
// An exec at it runs in a pane of its own, not typed after TYPED.
_ = wr(p, Node.of(serialOf(p), .exec), "echo hi\n");
- while (p.nextEffect()) |effect| if (effect == .write and effect.write.pane == term) {
+ while (p.nextEffect()) |effect| if (effect == .write and effect.write.pane.index() == term) {
typed_into = true;
};
try testing.expect(!typed_into);
@@ -2260,8 +2260,8 @@ test "a focus moved over 9P tells the programs that asked for focus reports, as
};
try testing.expectEqual(@as(usize, 2), n);
p.view().active = shells[0];
- p.update(.{ .output = .{ .pane = @intCast(shells[0]), .bytes = "\x1b[?1004h" } });
- p.update(.{ .output = .{ .pane = @intCast(shells[1]), .bytes = "\x1b[?1004h" } });
+ p.update(.{ .output = .{ .pane = .at(shells[0]), .bytes = "\x1b[?1004h" } });
+ p.update(.{ .output = .{ .pane = .at(shells[1]), .bytes = "\x1b[?1004h" } });
while (p.nextEffect()) |_| {}
var digits: [16]u8 = undefined;
const moved = wr(p, @backingInt(tree.TopFile.focus), try std.fmt.bufPrint(&digits, "{d}\n", .{p.panes[shells[1]].?.serial}));
@@ -2344,7 +2344,7 @@ test "a new file saved shows in /recent, open, while it is" {
const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)];
// A host that writes files, as the real ones do.
const Writing = struct {
- fn write(_: ?*anyopaque, _: u8, path: []const u8, bytes: []const u8) void {
+ fn write(_: ?*anyopaque, _: pardes.Pane.Id, path: []const u8, bytes: []const u8) void {
std.Io.Dir.cwd().writeFile(testing.io, .{ .sub_path = path, .data = bytes }) catch {};
}
};
@@ -2357,7 +2357,7 @@ test "a new file saved shows in /recent, open, while it is" {
_ = wr(p, Node.of(made, .name), try std.fmt.bufPrint(&name, "{s}\n", .{path}));
_ = wr(p, Node.of(made, .body), "fresh\n");
try testing.expectEqual(Status.ok, wr(p, Node.of(made, .ctl), "Save\n").reply.status);
- p.perform(.{ .save_file = .{ .pane = @intCast(p.paneBySerial(made).?) } });
+ p.perform(.{ .save_file = .{ .pane = .at(p.paneBySerial(made).?) } });
var want: [4300]u8 = undefined;
try testing.expect(std.mem.indexOf(u8, rd(p, @backingInt(tree.TopFile.recent), 0, 8192).bytes, try std.fmt.bufPrint(&want, "open {s}\n", .{path})) != null);
}
@@ -2575,7 +2575,7 @@ test "a word written to a raw terminal's look is listed as in normal mode" {
defer p.deinit();
const serial = serialOf(p);
const id = p.paneBySerial(serial).?;
- p.update(.{ .output = .{ .pane = @intCast(id), .bytes = "one MARK two\r\n" } });
+ p.update(.{ .output = .{ .pane = .at(id), .bytes = "one MARK two\r\n" } });
p.panes[id].?.body.mode = .tty;
try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .look), "MARK\n").reply.status);
const said = std.mem.trimEnd(u8, rd(p, Node.of(serial, .look), 0, 64).bytes, "\n");
@@ -2588,7 +2588,7 @@ test "@p<terminal>:<address> takes any address over the terminal's lines, select
defer p.deinit();
const serial = serialOf(p);
const id = p.paneBySerial(serial).?;
- p.update(.{ .output = .{ .pane = @intCast(id), .bytes = "one\r\ntwo MARK three\r\n" } });
+ p.update(.{ .output = .{ .pane = .at(id), .bytes = "one\r\ntwo MARK three\r\n" } });
const pane = p.panes[id].?;
const root = @backingInt(tree.TopFile.look);
var line: [64]u8 = undefined;