summaryrefslogtreecommitdiff
path: root/src/ninep
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 11:36:01 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commit05118f216d524c96ffe936e494b8ecce26303de1 (patch)
treee67fe916801ef58d32cd04988240571cae8f8a49 /src/ninep
parent35f06a55bad1891e3d5e779630b232b2c322bc83 (diff)
downloadpardes-05118f216d524c96ffe936e494b8ecce26303de1.tar.gz
pardes-05118f216d524c96ffe936e494b8ecce26303de1.zip
A builtin's Verbose announcement is the message row's alone, never logged
With Verbose on by default, /log filled with msg - DumpDir, msg 4 Grep and the like, with machinery to take an announcement back out when its builtin failed or said something itself. A msg record is now only something said; the take-back machinery goes with it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep')
-rw-r--r--src/ninep/cols.zig11
-rw-r--r--src/ninep/events.zig66
2 files changed, 7 insertions, 70 deletions
diff --git a/src/ninep/cols.zig b/src/ninep/cols.zig
index aae6d364..6b59f9e5 100644
--- a/src/ninep/cols.zig
+++ b/src/ninep/cols.zig
@@ -401,19 +401,18 @@ test "tagexec runs a word as a click in the workspace tag; exec files read back
try testing.expectEqual(tree.Status.ok, th.look_up(p, tree.root, "tagexec").reply.status);
try testing.expectEqual(tree.Status.ok, th.wr(p, tagexec, "Newcol\n").reply.status);
try testing.expectEqual(@as(usize, 2), p.ncol);
- // What it says is the session's (Newcol announcing itself); a pane's
- // word such as Msg is refused there.
- try testing.expect(th.logHas(p, "msg - Newcol\n"));
+ // Its announcement is the message row's, never logged; a pane's word
+ // such as Msg is refused there.
+ try testing.expect(!th.logHas(p, "msg - Newcol\n"));
try testing.expectEqual(E.INVAL, th.wr(p, tagexec, "Msg from the top\n").errno());
- // A column's exec makes a pane there, reads it back, and its Msg is
- // the session's too.
+ // A column's exec makes a pane there and reads it back.
const right = layout.columnSerial(p, 1);
try testing.expectEqual(tree.Status.ok, th.wr(p, Node.ofCol(right, .exec), "New\n").reply.status);
const made = p.panes[p.col_panes[1][0]].?.serial;
var want: [16]u8 = undefined;
try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d}\n", .{made}), th.rd(p, Node.ofCol(right, .exec), 0, 64).bytes);
try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d}\n", .{made}), th.rd(p, tagexec, 0, 64).bytes);
- try testing.expect(th.logHas(p, "msg - New\n"));
+ try testing.expect(!th.logHas(p, "msg - New\n")); // announced on the message row only
}
test "a word run from the workspace's or a column's tag runs in the session's directory, a pane's in its own" {
diff --git a/src/ninep/events.zig b/src/ninep/events.zig
index 690efbe5..95b4926e 100644
--- a/src/ninep/events.zig
+++ b/src/ninep/events.zig
@@ -161,10 +161,6 @@ pub fn noteMessage(p: *Pardes, serial: u32, said: []const u8) void {
var buf: [pardes.Messages.LoggedMessage.cap + 32]u8 = undefined;
const kept = pardes.Messages.clip(said, pardes.Messages.LoggedMessage.cap);
const cut = if (kept.len < said.len) "…" else "";
- // A builtin's own word for what it did stands in for its Verbose
- // announcement just before (`Undo` then `Undo: nothing to undo`), so
- // that 1000 Undos with nothing left are one line, counted, as err's are.
- dropAnnouncement(p, serial, kept);
pushCounting(p, (if (serial == 0)
std.fmt.bufPrint(&buf, "msg - {s}{s}\n", .{ kept, cut })
else
@@ -230,61 +226,6 @@ pub fn noteError(p: *Pardes, req: Req, reply: Reply) void {
pushCounting(p, record);
}
-/// Drops the newest record when it is the Verbose announcement (`msg
-/// <serial> <Word>`) of the builtin whose words `text` are (`Word: ...`):
-/// what the builtin said, or the err its failure logs, takes its place.
-/// Not one a follower has read.
-pub fn dropAnnouncement(p: *Pardes, serial: u32, text: []const u8) void {
- const last = newest(p) orelse return;
- if (followerRead(p, last.seq) or !std.mem.startsWith(u8, last.text, "msg ")) return;
- const rest = last.text["msg ".len..];
- const sp = std.mem.indexOfScalar(u8, rest, ' ') orelse rest.len;
- const word = rest[@min(sp + 1, rest.len)..];
- var who: [16]u8 = undefined;
- const mine = if (serial == 0) "-" else std.fmt.bufPrint(&who, "{d}", .{serial}) catch "";
- if (std.mem.eql(u8, rest[0..sp], mine) and word.len > 0 and std.mem.indexOfScalar(u8, word, ' ') == null and
- text.len > word.len and std.mem.startsWith(u8, text, word) and text[word.len] == ':')
- p.fs.log.buf.shrinkRetainingCapacity(last.at);
-}
-
-/// The sequence number of the newest log record when it is a msg that
-/// ends in `word` alone: not one counted (`(x2)`) over an earlier say.
-pub fn newestSaying(p: *Pardes, word: []const u8) ?u64 {
- const last = newest(p) orelse return null;
- if (!std.mem.startsWith(u8, last.text, "msg ") or !std.mem.endsWith(u8, last.text, word)) return null;
- if (last.text[last.text.len - word.len - 1] != ' ') return null;
- return last.seq;
-}
-
-/// Takes record `seq` back out of the log, unless a follower has read it.
-pub fn dropRecord(p: *Pardes, seq: u64) void {
- if (followerRead(p, seq)) return;
- const q = &p.fs.log;
- var at = q.head;
- var s = q.dropped;
- while (at + 4 <= q.buf.items.len) : (s += 1) {
- const size = 4 + std.mem.readInt(u32, q.buf.items[at..][0..4], .little);
- if (s == seq) {
- const items = q.buf.items;
- std.mem.copyForwards(u8, items[at..], items[at + size ..]);
- q.buf.shrinkRetainingCapacity(items.len - size);
- return;
- }
- at += size;
- }
-}
-
-/// A builtin's failure: its Verbose announcement goes from the log, when
-/// `text` is that builtin's (it starts with its word) or `any`, as for a
-/// failure said while the builtin itself runs.
-pub fn dropFailedAnnouncement(p: *Pardes, text: []const u8, any: bool) void {
- const seq = p.fs.announced_seq orelse return;
- const word = p.fs.announced_word[0..p.fs.announced_word_len];
- if (!any and !(std.mem.startsWith(u8, text, word) and text.len > word.len and (text[word.len] == ' ' or text[word.len] == ':'))) return;
- p.fs.announced_seq = null;
- dropRecord(p, seq);
-}
-
/// Drops the newest record when it is a msg saying `text` (of any pane)
/// that no follower has read: a failure its write's err record will say.
pub fn dropMessage(p: *Pardes, text: []const u8) void {
@@ -1100,13 +1041,10 @@ test "the log records whether or not anyone reads, and an open that follows wait
try std.fmt.bufPrint(&expected, "msg {d} save: two lines\n", .{serial}),
rdf.next(p, log, fh, frozen).bytes,
);
- // A builtin announces itself on the message row, so the log says which ran.
+ // A builtin announces itself on the message row only: the log has
+ // what it did.
try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .exec), "Del\n").reply.status);
try testing.expectEqualStrings(
- try std.fmt.bufPrint(&expected, "msg {d} Del\n", .{serial}),
- rdf.next(p, log, fh, frozen).bytes,
- );
- try testing.expectEqualStrings(
try std.fmt.bufPrint(&expected, "del {d} /tmp/logged.txt\n", .{serial}),
rdf.next(p, log, fh, frozen).bytes,
);