From 4c2125ecf47588d33f9894c1fdf2833d0512f3b4 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 03:20:04 -0300 Subject: client #2, one frontend a session: the daemon answers `other ` for an attach to a session attached already (as it did for one of the other kind), so a second `pardes --attach` or `pardes-gui --attach` on this machine is a replica client through the replica socket, the path a remote one takes; a session tells the daemon its clients (SO_PEERCRED on each replica socket, at every join and leave) and `--ps` lists `client ` under it; the tty's per-terminal Screens (Screen.create/drop/destroy, primary, its stub and Killed slot), the Poster and its `from` input, the Gui's window-fields swap (window_fields, GuiWindow, copyWindow, freshWindow, follow, route, openAnotherWindow, closeView, windowsOpen, closeOtherWindows, resumeWindows), drawOthers and every harness's extra terminals (snapshot.zig's `start ... views=N` and `view `, e2e_harness's initView and drainOthers, PARDES_TEST_VIEWS in both frontends, the GUI feed's `view;`, the monkey's --views) go; the pump draws the one view this process shows (views.shown), through drawOne when a client's input was the last; an Upgrade from a build that kept a second terminal of its own lets it go (its stub told it is detached) and closes its view; deleted: views.snap, views-term.snap and views-pan.snap with their goldens (the in-process second terminal they drove is gone; views.zig's unit tests keep the per-view cursor, layout, register, sizing, closing and panning behaviour, test/replicas.zig and the soak the views of clients); the two views.zig tests that drew through drawOthers draw through drawOne; daemon.py's second terminal is a client listed by --ps, typed into in both terminals, detached from inside and closed; its second window a client listed by --ps and closed; the reference and next-daemon.md say so; no golden changes; gates: core-test 956/956 both, behaviour-test 248/248 both, unit-test 1487/1488 tui and 1530/1531 gui, pane-test 171/172 both, snap all 102 ok, process-test 0 of 37 failed on both, hxdiff 19 and hxparity 6 mismatches (the base's names), hxgolf 0, replicas, addon-test, gui-golden and monkey-gui 0 of 1 failed, daemon.py main, --window-clients and --gui ok, soak local pass (differ, mispred, view_bad, lost 0) Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/views.zig | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'src/views.zig') diff --git a/src/views.zig b/src/views.zig index 0c96c792..354ae0d0 100644 --- a/src/views.zig +++ b/src/views.zig @@ -474,18 +474,11 @@ pub fn deinit(p: *Pardes) void { pub const Present = struct { ctx: ?*anyopaque, f: ?*const fn (?*anyopaque, *const pardes.Surface) void }; -/// Each view but the live one drawn and presented, the live one put back -/// after exactly as it was (`drawOne`). Before the live one's frame: the -/// surface after the pump is its. -pub fn drawOthers(p: *Pardes, h: pardes.Host) !void { - for (0..max) |i| { - const k: u8 = @intCast(i); - if (k == p.live or !isOpen(p, k) or (p.undrawn | p.views_away) & bit(k) != 0) continue; - // No post_present: what a shell acknowledges there moves the - // session's pointer and hover, which are the live view's to move; - // a view's panels are acknowledged when it is live and drawn. - try drawOne(p, k, .{ .ctx = h.ctx, .f = h.vtable.present }); - } +/// The view this process's frontend shows: the one open view that is no +/// replica client's (`undrawn`) and kept for none (`away`), if there is one. +pub fn shown(p: *const Pardes) ?u8 { + for (0..max) |i| if (isOpen(p, @intCast(i)) and (p.undrawn | p.views_away) & bit(i) == 0) return @intCast(i); + return null; } fn drawLive(present: Present, p: *Pardes) anyerror!void { @@ -782,7 +775,7 @@ test "a client's view kept for its rejoin: through an Upgrade's dump, each clien try testing.expect(!isAway(p, ks[0]) and isAway(p, ks[1])); } -test "drawing the other views leaves the live one as it was, to the digest" { +test "drawing another view leaves the live one as it was, to the digest" { const gpa = testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); defer p.deinit(); @@ -796,7 +789,7 @@ test "drawing the other views leaves the live one as it was, to the digest" { p.toView(0); cursorTo(p, pane, 95); const before = pardes.walk.digest(Pardes, p); - try drawOthers(p, .{}); + try drawOne(p, k, .{ .ctx = null, .f = null }); try testing.expectEqual(@as(u8, 0), p.live); try testing.expectEqual(before, pardes.walk.digest(Pardes, p)); p.toView(k); @@ -814,7 +807,7 @@ test "a view drawn while another is live keeps its own cursors" { try testing.expectEqual(@as(u16, 1), pane.body.nsel); p.toView(0); const before = pardes.walk.digest(Pardes, p); - try drawOthers(p, .{}); + try drawOne(p, k, .{ .ctx = null, .f = null }); try testing.expectEqual(before, pardes.walk.digest(Pardes, p)); p.toView(k); try testing.expectEqual(@as(u16, 1), pane.body.nsel); -- cgit v1.3