diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-30 21:00:30 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-30 21:53:52 -0300 |
| commit | d00c40694dc239854263616f710b4a197d25d145 (patch) | |
| tree | 3e7a980510e6c37507e0b60f1632cefc67d1c364 /src/daemon.zig | |
| parent | e6a114eed043dd1ca50be1cab912662fa9150fda (diff) | |
| download | pardes-d00c40694dc239854263616f710b4a197d25d145.tar.gz pardes-d00c40694dc239854263616f710b4a197d25d145.zip | |
views: a client that joins again has its own view back, layout, focus and the panes opened in it: an Upgrade's clients and one whose bye says it joins again (a divergence's, wire 19's `bye.again`) leave their view kept for them (`views_away`, digested and dumped, so an Upgrade's new build has it; taped `awayView`), the client names it in its next hello (`Hello.view`, handed on by the daemon with the connection) and its join takes it back (taped `rejoinView`) rather than a copy of the session's; the live view is never a kept one, `views.count` counts the others, and a join with every view taken lets one go (every Upgrade made each client's own panes leave its view: the hunt's 80 ms cell lost `+Search` and `+New`)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/daemon.zig')
| -rw-r--r-- | src/daemon.zig | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/daemon.zig b/src/daemon.zig index 467af8b8..b93f5d43 100644 --- a/src/daemon.zig +++ b/src/daemon.zig @@ -379,10 +379,13 @@ pub const Note = union(enum) { /// stub's pipe; for a window session, both -1: open a window. attach: struct { tty: c_int, stub: c_int }, adopted: struct { pids: [max_fds]libc.pid_t, fds: [max_fds]c_int, n: usize }, - /// A replica's connection, its hello taken (src/replica.zig `Peers`). - replica: c_int, + /// A replica's connection, its hello taken (src/replica.zig `Peers`), + /// and the view it joins again for, if it does. + replica: Joining, }; +pub const Joining = struct { fd: c_int, view: ?u8 = null }; + /// Hands every note the daemon sends on to `deliver`, on a thread of its /// own, until the link ends (`quit`). Called each loop: started once. pub fn watch(ctx: *anyopaque, deliver: *const fn (ctx: *anyopaque, note: Note) void) void { @@ -409,7 +412,8 @@ fn readNotes(fd: c_int, ctx: *anyopaque, deliver: *const fn (ctx: *anyopaque, no } }); for (got.fds[@min(got.nfds, 2)..got.nfds]) |f| _ = libc.close(f); } else if (std.mem.eql(u8, verb, "replica")) { - if (got.nfds >= 1) deliver(ctx, .{ .replica = got.fds[0] }); + const view = std.fmt.parseInt(u8, words.next() orelse "", 10) catch null; + if (got.nfds >= 1) deliver(ctx, .{ .replica = .{ .fd = got.fds[0], .view = view } }); for (got.fds[@min(got.nfds, 1)..got.nfds]) |f| _ = libc.close(f); } else if (std.mem.eql(u8, verb, "adopted")) { var note: Note = .{ .adopted = .{ .pids = undefined, .fds = undefined, .n = 0 } }; @@ -951,7 +955,9 @@ const Daemon = struct { } else return refuse(r, std.fmt.bufPrint(&why, "no session called '{s}'", .{h.session}) catch "no such session"); const t = &d.conns[target]; if (t.semantics != h.semantics) return refuse(r, std.fmt.bufPrint(&why, "session '{s}' runs another build of pardes (semantics {x:0>16}, this client's {x:0>16}): a replica needs the same build at both ends, as `pardes --version` shows", .{ h.session, t.semantics, h.semantics }) catch "another build"); - if (!send(t.fd, "replica", &.{r.fd})) { + var words: [16]u8 = undefined; + const note = if (h.view) |k| std.fmt.bufPrint(&words, "replica {d}", .{k}) catch unreachable else "replica"; + if (!send(t.fd, note, &.{r.fd})) { d.hangUp(@intCast(target)); return refuse(r, "that session does not answer"); } |
