diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-17 22:06:33 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 22:23:50 -0300 |
| commit | 920110be4c597b4b93fc2d38179c09b335186253 (patch) | |
| tree | fb5a3eaebb48b8c52ec0e23540e5065d940995d0 /src/tui | |
| parent | 7d10ad68b07a7bbab23fa8565d39183e4387c478 (diff) | |
| download | pardes-920110be4c597b4b93fc2d38179c09b335186253.tar.gz pardes-920110be4c597b4b93fc2d38179c09b335186253.zip | |
words: a session with no frontend of its own is `detached` in the code, one word for what was `headless`, `parked`, `alone_unattended`, `Term.none` and `!attached()` (PARDES.md ruling 1): main.zig's and gui.zig's `headless` (run, runNative, localSession) are `detached`, tui.zig's `Term.none` is `Term.detached`, the window's `Shell.parked` (its Gui kept while detached) is `Shell.detached`, `replica.Peers.alone_unattended` is `Peers.detached`, and the terminal's `Shell.attached()` is `Shell.detached()`, its five callers and `watched` negated to match (a test's Shell with no screen is not detached, as it was attached); the tape's `headless`, a replica core that skips `render` and the host calls inside it (set on every client), is `skips_render`, its replay run named `skips-render` ("replay X: skips-render replica: N digests agree"), and the two that read that line follow (test/tty.zig's other-build replay, test/cross_replay.py); NOT renamed, a different fact: `Core.unattended` (detached AND no client: nobody looks), a watched field on the tape by index; names only, no logic moved; tui core-test 811/950 (139 skipped), shell-test 993/996, behaviour-test 269/273 (the four addon ABI tests the base fails) and the same with --replay, process-test 2 of 144 failed (lspcomplete and lspcompletemoved, the base's), replicas pass (checked/wrong 0), daemon.py main passes; gui frame corpus 77/77 byte-identical against mbase, unit-test 1582/1590 (the base's 8 failures)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src/tui')
| -rw-r--r-- | src/tui/tui.zig | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/tui/tui.zig b/src/tui/tui.zig index 7aebeb7a..1c6a3b7f 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -582,10 +582,10 @@ fn surfaceHasKittyKey(surface: *const pardes.Surface, key: u64) bool { /// Where a session's terminal comes from: /dev/tty, as a plain `pardes` /// opens it; one open already (a session forked off its stub, -/// daemon.forkSession); or none, until one is attached (`--detach`). +/// daemon.forkSession); or none, detached until one is attached (`--detach`). /// The terminal a session starts on: /dev/tty, one its stub opened (an /// upgraded session's is raw already, `termios` the cooked one), or none. -pub const Term = union(enum) { open, fd: struct { fd: posix.fd_t, termios: ?posix.termios = null }, none }; +pub const Term = union(enum) { open, fd: struct { fd: posix.fd_t, termios: ?posix.termios = null }, detached }; pub fn run(init: std.process.Init, opts: pardes.Options, term: Term) !void { const io = init.io; @@ -608,7 +608,7 @@ pub fn run(init: std.process.Init, opts: pardes.Options, term: Term) !void { switch (term) { .open => try screen.enter(try vaxis.Tty.init(io, &tty_buf)), .fd => |t| try screen.enter(try Screen.ttyOn(io, &tty_buf, t.fd, t.termios)), - .none => {}, + .detached => {}, } defer screen.leave(); @@ -1076,7 +1076,7 @@ fn localSession( // An upgraded session's terminals, its own again. if (comptime !builtin.is_test) if (upgrade.resumed) |*rec| sh.resumeTerminals(rec); // Nobody to see it, and nobody to size it: `size` sets it (ctl.zig). - sh.setAttended(sh.attached()); + sh.setAttended(!sh.detached()); while (core.nextEffect()) |effect| core.perform(effect); // ...and its shells, once a fresh session's own has a directory to // adopt them in. @@ -1130,7 +1130,7 @@ fn localSession( if (live.on) clearNativeImages(&live.kitty, &live.vx, &live.tty); nc.view().frontend.native_images = live.on and live.vx.caps.kitty_graphics; nc.unattended = !live.on; - sh.peers.alone_unattended = !live.on; + sh.peers.detached = !live.on; if (fs) |f| f.reset(nc); core.deinit(); core = nc; @@ -1264,7 +1264,7 @@ const Shell = struct { /// Whether anyone looks at the session: a terminal here, or a replica /// client (Peers keeps it attended while one is there). fn setAttended(s: *Shell, on: bool) void { - s.peers.alone_unattended = !on; + s.peers.detached = !on; s.core.unattended = !on and s.peers.count() == 0; } @@ -1333,14 +1333,15 @@ const Shell = struct { return if (s.core.live == s.own) s.screen else null; } - fn attached(s: *const Shell) bool { - const screen = s.screen orelse return true; - return screen.on; + /// No terminal of its own (a test's, with none at all, is not detached). + fn detached(s: *const Shell) bool { + const screen = s.screen orelse return false; + return !screen.on; } /// Drawn only while a terminal shows it. fn watched(ctx: ?*anyopaque) bool { - return of(ctx).attached(); + return !of(ctx).detached(); } /// Detach: the terminal put back and let go, the stub told (it ends, @@ -1349,7 +1350,7 @@ const Shell = struct { const s = of(ctx); // A replica client's: its link ends. if (s.peers.detach(s.core.live)) return; - if (!s.attached()) return s.core.reportFailure(s.core.view().active, "Detach: no terminal is attached"); + if (s.detached()) return s.core.reportFailure(s.core.view().active, "Detach: no terminal is attached"); if (!daemon.kept()) return s.core.reportFailure(s.core.view().active, "Detach: no pardes daemon keeps this session (it is its terminal's job)"); s.leaveTerminal(); } @@ -1538,7 +1539,7 @@ const Shell = struct { if (s.moving()) wait = 1; // Detached, nobody's key dismisses a message: they go on the clock // (the pump's, after this wait), which wakes it. - if (!s.attached()) { + if (s.detached()) { for (s.core.panes) |slot| if (slot) |pane| if (pane.msg_len > 0) { wait = if (wait == 0) 100 else @min(wait, 100); break; @@ -1714,7 +1715,7 @@ const Shell = struct { // waits on it) is not started yet: started here. daemon.watch(s.loop, deliverNote); if (daemon.kept()) { - if (s.attached()) s.leaveTerminal(); + if (!s.detached()) s.leaveTerminal(); return true; } core.quit = true; @@ -1744,7 +1745,7 @@ const Shell = struct { s.feed(.pointer_leave); s.feed(.{ .focus = false }); }, - .winsize => |ws| if (s.attached()) s.resized(s.screen, ws), + .winsize => |ws| if (!s.detached()) s.resized(s.screen, ws), .pty_read => |pr| { tookRead(s.io, pr.id); s.output_seen = true; |
