From fe650384496d7ff8234fc10e62ea46c18c599b46 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 19 Nov 2026 20:43:55 -0300 Subject: core: the two tests that failed when their edits straddle a wall-clock second compare what was done, not when, and a failed rollback test no longer poisons the next: an edit stamps its text's mtime with the second (core/File.zig:782, CLOCK_REALTIME through tape.value(.mtime)), so rollback's "a copy put back..." (rollback.zig:599) and Places' "...loaded from its dump..." (Places.zig:893), each comparing whole-core digests of one edit made twice a moment apart, failed whenever a second turned between them (reproduced at will with an LD_PRELOAD that makes each CLOCK_REALTIME read a second later: 1 of 1 each; plainly 0 of 50 and 0 of 104 started 5-60 ms before a second turned); no clock can be handed in there (a tape's stamp answers only inside a step of a stepping tape, tape.zig:814, and Places' edit is no step), so each test sets the second edit's mtime to the first's before comparing, as draw.zig's twin test leaves mtime out by name; and the failed rollback test left syntax.held_trees pointing into its dead Epoch (Epoch.begin sets it, only end puts it back), so the next test ("a text written in place...") panicked in syntax.parseTree: Epoch.deinit now lets go of a hold that is its own (+3, product code no user could reach: an epoch dies held only in a failed test); with the shim the rollback file passes 14/14 and Places' 8/8, 50 runs each plain and shimmed 0 failures (load 17-18); tui core-test 848/991 (143 skipped), the base's Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/Places.zig | 3 +++ core/rollback.zig | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/core/Places.zig b/core/Places.zig index 1416dbd3..9ffbff88 100644 --- a/core/Places.zig +++ b/core/Places.zig @@ -890,5 +890,8 @@ test "a session's places loaded from its dump find what an edit makes as the ses pn.places.fill(p, pn, 0, frame_steps); try std.testing.expectEqual(@as(usize, 3), pn.places.hits.items.len); } + // An edit stamps the text with the wall clock's second (File.edit's + // mtime): the two cores' edits, a moment apart, can fall in two. + b.panes[b.view().active].?.file.?.mtime = a.panes[a.view().active].?.file.?.mtime; try std.testing.expectEqual(pardes.walk.digest(Pardes, a), pardes.walk.digest(Pardes, b)); } diff --git a/core/rollback.zig b/core/rollback.zig index 3d5ab921..c7d0a4e8 100644 --- a/core/rollback.zig +++ b/core/rollback.zig @@ -88,6 +88,9 @@ pub const Epoch = struct { } pub fn deinit(e: *Epoch) void { + // Gone with a copy still held (a test that failed between take and + // restore): the process-wide hold must not point into it. + if (pardes.syntax.held_trees == &e.trees) pardes.syntax.held_trees = null; var it = e.live.iterator(); while (it.next()) |kv| e.child.rawFree(@as([*]u8, @ptrFromInt(kv.key_ptr.*))[0..kv.value_ptr.len], kv.value_ptr.alignment, @returnAddress()); e.live.deinit(e.meta); @@ -579,6 +582,9 @@ test "a copy put back is the core as it was; one let go keeps what was done" { const gpa = e.allocator(); const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml", .image_allocator = gpa, .tree_sitter_allocator = gpa, .frame_allocator = gpa }); p.pump(.{}) catch {}; + const f = for (p.panes) |slot| { + if (slot) |pane| if (pane.file) |*file| break file; + } else return error.NoFile; const before = walk.digest(Pardes, p); var c: Copy = .{}; defer c.deinit(); @@ -588,6 +594,7 @@ test "a copy put back is the core as it was; one let go keeps what was done" { p.update(.{ .key = .{ .cp = pardes.Key.escape } }); p.pump(.{}) catch {}; const edited = walk.digest(Pardes, p); + const stamped = f.mtime; try std.testing.expect(edited != before); try std.testing.expect(c.restore()); try std.testing.expectEqual(before, walk.digest(Pardes, p)); @@ -596,6 +603,9 @@ test "a copy put back is the core as it was; one let go keeps what was done" { for (typed) |k| p.update(.{ .key = .{ .cp = k, .text = &.{k} } }); p.update(.{ .key = .{ .cp = pardes.Key.escape } }); p.pump(.{}) catch {}; + // An edit stamps the text with the wall clock's second (File.edit's + // mtime): the same typing in the next second is the same edit. + f.mtime = stamped; try std.testing.expectEqual(edited, walk.digest(Pardes, p)); c.release(); try std.testing.expectEqual(edited, walk.digest(Pardes, p)); -- cgit v1.3 From 261a652706c11615932b090f6572aa1732bff737 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 19 Nov 2026 20:55:36 -0300 Subject: test: the frame corpus's click is one write, so a loaded machine no longer keeps a 78th frame: `d.mouse("down")` and `d.mouse("up")` were two writes to the window's pty, and its test feed (dev/gui/gui.zig StdinFeed.pump) dispatches what one read gives, so a loaded window could read the press alone, draw its frame, and read the release a pass later: one more frame in the click scene, which keeps every frame, and every kept frame after it shifted (the coordinator's failure: 78 frames, 56 differ from frame 16, the click's first; made at will with 200 ms between the two writes: 78, 56 differ, the click scene 14 frames against 13; plain loaded runs 0 of 6 at load 12-44); the press and release now go in one write, one read, one pass, one step; nothing reads real time (the virtual clock was never the cause), and the window draws no extra frame a user's would not (a real click's two events are always apart); after: frames 77/77 in the quiet gate (gpu/robust-q, load ~25) and in 4 loaded runs at load 17-44, and 3 more runs after the change at load 29-41 with 16 busy loops of mine at nice 15, 77/77 each (the loaded gate itself reached no frame count: the window answered the snake's `Addon load` past the 9P client's 2 s reply deadline at load 46-50, runtime/9p_io.zig:1174, a deadline of the runtime's, said in the report) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- test/process/window.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/process/window.zig b/test/process/window.zig index 687b9000..00450a9b 100644 --- a/test/process/window.zig +++ b/test/process/window.zig @@ -426,8 +426,11 @@ fn corpus(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try d.mouse("wheel", -3, cell_w * 40, cell_h * 12); try k.keep(&d, from, "11 a wheel's glide, every frame", true); from = try k.mark(&d); - try d.mouse("down", 1, cell_w * 20, cell_h * 10); - try d.mouse("up", 1, cell_w * 20, cell_h * 10); + // The press and its release in one write (Detached.mouse's events), + // so the window reads them in one pass: written apart, a loaded + // machine let it read the press alone and draw a frame between, one + // more kept frame than the base's (78) and every one after shifted. + try d.typeKeys(f.at("\x1b]777;mouse;down;1;{d};{d}\x07\x1b]777;mouse;up;1;{d};{d}\x07", .{ cell_w * 20, cell_h * 10, cell_w * 20, cell_h * 10 })); try k.keep(&d, from, "11 a click moves the caret, every frame", true); from = try k.mark(&d); try d.typeKeys("gg"); -- cgit v1.3 From b92578b797e6907a355b23f52b9b5202aa5967e0 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 19 Nov 2026 20:55:36 -0300 Subject: test: three of the known process-test flakes wait on what they need, and grep's golden stops pinning a count still counting: winch typed its long line once `c-b` had started the pane's shell and the screen had held still 600 ms, so a loaded bash echoed it through the kernel before readline was up and drew it again, or ran it before the pane's own `ls` (12 of 20 runs failed, load 38-54; not the 600 SIGWINCHes: the tty drops a WINCH whose size did not change): it now waits for the pane's prompt row after its `ls`; headersweep and headersweep-restored waited for the echo's line, which the command pane's one body row shows only until `exit 0` follows it (10 of 20 failed, the wait timing out on a pane already at `exit 0`): they wait for the tag's `(echo SW''EPT-COL) exit 0`, which stays and names the whole swept command; grep's golden pinned `+Search 0+`, the count while a typed Grep's 80 ms pause and its worker still run, which the quiet machine's 60 ms stable probe caught and a loaded one not (9 of 20 failed): it waits for the query typed in, then for the final `+Search 0 `, and the golden says `0`; after, 50 runs each under load 42-98: winch 0, headersweep (both) 1 (the 8 s cap on the first frame at load 90, not a race), grep 0 of 45 (5 lost to a cache wipe); hscroll, pagercolor and Lspinfo did not fail in 50 runs each (left); cmdexit failed 1 of 50, a product race left for the terminal's owner (the report) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- test/process/tty_boot.zig | 15 +++++++++++---- test/process/tty_editing.zig | 6 ++++++ test/snapshots/grep.golden | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/test/process/tty_boot.zig b/test/process/tty_boot.zig index a5f42074..741f6260 100644 --- a/test/process/tty_boot.zig +++ b/test/process/tty_boot.zig @@ -300,6 +300,9 @@ fn restore(gpa: std.mem.Allocator, exe: [:0]const u8) !void { // when it comes up. Both headers used to run the word under the PRESS, on // the press, so a sweep of `echo SWEPT-COL` ran a bare `echo`. A right sweep // looks for what it swept the same way, and the other button cancels. +// What a sweep ran is waited for in its pane's tag, `(echo SW''EPT-COL) exit +// 0`, which stays: the echo's line shows in the pane's one body row only +// until `exit 0` follows it, and a loaded machine draws both in one frame. fn headersweep(gpa: std.mem.Allocator, exe: [:0]const u8) !void { var t = try Tty.init(gpa, exe, "headersweep"); defer t.deinit(); @@ -321,7 +324,7 @@ fn headersweep(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.style("col-sweeping"); try t.drag("middle", "@echo+16", 2); try t.release("middle", "@echo+16", 2); - try t.wait(8000, "SWEPT-COL"); + try t.wait(8000, "EPT-COL) exit 0"); try t.stable(700, 15000); try t.snap("col-swept"); // the workspace tag, the same @@ -335,7 +338,7 @@ fn headersweep(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.press("middle", "@echo", 1); try t.drag("middle", "@echo+15", 1); try t.release("middle", "@echo+15", 1); - try t.wait(8000, "SWEPT-WS"); + try t.wait(8000, "EPT-WS) exit 0"); try t.stable(700, 15000); try t.snap("ws-swept"); // a right sweep over part of a word looks for the part: `hay.txt` opens, @@ -399,7 +402,7 @@ fn headersweep_restored(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.style("col-sweeping"); try t.drag("middle", "@echo+19", 2); try t.release("middle", "@echo+19", 2); - try t.wait(8000, "RESTORED-COL"); + try t.wait(8000, "-COL) exit 0"); try t.stable(700, 15000); try t.snap("col-swept"); try t.press("left", "118", 1); @@ -415,7 +418,7 @@ fn headersweep_restored(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.style("ws-sweeping"); try t.drag("middle", "@echo+18", 1); try t.release("middle", "@echo+18", 1); - try t.wait(8000, "RESTORED-WS"); + try t.wait(8000, "-WS) exit 0"); try t.stable(700, 15000); try t.snap("ws-swept"); try t.done(); @@ -869,6 +872,10 @@ fn winch(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.start(31, 100, &.{ "-n", "3" }); try t.stable(700, 20000); try t.key("c-b"); + // Its shell at its prompt after its `ls` (a row of the 50-column pane + // holding `$` alone): typed into earlier, a loaded machine's bash echoed + // the line before its readline was up, or ran it before the `ls`. + try t.wait(20000, "\n $" ++ @as([47]u8, @splat(' '))); try t.stable(600, 8000); try t.send("for i in $(seq 600); do kill -WINCH $PPID; done; echo SUR''VIVED"); try t.key("enter"); diff --git a/test/process/tty_editing.zig b/test/process/tty_editing.zig index b5f0495c..63c75512 100644 --- a/test/process/tty_editing.zig +++ b/test/process/tty_editing.zig @@ -783,6 +783,12 @@ fn grep(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.key("g"); try t.stable(400, 5000); try t.send("zzqq"); + // Its count once the search is over (`0`): `0+` is while it still + // counts (its pause on the clock, then the worker), which a quiet + // machine's frame shows and a loaded one's not. The query typed in + // first: the pane's empty query counts `0` too. + try t.wait(10000, "Grep zzqq"); + try t.wait(10000, "+Search 0 "); try t.stable(700, 10000); try t.snap("nomatch"); try t.key("esc"); diff --git a/test/snapshots/grep.golden b/test/snapshots/grep.golden index 30c8612c..1d8d21ad 100644 --- a/test/snapshots/grep.golden +++ b/test/snapshots/grep.golden @@ -39,7 +39,7 @@ |9: +Search 3/3 Save Unattach Del |13: /tmp/pardes-snap/grep/cwd/sub/b.txt Save Term Collapse Follow Del == snap nomatch grid=180x31 cursor=11,15 -|14: ^ +Search 0+ Del +|14: ^ +Search 0 Del |15: Grep zzqq == snap esc grid=180x31 cursor=12,15 |14: 1 deep -- cgit v1.3 From 165f1f61a20dd95a9018177d66e6f4f40a4cb320 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 19 Nov 2026 20:55:36 -0300 Subject: lsp: "still loading the workspace" is said only when the server says it, so lspcomplete and lspcompletemoved pass: an empty answer inside the 250 ms after the server's initialize waits out that window for a progress notification and asks again, which stays, but it also posted " is still loading the workspace; the answer comes when it is done…" whether or not the server had said anything (`starting` alone, dev/lsp/lsp_client.zig:785), and zls says nothing, so the message was false and stayed on the message row after the (empty, right) answer; a Tab in a comment, the tests' first query, always lands in that window, so both failed on every base (their goldens' only difference); now the message and the trace's note need `c.loading` or `c.progress > 0`; a user saw it on the first completion after zls started; after, both 0 of 35 runs under load 46-65 (15 more lost to a cache wipe) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- dev/lsp/lsp_client.zig | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dev/lsp/lsp_client.zig b/dev/lsp/lsp_client.zig index 83aea44f..4ad8dace 100644 --- a/dev/lsp/lsp_client.zig +++ b/dev/lsp/lsp_client.zig @@ -783,8 +783,13 @@ fn answer(io: std.Io, arena: std.mem.Allocator, si: usize, req: lsp.Req, out: *s if (!try timedWait(c, io, startup_deadline)) break; } if (starting or c.loading or c.progress > 0) { - tr.note("{s} is still loading: waiting for it, then asking again", .{specs[si].name}); - post(si, .always, "{s} is still loading the workspace; the answer comes when it is done\u{2026}", .{specs[si].name}); + // Said only when the server says it: a startup window that ran + // out with no word of loading is asked again quietly, and the + // message row keeps what it had (an empty answer is an answer). + if (c.loading or c.progress > 0) { + tr.note("{s} is still loading: waiting for it, then asking again", .{specs[si].name}); + post(si, .always, "{s} is still loading the workspace; the answer comes when it is done\u{2026}", .{specs[si].name}); + } while ((c.loading or c.progress > 0) and c.gen == g and c.alive()) _ = try timedWait(c, io, nowMs() + 500); out.end = before; try attempt(c, io, si, arena, req, out, tr, g); -- cgit v1.3