summaryrefslogtreecommitdiff
path: root/src/tty/tty.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-30 02:17:56 -0300
committerGabriel Schneider <[email protected]>2026-10-30 03:13:15 -0300
commit44587446c2478de276b7c5c5a12063e6c7946b4e (patch)
treeb2789b64bf53495bb34590b1e58ccb7541236c16 /src/tty/tty.zig
parentf8a56c962d5103b84453d4305cd27973a71d4aa3 (diff)
downloadpardes-44587446c2478de276b7c5c5a12063e6c7946b4e.tar.gz
pardes-44587446c2478de276b7c5c5a12063e6c7946b4e.zip
remote client: predicted echo (src/echo.zig) over its own view, judged a frame at a time and woken while predictions are out; PARDES_NO_ECHO turns it off; a session's step that reads whether a terminal is at its prompt after its output (the first prompt's greeting, a command waiting for the prompt) is taped (`.prompt`), as a screen replica's emulator is the last delta's until the next
Found by a client opening a shell of its own (` nt`): the session's layout after the shell's first output saw the prompt and typed its greeting (`ls`, after a pty resize), and the client's replay of it, its emulator a delta behind, did not: it diverged at once. At 207 ms through the relay (Debug): a key into a shell on the client's screen p50 9.1 ms with prediction, 213.6 ms without. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/tty/tty.zig')
-rw-r--r--src/tty/tty.zig10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/tty/tty.zig b/src/tty/tty.zig
index e62da55c..b4eb6be9 100644
--- a/src/tty/tty.zig
+++ b/src/tty/tty.zig
@@ -1321,6 +1321,8 @@ const Remote = struct {
_ = std.fmt.bufPrint(why, "the session's dump would not load: {t}\x00", .{err}) catch {};
return null;
};
+ // PARDES_NO_ECHO: no predicted echo (the gates' baseline).
+ if (std.c.getenv("PARDES_NO_ECHO") != null) r.echo.on = false;
if (!r.loaded(joined.digest)) {
r.deinit();
_ = std.fmt.bufPrint(why, "the session's dump loaded as another session (a build's dump is not complete)\x00", .{}) catch {};
@@ -1525,7 +1527,7 @@ pub fn remote(init: std.process.Init, opts: pardes.Options, path: []const u8, se
try startInput(&loop, &screen);
defer stopInput(io, &screen.thread);
(try std.Thread.spawn(.{}, winchWatch, .{&loop})).detach();
- if (link.check != null) (try std.Thread.spawn(.{}, wakeWatch, .{ io, &loop })).detach();
+ (try std.Thread.spawn(.{}, wakeWatch, .{ io, &loop })).detach();
try screen.vx.queryTerminalSend(screen.tty.writer());
// A join a pass: the first, and one after the replica diverged or the
// session let it go to upgrade. The terminal stays as it is.
@@ -1544,6 +1546,8 @@ pub fn remote(init: std.process.Init, opts: pardes.Options, path: []const u8, se
sh.winched();
screen.vx.queueRefresh();
while (!link.quit) {
+ // Its predicted echo judged and caught up, once a frame.
+ if (r.echoFrame()) link.dirty = true;
if (link.dirty) link.draw(&sh);
const first = (loop.tryEvent() catch null) orelse idle: {
// Idle, its frame drawn: the next key needs no copy taken.
@@ -1565,7 +1569,9 @@ pub fn remote(init: std.process.Init, opts: pardes.Options, path: []const u8, se
screen.vx.queueRefresh();
link.dirty = true;
}
- if (link.owed) 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.animation.frame_ns / std.time.ns_per_ms));
if (link.check != null) {
// Quiet a while after a change: asked once (a wake, then the
// next quiet one).