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/tty | |
| 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/tty')
| -rw-r--r-- | src/tty/tty.zig | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/tty/tty.zig b/src/tty/tty.zig index 430c020d..4c054021 100644 --- a/src/tty/tty.zig +++ b/src/tty/tty.zig @@ -153,7 +153,7 @@ pub const Command = struct { files_changed, fs_ready, /// A replica's connection, handed over by the daemon (Peers). - replica: posix.fd_t, + replica: daemon.Joining, /// A replica's reader posted: the step boundary takes it in. replica_mail, /// A replica client's: what the session streamed (replica.Link). @@ -1333,7 +1333,7 @@ pub fn remote(init: std.process.Init, opts: pardes.Options, path: []const u8, se defer have_store.deinit(); const have: ?*replica.Have = if (far) &have_store else null; var dial_t0 = std.Io.Clock.awake.now(io).nanoseconds; - var joined = replica.dial(gpa, path, session, &why, have) orelse Said.no(io, "{s}", .{std.mem.sliceTo(&why, 0)}); + var joined = replica.dial(gpa, path, session, &why, have, null) orelse Said.no(io, "{s}", .{std.mem.sliceTo(&why, 0)}); if (joined.semantics != wire.semantics) Said.no(io, "{s}", .{replica.Link.upgrade_words}); const allocs = pardes.memory.init(gpa); @@ -1445,7 +1445,7 @@ pub fn remote(init: std.process.Init, opts: pardes.Options, path: []const u8, se if (r.diverged != null) link.quit = true; } if (init.environ_map.get("PARDES_REPLICA_STATS")) |file| link.writeStats(file); - if (!link.gone) replica.bye(joined.fd); + if (!link.gone) replica.bye(joined.fd, r.diverged != null); // The link's reader ends with the link, posting as it goes: what it // and the terminal posted is let go until it has. Its end is read // before the drain, not after: its last post (`link_gone`) comes @@ -1482,7 +1482,7 @@ pub fn remote(init: std.process.Init, opts: pardes.Options, path: []const u8, se // are not sent again. if (have) |h| h.leaving(r.core()); dial_t0 = std.Io.Clock.awake.now(io).nanoseconds; - joined = replica.Link.redial(gpa, path, session, &why, have, r.diverged == null) orelse { + joined = replica.Link.redial(gpa, path, session, &why, have, r.diverged == null, joined.view) orelse { screen.leave(); Said.no(io, "could not join again: {s}", .{std.mem.sliceTo(&why, 0)}); }; @@ -1916,8 +1916,8 @@ fn deliverNote(ctx: *anyopaque, note: daemon.Note) void { }; loop.postEvent(.{ .adopted = .{ .pid = 0, .fd = -1 } }) catch {}; }, - .replica => |fd| loop.postEvent(.{ .replica = fd }) catch { - _ = libc.close(fd); + .replica => |j| loop.postEvent(.{ .replica = j }) catch { + _ = libc.close(j.fd); }, } } @@ -2338,7 +2338,7 @@ const Shell = struct { /// An upgraded session's terminals, each its view's again (`primary`, /// run's, entered already); in a fresh session each but the primary a /// view of its own, as `--attach` makes one. A view left with none - /// closes. + /// closes, but a replica client's, kept for its rejoin (views.away). fn resumeTerminals(s: *Shell, rec: *const upgrade.Record, primary: *Screen) void { if (comptime builtin.is_test) unreachable; const core = s.core; @@ -2348,8 +2348,11 @@ const Shell = struct { } s.terms = @splat(null); if (rec.nttys == 0) { - pardes.views.only(core); + // The live view alone (never one kept for a rejoin) is the + // session's own. + for (0..pardes.views.max) |k| if (k != core.view and pardes.views.isOpen(core, @intCast(k)) and !pardes.views.isAway(core, @intCast(k))) core.closeView(@intCast(k)); s.terms[core.view] = primary; + primary.feed.view = core.view; return; } for (rec.ttys[0..rec.nttys]) |t| { @@ -2386,7 +2389,7 @@ const Shell = struct { sc.feed.view = t.view; s.terms[t.view] = sc; } - for (0..pardes.views.max) |k| if (pardes.views.isOpen(core, @intCast(k)) and s.terms[k] == null) core.closeView(@intCast(k)); + for (0..pardes.views.max) |k| if (pardes.views.isOpen(core, @intCast(k)) and s.terms[k] == null and !pardes.views.isAway(core, @intCast(k))) core.closeView(@intCast(k)); if (s.terms[core.view] == null) s.terms[core.view] = primary; } @@ -2623,8 +2626,8 @@ const Shell = struct { }, .attach => |a| s.attachTerminal(a.tty, a.stub, null), .adopted => |a| s.adoptShell(a.pid, a.fd), - .replica => |fd| { - s.peers.handed(fd); + .replica => |j| { + s.peers.handed(j.fd, j.view); s.input_seen = true; }, .replica_mail => s.input_seen = true, |
