diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-30 15:19:25 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-30 17:03:40 -0300 |
| commit | f2ede98aee0265e3506f5afd6039c70be7812767 (patch) | |
| tree | 284a64fc9fcf7ba777a20fad75cc6295d70695fb /src/detached/wire.zig | |
| parent | 08c9415dde1a1d5da2c20124c4fcd4c92783b290 (diff) | |
| download | pardes-f2ede98aee0265e3506f5afd6039c70be7812767.tar.gz pardes-f2ede98aee0265e3506f5afd6039c70be7812767.zip | |
remote clients: a pointer's hit carries the place it was made on (Layer.Place, on the wire, version 17) and a step resolves it from that, never from this process's frame (`surface`, `.local`), which a session never draws for a client: a window's pointer over a tag diverged it at once (the user's `tape byte 119`, 15 rejoins in 25 s) and a click there aborted it; a replay that meets a site its tape lacks, or makes a syscall that is none, is a divergence that goes on harmless (poisonOf), not a panic, and a speculation that makes one waits (Tty's shell lookup, untaped, is a value site now, as Shell's was); a copy over a queue is refused, not asserted; a session's last client, while no one else watches it, leaves it its layout (leaveView, settled as closeView is), which its rejoin copies; a redial waits only after an Upgrade's `refused` (a divergence's redialled a gone session 20 s); a dying session shuts its clients' links before its trace, and an --attach client ends its ssh and socket whatever way it exits; a far join's hashing stops at a blob once its client is let go (its leave waits for it in the step); a confirmed speculation's state is checked against its unit's digest, and the trace gives a key's and a pointer's words; test/daemon.py: 200 far joins level, a window's pointer swept over tags and body, ssh stand-in clients refused and detached, a client of a killed session ending in 2 s; in-process tests for each
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/detached/wire.zig')
| -rw-r--r-- | src/detached/wire.zig | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/detached/wire.zig b/src/detached/wire.zig index 1c9e554e..a809bebd 100644 --- a/src/detached/wire.zig +++ b/src/detached/wire.zig @@ -9,6 +9,8 @@ const builtin = @import("builtin"); const pardes = @import("../pardes.zig"); const config = @import("pardes_config"); +/// 17: a pointer's hit carries the place it was made on (Layer.Place) and +/// a tag hit its line, which the step resolves it by, not by its frame; /// 16: a far client says so, the session sends it its blobs' hashes before /// the rest and only the blobs it asks for, all of it in zstd (phase 6's /// content cache and zstd notes), and a client says its frontend (a window @@ -18,7 +20,7 @@ const config = @import("pardes_config"); /// part B); 14: the hello names a session and /// carries the semantics hash, and a ping is answered (phase 5's /// groundwork); 13: the frames went (phase 3). -pub const version: u16 = 16; +pub const version: u16 = 17; /// The terminal's build and the window's step alike (`semantics`). const family = switch (config.platform) { @@ -417,6 +419,17 @@ fn getMetrics(r: *std.Io.Reader) Error!?pardes.RowMetrics { return m; } +fn putPlace(w: *std.Io.Writer, at: pardes.Layer.Place) Error!void { + for ([_]u16{ at.viewport.x, at.viewport.y, at.viewport.w, at.viewport.h, at.cols, at.rows, at.context_rows }) |n| try w.writeInt(u16, n, .little); +} + +fn getPlace(r: *std.Io.Reader) Error!pardes.Layer.Place { + var n: [7]u16 = undefined; + for (&n) |*x| x.* = try r.takeInt(u16, .little); + if (n[6] > n[5]) return error.BadValue; + return .{ .viewport = .{ .x = n[0], .y = n[1], .w = n[2], .h = n[3] }, .cols = n[4], .rows = n[5], .context_rows = n[6] }; +} + fn putBodyHit(w: *std.Io.Writer, hit: ?pardes.Mouse.BodyHit) Error!void { try w.writeByte(@intFromBool(hit != null)); if (hit) |h| { @@ -426,12 +439,13 @@ fn putBodyHit(w: *std.Io.Writer, hit: ?pardes.Mouse.BodyHit) Error!void { try w.writeInt(u32, @bitCast(h.pixel_x), .little); try w.writeInt(u32, @bitCast(h.pixel_y), .little); try putMetrics(w, h.metrics); + try putPlace(w, h.place); } } fn getBodyHit(r: *std.Io.Reader) Error!?pardes.Mouse.BodyHit { if (!try getBool(r)) return null; - const hit: pardes.Mouse.BodyHit = .{ .serial = try r.takeInt(u32, .little), .row = try r.takeInt(u16, .little), .col = try r.takeInt(u16, .little), .pixel_x = try getF32(r), .pixel_y = try getF32(r), .metrics = (try getMetrics(r)) orelse return error.BadValue }; + const hit: pardes.Mouse.BodyHit = .{ .serial = try r.takeInt(u32, .little), .row = try r.takeInt(u16, .little), .col = try r.takeInt(u16, .little), .pixel_x = try getF32(r), .pixel_y = try getF32(r), .metrics = (try getMetrics(r)) orelse return error.BadValue, .place = try getPlace(r) }; if (!std.math.isFinite(hit.pixel_x) or !std.math.isFinite(hit.pixel_y)) return error.BadValue; return hit; } @@ -443,9 +457,11 @@ fn putTagHit(w: *std.Io.Writer, hit: ?pardes.TagHit) Error!void { try w.writeInt(u16, h.id, .little); try w.writeInt(u32, h.serial, .little); try w.writeInt(u16, h.col, .little); + try w.writeInt(u16, h.line, .little); try w.writeInt(u32, @bitCast(h.pixel_x), .little); try w.writeInt(u32, @bitCast(h.pixel_y), .little); try putMetrics(w, h.metrics); + try putPlace(w, h.place); } } @@ -456,9 +472,11 @@ fn getTagHit(r: *std.Io.Reader) Error!?pardes.TagHit { .id = try r.takeInt(u16, .little), .serial = try r.takeInt(u32, .little), .col = try r.takeInt(u16, .little), + .line = try r.takeInt(u16, .little), .pixel_x = try getF32(r), .pixel_y = try getF32(r), .metrics = (try getMetrics(r)) orelse return error.BadValue, + .place = try getPlace(r), }; if (!std.math.isFinite(hit.pixel_x) or !std.math.isFinite(hit.pixel_y)) return error.BadValue; return hit; @@ -618,7 +636,9 @@ pub fn clientBound(msg: ClientMsg) usize { .bye, .ping, .check, .far => 0, .screen_ack, .want => |bytes| bytes.len, .event => |ev| switch (ev) { - .mouse, .resize, .pdf_scroll, .pinch, .touch_scroll, .pointer_leave, .focus, .frontend => 0, + // Its hits' places (14 bytes each) past the slack. + .mouse => 28, + .resize, .pdf_scroll, .pinch, .touch_scroll, .pointer_leave, .focus, .frontend => 0, .key => |k| k.text.len, .paste => |b| b.len, .command => |line| line.len, |
