diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-22 21:06:02 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-22 21:20:44 -0300 |
| commit | 1017496cc9c7e95a39b93928653e7ff338069152 (patch) | |
| tree | 47a771929d6d12bb76b9b4211590d85eab0f0376 /dev | |
| parent | 34e2d82a322bd3767a8ec62b3a4c0894399e8c04 (diff) | |
| download | pardes-1017496cc9c7e95a39b93928653e7ff338069152.tar.gz pardes-1017496cc9c7e95a39b93928653e7ff338069152.zip | |
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 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/Inbox.zig | 8 | ||||
| -rw-r--r-- | dev/gui/gui.zig | 2 | ||||
| -rw-r--r-- | dev/tui/tui.zig | 2 |
3 files changed, 8 insertions, 4 deletions
diff --git a/dev/Inbox.zig b/dev/Inbox.zig index d733b971..1df516cb 100644 --- a/dev/Inbox.zig +++ b/dev/Inbox.zig @@ -118,7 +118,9 @@ pub fn acceptReader(q: *Inbox, pane: pardes.Pane.Id, gen: u32) void { /// One of `pane`'s reads applied, or dropped unapplied. pub fn applied(q: *Inbox, pane: pardes.Pane.Id) void { const n = &q.unapplied[pane.index()]; - if (n.load(.acquire) > 0) _ = n.fetchSub(1, .acq_rel); + if (n.load(.acquire) == 0) return; + _ = n.fetchSub(1, .acq_rel); + pardes.turn.outputApplied(); } pub fn cancelReader(q: *Inbox, pane: pardes.Pane.Id, gen: u32) void { @@ -316,8 +318,10 @@ fn readPty(q: *Inbox, pty: std.Io.File, pane: pardes.Pane.Id, gen: u32) void { }, }; if (n == 0) continue; - // Counted at once: out of the pty, the poll no longer sees it. + // Counted at once: out of the pty, the poll no longer sees it, + // nor a write after it (Turn.awaitOutput). _ = q.unapplied[pane.index()].fetchAdd(1, .acq_rel); + _ = pardes.turn.reads.fetchAdd(1, .acq_rel); const bytes = q.gpa.dupe(u8, buf[0..n]) catch |err| { q.applied(pane); failure = err; diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig index 3193d966..b00073fa 100644 --- a/dev/gui/gui.zig +++ b/dev/gui/gui.zig @@ -2696,7 +2696,7 @@ fn waitInput(ctx: ?*anyopaque, timeout_ms: u32) void { s.held = null; if (held) |h| sev = h; // The wait is the 9P connections' turn with the core. - pardes.turn.rest(); + pardes.turn.listen(); const got = held != null or c.SDL_WaitEventTimeout(&sev, ms); pardes.turn.wake(); // A virtual clock: while a render-time animation moves, each loop 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; |
