diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-19 16:41:27 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-19 18:42:47 -0300 |
| commit | 78d94c4a62ec3f4039a475b637ff6a60649fde52 (patch) | |
| tree | 92b7d29d43bd1f563291db3aa1ab4b90ba55824a /core/look.zig | |
| parent | d0e36bb453526af64349a4eb2335b86c94bea56d (diff) | |
| download | pardes-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/look.zig')
| -rw-r--r-- | core/look.zig | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/core/look.zig b/core/look.zig index e075bbae..b2a7b945 100644 --- a/core/look.zig +++ b/core/look.zig @@ -311,7 +311,7 @@ pub fn submitSearch(p: *Pardes, id: usize) void { if (normal.selRegexArmed(pane)) |a| { // helix keeps the pattern in `/` if (a.pat.len > 0) { - p.registers.put(p.gpa, '/', a.pat, 0, 1, true) catch |err| return p.reportError(id, "search", err); + p.registers.put(p.gpa, '/', a.pat, 0, 1, true) catch |err| return p.reportError(.at(id), "search", err); p.registers.last_search = '/'; } return if (panes.promptTarget(p, pane)) |t| normal.applySelRegex(p, pane, t, a.pat, a.mode); @@ -321,10 +321,10 @@ pub fn submitSearch(p: *Pardes, id: usize) void { if (std.mem.startsWith(u8, armed, config.rename_marker)) return p.lspRequest(id, .rename, armed[slash + 1 ..]); if (std.mem.startsWith(u8, armed, config.symbol_marker)) return p.lspRequest(id, .workspace_symbols, armed[slash + 1 ..]); // A PDF's `/` and a terminal's: a text's is its query pane (Query.zig). - _ = runSearch(p, id, armed[slash + 1 ..], .top, true) catch |err| return p.reportError(id, "search", err); + _ = runSearch(p, id, armed[slash + 1 ..], .top, true) catch |err| return p.reportError(.at(id), "search", err); var pattern: std.ArrayList(u8) = .empty; - normal.appendSearchLiteral(&pattern, p.scratch.allocator(), armed[slash + 1 ..]) catch |err| return p.reportError(id, "search", err); - p.registers.put(p.gpa, '/', pattern.items, 0, 1, true) catch |err| return p.reportError(id, "search", err); + normal.appendSearchLiteral(&pattern, p.scratch.allocator(), armed[slash + 1 ..]) catch |err| return p.reportError(.at(id), "search", err); + p.registers.put(p.gpa, '/', pattern.items, 0, 1, true) catch |err| return p.reportError(.at(id), "search", err); p.registers.last_search = '/'; lookFirstHit(p, id); } @@ -756,7 +756,7 @@ pub fn focusPaneLine(p: *Pardes, id: usize, at: Spot, landing: enum { center, ke } fn selectSpan(p: *Pardes, pane: *Pane, at: Spot) void { - const text = edit.flatSurface(p.editor(), &pane.body) catch |err| return p.reportError(p.view().active, "look", err); + const text = edit.flatSurface(p.editor(), &pane.body) catch |err| return p.reportError(.at(p.view().active), "look", err); // saturating, not `- 1`: `f.zig:0-5` is a legal thing to type and a // 1-based zero is the same nothing an absent number is const acol: i32 = @intCast(at.col -| 1); @@ -952,7 +952,7 @@ fn missed(p: *Pardes, id: usize, comptime fmt: []const u8, args: anytype) void { var msg: Kind.Buf(miss_path_cap + 72) = .{}; // Shown on the pane; logged once, as the err below, not a msg too. p.fs.unlogged = true; - p.setMessage(id, msg.print("Look: {s}", .{why})); + p.setMessage(.at(id), msg.print("Look: {s}", .{why})); p.fs.unlogged = false; const serial = if (p.panes[id]) |pane| pane.serial else 0; var rec: Kind.Buf(miss_path_cap + 96) = .{}; @@ -1047,7 +1047,7 @@ fn lookUnresolved(p: *Pardes, id: usize, pane: *Pane, trimmed: []const u8, text: p.word_look = true; defer p.word_look = false; const rows = runSearch(p, id, text, .cursor, false) catch |err| { - p.reportError(id, "search", err); + p.reportError(.at(id), "search", err); return; }; if (rows == 0) { @@ -1123,7 +1123,7 @@ fn lookAddress(p: *Pardes, id: usize, path: []const u8, expr: []const u8) void { var placed: Kind.Buf(miss_path_cap + "…".len + 24) = .{}; const place = placed.print("{s}:{d}", .{ name, line }); if (!opened_here) return missedLine(p, target, place, line); - p.removePane(target, null) catch |err| p.reportError(id, "look", err); + p.removePane(target, null) catch |err| p.reportError(.at(id), "look", err); if (p.panes[id] != null) v.active = id; return missedLine(p, id, place, line); } else |_| {} @@ -1163,7 +1163,7 @@ fn lookKind(p: *Pardes, id: usize, target: usize, expr_raw: []const u8, opened: if (opened) { var kept: [miss_path_cap + "…".len]u8 = undefined; @memcpy(kept[0..name.len], name); - p.removePane(target, null) catch |err| p.reportError(id, "look", err); + p.removePane(target, null) catch |err| p.reportError(.at(id), "look", err); if (p.panes[id] != null) p.view().active = id; return missed(p, id, "{s} {s}", .{ kept[0..name.len], if (said.len > 0) said.slice() else "is no text to address" }); } @@ -1179,7 +1179,7 @@ fn spotText(at: Spot, buf: *[41]u8) []const u8 { fn closeAndMiss(p: *Pardes, id: usize, opened: usize, name: []const u8, why: []const u8) void { var kept: [miss_path_cap + "…".len]u8 = undefined; @memcpy(kept[0..name.len], name); - p.removePane(opened, null) catch |err| p.reportError(id, "look", err); + p.removePane(opened, null) catch |err| p.reportError(.at(id), "look", err); if (p.panes[id] != null) p.view().active = id; missed(p, id, "{s}: {s}", .{ kept[0..name.len], why }); } @@ -1197,8 +1197,8 @@ fn lookTerminalAddress(p: *Pardes, id: usize, target: usize, expr: []const u8) v var dot: u32 = 0; for (lines, 0..) |ln, i| { if (i == row) dot = @intCast(text.items.len + @min(ln.len, @as(usize, @intCast(@max(0, pane.body.cur_col))))); - text.appendSlice(arena, ln) catch |err| return p.reportError(id, "look", err); - text.append(arena, '\n') catch |err| return p.reportError(id, "look", err); + text.appendSlice(arena, ln) catch |err| return p.reportError(.at(id), "look", err); + text.append(arena, '\n') catch |err| return p.reportError(.at(id), "look", err); } var a: Addr = .{ .text = text.items, .lim = null, .expr = expr }; const r = a.address(.{ .q0 = dot, .q1 = dot }) orelse return missed(p, id, "{s}", .{a.err}); @@ -1266,7 +1266,7 @@ pub fn reopenAt(p: *Pardes, from: usize, path: []const u8, at: Spot) void { if (at.line > n or at.end_line > n) { var said: Kind.Buf(miss_path_cap + 64) = .{}; var cut: [miss_path_cap + "…".len]u8 = undefined; - p.setMessage(id, said.print("{s} has {d} lines now: at its last", .{ missText(path, &cut), n })); + p.setMessage(.at(id), said.print("{s} has {d} lines now: at its last", .{ missText(path, &cut), n })); } } @@ -1393,7 +1393,7 @@ fn settleLine(p: *Pardes, id: usize, path: []const u8, at: Spot, before: usize, const shown = p.panes[p.view().active] orelse return; const f = if (shown.file) |*file| file else return; if (at.line > panes.File.nlines(p.gpa, f)) { - if (opened) |free| p.removePane(free, null) catch |err| p.reportError(id, "look", err); + if (opened) |free| p.removePane(free, null) catch |err| p.reportError(.at(id), "look", err); if (p.panes[before] != null) p.view().active = before; return missedLine(p, id, path, at.line); } @@ -1415,7 +1415,7 @@ fn focusPaneByPath(p: *Pardes, path: []const u8, at: Spot) bool { /// A file that is there but would not open: said with its path, `look: /// <path>: permission denied`, the path cut in its middle when long. fn lookOpenFailed(p: *Pardes, id: usize, path: []const u8, err: anyerror) void { - if (@import("Messages.zig").dialReason(err) != null) return p.reportError(id, path, err); + if (@import("Messages.zig").dialReason(err) != null) return p.reportError(.at(id), path, err); var cut: [miss_path_cap + "…".len]u8 = undefined; // Not there, on a peer's mount as on this host: a miss, the write // answered, as any path to no file is. @@ -1423,7 +1423,7 @@ fn lookOpenFailed(p: *Pardes, id: usize, path: []const u8, err: anyerror) void { if (err == error.FileNotFound or err == error.NotFound or remote_missing) return missed(p, id, "{s}: no such file", .{missText(path, &cut)}); var said: Kind.Buf(miss_path_cap + 16) = .{}; - p.reportError(id, said.print("look: {s}", .{missText(path, &cut)}), err); + p.reportError(.at(id), said.print("look: {s}", .{missText(path, &cut)}), err); } pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void { @@ -1468,7 +1468,7 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void { break :looked operand; }; // The operand may borrow selected terminal/PDF text released below. - const txt = p.scratch.allocator().dupe(u8, looked) catch |err| return p.reportError(id, "look", err); + const txt = p.scratch.allocator().dupe(u8, looked) catch |err| return p.reportError(.at(id), "look", err); // A trailing `:` (`a.txt:2:3:`, as a compiler's message ends) is no // part of the place, as a click's expansion leaves it off. const bare = std.mem.trimEnd(u8, std.mem.trim(u8, txt, " \t\r\n"), ":"); @@ -1586,7 +1586,7 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void { const before = v.active; var opened: ?usize = null; if (!focusPaneByPath(p, target.path, target.at)) { - const free = p.freeSlot() orelse return p.reportError(id, "look", error.NoPaneSlots); + const free = p.freeSlot() orelse return p.reportError(.at(id), "look", error.NoPaneSlots); const nt = panes.File.open(p, free, target.path, target.at.line) catch |err| return lookOpenFailed(p, id, target.path, err); if (target.at.col > 0) nt.body.cur_col = @intCast(target.at.col - 1); @@ -1624,7 +1624,7 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void { if (target.at.line > 0) lookKind(p, id, v.active, spotText(target.at, &place), false); return; } - const free = p.freeSlot() orelse return p.reportError(id, "look", error.NoPaneSlots); + const free = p.freeSlot() orelse return p.reportError(.at(id), "look", error.NoPaneSlots); const made = Kind.openFile(p, free, target.kind, target.path) catch |err| return lookOpenFailed(p, id, target.path, err); // One its kind refuses (an image corrupt, truncated, not what @@ -1975,19 +1975,19 @@ test "cwd changes cancel only the affected pane's Look hover" { const first = p.panes[0] orelse return error.MissingFirstPane; const other = p.panes[1] orelse return error.MissingOtherPane; - p.setCwd(0, "/work/first"); - p.setCwd(1, "/work/other"); + p.setCwd(.at(0), "/work/first"); + p.setCwd(.at(1), "/work/other"); p.look_hover_wait = .{ .col = 1, .row = 1, .pane = 0, .serial = first.serial }; // Hosts poll cwd every frame. An unchanged answer is observational and a // change reported for another pane cannot invalidate this pane's operand. - p.setCwd(0, "/work/first"); + p.setCwd(.at(0), "/work/first"); try std.testing.expect(p.look_hover_wait != null); - p.setCwd(1, "/work/elsewhere"); + p.setCwd(.at(1), "/work/elsewhere"); try std.testing.expect(p.look_hover_wait != null); try std.testing.expectEqual(other.serial, p.panes[1].?.serial); - p.setCwd(0, "/work/changed"); + p.setCwd(.at(0), "/work/changed"); try std.testing.expect(p.look_hover_wait == null); try std.testing.expect(p.look_hover_preview == null); } @@ -2671,7 +2671,7 @@ test "Plumb: a look sends what it looks at, the rules written first: a rule's wo const opened = p.view().active; try std.testing.expect(opened != 0); p.view().active = 0; - p.setMessage(0, "before"); + p.setMessage(.at(0), "before"); lookAt(p, 0, pic); try std.testing.expectEqual(opened, p.view().active); try std.testing.expectEqualStrings("before", pane.msg[0..pane.msg_len]); |
