From 1017496cc9c7e95a39b93928653e7ff338069152 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 22 Nov 2026 21:06:02 -0300 Subject: 9P: a request that changes the core waits for the output already read out of the ptys before it, as a terminal shows a program's output before what it led to: `cmd | pardes -` typed in a pane writes its pager over 9P after the shell echoed the line and started the command, and the session, which feeds its queue a read a step (dev/tui/tui.zig `takeQueue`), could still hold that echo when the write was served at its next rest (runtime/9p_io.zig `onServe`); the pager's layout then gave the shell's pane its rows as the stale emulator had its cursor (one short), and the emulator's resize cleared the command line as a prompt the shell would draw again (ghostty's Screen.clearPromptForRedraw: the cursor still after `133;B`, the `133;C` not yet fed), which bash, running the command, never did; process-test's `pagercolor` failed so as a pair 7 of 20 pinned to one CPU (a client's keys reach the shell a step each, so its echo comes a key a read: 55 reads queued in a failing run, the write served with seven still to feed) and on the own path 1 of 20 (its keys a burst a step: a read or two); now core/Turn.zig counts the reads (`reads`, by each pty reader as it reads, dev/Inbox.zig `readPty`, beside `unapplied`) and those applied or dropped (`applied`, `outputApplied` from `Inbox.applied`), and `awaitOutput` waits, the turn given up, until every read made before the request is applied, only while the editor waits in its loop (`listening`, set by the new `listen` in the tui's `waitOnce` and the window's `waitInput`, cleared by `wake`): resting in a call of its own (a save through its own mount, core/fs.zig `writeOut`) it applies nothing and the request goes first as before; `onServe` waits so for every request that `needsQuiet` and asks `quiet` after; a user could hit it typing or pasting `cmd | pardes -` in a pane of a session with a client attached, or under load on the own path (the pager open, the command line wiped from the shell's screen); pagercolor pinned to CPU 5 after: as a pair 20 of 20 first time, own path 20 of 20 (before: 13 of 20, 19 of 20); a core test of the rule (`Turn` now in core's test imports); core-test 918/1075 (157 skipped), shell-test 1116/1119 (3 skipped) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- dev/tui/tui.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dev/tui') diff --git a/dev/tui/tui.zig b/dev/tui/tui.zig index 5d75722f..ec5a3309 100644 --- a/dev/tui/tui.zig +++ b/dev/tui/tui.zig @@ -1494,7 +1494,7 @@ const Shell = struct { s.wake_to = s.core.nextWake() orelse if (s.moving()) s.core.clock.now_ns + pardes.frame_ns else 0; requestWake(s.io, wait); } - pardes.turn.rest(); + pardes.turn.listen(); const got = s.loop.nextEvent() catch { pardes.turn.wake(); if (s.client) |c| c.link.quit = true; -- cgit v1.3 From 0593b639b584e272518562e587f2a02cdfad8f5a Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 22 Nov 2026 21:20:39 -0300 Subject: tty: a pair's client glides on the case's clock, as the session's own terminal does: its Shell was built in `runClient` with no `test_clock`, so under PARDES_TEST_CLOCK its glide (dev/glide.zig: a scroll's picture, critically damped, at whole rows: a one-row glide's first frames keep the old rows) ran on the real clock, frames 16 ms apart with the process asleep between them, longer than a case's stable probe waits (test/tty.zig `waitStable`'s fast path, 50 ms unchanged and 10 ms asleep): process-test's `themesel` as a pair snapped the list's selection moved and the list not yet scrolled, 0 of 10 first time pinned to one CPU (the runner's retry, its probes wider, waited the glide out: why the retry always passed, open since pair-8); and the clock alone was not enough (0 of 10, now at the first scroll every time): the virtual clock jumps at each wake to `wake_to`, which `Shell.waitOnce` set from the core's clock, and a client's core clock is the session's, still between units, so its glide never moved: a client's `wake_to` while it glides is its own virtual clock plus a frame (the session's own unchanged); a user cannot hit it (the clock is the tests'); themesel as a pair pinned after: 10 of 10 first time; process-test as pairs 0 of 146 failed but for `root-ctl: Exit is answered` once (a detached start's socket not there in 20 s at load 8.6; 10 of 10 alone pinned), `tty boot: ninep`'s dial refused once in the parallel batch and passed alone (the base's, pardes-raw-tty's words), own path 0 of 146 with none failing first time Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- dev/tui/tui.zig | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'dev/tui') diff --git a/dev/tui/tui.zig b/dev/tui/tui.zig index ec5a3309..d1bbe140 100644 --- a/dev/tui/tui.zig +++ b/dev/tui/tui.zig @@ -791,6 +791,9 @@ pub fn runClient(init: std.process.Init, opts: pardes.Options, path: []const u8, .client = &c, .peers = &no_peers, .ptys = &no_ptys, + // Its own motions (the glide) on the case's clock, as a session's + // own terminal's (`Own.open`). + .test_clock = host_io.testClock(), }; tty = .{ .sh = &sh, .screen = &screen, .loop = &loop, .joins = &start }; no_inbox.wake_fn = Shell.wakeForQueue; @@ -1490,8 +1493,13 @@ const Shell = struct { } else next: { if (wait != 0) { // A virtual clock moves a frame a wake while the tty's own - // motions move (the glide), as the real one would. - s.wake_to = s.core.nextWake() orelse if (s.moving()) s.core.clock.now_ns + pardes.frame_ns else 0; + // motions move (the glide), as the real one would: a + // client's from where it is, its core's clock and wakes + // the session's, still between units. + s.wake_to = if (s.client != null) + (if (s.moving()) (s.test_clock orelse 0) + pardes.frame_ns else 0) + else + s.core.nextWake() orelse if (s.moving()) s.core.clock.now_ns + pardes.frame_ns else 0; requestWake(s.io, wait); } pardes.turn.listen(); -- cgit v1.3