diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-22 16:57:59 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-22 18:52:03 -0300 |
| commit | b3c38ea198e1fe915f029d7e41b469b8a53d2338 (patch) | |
| tree | d6db809889ae1412146ca9dc806fb7d61f8e2bd2 /runtime | |
| parent | 9863a63b614d200852853825031189364dcacfdc (diff) | |
| parent | 6401b327a217c144895e22fb7ad24d986af97d86 (diff) | |
| download | pardes-b3c38ea198e1fe915f029d7e41b469b8a53d2338.tar.gz pardes-b3c38ea198e1fe915f029d7e41b469b8a53d2338.zip | |
integration: the pair's chain on the gathered line: pardes-pair-10 (`vxutwuwz`, the pair's ten changes on pardes-merge50 past the four already gathered: a window's facts its client's (P47: WindowOpacity applied by a client window, `Font` gated by the desktop builds' capabilities, not the frontend's build), a window pair's session listed as a window's (P49), the user's terminal put back when a pair's client dies with no word (P48), a pair's user told a newer build is installed, an addon's landing on the tape and a client on the session's machine running a kind loaded by path (`Site.landing`, P51), an upgraded pair's session attended until its client is back, and test/daemon.py's `--with-pair`, `base_env`, `listed_as` and the Restore test as P44) on pardes-merge57 (the terminals' old road deleted, the wire at 30); two textual conflicts: core/replica.zig `Peer`'s fields (the pair's `bye` and `pair` kept, the deletion's removal of `sid` with its `Screens` kept) and test/daemon.py's head (the pair's `WITH_PAIR`, `base_env` and `listed_as` kept where the deletion had removed `KEEP`); the semantic ones the text did not show: the pair's `zwrkukrx` (`PARDES_TERM_BYTES`, its switch to the bytes road) merged without a conflict into core/replica.zig `takeJoined` (setting `r.t.screen_state`, a field the deletion removed), runtime/session.zig (`Peers.bytes`, removed) and test/process.zig (its passthrough): all three taken out, the gathered line's text there exactly, no road to choose (core/root.zig's machine_lines for replica.zig stays at the gathered line's 76: the pair's +1 was that getenv); test/daemon.py's two functions the gathered line added after the pair's base (`kept_views`, `kitty_image`) built their environment in the idiom `base_env()` replaced at every other site: now `base_env()` (the same without `--with-pair`; with it they run as a user who exported PARDES_PAIR, as every other mode does); the pair's `Peers.input` focus line, written after `screensOut` (deleted), stands alone before the step; `Site.landing` stays at the enum's end after `medium` (`images` gone): `wire.semantics` moves as any tape change does, no version line; and found by the gate: test/panes.zig's P51 test (the pair's, written on its old base) called `Authority.init` and `Replica.init` with the road's flag the deletion removed (pane-test did not compile): the argument removed, as merge57 did in core/jj.zig; nothing in core/tape.zig, abi/wire.zig or core/views.zig resolved by hand; gate (Debug tui in the workspace, loads 2-10): core-test 916/1073 (157 skipped), shell-test 1115/1118 (3 skipped), pane-test 182/183 (1 skipped: the base's + the P51 test), term-test 15/15, kitty-test 45/45, addon-test 5/5, behaviour-test and --replay 275/275, consumer-test, process-test own 0 of 146 and as pairs 0 of 146 (themesel first time as a pair, alone 0 of 5 first time and 5 of 5 on the runner's retry: pair-8's open case); the soak --clients 5 diverged 0, unequal 0 at 30/80/207 ms, unlisted 0, the corpus 22 of 22, no leak; daemon.py on Debug and ReleaseSafe: plain 3 of 3 each, --restore PASS each (P44's test, failing on the base), --pair, --attach-upgrading, --clients 3 of 3 each, --far PASS on ReleaseSafe and on Debug 3 of 3 alone (once at load 10 by_hash saw a client join again); --upgrade from the installed build PASS; with --with-pair every mode passes on both builds (plain, clients, manage, launch, relink, far, restore, attach-upgrading, pair, window-clients, gui, games, kitty-image), its --upgrade both ways past pair-10's wall and failing later (far_exec; a client's check differing after a ReleaseSafe-to-Debug Upgrade); the frame and perf gate against tree3 (gpu/pp11-g): 77/77 frames, perfab corpus2x +0.105% (noise 0.048%), 121 counts within 0.1% (largest terminal-on-all +0.085%)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/main.zig | 38 | ||||
| -rw-r--r-- | runtime/session.zig | 12 |
2 files changed, 31 insertions, 19 deletions
diff --git a/runtime/main.zig b/runtime/main.zig index aa35e687..5cdf5ee0 100644 --- a/runtime/main.zig +++ b/runtime/main.zig @@ -1583,17 +1583,17 @@ fn nativeMain(std_init: std.process.Init) !void { daemon.resumeLink(rec.link, rec.stub, kind, opts.ninep_name, rec.state orelse if (detached) .detached else .attached); } else if (paired) |fd| { // A window's pair's session: its first client on `fd`, the daemon - // its own to dial (and to start, when none runs). + // its own to dial (and to start, when none runs), listed as the + // window's (P49: only a window's pair execs one with `--paired`). opts.pair = fd; term = .detached; detached = true; - if (daemon.wanted()) _ = daemon.register(null, kind, opts.ninep_name, .pair); + if (daemon.wanted()) _ = daemon.register(null, .gui, opts.ninep_name, .pair); } else if (detach == null and std.c.getenv("PARDES_PAIR") != null) { // The last step's way, behind its variable until it is the default: // this terminal or window a client of a session forked off for it // (`pair`). - pair(init, &opts, args); - term = .detached; + term = if (pair(init, &opts, args)) |kept| .{ .pair = kept } else .detached; } else if (daemon.wanted()) { if (detach != null or pardes.platform == .gui) { // A session started detached is kept from birth: a pair's word. @@ -1756,9 +1756,11 @@ fn pardesBeside(buf: *[4104]u8) ?[:0]const u8 { /// effects (runtime/session.zig). A window's child execs the `pardes` /// beside it (`--paired=FD` first, its arguments after), which dials the /// daemon itself: a window's session loop is woken through SDL (gui.zig -/// `sdlWake`), a terminal's needs none. Returns in a terminal's session; -/// the client exits. No fork to be had: returns, and this process is the -/// session, with no terminal: said by the caller's run. A window with no +/// `sdlWake`), a terminal's needs none. Returns in a terminal's session, +/// with the terminal its client draws on, cooked as it is now (P48: put +/// back if that client dies with no word); the client exits. No fork to +/// be had: returns, and this process is the session, with no terminal: +/// said by the caller's run. A window with no /// `pardes` beside it returns at once, its own session as before. /// A terminal's launch with no terminal to draw on (a detached pty, a /// daemon): said, not an error trace, and exit 1. @@ -1767,23 +1769,22 @@ fn noTerminal(io: std.Io) noreturn { std.process.exit(1); } -fn pair(init: std.process.Init, opts: *pardes.Options, args: []const [:0]const u8) void { +fn pair(init: std.process.Init, opts: *pardes.Options, args: []const [:0]const u8) ?@import("dev").tui.Kept { var path_buf: [4104]u8 = undefined; var fd_buf: [32]u8 = undefined; var argv: [64:null]?[*:0]const u8 = @splat(null); if (pardes.platform == .gui) { - const path = pardesBeside(&path_buf) orelse return; - if (args.len >= argv.len - 1 or std.c.access(path, std.c.X_OK) != 0) return; + const path = pardesBeside(&path_buf) orelse return null; + if (args.len >= argv.len - 1 or std.c.access(path, std.c.X_OK) != 0) return null; argv[0] = path.ptr; for (args[1..], 2..) |a, k| argv[k] = a.ptr; } // Its client draws on /dev/tty: none to be had, said as the own path - // says it, before a session is forked for nobody. - if (pardes.platform == .tui) { - const tty = std.c.open("/dev/tty", .{ .ACCMODE = .RDWR, .CLOEXEC = true }, @as(std.c.mode_t, 0)); - if (tty < 0) noTerminal(init.io); - _ = std.c.close(tty); - } + // says it, before a session is forked for nobody. The session keeps it, + // cooked as it is now. std.posix's termios: glibc's is a bigger struct. + const tty: c_int = if (pardes.platform == .tui) std.c.open("/dev/tty", .{ .ACCMODE = .RDWR, .CLOEXEC = true }, @as(std.c.mode_t, 0)) else -1; + if (pardes.platform == .tui and tty < 0) noTerminal(init.io); + const cooked = if (tty >= 0) std.posix.tcgetattr(tty) catch null else null; const conn: ?c_int = if (pardes.platform == .tui and daemon.wanted()) daemon.connect(true) else null; var fds: [2]c_int = undefined; if (std.c.socketpair(std.c.AF.UNIX, std.c.SOCK.STREAM | std.c.SOCK.CLOEXEC, 0, &fds) != 0) @@ -1815,8 +1816,11 @@ fn pair(init: std.process.Init, opts: *pardes.Options, args: []const [:0]const u // The daemon is the client's to start; the hello is this one's. daemon.startPending(false); if (conn) |c| _ = daemon.register(c, .tty, opts.ninep_name, .pair); - return; + if (cooked) |t| return .{ .fd = tty, .termios = t }; + if (tty >= 0) _ = std.c.close(tty); + return null; } + if (tty >= 0) _ = std.c.close(tty); _ = std.c.close(fds[0]); if (conn) |c| _ = std.c.close(c); daemon.startPending(true); diff --git a/runtime/session.zig b/runtime/session.zig index 75e8efcc..50497560 100644 --- a/runtime/session.zig +++ b/runtime/session.zig @@ -23,7 +23,8 @@ //! - `start(l)`: after the first effects, the ptys and the watches //! read: its input, its readers, the listener's wake, a detached //! session's first wait (`l.watch`). -//! - `sent()`: after each step's unit went to the clients. +//! - `sent()`: after each step's unit went to the clients (a pair's +//! client gone with it: before its session ends). //! - `upgradeAsked()`: an Upgrade asked in the step, done (it execs). //! - `restoring(nc)`, `restored(l)`: a Restore's new core, before it //! replaces the old one (its devices let go, what it is told of the @@ -130,11 +131,18 @@ pub fn Loop(comptime Frontend: type) type { try l.core.pump(l.host); // Its unit to each replica client, and theirs taken in. l.peers.boundary(l.core); + // Before a pair's end: its client's terminal put back (P48). + fe.sent(); + // A pair's client stands for the frontend it was started + // for: at its focus in, a newer build said (upgrade.zig). + if (l.peers.pair_focused) { + l.peers.pair_focused = false; + upgrade.noticeNewer(l.core); + } // A pair's session with no daemon ends with its last link: // nothing could attach to it again; with one, when its last // client left with a close (not a loss) and it is not kept. if (l.peers.count() == 0 and (l.peers.closed or (o.pair != null and daemon.link < 0))) break; - fe.sent(); upgrade.locate(); // Asked in the step (the word), done between steps: the // session whole. |
