summaryrefslogtreecommitdiff
path: root/core/Messages.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/Messages.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/Messages.zig')
-rw-r--r--core/Messages.zig60
1 files changed, 30 insertions, 30 deletions
diff --git a/core/Messages.zig b/core/Messages.zig
index 767eb297..1fb232c7 100644
--- a/core/Messages.zig
+++ b/core/Messages.zig
@@ -127,14 +127,14 @@ pub const Message = struct {
/// A status updates the message line in place (a progress count does not
/// pile up); a message is an event, and stacks.
pub const setStatus = pardes.tape.taped(setStatusInner);
-fn setStatusInner(p: *Pardes, id: usize, text: []const u8) void {
- showMessage(p, id, text, false);
+fn setStatusInner(p: *Pardes, id: Pane.Id, text: []const u8) void {
+ showMessage(p, id.index(), text, false);
}
pub const setMessage = pardes.tape.taped(setMessageInner);
-fn setMessageInner(p: *Pardes, id: usize, text: []const u8) void {
- logMessage(p, id, text);
- showMessage(p, id, text, true);
+fn setMessageInner(p: *Pardes, id: Pane.Id, text: []const u8) void {
+ logMessage(p, id.index(), text);
+ showMessage(p, id.index(), text, true);
}
fn showMessage(p: *Pardes, id: usize, text: []const u8, stack: bool) void {
@@ -346,7 +346,7 @@ pub fn dialReason(err: anyerror) ?[]const u8 {
}
pub const reportError = pardes.tape.taped(reportErrorInner);
-fn reportErrorInner(p: *Pardes, id: usize, operation: []const u8, err: anyerror) void {
+fn reportErrorInner(p: *Pardes, id: Pane.Id, operation: []const u8, err: anyerror) void {
// Room for an operation naming the longest path and the reason after
// it: a shorter one cut the reason off (`Save /long…`), and the reason
// is what a failure is for. Where it must be shorter, the path gives.
@@ -356,7 +356,7 @@ fn reportErrorInner(p: *Pardes, id: usize, operation: []const u8, err: anyerror)
// A peer out of reach says so, not the error's name (`dial`).
if (dialReason(err)) |why| {
w.print("dial failed: {s}", .{why}) catch {};
- return reportFailure(p, id, w.buffered());
+ return reportFailure(p, id.index(), w.buffered());
}
// Every route that opens a pane says the cap the same way.
if (err == error.NoPaneSlots or err == error.NoPaneRoom) {
@@ -368,11 +368,11 @@ fn reportErrorInner(p: *Pardes, id: usize, operation: []const u8, err: anyerror)
p.fs.no_pane_slot = true;
@memcpy(p.fs.ename[0..w.buffered().len], w.buffered());
p.fs.no_pane_slot_len = @intCast(w.buffered().len);
- return reportFailure(p, id, w.buffered());
+ return reportFailure(p, id.index(), w.buffered());
}
var words: [128]u8 = undefined;
w.writeAll(errorWords(err, &words)) catch {};
- reportFailure(p, id, w.buffered());
+ reportFailure(p, id.index(), w.buffered());
}
/// An error in a person's words, never its Zig name: the few that read
@@ -444,9 +444,9 @@ pub fn reportFailure(p: *Pardes, id: usize, text: []const u8) void {
if (failing_write) {
p.fs.unlogged = true;
defer p.fs.unlogged = false;
- return setMessage(p, id, text);
+ return setMessage(p, .at(id), text);
}
- setMessage(p, id, text);
+ setMessage(p, .at(id), text);
}
/// The one place that decides which transient lines a pane is showing and
@@ -536,9 +536,9 @@ test "the message log keeps what the row forgets, and collapses repeats" {
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 30 });
defer p.deinit();
- setMessage(p, 0, "14:32:07 saved /x.zig");
- setMessage(p, 0, "14:32:09 saved /x.zig"); // same event, later clock
- setMessage(p, 0, "save: AccessDenied");
+ setMessage(p, .at(0), "14:32:07 saved /x.zig");
+ setMessage(p, .at(0), "14:32:09 saved /x.zig"); // same event, later clock
+ setMessage(p, .at(0), "save: AccessDenied");
try std.testing.expectEqual(@as(usize, 2), p.messages.len);
const first = p.messages.at(0).?;
@@ -553,19 +553,19 @@ test "the message log keeps what the row forgets, and collapses repeats" {
// failure must not be recorded as another's.
p.newScratchBelow(0);
const other = p.view().active;
- setMessage(p, other, "save: AccessDenied");
+ setMessage(p, .at(other), "save: AccessDenied");
try std.testing.expectEqual(@as(usize, 3), p.messages.len);
try std.testing.expectEqual(p.panes[other].?.serial, p.messages.at(2).?.serial);
// Progress is NOT logged: it arrives several times a second for a whole
// index and would push everything else out (`setStatus`).
- setStatus(p, 0, "14:32:10 lsp rust-analyzer: Indexing 47%");
+ setStatus(p, .at(0), "14:32:10 lsp rust-analyzer: Indexing 47%");
try std.testing.expectEqual(@as(usize, 3), p.messages.len);
// The ring wraps rather than grows, and still reads oldest-first.
for (0..limits.message_log + 5) |i| {
var buf: [32]u8 = undefined;
- setMessage(p, 0, std.fmt.bufPrint(&buf, "line {d}", .{i}) catch unreachable);
+ setMessage(p, .at(0), std.fmt.bufPrint(&buf, "line {d}", .{i}) catch unreachable);
}
try std.testing.expectEqual(@as(usize, limits.message_log), p.messages.len);
try std.testing.expectEqualStrings("line 5", p.messages.at(0).?.slice());
@@ -621,8 +621,8 @@ test "with no frontend attached a message goes once it has lingered, on the cloc
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
defer p.deinit();
const pane = p.panes[p.view().active].?;
- p.setMessage(p.view().active, "said");
- p.setMessage(p.view().active, "said again");
+ p.setMessage(.at(p.view().active), "said");
+ p.setMessage(.at(p.view().active), "said again");
// Attached: it waits for input, however long.
pane.msg_said_ms -= 60_000;
p.update(.tick);
@@ -638,7 +638,7 @@ test "with no frontend attached a message goes once it has lingered, on the cloc
try std.testing.expectEqual(@as(u16, 0), pane.msg_len);
try std.testing.expectEqual(@as(u8, 0), pane.msg_older_len);
// A fresh one stays until its linger is up.
- p.setMessage(p.view().active, "fresh");
+ p.setMessage(.at(p.view().active), "fresh");
p.update(.tick);
try std.testing.expect(pane.msg_len > 0);
}
@@ -679,7 +679,7 @@ test "a message lingers past the input that dismisses it, and goes" {
try std.testing.expectEqual(Pane.MessagePhase.lingering, pane.msg_life.phase);
try std.testing.expect(p.executeBuiltinLine(p.view().active, "Msg again"));
try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase);
- setStatus(p, p.view().active, "progress 50%");
+ setStatus(p, .at(p.view().active), "progress 50%");
try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase);
try std.testing.expectEqualStrings("progress 50%", pane.msg[0..pane.msg_len]);
try std.testing.expectEqual(@as(u8, 0), pane.msg_older_len);
@@ -695,10 +695,10 @@ test "messages stack, oldest on top, each on its own timing" {
// `Verbose off` announced itself before it took effect.
pane.msg_len = 0;
pane.msg_life = .{};
- setMessage(p, p.view().active, "first");
+ setMessage(p, .at(p.view().active), "first");
try std.testing.expectEqual(Pane.MessagePhase.shown, pane.msg_life.phase);
// A second message stacks under the first instead of replacing it.
- setMessage(p, p.view().active, "second");
+ setMessage(p, .at(p.view().active), "second");
try std.testing.expectEqual(@as(u8, 1), pane.msg_older_len);
try std.testing.expectEqualStrings("first", pane.msg_older[0].slice());
try std.testing.expectEqualStrings("second", pane.msg[0..pane.msg_len]);
@@ -711,7 +711,7 @@ test "messages stack, oldest on top, each on its own timing" {
try std.testing.expectEqual(Pane.MessagePhase.lingering, pane.msg_older[0].life.phase);
try std.testing.expectEqual(Pane.MessagePhase.lingering, pane.msg_life.phase);
p.update(.tick);
- setMessage(p, p.view().active, "third");
+ setMessage(p, .at(p.view().active), "third");
try std.testing.expectEqual(@as(u8, 2), pane.msg_older_len);
p.update(.{ .key = .{ .cp = 'h' } });
const linger = messageFrames(p.settings.message_linger_ms);
@@ -724,24 +724,24 @@ test "messages stack, oldest on top, each on its own timing" {
try std.testing.expectEqual(@as(u16, 0), pane.msg_len);
try std.testing.expect(!p.animationActive());
// A status ticking in place does not pile up.
- setStatus(p, p.view().active, "lsp 10%");
- setStatus(p, p.view().active, "lsp 20%");
+ setStatus(p, .at(p.view().active), "lsp 10%");
+ setStatus(p, .at(p.view().active), "lsp 20%");
try std.testing.expectEqual(@as(u8, 0), pane.msg_older_len);
// Lines keep their rows: when the top one leaves, the one under it does
// not move up, and the next message fills the gap instead.
- setMessage(p, p.view().active, "top");
- setMessage(p, p.view().active, "under");
+ setMessage(p, .at(p.view().active), "top");
+ setMessage(p, .at(p.view().active), "under");
try std.testing.expectEqual(@as(u8, 0), pane.msg_older[0].slot);
try std.testing.expectEqual(@as(u8, 1), pane.msg_slot);
pane.removeOlderMessage(0);
collectNotices(p, pane, p.view().rects[p.view().active], p.view().active);
try std.testing.expectEqual(@as(u8, 1), pane.notices.row[0]);
try std.testing.expectEqual(@as(u8, 2), pane.notices.span());
- setMessage(p, p.view().active, "fills");
+ setMessage(p, .at(p.view().active), "fills");
try std.testing.expectEqual(@as(u8, 0), pane.msg_slot);
try std.testing.expectEqual(@as(u8, 1), pane.msg_older[0].slot);
// The stack keeps the newest few.
- for ([_][]const u8{ "a", "b", "c", "d", "e" }) |text| setMessage(p, p.view().active, text);
+ for ([_][]const u8{ "a", "b", "c", "d", "e" }) |text| setMessage(p, .at(p.view().active), text);
try std.testing.expectEqual(@as(u8, Pane.message_stack), pane.msg_older_len);
try std.testing.expectEqualStrings("b", pane.msg_older[0].slice());
try std.testing.expectEqualStrings("e", pane.msg[0..pane.msg_len]);