diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-20 09:23:54 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 11:15:26 -0300 |
| commit | c6234f250ee6f94bdeb57e1d77045d74149325fa (patch) | |
| tree | 52cf0c0beb4dd7fcab41c39b0877278ada99b1b4 /abi | |
| parent | 446cde19a6b6fb7125fc749608cc12b7452dad6e (diff) | |
| download | pardes-c6234f250ee6f94bdeb57e1d77045d74149325fa.tar.gz pardes-c6234f250ee6f94bdeb57e1d77045d74149325fa.zip | |
pair: under PARDES_PAIR `pardes-gui FILE` is a window client and a session with no SDL (the last step's design 1.2, Z1's rest): the child of a fork before SDL_Init EXECS the `pardes` beside it (`--paired=FD` first, the window's arguments after; its end of the socket pair kept across the exec), since a window binary's session loop is woken through SDL (gui.zig `sdlWake` is the Inbox's and the Peers' wake) and the terminal's binary needs none; with no `pardes` beside it the window is its own session as before; the session registers itself (and starts the daemon when none runs); the window's close button ends the session when it was its last client and no Detach was typed in any (a CLOSE: the client's bye says so, wire byte 2, protocol 24), a killed window leaves it running (a LOSS), with no daemon it ends with its last link; a client dialling again after an Upgrade that moved the protocol now stops at the daemon's "run the same pardes at both ends" as at "runs another build" (it dialled 20 s in vain); test/daemon.py `gui_pair` (in --gui, alone --pair-gui; on the base: the window was its own session) and `upgrade_clients` (in --upgrade when a pardes-gui is beside each build); the window's start, ReleaseFast, medium.zig, offscreen test mode, one build alternated, instructions:u (perf stat total, perf record split by pid): own 387.9-393.3 M, pair 397.5-398.3 M = window client 379.8-380.5 M + session 17.6-17.9 M (wall best 260 ms own, 282 pair, NOT judged, load 12-14); idle pair 0 wakeups in 2 s on the session side, terminal client 0, a window client unmeasurable offscreen (SDL's offscreen driver polls ~920/s, the own window the same); tui core-test 858/1013 (155 skipped), shell-test 1053/1056, term 17/17, pane 183/184, kitty 45/45, behaviour 275/275 and --replay 275/275, process-test 0 of 144 failed, soaks --clients 5 and --bytes --clients 5 diverged 0 unequal 0 corpus 22, daemon.py plain, --far, --games, --window-clients, --gui and --upgrade both ways (the base built once, pfx-old) pass, gui unit-test 1650/1654 with the perf check's BaselineHarnessMismatch its one failure (loads 5-25)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'abi')
| -rw-r--r-- | abi/wire.zig | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/abi/wire.zig b/abi/wire.zig index 8713ba98..6c86685d 100644 --- a/abi/wire.zig +++ b/abi/wire.zig @@ -10,6 +10,8 @@ const pardes = @import("core"); const config = @import("pardes_options"); const build_info = @import("build_info"); +/// 24: a bye's byte says the client's window was closed (2), which ends a +/// pair's session at its last client; /// 23: a pane of a kind's frame names its rasters by key, their pixels /// crossing before it as strips of 4 MiB at most over the rows it shows /// (screen kind 5), and a replica lacking one asks for its pane again @@ -36,7 +38,7 @@ const build_info = @import("build_info"); /// 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 = 23; +pub const version: u16 = 24; /// The terminal's build and the window's step alike (`semantics`). const family = switch (config.platform) { @@ -296,8 +298,9 @@ pub fn helloVersion(payload: []const u8) Error!u16 { /// one call and no longer. pub const ClientMsg = union(enum) { hello: Hello, - /// The client's end: `again`, it joins again for its view at once. - bye: struct { again: bool = false }, + /// The client's end: `again`, it joins again for its view at once; + /// `close`, its window was closed (a pair's session ends at its last). + bye: struct { again: bool = false, close: bool = false }, /// A round trip's probe, answered `pong` with the same value. ping: u64, screen_ack: []const u8, @@ -514,7 +517,8 @@ pub fn encodeClient(out: []u8, msg: ClientMsg) Error![]const u8 { try putSlice16(&w, h.session); try w.writeByte(h.view orelse 0xff); }, - .bye => |b| try w.writeByte(@intFromBool(b.again)), + // 0 it leaves, 1 it joins again, 2 its window was closed. + .bye => |b| try w.writeByte(if (b.close) 2 else @intFromBool(b.again)), .ping => |v| try w.writeInt(u64, v, .little), .screen_ack, .want => |bytes| try w.writeAll(bytes), .check => {}, @@ -584,7 +588,12 @@ pub fn decodeClient(tag: u8, payload: []const u8) Error!ClientMsg { else => |k| k, }, } }, - .bye => .{ .bye = .{ .again = try getBool(&r) } }, + .bye => .{ .bye = switch (try r.takeByte()) { + 0 => .{}, + 1 => .{ .again = true }, + 2 => .{ .close = true }, + else => return error.BadValue, + } }, .ping => .{ .ping = try r.takeInt(u64, .little) }, .screen_ack => return .{ .screen_ack = payload }, .check => .check, @@ -699,6 +708,7 @@ test "detached wire: every Event variant round-trips" { try testing.expectEqualStrings("work", got.hello.session); } try testing.expect((try roundClient(&buf, .{ .bye = .{ .again = true } })).bye.again); + try testing.expect((try roundClient(&buf, .{ .bye = .{ .close = true } })).bye.close); try testing.expectEqual(@as(?u8, 2), (try roundClient(&buf, .{ .hello = .{ .session = "work", .view = 2 } })).hello.view); try testing.expectEqual(@as(u64, 0xfeed_beef_0000_0001), (try roundClient(&buf, .{ .ping = 0xfeed_beef_0000_0001 })).ping); { |
