summaryrefslogtreecommitdiff
path: root/core/echo.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-22 16:50:34 -0300
committerGabriel Schneider <[email protected]>2026-11-22 16:53:19 -0300
commit9863a63b614d200852853825031189364dcacfdc (patch)
treed235648a2ac14b3e311746ced3433ed6865e2061 /core/echo.zig
parent6544f73a6b50e5ba68564beea7784593bb54348e (diff)
parentbad506bd45846e012246a33b5d3097b3e92f02bc (diff)
downloadpardes-9863a63b614d200852853825031189364dcacfdc.tar.gz
pardes-9863a63b614d200852853825031189364dcacfdc.zip
integration: the old road deleted and the emulator's boundary on the gathered line: pardes-merge56 (`qvwrwxtu`: the installed tree and the source view's changes to their last slice) and pardes-term-join-9 (`twssqzqw`, fourteen changes on pardes-merge55: every client's terminals by the pty's bytes and nothing else: the delta protocol, its flow control and core/term/screen_state.zig deleted (-3,605 +504 lines), the wire at 30, one soak; S1: abi/term.zig's Ops in replicated and local, the terminal's digest covering what a step reads, every call of the core's into a terminal listed with its rule as a test; a client's own join again judged after its goodbye; a pty's size one fact the core hands its host for every fork, adopt and resize; a closed view sizes no terminal); no textual conflict; one semantic one, resolved here: core/jj.zig's Churn test (the layers' last round) called Authority.init and Replica.init with the road's flag the deletion took away: the argument removed; core-test 916/1073 (157 skipped), shell-test 1115/1118; its gate: .scratch/sketch/reorg/merge57, the numbers in PARDES.md (2026-11-22)
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/echo.zig')
-rw-r--r--core/echo.zig57
1 files changed, 26 insertions, 31 deletions
diff --git a/core/echo.zig b/core/echo.zig
index 95127f55..93b877b8 100644
--- a/core/echo.zig
+++ b/core/echo.zig
@@ -18,9 +18,10 @@
//! never drawn where the completion was not.
//!
//! Judged as mosh does, once the authority confirmed the key and `grace`
-//! passed: at a delta, a cell the screen shows goes, and one it does not is
-//! a misprediction, and every prediction goes. With no delta (nothing
-//! changed: no echo), a frame judges it `stale` later. Shown at once at a
+//! passed: when the terminal is fed a unit's output (`fed`), a cell the
+//! screen shows goes, and one it does not is a misprediction, and every
+//! prediction goes. With no output (no echo), a frame judges it `stale`
+//! later. Shown at once at a
//! shell's prompt (pardes's OSC 133 marks say its line editor echoes);
//! elsewhere only once an echo was confirmed there since the last key that
//! was not predicted (`cat`, a shell without marks), and underlined; never
@@ -37,19 +38,19 @@ const Key = pardes.Key;
const ms = std.time.ns_per_ms;
/// After the authority confirmed a key, how long its echo has to come back
-/// before a delta that does not show it makes a misprediction (mosh's
+/// before output that does not show it makes a misprediction (mosh's
/// ECHO_TIMEOUT): the shell's echo, then the authority's next frame.
// ponytail: fixed; a loaded host's later echo makes a drawn character go and
// come back. The echo delay measured per terminal would be the bound.
pub const grace_ns = 50 * ms;
-/// With no delta at all, how much longer a frame waits to judge a key.
+/// With no output at all, how much longer a frame waits to judge a key.
pub const stale_ns = 250 * ms;
const never = std.math.maxInt(u64);
/// Cells predicted at once: a line typed a round trip ahead.
const max = 64;
/// A cell predicted: `cp` at column `x` of absolute row `row` (the
-/// authority's numbering, screen_state's), a space for a cell backspace
+/// authority's numbering), a space for a cell backspace
/// cleared; `was` what the screen showed there before; `seq` the key's.
pub const Cell = struct { x: u16, row: u64, cp: u21, was: u21, seq: u32, due: u64 = never };
pub const Cursor = struct { x: u16, row: u64, seq: u32, due: u64 = never };
@@ -73,7 +74,7 @@ pub const Echo = struct {
view: u8 = 0,
pane: u8 = 0,
serial: u32 = 0,
- /// Each terminal's last delta: its active area's first row, absolute.
+ /// Each terminal's active area's first row, absolute, as last fed.
tops: [pardes.MAX_PANES]u64 = @splat(0),
cells: [max]Cell = undefined,
n: u8 = 0,
@@ -347,7 +348,7 @@ pub const Echo = struct {
};
if (e.wait <= seq and e.wait_due == never) {
// The authority stepped a key this did not predict, after every
- // one it did: its deltas from here show that key's doing, which
+ // one it did: its output from here shows that key's doing, which
// no prediction knew of. They go, judged neither way.
e.wait_due = due;
e.drop();
@@ -355,30 +356,24 @@ pub const Echo = struct {
e.catchUp(c);
}
- /// Terminal `id`'s delta was applied, its active area's first row now
- /// `top`.
- pub fn delta(e: *Echo, c: *Pardes, id: u8, top: u64) void {
- if (id == e.pane and top != e.tops[id] and (e.n > 0 or e.cursor != null)) {
+ /// The emulators were fed a unit's output (the session's echo among
+ /// it, perhaps): judged, the active area's first row its grid's.
+ /// ponytail: at the history's cap that row stops moving as the output
+ /// scrolls; a guess there is judged wrong and taken back, never kept.
+ pub fn fed(e: *Echo, c: *Pardes) void {
+ const pane = c.panes[e.pane] orelse return;
+ const g = Term.grid(pane.terminal orelse return);
+ const top = g.total - g.len;
+ if (top != e.tops[e.pane] and (e.n > 0 or e.cursor != null)) {
// Scrolled: the rows predicted are others now.
- e.tops[id] = top;
+ e.tops[e.pane] = top;
return e.lose();
}
- e.tops[id] = top;
- if (id == e.pane) e.judge(c, 0);
+ e.tops[e.pane] = top;
+ e.judge(c, 0);
e.catchUp(c);
}
- /// The pty's bytes road: the emulators were fed a unit's output (the
- /// session's echo among it, perhaps): judged as at a delta, the active
- /// area's first row its grid's. ponytail: at the history's cap that
- /// row stops moving as the output scrolls; a guess there is judged
- /// wrong and taken back, never kept.
- pub fn fed(e: *Echo, c: *Pardes) void {
- const pane = c.panes[e.pane] orelse return;
- const g = Term.grid(pane.terminal orelse return);
- e.delta(c, e.pane, g.total - g.len);
- }
-
/// Once a frame: what is stale judged. Whether to draw.
pub fn frame(e: *Echo, c: *Pardes) bool {
if (e.n > 0 or e.cursor != null) e.judge(c, stale_ns);
@@ -588,8 +583,8 @@ const Rig = struct {
g.now = 1_000 * ms;
// The one road: the shell's bytes in the units, fed to the
// replica's own emulator.
- g.a = try replica.Authority.init(gpa, .{ .cols = 60, .rows = 16, .boot = .tty_shell }, .{ .ctx = g, .vtable = &vtable }, false);
- g.r = try replica.Replica.init(gpa, 1, try g.a.unit(0, 0), false);
+ g.a = try replica.Authority.init(gpa, .{ .cols = 60, .rows = 16, .boot = .tty_shell }, .{ .ctx = g, .vtable = &vtable });
+ g.r = try replica.Replica.init(gpa, 1, try g.a.unit(0, 0));
g.r.core().echo = &g.r.echo;
g.shell = for (g.a.core.panes, 0..) |slot, id| {
if (slot) |pane| if (pane.isTerminal()) break @intCast(id);
@@ -671,8 +666,8 @@ test "keys typed at a shell's prompt are drawn at once, and the authority's echo
try testing.expectEqual(@as(u8, 's'), (try g.drawn(&arena, 3)).cp);
// The authority's core draws no overlay of its own.
try testing.expect(g.a.core.echo == null);
- // The authority takes them, its shell echoes, the delta lands after the
- // grace: confirmed, and the screen's own cells and cursor shown.
+ // The authority takes them, its shell echoes, its output lands after
+ // the grace: confirmed, and the screen's own cells and cursor shown.
try g.take(l);
try g.take(s);
try testing.expectEqualStrings("ls", g.written.items);
@@ -711,7 +706,7 @@ test "a password prompt shows nothing typed, and a full-screen program is not pr
try testing.expectEqual(@as(u32, 1), g.r.echo.stats.predicted);
try testing.expectEqual(@as(u8, ' '), (try g.drawn(&arena, x)).cp);
try g.take(k);
- // No echo, so no delta: a frame lets it go once it is stale.
+ // No echo, so no output: a frame lets it go once it is stale.
g.later(grace_ns + stale_ns);
_ = g.r.echoFrame();
try testing.expectEqual(@as(u8, 0), g.r.echo.n);