From 96e8398a38bba02e0ea5a9e59c14016dba270531 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 18 Nov 2026 06:20:16 -0300 Subject: session: a detached session's terminal deltas go a unit a frame, as a terminal's frame paces its output (waitInput), not a unit and a delta for every pty read: the unit sent at the step boundary is its clients' frame (drawn_ns), a client's acknowledgement of a delta no longer counts as an input (Peers.urgent: an input or a join wakes the step at once, an ack waits for the next frame), and its clients' echo is the frame's after an input (pardes.frame_ns, where a terminal of its own keeps its second); a session with no client and the own frontend's loop are as they were. cat of 20,000 lines in a shell pane of a client, tty, ReleaseFast, per cat: the session's own instructions on top 313.8M -> 74.8M (boundaries 9,165 -> 1,515 and units 11,460 -> 3,807 over the whole run), the client's 1,605M -> 145.7M with the client's loop change below it (own 115.3M); settled wall min 71.6 -> 35.1 ms, median 179.6 -> 131.9 ms (own 16.8 / 17.9; load 4-27, to retake quiet); window client's cat session 113.3M -> 81.5M Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- src/tui/tui.zig | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/tui') diff --git a/src/tui/tui.zig b/src/tui/tui.zig index 6d323183..7cc45e25 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -1107,6 +1107,10 @@ fn localSession( try core.pump(host); // Its unit to each replica client, and theirs taken in. sh.peers.boundary(core); + // Detached, the unit is its clients' frame: its output is paced to + // it as a terminal's frame paces it (waitInput), a unit a frame, not + // a unit and a delta for every read of a flood. + if (sh.peers.recording and sh.detached()) sh.drawn_ns = @intCast(std.Io.Clock.awake.now(io).nanoseconds); upgrade.locate(); // Asked in the step (the word), done between steps: the session whole. if (sh.upgrade_asked) |pane| sh.upgradeNow(pane); @@ -1580,9 +1584,13 @@ const Shell = struct { // (its frame held for the terminal's answer, FrameAck), or the // focused pane's output soon after one, its echo (a remote shell's // an RTT later). + // Detached, its clients' echo is the frame's after an input: what a + // flood says after that goes a unit a frame (their own echo is + // predicted, src/echo.zig), not a unit and a delta a read for a second. + const echo_ns: u64 = if (s.detached()) pardes.frame_ns else std.time.ns_per_s; while (!paced and s.output_seen and !s.input_seen and !s.core.quit and s.test_clock == null) { if (s.input_ns > s.drawn_ns) break; - if (s.focused_ns > s.drawn_ns and s.focused_ns -| s.input_ns < std.time.ns_per_s) break; + if (s.focused_ns > s.drawn_ns and s.focused_ns -| s.input_ns < echo_ns) break; const due = s.drawn_ns + pardes.frame_ns; const now: u64 = @intCast(std.Io.Clock.awake.now(s.io).nanoseconds); if (now + std.time.ns_per_ms > due) break; @@ -1729,7 +1737,9 @@ const Shell = struct { s.peers.handed(j.fd, j.view); s.input_seen = true; }, - .replica_mail => s.input_seen = true, + .replica_mail => if (s.peers.urgent.swap(false, .acq_rel)) { + s.input_seen = true; + }, .said => |said| if (s.client) |c| { // The session's units and deltas are a client's output // (waitInput paces it): a terminal's delta, or the unit -- cgit v1.3