summaryrefslogtreecommitdiff
path: root/src/tui
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-18 10:19:31 -0300
committerGabriel Schneider <[email protected]>2026-11-18 10:19:31 -0300
commita2538c49b1bb69dcd1a6f1350834e13f68c3c05d (patch)
tree92c0cfb229d44974bf34ce6d4caa379142fbae44 /src/tui
parentb2f709d7130571658220636f33b5f89414a5101a (diff)
parent5c5e0102f92938f433a3465c92818be810c1ef78 (diff)
downloadpardes-a2538c49b1bb69dcd1a6f1350834e13f68c3c05d.tar.gz
pardes-a2538c49b1bb69dcd1a6f1350834e13f68c3c05d.zip
integration: addons in a client part 3 (the core's prerequisites and the double free; the PDF kind where it is shown: a plain record and pages as draws) with the client path's round 1: no conflict; tui core-test 820/959 (139 skipped), shell-test 994/997, behaviour-test 274/274, replicas pass, pane-test 180/181; gui unit-test 1588/1592 (its perf check refuses the baseline by compiler version, as on the base), the tui build has no SDL symbol, the frame corpus 74/77 against mbase in Debug and ReleaseFast: frames 58 to 60 show WindowOpacity's notice alone where the base stacked it under InactiveDim's (a PDF render's answer no longer lands between the two ctl writes: accepted, and the baseline recorded anew as mbase2 with those three frames), the perf window -0.405% (threshold 0.5%)
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src/tui')
-rw-r--r--src/tui/tui.zig76
1 files changed, 49 insertions, 27 deletions
diff --git a/src/tui/tui.zig b/src/tui/tui.zig
index 3938c854..5714ea0c 100644
--- a/src/tui/tui.zig
+++ b/src/tui/tui.zig
@@ -760,30 +760,34 @@ pub fn runClient(init: std.process.Init, opts: pardes.Options, path: []const u8,
while (!link.quit) {
// Its predicted echo judged and caught up, once a frame.
if (r.echoFrame()) link.dirty = true;
- if (link.dirty) client_link.draw(&sh);
- // The tty's own motions (its glide, a jump's trail) drawn a frame
- // a tick while they move, as waitInput wakes the local loop: a
- // wheel's glide was drawn only at the next event. After the
- // draw, which starts a glide, and after the last iteration's
- // wakes, as the latest asked for is the one kept.
- if (sh.moving()) {
- link.dirty = true;
- requestWake(io, @intCast(pardes.frame_ns / std.time.ns_per_ms));
- }
- const first = (loop.tryEvent() catch null) orelse idle: {
- // Idle, its frame drawn: the next key needs no copy taken.
- r.ready();
- break :idle loop.nextEvent() catch break;
- };
- var ev = first;
- var batch: usize = 1;
- while (true) {
- _ = sh.apply(ev);
- if (link.quit or (!sh.in_paste and batch >= 64)) break;
- ev = (loop.tryEvent() catch null) orelse break;
- batch += 1;
+ if (link.dirty) {
+ client_link.draw(&sh);
+ } else if (sh.moving() and r.core().surface.cells.len != 0) {
+ // The tty's own motions (its glide, a jump's trail): the last
+ // frame again, moved on, as the session's terminal draws them
+ // (`ownFrame`), not rendered again. One the terminal's answer
+ // holds is skipped (the next tick's moves on): nothing of it
+ // is written in the core, as `Client.draw` puts it back.
+ const skipped = r.core().present_skipped;
+ Shell.present(&sh, &r.core().surface);
+ r.core().present_skipped = skipped;
+ link.again += 1;
}
+ // Idle, its frame drawn: the next key needs no copy taken.
+ if (loop.tryEvent() catch null) |ev| sh.held = ev else r.ready();
+ // The session's own wait: an input drawn at once, the session's
+ // units and deltas a frame a tick at most, the tty's own motions
+ // on its grid of ticks; predictions judged a frame at a time.
+ var wait: u32 = if (r.echo.n > 0 or r.echo.cursor != null or r.echo.nd > 0) @intCast(pardes.frame_ns / std.time.ns_per_ms) else 0;
+ if (link.quietCheck()) |ms| wait = if (wait == 0) ms else @min(wait, ms);
+ Shell.waitInput(&sh, wait);
r.settle();
+ // A rollback since it drew (`toConfirmed`): its frame is drawn
+ // again, never moved on from cells the copy put back.
+ if (r.moved) {
+ r.moved = false;
+ link.dirty = true;
+ }
if (screen.caps_pending and screen.vx.queries_done.load(.unordered)) {
screen.caps_pending = false;
screen.vx.enableDetectedFeatures(screen.tty.writer()) catch {};
@@ -791,9 +795,6 @@ pub fn runClient(init: std.process.Init, opts: pardes.Options, path: []const u8,
link.dirty = true;
}
if (link.owed or r.echo.changed) link.dirty = true;
- // Predictions out: judged a frame at a time while they are.
- if (r.echo.n > 0 or r.echo.cursor != null or r.echo.nd > 0) requestWake(io, @intCast(pardes.frame_ns / std.time.ns_per_ms));
- if (link.quietCheck()) |ms| requestWake(io, ms);
if (r.diverged != null) link.quit = true;
}
if (init.environ_map.get("PARDES_REPLICA_STATS")) |file| link.writeStats(file);
@@ -1110,6 +1111,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);
@@ -1583,9 +1588,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;
@@ -1608,6 +1617,7 @@ const Shell = struct {
pardes.turn.rest();
const got = s.loop.nextEvent() catch {
pardes.turn.wake();
+ if (s.client) |c| c.link.quit = true;
s.core.quit = true;
return s.reloadWatched();
};
@@ -1731,8 +1741,20 @@ 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
+ // that answers its own input, is its echo, drawn at once.
+ s.output_seen = true;
+ const echo = switch (said) {
+ .screen => true,
+ .unit => |b| if (replica.parseUnit(b)) |u| u.origin == c.link.r.id else false,
+ else => false,
+ };
+ if (echo) s.focused_ns = @intCast(std.Io.Clock.awake.now(s.io).nanoseconds);
c.link.take(said);
if (said == .refused) return true;
} else switch (said) {