From ab9fa40a7bbbbb2e5589335f701f26ca225f9479 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 26 Nov 2026 16:03:21 -0300 Subject: ninep/ctl: a look or exec that makes a file in an untouched +New's place answers that file, by the +New's number, from /look and /exec (M3's gate, rel-upgrade-self and rel-upgrade-back at test/daemon.py:3992: `pardes --tty` with `Shell bash`, a 9P look at notes.txt written to the shell's /pane/1/look, then `int(client.read('/look'))` read b''; the installed build makes pane 3 and answers `3`); THE CAUSE: ctl.run (and runBuiltin, a ctl write's) told the panes a command made by their serials alone, those not there before it (Serials.snapshot); since kwustpxl 0e9d91dcf8bf (UX DESIGN J, free space first) a file made in an untouched +New's place takes the +New's number (layout.takePane swaps the two serials), so the file's serial was there before and it is no new pane, while the +New, closing at the step's end (Pardes.unplaced) under the file's fresh number, is: the look answered the +New, and readResults, which answers a look no pane closed since, read back nothing; THE FIX: Serials keeps each slot's serial, and a pane is made when its slot held no pane or another before and it is not closing at the step's end: the file in its own slot under the +New's number is, the +New under the fresh one is not; a walk step (Trail.show, its file in a new slot under the pane's own number) answers the same pane it did (it was the focused one); no dump, digest, frame or hot path touched (a 9P look or exec, a MAX_PANES loop as before); RUN (TEST FIRST): reproduced in Debug with this tree's build, `test/daemon.py --upgrade` (the same ValueError at 3992); behaviour/look_and_exec.zig "a look whose file takes an untouched +New's place (UX J1) reads back that pane, by the +New's number: ..." boots a terminal, runs New from it and writes a path to the terminal's look, then New again and a path to the root's look with the +New the active pane, and asks each time the +New's number named for the file and read back from /look (and the terminal's look): fails on dc82c33cf9ab at look_and_exec.zig:833 (/look read empty, the name already the file's), passes now; a user hit it with any script that reads /look after a look landing in a +New (the boot's, under the shell of `pardes --tty`); the daemon row in Debug, this tree's build and a -Dstamp-commit one (a copy is the same build and the row asserts the two differ), both ways: rc 0, 41 s each, `upgrade: nothing left behind`; core-test 1172/1347 (175 skipped, as on the base), shell-test 1388/1391 (3 skipped, as on the base), behaviour-test 289/289 and --replay 289/289 (+1), process-test 0 of 149 failed (3 skipped); the coordinator's gate (reorg/mgate.sh lk, without --frames: no frame or hot path touched), every row green but the three pre-existing on the installed tree: Debug: core-test 1172/1347, shell-test 1388/1391, addons 8/8, term-test 17/17, kitty-test 45/45, process-test 0 of 149 failed (3 skipped), pane-test 184/185, behaviour-test 289/289 and --replay 289/289, consumer-test, the soak twice (rtt 30/80/207: diverged 0, unequal 0, quiet checks 577/0 470/0 581/0 and 654/0 383/0 679/0, unlisted stops 0, the corpus 22 of 22 scenes the same, no leak), daemon.py plain x3, games, window-clients, clients x5, relink, launch, pair, gui, client-motion rc 0, far rc 1 (`no link of the far client ended under the flood`, as M3's), client-resize-real skipped (no compositor), the macOS x86_64 and arm64 and FreeBSD cross-builds; ReleaseSafe: the build (0 invalid options), the soak (diverged 0, unequal 0, quiet checks 417/0 368/0 591/0, unlisted stops 0), process-test 1 of 149 failed (root-ctl Restore, as M3's), upgrade from the installed 1e8787e0b2eb, upgrade-gui, upgrade-self (Debug to ReleaseSafe, 64 s) and upgrade-back (40 s) each `upgrade: nothing left behind`, launch, clients x3, far, gui, client-motion, client-resize-real, client-idle, pair, plain x3 rc 0; load 0.6 to 4.5 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/ninep/ctl.zig | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'core') diff --git a/core/ninep/ctl.zig b/core/ninep/ctl.zig index 6d78bc44..c99ec9ab 100644 --- a/core/ninep/ctl.zig +++ b/core/ninep/ctl.zig @@ -29,18 +29,27 @@ const E = tree.E; // ---- which panes a command made or touched ---- +/// The serial of the pane in each slot, 0 for none. const Serials = struct { - list: [MAX_PANES]u32 = undefined, - len: usize = 0, + of: [MAX_PANES]u32 = @splat(0), fn snapshot(p: *Pardes) Serials { var s: Serials = .{}; - for (p.panes) |slot| if (slot) |pane| { - s.list[s.len] = pane.serial; - s.len += 1; + for (p.panes, &s.of) |slot, *serial| if (slot) |pane| { + serial.* = pane.serial; }; return s; } + + /// Whether the pane in slot `id` was made since the snapshot: it is in + /// a slot that held no pane or another, as a file made in an untouched + /// +New's place is under the +New's number (layout.takePane), and it + /// is not closing at the step's end, as that +New is under the number + /// it was given (Pardes.unplaced). + fn made(s: *const Serials, p: *const Pardes, id: usize) bool { + const pane = p.panes[id] orelse return false; + return pane.serial != s.of[id] and !p.unplaced.isSet(id); + } }; fn noteResult(p: *Pardes, serial: u32) void { @@ -89,14 +98,14 @@ pub fn run(p: *Pardes, id: usize, exec: bool, text: []const u8, in_tag: bool) vo }; // A look that found nothing answers nothing, not the pane before it. if (!exec and p.look_missed) return; - const after = Serials.snapshot(p); var created = false; - for (after.list[0..after.len]) |serial| if (std.mem.indexOfScalar(u32, before.list[0..before.len], serial) == null) { + for (0..MAX_PANES) |k| if (before.made(p, k)) { + const made = p.panes[k].?; // A query pane's +Preview is its query pane's: that answers. - if (p.paneBySerial(serial)) |made| if (p.panes[made].?.file) |f| if (f.output) |o| if (o.from == .preview) continue; + if (made.file) |f| if (f.output) |o| if (o.from == .preview) continue; // A look that made a +Search pane (a terminal's word) // answers it: that is where the places it found are. - noteResult(p, serial); + noteResult(p, made.serial); created = true; }; if (created) return; @@ -598,10 +607,9 @@ pub fn runBuiltin(p: *Pardes, req: Req, id: usize, line: []const u8) ?Reply { const context = if (p.panes[id]) |pane| pane.serial else 0; const before = Serials.snapshot(p); _ = exec_line.executeBuiltinLine(p, id, line); - const after = Serials.snapshot(p); var created = false; - for (after.list[0..after.len]) |serial| if (std.mem.indexOfScalar(u32, before.list[0..before.len], serial) == null) { - noteResult(p, serial); + for (0..MAX_PANES) |k| if (before.made(p, k)) { + noteResult(p, p.panes[k].?.serial); created = true; }; if (!created) noteResult(p, context); -- cgit v1.3