summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-30 21:00:30 -0300
committerGabriel Schneider <[email protected]>2026-10-30 21:53:52 -0300
commitd00c40694dc239854263616f710b4a197d25d145 (patch)
tree3e7a980510e6c37507e0b60f1632cefc67d1c364 /src/pardes.zig
parente6a114eed043dd1ca50be1cab912662fa9150fda (diff)
downloadpardes-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/pardes.zig')
-rw-r--r--src/pardes.zig31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index 22f446a5..edab4a58 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -4732,6 +4732,8 @@ pub const Pardes = struct {
/// there are, one a window or terminal; each not live is in `parked`.
view: u8 = 0,
views_open: u8 = 1,
+ /// The open views kept for their clients' rejoin (views.away).
+ views_away: u8 = 0,
parked: [views.max]?*views.Parked = @splat(null),
/// The views no frontend here draws: a replica client's, which its own
/// process draws (src/replica.zig). A pump skips them.
@@ -5706,6 +5708,14 @@ pub const Pardes = struct {
pub fn openView(p: *Pardes) ?u8 {
const taped = tape.enter(p, .open_view);
defer tape.leave(p, taped);
+ // Every view taken: one kept for a client that has not come back
+ // for it (views.away) goes first. ponytail: no timer lets one go;
+ // until its place is wanted it costs a parked slot, and a terminal
+ // it sized last keeps that size until another view types into it.
+ if (@popCount(p.views_open) == views.max and p.views_away != 0) {
+ views.close(p, @ctz(p.views_away));
+ p.sync();
+ }
// What was queued since the last pump (a leaving client's view
// closed, a 9P request's step) done first, as every client of the
// tape does it here: a join dumps the session next, and a core
@@ -5740,6 +5750,27 @@ pub const Pardes = struct {
p.settle();
}
+ /// The client of view `k` gone, to join again for it (an Upgrade's
+ /// rejoin, a divergence's): its view kept as it is (views.away).
+ pub fn awayView(p: *Pardes, k: u8) void {
+ const taped = tape.enter(p, .{ .away_view = k });
+ defer tape.leave(p, taped);
+ views.away(p, k);
+ }
+
+ /// A client back for view `k`, kept for it (`awayView`): its own again,
+ /// as it left it; false when it was let go meanwhile. Settled as
+ /// `openView` is, for the join's dump next.
+ pub fn rejoinView(p: *Pardes, k: u8) bool {
+ const taped = tape.enter(p, .{ .rejoin_view = k });
+ defer tape.leave(p, taped);
+ if (!views.isAway(p, k)) return false;
+ p.views_away &= ~(@as(u8, 1) << @intCast(k));
+ p.settle();
+ p.needs_frame = true;
+ return true;
+ }
+
/// Into view `k`, before the input its client sent.
pub fn toView(p: *Pardes, k: u8) void {
if (k == p.view) return;