diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-20 06:07:10 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 06:07:21 -0300 |
| commit | 26d0581168ac4b582025ecb01b36968850344811 (patch) | |
| tree | b91cab46612fa48c55d7ec93fbe802af5da6bf23 /dev/tui | |
| parent | 8d9f4c88072089b53c77ab7e66b01c461fbbee74 (diff) | |
| download | pardes-26d0581168ac4b582025ecb01b36968850344811.tar.gz pardes-26d0581168ac4b582025ecb01b36968850344811.zip | |
runtime, dev: the daemon's notes are the session loop's own, so `note` leaves the frontend calls (nine to eight: options, open, close, start, sent, upgradeAsked, restoring, restored): the loop's note puts an adopted shell on its queue (both frontends take it in their wait), hands a client's connection to Peers (joined at the next step boundary, its post the wake, as the window did) and wakes the queue for a new daemon's hello; the terminal's deliverNote, its adopted and replica messages and arms (in apply and in Own.close's drain) and the window's deliverNote and both Own.note are deleted, the terminal's Shell names its session loop (`session`) so that a quit before the first frame starts the daemon's reader through the loop's watch; and the test first: an Adopt's shells arriving while output fills the queue were dropped by Inbox.push, their masters closed and the shells lost with them (448 outputs in, the shell and the end of the list pushed, 448 taken), in the window today, and in the terminal once its notes came through this queue (vaxis's queue had made the daemon's thread wait); the queue now keeps room for one Adopt's shells beyond the output's (adopt_capacity, the ring 64 + 1 longer, the output's bound unchanged) and each pane's end of file beyond those; a user could have hit it: Adopt in a window while another pane floods; tui core-test 858/1009 (151 skipped), shell-test 1049/1052, term 17/17, pane 183/184, kitty 45/45, behaviour-test and --replay 275/275, process-test 0 of 144 failed (msg, pagercolor and exec-bigdrag failed once in the run, passed on their retries), soak --clients 5 diverged 0, unequal 0, checked/wrong 1874/0 1937/0 1831/0, quiet checks 597/0 673/0 779/0, unlisted 0, corpus 22 of 22, no leak; --bytes --clients 5 diverged 0, unequal 0, quiet checks 693/0 586/0 802/0, corpus 22 of 22, no leak, its one unlisted stop at `now` the base's; gui unit-test 1646/1650 with only BaselineHarnessMismatch; daemon.py plain, --far, --games (keys stopped 0 and 0), --window-clients, --upgrade both ways pass (load 8-22)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'dev/tui')
| -rw-r--r-- | dev/tui/tui.zig | 47 |
1 files changed, 10 insertions, 37 deletions
diff --git a/dev/tui/tui.zig b/dev/tui/tui.zig index 1b00d1b9..ecc52df0 100644 --- a/dev/tui/tui.zig +++ b/dev/tui/tui.zig @@ -97,16 +97,14 @@ fn kittyShmProbe(w: *std.Io.Writer, feed: *Feed) void { w.flush() catch {}; } -/// What the loop's queue carries: a terminal's input, a wake, what the -/// daemon and a replica's reader hand over. A pane's output and a worker's -/// answer are the session's queue's (Inbox, `takeQueue`). +/// What the loop's queue carries: a terminal's input, a wake, what a +/// replica client's reader hands over. A pane's output, a worker's answer +/// and the daemon's notes are the session's queue's (Inbox, `takeQueue`). const Msg = union(enum) { nop, /// The terminal's input ended: its end of file, a hangup. A session /// a daemon keeps carries on detached; any other ends. quit, - /// A shell a dead session left, its pty's master (daemon.Note.adopted). - adopted: struct { pid: posix.pid_t, fd: posix.fd_t }, /// A timed wait ran out: the core's next wake has come. wake, /// A SIGWINCH: a terminal changed size (Shell.winched). @@ -122,8 +120,6 @@ const Msg = union(enum) { paste_start, paste_end, fs_ready, - /// A replica's connection, handed over by the daemon (Peers). - 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). @@ -953,6 +949,7 @@ const Own = struct { .test_clock = host_io.testClock(), .peers = &l.peers, .ptys = &l.ptys, + .session = l, }; const sh = &o.sh; sh.screen = o.screen; @@ -983,7 +980,6 @@ const Own = struct { host_io.setExitWake(null, null); while (loop.tryEvent() catch null) |ev| switch (ev) { .paste => |b| gpa.free(@constCast(b)), - .adopted => |a| _ = libc.close(a.fd), else => {}, }; o.screen.art.deinit(gpa); @@ -1019,10 +1015,6 @@ const Own = struct { if (o.sh.upgrade_asked) |pane| o.sh.upgradeNow(pane); } - pub fn note(o: *Own, n: daemon.Note) void { - deliverNote(o.loop, n); - } - pub fn restoring(o: *Own, nc: *pardes.Pardes) void { const sh = &o.sh; const io = sh.io; @@ -1054,24 +1046,6 @@ fn clearNativeImages( kitty_handles.clearRetainingCapacity(); } -/// The daemon's thread: what it says, onto the loop's queue. -fn deliverNote(ctx: *anyopaque, note: daemon.Note) void { - const loop: *Loop = @ptrCast(@alignCast(ctx)); - switch (note) { - // A full queue wakes it anyway. - .relinked => _ = loop.tryPostEvent(.nop) catch false, - .adopted => |a| { - for (a.pids[0..a.n], a.fds[0..a.n]) |pid, fd| loop.postEvent(.{ .adopted = .{ .pid = pid, .fd = fd } }) catch { - _ = libc.close(fd); - }; - loop.postEvent(.{ .adopted = .{ .pid = 0, .fd = -1 } }) catch {}; - }, - .replica => |j| loop.postEvent(.{ .replica = j }) catch { - _ = libc.close(j.fd); - }, - } -} - /// A replica reader's post: the session's wait ends, and its step /// boundary takes the post in. fn wakeForReplica(ctx: ?*anyopaque) void { @@ -1103,6 +1077,9 @@ const Shell = struct { /// The session's ptys (runtime/session.zig's); a client's, an empty /// table over an empty queue. ptys: *host_io.Ptys, + /// The session's loop (its `watch`, the daemon's notes); a client's + /// and a test's, none. + session: ?*Own.Session = null, /// What `takeQueue` takes off the ptys' queue, and whether the loop /// was woken for it since it last did (one wake, not one a read ahead /// of the terminal's keys in the loop's queue). @@ -1563,7 +1540,7 @@ const Shell = struct { // without it, to be attached again. Gone before the first // frame, the reader that takes the daemon's `ok` (kept // waits on it) is not started yet: started here. - daemon.watch(s.loop, deliverNote); + if (s.session) |l| l.watch(); if (daemon.kept()) { if (!s.detached()) s.leaveTerminal(); return true; @@ -1571,11 +1548,6 @@ const Shell = struct { core.quit = true; return true; }, - .adopted => |a| s.ptys.adoptions.adoptShell(s.core, a.pid, a.fd), - .replica => |j| { - s.peers.handed(j.fd, j.view); - s.input_seen = true; - }, .replica_mail => if (s.peers.urgent.swap(false, .acq_rel)) { s.input_seen = true; }, @@ -1873,7 +1845,8 @@ const Shell = struct { // A client's draw done: its frame is its own to draw again. if (s.client) |cl| cl.link.dirty = true; }, - .fs_ready, .adopted => m.deinit(s.gpa, s.lsp_gpa), + .adopted => |a| s.ptys.adoptions.adoptShell(s.core, a.pid, a.fd), + .fs_ready => {}, else => s.ptys.queue.land(s.core, m), } } |
