diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-26 04:54:39 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-26 06:12:14 -0300 |
| commit | 02b64ff90ae2f82fb83a604f6d4ded3459a84620 (patch) | |
| tree | 066e398aac05727d7b64d3413fdbe92f6c204fcc /core | |
| parent | 5dab435d7262b87d2cf40d6a27cea9c2d981c2e8 (diff) | |
| download | pardes-02b64ff90ae2f82fb83a604f6d4ded3459a84620.tar.gz pardes-02b64ff90ae2f82fb83a604f6d4ded3459a84620.zip | |
Lsp, lsp_client, File, dump: a file of a language a server speaks, opened in a pane (a Look, a landing, a walk step, the boot's file, a restored session's), starts that server and tells it of the file on a worker of its own, so the file's first question finds it ready (agent V4's find for the comparison video, VIDEO2/STORY.md §4.1 and §10.2: pardes's first `gd` cost about 2.5 s where Helix's, LazyVim's and Doom's cost 0.05 s; the user was asked, the default yes); THE CAUSE: dev/lsp/lsp_client.zig spawned a server on the first query that needed it (its header's lifecycle), and that query paid the spawn, the handshake and the server's first parse of the file; THE FIX: an effect `lsp_open`, emitted beside the file's watch by File.open (look.open, Trail's step, the boot document) and dump.revivePane (a restored or upgraded session), performed through a Host entry `lsp_open` (tui, gui and macOS: Inbox.openLsp; not held for `threads_ok`: the boot's file and a restored session's are opened before the loop's threads start); dev/Lsp.zig `open` asks nothing for a file no spec speaks for (lsp.speaks, on the loop), else copies the pane's file (`snapshot`) and hands it to a worker of its own (`Opener`, one at a time: a file opened while one is under way is let go and told at its first query, syncDoc; one done is awaited, at once, before the next), which calls lsp_client.open: a spec disabled asks nothing, a binary not found disables the spec without a word (its first query says `language server for .py not found`, not every file opened), else `ensure` (the server started as a query starts it, `starting` and `ready` narrated as before, one per spec) and `syncDoc` (didOpen); nothing in the query log; not through Lsp.start (its cancel and join of the query in flight waits out a protected handshake, up to init_ms = 8 s, on the loop) nor `work` (the queries' one fixed region, memory.takeLspQuery); a picker's preview (Pick.preview, no pane) and a 9P `ctl get` (ninep/ctl.zig getFile, no File.open) start none; Lspinfo says `not started yet (a file of its opened starts it)`; docs/typ/setup.typ and reference.typ say when a server starts; THE HARNESSES (the coordinator's ruling: no test starts a server of this machine's): PARDES_LSP_OPEN=off starts none and is the process harnesses' default (test/process.zig's child environment, test/tty.zig, and test/fs.py, selfmount.py and daemon.py's base_env), so the `lsp` tty cases' zls is started by their first query as before; a test binary (builtin.is_test) starts none unless it says `on`, as the behaviour harness's language sessions do (Session.initLanguage, every spec the mock or off, `.lsp_open` drained as a host performs it, awaited); RUN (TEST FIRST): behaviour/language_servers.zig "a file of a server's language opened in a pane starts that server and tells it of the file, with no query asked; a picker's preview of one starts none, a second file no second server, and a server not installed is found silently" previews a.zig in Find's picker (Lspinfo: zls `not started yet`), opens it (zls `ready`, `docs 1`, the query count unchanged), opens b.zig (`docs 2`: the same server), and opens c.py and d.py with PARDES_LSP_PY naming no binary (pyright `disabled`, no query, nothing on the screen): fails on the base at language_servers.zig:367 (zls not started by the open), passes now; lsp_client.zig "a file opened whose server is not installed disables it without a word ..." opens two .py files with a status sink set: the spec disabled, no word posted, a query then `not found`; MEASURED (.scratch/walkui/T23/measure-v8.sh: VIDEO's probe.py, the screen polled every 50 ms, this change's Debug tui, a reflink copy of VIDEO2's V8 tree with clangd and its 27-file compile database, torque-parser.cc opened, `743ggfI` then `gd` 4 s after the start, until utils.h's `bool IsUpperCamelCase` shows): with PARDES_LSP_OPEN=off (the base's way) 1.97, 1.98, 1.97 s; started at the open 0.05, 0.05, 0.05 s; on VIDEO's tally with zls (measure.sh) both ways 0.05-0.10 s (zls starts and answers within one poll there); a user hit it on the first question of every file of a session's languages, about 2 s with clangd over a real project; NEW HOT PATHS: none per key or frame; per file opened, one effect more and on the loop lsp.speaks (the spec table's extensions); for a file a spec speaks for, a copy of its text (the snapshot a query makes) and a worker started; GATES: core-test 1130/1304 (174 skipped: +1), shell-test 1352/1355 (3 skipped: +1), pane-test 183/184, behaviour-test 286/286 (+1) and --replay 20 seeds of 70 steps, 0 failures, process-test 0 of 147 failed (3 skipped), term-test 17/17, kitty-test 45/45; the wire's semantics move (a Host entry, tape.shape); no dump change (effects are local, not dumped); the soak `replicas -- --clients 5 --rtt 30,80,207` dies on the base too (5dab435d7262, run here: `allocator leaks detected` at seed 0 rtt 80, MuPDF's allocations of documents a picker previewed, Pick.showKind), so run without the pdf addon (its binary, `--addon` image and life): diverged 0, unequal 0, quiet checks 468/0 251/0 657/0, stops not on may_wait 0, the corpus 22 of 22 scenes the same, no leak (a first run had one key stop at `spawn` at seed 3 rtt 80, exec.zig's rerun of a command pane, which emits a spawn with no `open a terminal` stop; the base's run and a second run had none); the gui unit-test run once, on T3's change over this one (its description); no frame or perf gate (the user's rule of 2026-11-26); load 1.1 to 9.1
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core')
| -rw-r--r-- | core/Effect.zig | 6 | ||||
| -rw-r--r-- | core/File.zig | 8 | ||||
| -rw-r--r-- | core/dump.zig | 6 | ||||
| -rw-r--r-- | core/lsp/lsp.zig | 6 |
4 files changed, 23 insertions, 3 deletions
diff --git a/core/Effect.zig b/core/Effect.zig index 3bca04c9..72244f2b 100644 --- a/core/Effect.zig +++ b/core/Effect.zig @@ -64,6 +64,10 @@ pub const Effect = union(enum) { /// `arg` up to 128 bytes, or for `explain` the query it explains, /// `<kind> <arg>`. lsp: struct { id: u32, kind: lsp.Kind, pane: Pane.Id, offset: u32, arg: Buf(160) }, + /// A file opened in pane `pane` (File.open, a session's revived pane): + /// the server its language speaks to started and told of it, off the + /// loop (dev/Lsp.zig open), so its first query finds it ready. + lsp_open: struct { pane: Pane.Id }, /// Snapshot the matching request with pipeRequest(id), then run it away /// from the UI/event loop and answer with pipe_resp. pipe: struct { id: u32 }, @@ -216,6 +220,8 @@ fn performInner(p: *Pardes, e: Effect) void { }, .lsp => |q| p.tape.host(p, .lsp, .{.{ .id = q.id, .kind = q.kind, .pane = q.pane, .offset = q.offset, .arg = q.arg.slice() }}) orelse p.update(.{ .lsp_resp = .{ .id = q.id, .rows = "" } }), + // No workers here (a test, a board): no server starts before a query. + .lsp_open => |o| _ = p.tape.host(p, .lsp_open, .{o.pane}), .pipe => |q| p.tape.host(p, .pipe, .{q.id}) orelse p.update(.{ .pipe_resp = .{ .id = q.id, .success = false, .outputs = &.{} } }), // No workers here (a test, a board): it runs on the loop. diff --git a/core/File.zig b/core/File.zig index 0f9178ac..d16b0c73 100644 --- a/core/File.zig +++ b/core/File.zig @@ -922,7 +922,13 @@ pub fn open(p: *Pardes, id: usize, path: []const u8, line: usize) !*Pane { pane.body.cur_pinned = true; pane.body.cur_row = @intCast(scroll); p.installPane(id, pane); - if (filesystem.localPath(path) != null) p.emit(.{ .watch = .{ .pane = .at(id), .on = true } }); + if (filesystem.localPath(path) != null) { + p.emit(.{ .watch = .{ .pane = .at(id), .on = true } }); + // Its language's server started now, off the loop: the first + // question asked of it finds it ready. Not a picker's preview's, + // which opens no pane (Pick.preview). + p.emit(.{ .lsp_open = .{ .pane = .at(id) } }); + } return pane; } diff --git a/core/dump.zig b/core/dump.zig index 2dde9c8c..d7c44b71 100644 --- a/core/dump.zig +++ b/core/dump.zig @@ -718,8 +718,9 @@ fn reviveSession(p: *Pardes, previous: ?*Pardes, resumed: bool) !void { } /// A loaded pane given to this host: a terminal a new shell in its old -/// one's directory under its history, a file watched again (one changed on -/// disk since comes back as it is now, one unsaved is marked changed), a +/// one's directory under its history, a file watched again and its +/// language's server started (one changed on disk since comes back as it +/// is now, one unsaved is marked changed), a /// kind's pane opened again (a PDF a build before the pdf addon dumped, as /// the addon's). fn revivePane(p: *Pardes, id: usize, pane: *pardes.panes.Pane, was_on_disk: bool) void { @@ -762,6 +763,7 @@ fn revivePane(p: *Pardes, id: usize, pane: *pardes.panes.Pane, was_on_disk: bool } else |_| {} } p.emit(.{ .watch = .{ .pane = .at(id), .on = true } }); + p.emit(.{ .lsp_open = .{ .pane = .at(id) } }); // Its file gone from disk since the dump: its text is nowhere else, so // it is said deleted, and Del, Exit and Restore ask first. One never on // disk (a name not yet saved) comes back as it was. diff --git a/core/lsp/lsp.zig b/core/lsp/lsp.zig index 7a636f72..00ffc98b 100644 --- a/core/lsp/lsp.zig +++ b/core/lsp/lsp.zig @@ -96,6 +96,12 @@ pub fn query(io: std.Io, arena: std.mem.Allocator, req: Req, out: *std.Io.Writer return client.query(io, arena, req, out); } +/// A file opened in a pane: its language's server started and told of it +/// (lsp_client.open), on a host's worker. +pub fn open(io: std.Io, arena: std.mem.Allocator, req: Req) !void { + return client.open(io, arena, req); +} + /// The one line the client answers with when it cannot answer at all, and /// why: the core says it rather than "nothing found". pub fn none(out: *std.Io.Writer, comptime fmt: []const u8, args: anytype) std.Io.Writer.Error!void { |
