summaryrefslogtreecommitdiff
path: root/core/keys.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/keys.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/keys.zig')
-rw-r--r--core/keys.zig24
1 files changed, 12 insertions, 12 deletions
diff --git a/core/keys.zig b/core/keys.zig
index 5a3ad10f..2f63d045 100644
--- a/core/keys.zig
+++ b/core/keys.zig
@@ -43,7 +43,7 @@ pub fn cycleMode(p: *Pardes, id: usize) void {
pane.body.mode = .normal;
pane.body.normal.clear();
},
- .normal => edit.enterInsert(p.editor(), &pane.body, .at, 1) catch |err| p.reportError(id, "edit", err),
+ .normal => edit.enterInsert(p.editor(), &pane.body, .at, 1) catch |err| p.reportError(.at(id), "edit", err),
.insert => {
edit.exitInsert(p.editor(), &pane.body);
if (pane.isTerminal()) enterTty(p, id);
@@ -88,7 +88,7 @@ pub fn forwardKey(p: *Pardes, id: usize, key: Key) void {
var first: std.heap.BufferFirstAllocator = .init(&room, p.gpa);
var out: std.Io.Writer.Allocating = .init(first.allocator());
defer out.deinit();
- panes.Term.key(state, key, &out.writer) catch |err| return p.reportError(id, "key", err);
+ panes.Term.key(state, key, &out.writer) catch |err| return p.reportError(.at(id), "key", err);
if (out.written().len > 0) p.emitWrite(id, out.written());
}
@@ -177,7 +177,7 @@ pub fn answerQuestion(p: *Pardes, id: usize, choice: ?u8) bool {
exec.sendToRepl(p, id, to, ask.text);
return true;
};
- p.setMessage(id, "Repl: the REPL chosen is gone; nothing sent");
+ p.setMessage(.at(id), "Repl: the REPL chosen is gone; nothing sent");
},
.del_side => {
asked.prompt = .none;
@@ -194,7 +194,7 @@ pub fn answerQuestion(p: *Pardes, id: usize, choice: ?u8) bool {
pub fn handleKey(p: *Pardes, key: Key) void {
// A double-click is two clicks with nothing between them.
p.view().last_click = null;
- if (p.macro.recording != 0 and p.macro.replaying == 0) Macro.append(&p.macro.recorded, p.gpa, key) catch |err| p.reportError(p.view().active, "macro", err);
+ if (p.macro.recording != 0 and p.macro.replaying == 0) Macro.append(&p.macro.recorded, p.gpa, key) catch |err| p.reportError(.at(p.view().active), "macro", err);
// A question waiting on a pane takes the next key, whatever mode the
// pane or a header edit is in: that key is its answer.
for (p.panes, 0..) |slot, id| {
@@ -298,8 +298,8 @@ pub fn handleKey(p: *Pardes, key: Key) void {
// global window ops (any mode): Alt-n new terminal below, Alt-c move
// the active terminal into a fresh column
if (hit(key, config.new_shell_below)) {
- const free = p.freeSlot() orelse return p.reportError(p.view().active, "Term", error.NoPaneSlots);
- const nt = p.newShell(free, "") catch |err| return p.reportError(p.view().active, "Term", err);
+ const free = p.freeSlot() orelse return p.reportError(.at(p.view().active), "Term", error.NoPaneSlots);
+ const nt = p.newShell(free, "") catch |err| return p.reportError(.at(p.view().active), "Term", err);
nt.greet = true;
// From a tag, as a 9P new is: acme's t->w == nil.
layout.placeNew(p, p.view().active, if (p.view().header != null) null else p.view().active, free, .shell);
@@ -339,7 +339,7 @@ pub fn handleKey(p: *Pardes, key: Key) void {
}
if (hit(key, config.escape) or pending) {
pane.input.mode = .normal;
- p.setMessage(p.view().active, "name drafted: Enter renames the buffer, Esc drops the draft");
+ p.setMessage(.at(p.view().active), "name drafted: Enter renames the buffer, Esc drops the draft");
return;
}
edit.handleInsert(p.editor(), &pane.input, key);
@@ -381,7 +381,7 @@ pub fn handleKey(p: *Pardes, key: Key) void {
if (t.what != .body) {
// An explicit selection, else the word under the cursor in the
// text as it is shown: a tag's prefix is part of what a word is.
- const shown = p.scratch.allocator().dupe(u8, edit.flatSurface(p.editor(), t) catch |err| return p.reportError(p.view().active, "exec", err)) catch |err| return p.reportError(p.view().active, "exec", err);
+ const shown = p.scratch.allocator().dupe(u8, edit.flatSurface(p.editor(), t) catch |err| return p.reportError(.at(p.view().active), "exec", err)) catch |err| return p.reportError(.at(p.view().active), "exec", err);
const range = t.primaryRange(shown, 0);
const lo = @min(range.anchor, range.head);
const hi = @max(range.anchor, range.head);
@@ -451,17 +451,17 @@ pub fn handleKey(p: *Pardes, key: Key) void {
const m = &p.macro;
switch (was) {
.normal => {
- Macro.append(&m.command, p.gpa, key) catch |err| p.reportError(p.view().active, "macro", err);
+ Macro.append(&m.command, p.gpa, key) catch |err| p.reportError(.at(p.view().active), "macro", err);
if (t.mode == .insert) {
m.last_insert.clearRetainingCapacity();
- m.last_insert.appendSlice(p.gpa, m.command.items) catch |err| p.reportError(p.view().active, "macro", err);
+ m.last_insert.appendSlice(p.gpa, m.command.items) catch |err| p.reportError(.at(p.view().active), "macro", err);
m.typed_from = m.last_insert.items.len;
m.inserting = true;
m.command.clearRetainingCapacity();
} else if (std.meta.eql(t.normal, modal.Normal.State{})) m.command.clearRetainingCapacity();
},
.insert => if (m.inserting) {
- Macro.append(&m.last_insert, p.gpa, key) catch |err| p.reportError(p.view().active, "macro", err);
+ Macro.append(&m.last_insert, p.gpa, key) catch |err| p.reportError(.at(p.view().active), "macro", err);
if (t.mode != .insert) m.inserting = false;
},
.tty => {},
@@ -483,7 +483,7 @@ fn leaderKey(p: *Pardes, key: Key) void {
const c: u8 = @intCast(key.cp);
if (c == config.leader_help) {
panes.Output.openHelp(p, v.active, v.leader_keys[0..p.view().leader_n]) catch |err|
- p.reportError(v.active, "help", err);
+ p.reportError(.at(v.active), "help", err);
return;
}
if (v.leader_n >= v.leader_keys.len) return;