diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-30 01:34:23 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-30 02:10:05 -0300 |
| commit | 3703c2526fb59708b00e12816bd88ffd8a15fc69 (patch) | |
| tree | bfec0f20e970edf6d41a9943446dd6a52296e0db /src/replica.zig | |
| parent | 965a78eafacbffb7cd25104181c81fe5871102c1 (diff) | |
| download | pardes-3703c2526fb59708b00e12816bd88ffd8a15fc69.tar.gz pardes-3703c2526fb59708b00e12816bd88ffd8a15fc69.zip | |
echo: a replica draws a key typed into a terminal at once, mosh's way (a printable character at the cursor, Backspace, Left and Right, in tty mode on the primary screen), from an overlay of its own that no digest, dump or rollback copy sees, painted over the terminal's body at the end of renderBody (the tty's and the GUI's); judged at each delta once the authority has the key and 50 ms have passed, every prediction taken back on a mismatch; drawn at once at a prompt pardes's marks vouch for, elsewhere only once an echo was confirmed, never after a drawn misprediction until one is, so a password prompt or a program that ignores input shows nothing typed; the keys typed behind one not predicted (Tab, Enter) predicted over the screen that shows its doing; zig build replicas -- --echo types a corpus into a played shell at 30/80/207 ms: a key to its character p50 239 -> 8.9 ms and p90 248 -> 15.8 ms at 207, no wrong character drawn; docs/next-daemon.md: the decisions, the hook for the remote client, the numbers, the gates and what is not done
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/replica.zig')
| -rw-r--r-- | src/replica.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/replica.zig b/src/replica.zig index 0b55a5bf..032e50af 100644 --- a/src/replica.zig +++ b/src/replica.zig @@ -467,6 +467,9 @@ pub const Replica = struct { /// Its terminals' screen state, as the authority's deltas made it. screens: [pardes.MAX_PANES]?ScreenOf = @splat(null), screen_out: std.ArrayListUnmanaged(u8) = .empty, + /// Its predicted echo (src/echo.zig), drawn over its core's terminals: + /// fed by its keys, its units and its deltas here, and by `echoFrame`. + echo: pardes.echo.Echo = .{}, const ScreenOf = struct { serial: u32, @@ -490,6 +493,7 @@ pub const Replica = struct { r.deinit(); return error.NoCore; } + if (screens) r.core().echo = &r.echo; return r; } @@ -538,6 +542,7 @@ pub const Replica = struct { try r.pending.append(r.gpa, .{ .seq = seq, .msg = msg }); r.dirty = true; r.settle(); + if (r.t.screen_state and r.diverged == null) r.echo.typed(r.core(), r.view, ev, seq, r.applied == r.pending.items.len); r.out.clearRetainingCapacity(); try r.out.appendSlice(r.gpa, msg); return r.out.items; @@ -548,6 +553,7 @@ pub const Replica = struct { if (r.diverged != null) return; const u = parseUnit(msg) orelse return r.fail("a unit too short to read"); r.stats.units += 1; + if (u.origin == r.id) if (r.t.core) |c| r.echo.confirmed(c, u.seq); const was = Stepping.begin(&r.t, &r.epoch); defer was.end(); if (u.origin == r.id and r.pending.items.len > 0 and r.pending.items[0].seq == u.seq and r.applied > 0 and @@ -716,6 +722,15 @@ pub const Replica = struct { return true; } + /// Its client's, once a frame before it draws: a predicted echo the + /// screen has not shown in time goes, and keys deferred behind one not + /// predicted are predicted once its doing is on the screen. Whether what + /// the overlay draws changed since the last call (by a key, a unit, a + /// delta or this: `echo.changed`). + pub fn echoFrame(r: *Replica) bool { + return r.echo.frame(r.core()); + } + /// Nothing pending and nothing applied: the replica is the authority's /// confirmed state, which `digest` says. pub fn quiet(r: *const Replica) bool { @@ -754,6 +769,7 @@ pub const Replica = struct { r.stats.apply_ns.append(r.gpa, nowNs() - t0) catch {}; sc.refused = false; terminal.takeMarks(state, applied.extra); + r.echo.delta(c, m.pane, sc.rep.top); // Its rows as the core keeps them read are another grid's. c.shell_rows.markStale(pane); var seq: [4]u8 = undefined; |
