From fed268f2282a6d393a116d103e1fd88da87ecbff Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 26 Nov 2026 04:36:36 -0300 Subject: themes, colors, gen_themes: `dark` refreshed and four new pardes themes, light, mono, okabe and sepia, and the ring in DESIGN.md E's groups (the themes programme's L5; DESIGN.md C, D, E, G2, G3): DARK (C): still the one theme with no page and no text of its own, so a terminal keeps the host's cell, ink and sixteen (ansi.inkOf's `host`), and a window draws colors.null_page #121212 and #cccccc (G2 (a)); its comments the brightest ink, #f0f0f0; keywords violet #d76ef0 (6.6:1; was #da5eea, 5.9:1); the lilac tag #2c2a3e with #aba9c3 ink, focused #d6d4e8; the grip #a58bff (3.4:1 on its focused tag; was #663fe0, 1.45:1); a violet selection #46337a in #f4f0ff (G3 (a): the tan #513c17 sat in the hits' amber); its own severities #ff6e7f #ffb454 #7fa8ff #62d2c4, line numbers #5c5c66 / #8e8c9e, and a designed sixteen for the window (its ANSI 8 #7e7b96, 4.6:1, where L1's derived one was 3:1); its focused tag, mode ring, grip ring, dirty, rules, hits and diff rows Chrome.of's; LIGHT, MONO, OKABE, SEPIA (D): each its primitives as the designer's prototype resolved and audited them (.scratch/themes/C1/newthemes.py, swatches.md: page, text, tag and its ink, accent, selection and its ink, the four syntax hues, line numbers, the four severities, the sixteen; okabe's added blue #56b4e9 and deleted vermilion #ff8a4c), everything else Chrome.of's; THE RING (E): curated in the picker's sections: Pardes (dark, light, orchard, orchard_black, ink, mono, okabe, sepia, paper, daybreak, dusk, lapis), Pardes, after a classic (forge, forge_black, forge_soft, lagoon, solarium, spectrum, harvest, clay), acme (acme, atelier), the faithful ports a family at a time as before, Captured (helix; "Legacy themes" gone); the imported a family at a time, each under its heading (`Imported: gruvbox`, a family the name's first word, two themes or more), the lone ones last under one (`Imported, one of a kind`): the generator rings them so (gen_themes `byFamily`) and colors.zig heads them at comptime (`import_heads`, a compile error where a family rings after a lone theme); ORCHARD THE DEFAULT BY NAME (`colors.default_theme`: config.Settings' `theme`, the library's `default_theme`, macos.zig's bare page), never index 0, which is dark now; THE RING TEST: dusk, lagoon, solarium and forge_soft `soft` (`soft_themes`: held at AA, their text and tag text never to the pro 7:1; the coordinator's ruling) where they were on the expected list; the diff rows' "unless the text holds it nearer" exception for the ports and imports only, pardes's own held to 1.15:1 (the coordinator's ruling: every one of them meets it); pardes's own are every theme before the first faithful port, so dark and the new four are held to the pro floors with the natives; the old tests that read the first fifteen by place read the fifteen designed natives by name (`designed`; `native_theme_count` gone, B8); RUN (TEST FIRST): the ring test with dark off its list and the soft four marked failed on L4's dark (ansi_pro: its ANSI 8 3:1) and, with the soft mark on text alone, on lagoon's and solarium's tag_text7: 281 of 289 themes pass (272 of 285 at L4, the four new ones passing every floor, pro included), 8 on the list (L7's retired); colors.zig "the picker's sections run in ring order and cover it": dark first, orchard the default by name, each imported family's heading at its first, none after the lone ones' (fails on L4: "Pardes themes", orchard at 0); test/process/tty_themes.zig's `theme` case boots in dark (`Theme dark`, its own init line) and steps NextColor through the 24 of the new order into the first ports (dark, light, orchard, orchard-black, ink, mono, okabe, sepia, paper, daybreak, dusk, lapis, forge, ..., clay, acme, atelier, dark-plus, solarized-dark), `themesel` walks the Themes list from its first row the same 24 (both goldens re-recorded and read at the programme's end gate: the snaps are named for the new order); core-test 1140/1313 (173 skipped: as L4, the picker test grown); OUTSIDE my files: core/config.zig (the default, 1 line), core/lib_syntax.zig (`default_theme`), runtime/macos.zig (1 line), test/consumer/lib.zig (orchard is `default_theme`), test/process/tty_themes.zig (the two cases); no dump or digest change (a dump names its theme; settings.theme is a place in this build's ring, as before) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- test/process/tty_themes.zig | 177 +++++++++++++++++++++++++++++--------------- 1 file changed, 116 insertions(+), 61 deletions(-) (limited to 'test/process') diff --git a/test/process/tty_themes.zig b/test/process/tty_themes.zig index 1975c02b..8c49b77f 100644 --- a/test/process/tty_themes.zig +++ b/test/process/tty_themes.zig @@ -17,6 +17,10 @@ pub const cases = .{ fn theme(gpa: std.mem.Allocator, exe: [:0]const u8) !void { var t = try Tty.init(gpa, exe, "theme"); defer t.deinit(); + // From the ring's first, dark (the host's page: the tty's own cells), + // through pardes's own, those after a classic and acme's, into the first + // faithful ports (DESIGN.md E's groups). + try t.config("Theme dark"); try t.file("t.txt", "x"); try t.start(31, 100, &.{ "-n", "3" }); try t.wait(8000, "t.txt"); @@ -30,13 +34,23 @@ fn theme(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.key("esc"); try t.settle(100); try t.stable(700, 10000); + try t.snap("dark"); + try t.style("dark"); + try t.press("middle", "@NextColor", 1); + try t.release("middle", "@NextColor", 1); + try t.stable(700, 10000); + try t.snap("light"); + try t.style("light"); + try t.press("middle", "@NextColor", 1); + try t.release("middle", "@NextColor", 1); + try t.stable(700, 10000); try t.snap("orchard"); try t.style("orchard"); try t.press("middle", "@NextColor", 1); try t.release("middle", "@NextColor", 1); try t.stable(700, 10000); - try t.snap("dusk"); - try t.style("dusk"); + try t.snap("orchard-black"); + try t.style("orchard-black"); try t.press("middle", "@NextColor", 1); try t.release("middle", "@NextColor", 1); try t.stable(700, 10000); @@ -45,6 +59,21 @@ fn theme(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.press("middle", "@NextColor", 1); try t.release("middle", "@NextColor", 1); try t.stable(700, 10000); + try t.snap("mono"); + try t.style("mono"); + try t.press("middle", "@NextColor", 1); + try t.release("middle", "@NextColor", 1); + try t.stable(700, 10000); + try t.snap("okabe"); + try t.style("okabe"); + try t.press("middle", "@NextColor", 1); + try t.release("middle", "@NextColor", 1); + try t.stable(700, 10000); + try t.snap("sepia"); + try t.style("sepia"); + try t.press("middle", "@NextColor", 1); + try t.release("middle", "@NextColor", 1); + try t.stable(700, 10000); try t.snap("paper"); try t.style("paper"); try t.press("middle", "@NextColor", 1); @@ -55,8 +84,13 @@ fn theme(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.press("middle", "@NextColor", 1); try t.release("middle", "@NextColor", 1); try t.stable(700, 10000); - try t.snap("atelier"); - try t.style("atelier"); + try t.snap("dusk"); + try t.style("dusk"); + try t.press("middle", "@NextColor", 1); + try t.release("middle", "@NextColor", 1); + try t.stable(700, 10000); + try t.snap("lapis"); + try t.style("lapis"); try t.press("middle", "@NextColor", 1); try t.release("middle", "@NextColor", 1); try t.stable(700, 10000); @@ -65,6 +99,16 @@ fn theme(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.press("middle", "@NextColor", 1); try t.release("middle", "@NextColor", 1); try t.stable(700, 10000); + try t.snap("forge-black"); + try t.style("forge-black"); + try t.press("middle", "@NextColor", 1); + try t.release("middle", "@NextColor", 1); + try t.stable(700, 10000); + try t.snap("forge-soft"); + try t.style("forge-soft"); + try t.press("middle", "@NextColor", 1); + try t.release("middle", "@NextColor", 1); + try t.stable(700, 10000); try t.snap("lagoon"); try t.style("lagoon"); try t.press("middle", "@NextColor", 1); @@ -90,28 +134,13 @@ fn theme(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.press("middle", "@NextColor", 1); try t.release("middle", "@NextColor", 1); try t.stable(700, 10000); - try t.snap("forge-black"); - try t.style("forge-black"); - try t.press("middle", "@NextColor", 1); - try t.release("middle", "@NextColor", 1); - try t.stable(700, 10000); - try t.snap("forge-soft"); - try t.style("forge-soft"); - try t.press("middle", "@NextColor", 1); - try t.release("middle", "@NextColor", 1); - try t.stable(700, 10000); - try t.snap("orchard-black"); - try t.style("orchard-black"); - try t.press("middle", "@NextColor", 1); - try t.release("middle", "@NextColor", 1); - try t.stable(700, 10000); try t.snap("acme"); try t.style("acme"); try t.press("middle", "@NextColor", 1); try t.release("middle", "@NextColor", 1); try t.stable(700, 10000); - try t.snap("lapis"); - try t.style("lapis"); + try t.snap("atelier"); + try t.style("atelier"); try t.press("middle", "@NextColor", 1); try t.release("middle", "@NextColor", 1); try t.stable(700, 10000); @@ -120,7 +149,6 @@ fn theme(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.press("middle", "@NextColor", 1); try t.release("middle", "@NextColor", 1); try t.stable(700, 10000); - // After orchard_black: acme and lapis, then the first faithful ports. try t.snap("solarized-dark"); try t.style("solarized-dark"); try t.done(); @@ -138,10 +166,10 @@ fn theme(gpa: std.mem.Allocator, exe: [:0]const u8) !void { // running it and stopping. There is still no preview state, nothing to confirm // and nothing to cancel: the row you ran is the theme you have. // -// The whole ring is in the buffer, in sections: the fifteen native themes, -// acme and lapis, the faithful ports a family at a time, the legacy helix and -// dark, then everything exported from the vendored helix .toml and zed .json -// files, sorted. The colors below are +// The whole ring is in the buffer, in sections (DESIGN.md E): pardes's own, +// those after a classic, acme's, the faithful ports a family at a time, the +// captured helix, then everything imported from the vendored helix .toml and +// zed .json files, a family at a time and the lone ones last, sorted. The colors below are // read with snapstyle, so this proves the generated themes are real data and // not just names in a list. fn themesel(gpa: std.mem.Allocator, exe: [:0]const u8) !void { @@ -159,66 +187,77 @@ fn themesel(gpa: std.mem.Allocator, exe: [:0]const u8) !void { // fresh output buffer is where the walk's ring starts, so the first n goes // into the list and every one after it carries on down it. try t.key("space t t"); - try t.wait(10000, "Theme orchard"); + try t.wait(10000, "Theme dark"); try t.stable(700, 15000); try t.snap("list"); - // n selects row 1 whole and Tab runs it: `Theme orchard`, which is already the - // boot theme, so only the selection moves. That is the honest first step — an - // idempotent command has to be safe to run. + // n selects row 1 whole and Tab runs it: `Theme dark`, the ring's first; + // the theme changes under the cursor one row at a time, a section's + // heading and its blank line skipped (Output.isWalkRow). + try t.key("space j n"); + try t.key("tab"); + try t.stable(700, 15000); + try t.snap("step-dark"); + try t.style("step-dark"); + try t.key("space j n"); + try t.key("tab"); + try t.stable(700, 15000); + try t.snap("step-light"); + try t.style("step-light"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); try t.snap("step-orchard"); try t.style("step-orchard"); - // ...and now the theme really does change under the cursor, one row at a time try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); - try t.snap("step-dusk"); - try t.style("step-dusk"); - // Selection alone can skip rows without previewing or applying their themes. - // Four steps reach atelier, the Acme homage; Tab then applies it. - try t.key("space j n"); + try t.snap("step-orchard-black"); + try t.style("step-orchard-black"); try t.key("space j n"); + try t.key("tab"); + try t.stable(700, 15000); + try t.snap("step-ink"); + try t.style("step-ink"); try t.key("space j n"); + try t.key("tab"); + try t.stable(700, 15000); + try t.snap("step-mono"); + try t.style("step-mono"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); - try t.snap("step-atelier"); - try t.style("step-atelier"); + try t.snap("step-okabe"); + try t.style("step-okabe"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); - try t.snap("step-forge"); - try t.style("step-forge"); + try t.snap("step-sepia"); + try t.style("step-sepia"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); - try t.snap("step-lagoon"); - try t.style("step-lagoon"); + try t.snap("step-paper"); + try t.style("step-paper"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); - try t.snap("step-solarium"); - try t.style("step-solarium"); + try t.snap("step-daybreak"); + try t.style("step-daybreak"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); - try t.snap("step-spectrum"); - try t.style("step-spectrum"); + try t.snap("step-dusk"); + try t.style("step-dusk"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); - try t.snap("step-harvest"); - try t.style("step-harvest"); + try t.snap("step-lapis"); + try t.style("step-lapis"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); - try t.snap("step-clay"); - try t.style("step-clay"); - // The three native contrast variants precede acme and lapis, and then the first - // ported family's section. Its heading - // and blank separator are not stops in the n/N command walk. + try t.snap("step-forge"); + try t.style("step-forge"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); @@ -232,8 +271,28 @@ fn themesel(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); - try t.snap("step-orchard-black"); - try t.style("step-orchard-black"); + try t.snap("step-lagoon"); + try t.style("step-lagoon"); + try t.key("space j n"); + try t.key("tab"); + try t.stable(700, 15000); + try t.snap("step-solarium"); + try t.style("step-solarium"); + try t.key("space j n"); + try t.key("tab"); + try t.stable(700, 15000); + try t.snap("step-spectrum"); + try t.style("step-spectrum"); + try t.key("space j n"); + try t.key("tab"); + try t.stable(700, 15000); + try t.snap("step-harvest"); + try t.style("step-harvest"); + try t.key("space j n"); + try t.key("tab"); + try t.stable(700, 15000); + try t.snap("step-clay"); + try t.style("step-clay"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); @@ -242,17 +301,13 @@ fn themesel(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); - try t.snap("step-lapis"); - try t.style("step-lapis"); + try t.snap("step-atelier"); + try t.style("step-atelier"); try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); try t.snap("step-dark-plus"); try t.style("step-dark-plus"); - // across the Visual Studio Code section into Solarized: a section heading and - // its blank line are skipped like the first. (The imported half, past the - // legacy section, is sorted by name, so the ring is the same everywhere - // whatever order the directory read handed the files over in.) try t.key("space j n"); try t.key("tab"); try t.stable(700, 15000); -- cgit v1.3 From 849542a05f7be03f37a0e6444e0eb70fb4dbea0c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 26 Nov 2026 06:14:26 -0300 Subject: ninep/ctl, Pick, Names: a key written to 9P's kbdin (and a mouse line to mousein) takes the keyboard's path: the write is answered once its keys are handled, and what they start runs on a worker as the keyboard's does, its rows after (agent W78's find, rqouyxqp's description: a scripted `SPC f g` over V8's 18,441 files held the session until the 9P client timed out; and W6's: kbdin's Symbols picker over a text of more than 64 KB listed nothing); THE CAUSE: writeKbdin and writeMousein ran their keys inside serveFs with `p.fs.serving` set, which these places read as "a script's write, answered with its result": Pick.start and filter (Find's listing and Grep's search stepped on the loop, `.now`), Query (a query pane's), Stream.step (runHere, not the worker), Stream.parseFor (no worker: a text over 64 KB never parsed), paintAhead and paintRows, builtins' search (a miss said to the write), look (a tty pane's click searched), edit_cmd (the write held for an Edit's filters), panes (a Save's question to /log) and lsp/Ask (the write waits for the server's answer); `fs.typed` made Pick.asked alone take the keys as the user's; THE FIX: writeKbdin and writeMousein run their keys with `serving` off and put it back after, so every one of those places takes the keyboard's path for typed keys and keeps the script's for a script's write; `fs.typed` has no reader and goes (FsState, its replica list); A CRASH IT UNCOVERED: with the parse on a worker, Pick.declsArrived scored the declarations that came by typing the picker's own query again, `names.typed(gpa, names.queryText())`, and Names.typed copied the query onto itself with @memcpy, `@memcpy arguments alias`, a panic in a safe build (the installed ReleaseSafe's): a keyboard's `SPC s s` whose query was typed before its file's parse landed (a big file) killed the session; Names.typed copies with copyForwards; ACCEPTED (the coordinator): a kbdin `gd` no longer waits for the server's answer, nor a kbdin `SPC f f` for its rows: a script reads them after, as a keyboard user sees them a frame later (docs/typ/reference.typ's kbdin says so; a script that wants the answer in its write writes the word to a pane's ctl, `Def`, `Find x`, which still waits); RUN (TEST FIRST): process/other_files.zig "kbdin's SPC f f over a work tree of 20,000 files is answered before the listing, which a worker runs as the keyboard's, its rows after" (a detached session, a tree of 200 directories of 100 files with a `.git`, `SPC f f zzlast` in one kbdin write timed, then /screen read until zzlast.txt's row shows): on T2 the write took 46-47 ms and the row was there at 62-63 ms (the listing ran in the write), now the write takes 3 ms and the row comes at 58-60 ms (three runs); "kbdin's SPC s s lists the declarations of a file over 64 KB, parsed on a worker as the keyboard's are" (4,001 two-line functions, 80 KB, `SPC s s zzlast`): on T2 nothing in 20 s, with the fix alone the session died at Pick.declsArrived (the probe, .scratch/walkui/T23/symprobe.sh: `panic: @memcpy arguments alias` at Names.zig typed), now its row in under a second; Names.zig "Names takes its own query typed again: ..." types a query, adds two names and types its own query again: panics before (`@memcpy arguments alias`), one hit now; behaviour tests that read a picker's rows in the write that typed its keys read them a frame later (Session.tick): other_files.zig's SPC f f, and addons.zig's two `SPC f f ...` then Enter, now the query, a tick, then Enter (Enter typed before the rows came picks none, for a keyboard too); a user hit the stall with any script driving a session's keys over a big tree, and the crash with `SPC s s` typed ahead of a big file's parse; NEW HOT PATHS: none (a write of keys saves and puts back one flag); GATES: core-test 1131/1305 (174 skipped: +1), shell-test 1353/1356 (3 skipped: +1), pane-test 183/184, behaviour-test 286/286 and --replay 20 seeds of 70 steps, 0 failures, process-test 0 of 149 failed (3 skipped: +2), term-test 17/17, kitty-test 45/45, the gui unit-test (Debug, this change over T2's mlvruznk) 1962/1966 (4 skipped: T2's lsp_client test and this change's Names test among the new; its perf check's BaselineHarnessMismatch, every base's); no dump change (`typed` was a field of the server's own, out of the digest: fs.zig's authority list) and no wire change (FsState is not on the tape), so no fuzz or soak; Stream.parseFor keeps its `!p.fs.serving` for a script's write, whose answer holds its rows (a script's `Symbols` word over a text past 64 KB still lists nothing: not this change's); no frame or perf gate (the user's rule of 2026-11-26); load 1.2 to 2.6 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/Names.zig | 16 ++++++++++- core/Pick.zig | 8 +++--- core/fs.zig | 10 +++---- core/ninep/ctl.zig | 18 +++++++++---- docs/typ/reference.typ | 5 +++- test/behaviour/addons.zig | 11 +++++--- test/behaviour/other_files.zig | 4 ++- test/process/other_files.zig | 60 ++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 111 insertions(+), 21 deletions(-) (limited to 'test/process') diff --git a/core/Names.zig b/core/Names.zig index d063bd17..01dbecf0 100644 --- a/core/Names.zig +++ b/core/Names.zig @@ -128,7 +128,9 @@ pub fn typed(n: *Names, gpa: std.mem.Allocator, text: []const u8) void { // only those are scored again (and then the ones not yet scored). const grew = n.query_len > 0 and std.mem.startsWith(u8, q, n.queryText()) and std.mem.indexOfScalar(u8, q[n.query_len..], ' ') == null; n.query_len = @intCast(q.len); - @memcpy(n.query_buf[0..q.len], q); + // Its own query typed again, to score names that came after it + // (Pick.declsArrived), is the buffer itself. + std.mem.copyForwards(u8, n.query_buf[0..q.len], q); n.reach = max_rows; if (grew) { const pending = n.pending.items[n.pending_at..]; @@ -435,3 +437,15 @@ test "Names keeps its best `reach` hits first in a full sort's order, the rest a n.reachTo(max_rows + 500); try std.testing.expectEqualSlices(Hit, all[0 .. max_rows + 500], n.hits.items[0 .. max_rows + 500]); } + +test "Names takes its own query typed again: names added after it (a Symbols picker's declarations from a worker, Pick.declsArrived) are scored against it" { + const gpa = std.testing.allocator; + var n: Names = .{}; + defer n.deinit(gpa); + n.typed(gpa, "zzlast"); + for ([_][]const u8{ "fn f0001() void {", "fn zzlastfn() void {" }) |cand| try n.add(gpa, cand, 0, cand.len, 0, 0); + n.typed(gpa, n.queryText()); + while (n.busy()) n.rescore(gpa); + try std.testing.expectEqualStrings("zzlast", n.queryText()); + try std.testing.expectEqual(@as(usize, 1), n.hits.items.len); +} diff --git a/core/Pick.zig b/core/Pick.zig index 9a9d0cde..5951f925 100644 --- a/core/Pick.zig +++ b/core/Pick.zig @@ -182,11 +182,11 @@ pub fn deinit(pk: *Pick, gpa: std.mem.Allocator) void { /// Whether a search a builtin asks for from pane `id` is a picker in the /// tag (SPEC §14.3 phase 4): in a session whose jumps walk, from the -/// keyboard or a click (kbdin's and mousein's too), never a script's word -/// (a 9P exec's: the query pane, whose rows it reads back, and whose `not -/// found` it hears). +/// keyboard or a click (kbdin's and mousein's too, which run as theirs: +/// ninep/ctl.zig writeKbdin), never a script's word (a 9P exec's: the query +/// pane, whose rows it reads back, and whose `not found` it hears). pub fn asked(p: *const Pardes) bool { - return p.settings.jumps == .walk and (!p.fs.serving or p.fs.typed); + return p.settings.jumps == .walk and !p.fs.serving; } /// Picker `id`, kept or live. diff --git a/core/fs.zig b/core/fs.zig index 594c89cf..c5eb432d 100644 --- a/core/fs.zig +++ b/core/fs.zig @@ -868,7 +868,7 @@ pub const Namespace = struct { .authority = .{ "socket_path", "tcp_address", "mounts", "node_name", "os_paths", "out", "listeners", "origin", "no_prompt", "session_write", "unlogged", "capturing", - "serving", "typed", "refused", "failure", "failure_len", "no_pane_slot", "no_pane_slot_len", + "serving", "refused", "failure", "failure_len", "no_pane_slot", "no_pane_slot_len", "said", "said_len", "said_at", "late_failure", "late_failure_len", "lsp_answer_at", "edit_started", "edit_hold", "edit_said", "lsp_result", "write_room", "write_waits", "log_full_hash", "pages", "closed_lines", "ran_at", "refilled", @@ -908,12 +908,10 @@ pub const Namespace = struct { /// which also refuses prompts, which a click may open). capturing: bool = false, /// A 9P request is being served (Pardes.serveFs): a prompt it opens is - /// a question for the log (`ask`), answered with `answer`. + /// a question for the log (`ask`), answered with `answer`. Not while + /// the keys or the mouse written to `kbdin` or `mousein` run: they are + /// the user's own (ninep/ctl.zig writeKbdin). serving: bool = false, - /// The request is keys or a mouse written to `kbdin` or `mousein`: - /// the user's own, so a builtin they reach routes as typed - /// (Pick.asked), though their write is served as any other. - typed: bool = false, refused: bool = false, failure: [256]u8 = undefined, failure_len: u16 = 0, diff --git a/core/ninep/ctl.zig b/core/ninep/ctl.zig index 2411b20f..17f58e7f 100644 --- a/core/ninep/ctl.zig +++ b/core/ninep/ctl.zig @@ -882,7 +882,10 @@ const e_no_pane = "no such pane"; /// rio's kbdin (windows/rio/xfid.c:515): each rune written is a key typed /// at the pane with the keyboard, the user's own, each done before the next -/// and all before the write is answered. Control runes are Ctrl and a +/// and all before the write is answered. They run as the keyboard's, not as +/// a script's write: what they start on a worker (a picker's listing or +/// search, a parse, a language server's answer) comes after the answer, as +/// a keyboard's comes a frame later. Control runes are Ctrl and a /// letter, but for Plan 9's keys (include/ALL/keyboard.h): \n or \r Enter, /// \t Tab, \b Backspace, 0x7f Delete, 0x1b Esc, and the arrows, Home, End, /// Page Up and Down, Insert and F1-F12 at its private-use runes. Its @@ -890,8 +893,11 @@ const e_no_pane = "no such pane"; /// or Ctrl to the key after them. pub fn writeKbdin(p: *Pardes, req: Req) Reply { const view = std.unicode.Utf8View.init(req.data) catch return tree.failText(req.tag, E.INVAL, "invalid UTF-8"); - p.fs.typed = true; - defer p.fs.typed = false; + // The keyboard's path, not a script's write's: nothing waits on the + // loop for a picker's source or an answer (Pick.asked, Stream.step). + const serving = p.fs.serving; + p.fs.serving = false; + defer p.fs.serving = serving; var it = view.iterator(); var mods: pardes.Key = .{ .cp = 0 }; while (it.nextCodepointSlice()) |rune| { @@ -946,8 +952,10 @@ fn kbdKey(rune: []const u8) pardes.Key { /// changed since the last line is pressed or released there, in that order /// of buttons; a move with one held drags, with none moves. pub fn writeMousein(p: *Pardes, req: Req) Reply { - p.fs.typed = true; - defer p.fs.typed = false; + // The mouse's path, as kbdin's keys take the keyboard's. + const serving = p.fs.serving; + p.fs.serving = false; + defer p.fs.serving = serving; var lines = std.mem.tokenizeScalar(u8, req.data, '\n'); while (lines.next()) |line| { var words = std.mem.tokenizeAny(u8, line, " \t\r"); diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ index a08d3acc..449e6176 100644 --- a/docs/typ/reference.typ +++ b/docs/typ/reference.typ @@ -958,7 +958,10 @@ at 200, ending in `…`. Control characters become spaces. - #file("/kbdin") (write only), rio's: each rune written is a key typed at the pane with the keyboard, done before the write is answered, so a - script that writes keys then reads a file sees what they did. Control + script that writes keys then reads a file sees what they did. What they + start on a worker, as the keyboard's keys do, comes after the answer: a + picker's listing or search, a file's declarations, a language server's + answer; a script reads again until it is there. Control runes are Ctrl and a letter, but for Plan 9's keys (`keyboard.h`): `\n` or `\r` #key("Enter"), `\t` #key("Tab"), `\b` Backspace, `0x7f` Delete, `0x1b` #key("Esc"), and the diff --git a/test/behaviour/addons.zig b/test/behaviour/addons.zig index 90f4e383..0b0555c2 100644 --- a/test/behaviour/addons.zig +++ b/test/behaviour/addons.zig @@ -411,8 +411,10 @@ test "addons: a picker shows a file of an addon's kind through its kind in the p try s.expect(body, "the notes\n"); try std.testing.expectEqualStrings(index, try s.read("/index")); // Enter: the kind's pane where a Look puts it; the reading pane keeps - // its text. - try s.keys(" ffseven\n"); + // its text. (The listing is the next frame's, as for the keyboard.) + try s.keys(" ffseven"); + s.tick(); + try s.keys("\n"); s.tick(); const opened = try paneOf(&s, "fake"); try std.testing.expect(opened != pane); @@ -516,7 +518,10 @@ test "addons: Enter on a picture in a picker opens its kind's pane, never its by defer unload(&s, "image"); const dir = try dirOf(&s, &tmp); const pane = try s.lookFile(s.at("{s}/notes.txt", .{dir})); - try s.keys(" ffpic\n"); + // The listing is the next frame's, as for the keyboard. + try s.keys(" ffpic"); + s.tick(); + try s.keys("\n"); s.tick(); try s.expect(s.at("/pane/{d}/body", .{pane}), "the notes\n"); const image = try paneOf(&s, "image"); diff --git a/test/behaviour/other_files.zig b/test/behaviour/other_files.zig index 8a9016bc..95d4de6d 100644 --- a/test/behaviour/other_files.zig +++ b/test/behaviour/other_files.zig @@ -35,7 +35,9 @@ test "other-files: kbdin's keys are the user's: SPC f f opens Find's picker in t _ = try s.lookFile(s.at("{s}/a.txt", .{buf[0..try tmp.dir.realPath(std.testing.io, &buf)]})); try s.keys(" ff"); try std.testing.expect(std.mem.indexOf(u8, try s.read("/index"), "+Search") == null); - // Its rows under the tag of the pane typed at, the cursor on the first. + // Its rows under the tag of the pane typed at, the cursor on the first, + // the next frame, as the keyboard's: the listing is not the write's. + s.tick(); _ = try s.where("▶ a.txt"); _ = try s.where(" b.txt"); } diff --git a/test/process/other_files.zig b/test/process/other_files.zig index 69f65884..48ba06d0 100644 --- a/test/process/other_files.zig +++ b/test/process/other_files.zig @@ -8,6 +8,8 @@ pub const cases = .{ .{ "other-files: a held connection lists a directory, stats a file, writes and reads, is refused in words and removes a pane", heldConnection }, .{ "other-files: a file opened and closed is in /recent closed, and still is in the next session; Recent's row opens it again", recentSurvivesRestart }, .{ "other-files: two sessions share Recent: a file opened in one is in the other's /recent, a Del'd pane comes back from @p only where it was", recentShared }, + .{ "other-files: kbdin's SPC f f over a work tree of 20,000 files is answered before the listing, which a worker runs as the keyboard's, its rows after", findOnWorker }, + .{ "other-files: kbdin's SPC s s lists the declarations of a file over 64 KB, parsed on a worker as the keyboard's are", symbolsOnWorker }, }; extern "c" fn system(cmd: [*:0]const u8) c_int; @@ -185,3 +187,61 @@ fn recentShared(gpa: std.mem.Allocator, exe: [:0]const u8) !void { } try std.testing.expect(stateExists(root)); } + +/// A kbdin `SPC f f` over a work tree of 20,000 files: the keys handled and +/// the write answered, the listing run on a worker as the keyboard's is, +/// its rows on the screen after. (Before, the listing ran on the loop in the +/// write: over V8's 18,441 files a script's `SPC f g` held the session past +/// its client's timeout.) +fn findOnWorker(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var d = try process.Detached.start(gpa, exe, "kbdfind", .{}); + defer d.deinit(); + const f = &d.files; + const eh = @import("../e2e_harness.zig"); + var buf: [4096]u8 = undefined; + const tree = f.at("{s}/tree", .{d.root()}); + for ([_][]const u8{ "", "/.git" }) |sub| _ = std.c.mkdir(try std.fmt.bufPrintSentinel(&buf, "{s}{s}", .{ tree, sub }, 0), 0o755); + for (0..200) |dir| { + _ = std.c.mkdir(try std.fmt.bufPrintSentinel(&buf, "{s}/d{d:0>3}", .{ tree, dir }, 0), 0o755); + for (0..100) |i| try eh.writeFile(try std.fmt.bufPrintSentinel(&buf, "{s}/d{d:0>3}/f{d:0>3}.txt", .{ tree, dir, i }, 0), ""); + } + try eh.writeFile(try std.fmt.bufPrintSentinel(&buf, "{s}/zzlast.txt", .{tree}, 0), "last\n"); + try eh.writeFile(try std.fmt.bufPrintSentinel(&buf, "{s}/notes.txt", .{tree}, 0), "notes\n"); + try f.write("/look", f.at("{s}/notes.txt\n", .{tree})); + const t0 = process.nowMs(); + try f.keys(" ffzzlast"); + const answered = process.nowMs() - t0; + const listed = while (true) { + if (has(try f.screen(), "zzlast.txt")) break process.nowMs() - t0; + if (process.nowMs() - t0 > 30_000) return error.RowsNeverCame; + process.nap(5); + }; + try process.check(answered * 3 < listed, "kbdin's SPC f f answered after {d} ms, its row there after {d} ms: the listing ran in the write", .{ answered, listed }); + try f.keys("\x1b"); +} + +/// kbdin's `SPC s s` over a file of more than 64 KB: its declarations +/// parsed on a worker, as the keyboard's are, and listed. (Before, the +/// keys ran as a script's write, whose parse has no worker and leaves a +/// text this big unparsed: the picker listed nothing.) +fn symbolsOnWorker(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var d = try process.Detached.start(gpa, exe, "kbdsym", .{}); + defer d.deinit(); + const f = &d.files; + var text: std.ArrayList(u8) = .empty; + defer text.deinit(gpa); + // Two lines each: a declaration on one line is none (syntax.contextSpan). + for (0..4000) |i| try text.print(gpa, "fn f{d:0>4}() void {{\n}}\n", .{i}); + try text.appendSlice(gpa, "fn zzlastfn() void {\n}\n"); + try process.check(text.items.len > 64 << 10, "{d} bytes", .{text.items.len}); + var buf: [4096]u8 = undefined; + try @import("../e2e_harness.zig").writeFile(try std.fmt.bufPrintSentinel(&buf, "{s}/big.zig", .{d.root()}, 0), text.items); + try f.write("/look", f.at("{s}/big.zig\n", .{d.root()})); + try f.keys(" sszzlast"); + const t0 = process.nowMs(); + while (!has(try f.screen(), "zzlastfn")) { + if (process.nowMs() - t0 > 20_000) return process.check(false, "kbdin's SPC s s over big.zig listed nothing", .{}); + process.nap(10); + } + try f.keys("\x1b"); +} -- cgit v1.3