summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 14:33:20 -0300
committerGabriel Schneider <[email protected]>2026-11-20 14:52:49 -0300
commit1f731da28bd9983cc414839bd32372d183438164 (patch)
treebfcc603bfe156ee5c317f72535ba6564b1d217f5 /core
parent8a8ce0a6740e9a98ea37a70d401c3ba3fffe0ee1 (diff)
downloadpardes-1f731da28bd9983cc414839bd32372d183438164.tar.gz
pardes-1f731da28bd9983cc414839bd32372d183438164.zip
pair: `kept`, whole (P36): a session's state the daemon hears is one of attached, detached, pair, kept (daemon.State, its hello's and `state` word, numbered as the daemon's record said its bool), a `new --detach` (and the bare `--detach`) under PARDES_PAIR kept from birth, a pair's session `pair` until a Detach typed in any client makes it kept (daemon.keepSession, never cleared), an Upgrade carrying it (the record's `state` word), and Peers.kept deleted: a client's close ends the session only while it is `pair` (Peers.leave), the end condition no longer asks Options.pair but for the daemonless pair; `pardes ps` says `(tty)` of a pair's session not kept and `(tty, kept)` of a kept one, an own-path session's line unchanged (`(tty, has a frontend)`, `(tty, detached)`), and a bare attach takes any session without a frontend; test/daemon.py `pair_rows` rewritten (a `new --detach` kept, its clients ended by HUP and TERM: runs on; a pair `(tty)` across an Upgrade, its Detach `(tty, kept)` across another, its clients ended by TERM, KILL, HUP: runs on), `pair` and `gui_pair` read the new line, and gui_pair closes a window client of a `new --detach` session: it runs on; on the base `--pair` fails at "the client listed" (ps said `(tty, detached)`), here it passes (load 5-8), shell-test's record and bare-attach tests 32/32 and 9/9
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core')
-rw-r--r--core/replica.zig10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/replica.zig b/core/replica.zig
index 49787c76..b9ac789e 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -2059,10 +2059,10 @@ pub const Peers = struct {
/// No frontend of its own (the host says): with no client either, the
/// session is unattended.
detached: bool = false,
- /// Its last client left by closing its window, and no Detach was typed
- /// in any (`kept`): a pair's session ends there (runtime/session.zig).
+ /// Its last client left with a close (its window closed, its terminal
+ /// hung up) and the session is a pair's not kept (daemon.sessionState): it
+ /// ends there (runtime/session.zig).
closed: bool = false,
- kept: bool = false,
/// The worst a join cost the session's step, and the last one's dump.
join_ns: u64 = 0,
each_join: std.ArrayListUnmanaged(u64) = .empty,
@@ -2362,7 +2362,7 @@ pub const Peers = struct {
core.undrawn &= ~(@as(u8, 1) << @intCast(peer.view));
ps.closeViewOf(core, peer, peer.again);
if (ps.count() == 0) core.unattended = ps.detached;
- if (ps.count() == 0 and peer.close and !ps.kept) ps.closed = true;
+ if (ps.count() == 0 and peer.close and daemon.sessionState() == .pair) ps.closed = true;
ps.seq += 1;
ps.unit(0, ps.seq);
ps.letGo(peer);
@@ -2467,7 +2467,7 @@ pub const Peers = struct {
/// (`left`), its last word; the client goes, and its reader says so.
pub fn detach(ps: *Peers, k: u8) bool {
for (ps.list) |slot| if (slot) |peer| if (peer.view == k) {
- ps.kept = true;
+ daemon.keepSession();
var out: [wire.max_name + 8]u8 = undefined;
peer.last(wire.encodeServer(&out, .{ .left = ps.name[0..@min(ps.name.len, wire.max_name)] }) catch unreachable);
return true;