diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-21 17:31:13 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-22 02:33:28 -0300 |
| commit | 245dd088a5b502c72f94c85bf1cc5bd0ba7ebb56 (patch) | |
| tree | 8772fea20505fb9d5a959bcf2fc646a81c614994 | |
| parent | 242095c9e7e2eca11af92b9a0d563d640cfa65f2 (diff) | |
| download | pardes-245dd088a5b502c72f94c85bf1cc5bd0ba7ebb56.tar.gz pardes-245dd088a5b502c72f94c85bf1cc5bd0ba7ebb56.zip | |
terminals: every client's terminals by the pty's bytes, the one road (the user's ruling of 2026-11-22: "just start the structural fix"): a session's units carry its ptys' bytes and each client feeds its own emulator in the tape's order (`Peers.bytes`, set by runtime/session.zig unless PARDES_TERM_SCREEN, a working name for the way back until screen state's road is deleted), and the welcome says the road (wire 29: one byte before `blobs`; test/daemon.py `WIRE`), which a client loads its dump on BEFORE its digest check (`fromDump`, join's and confirmBoot's one load, written twice before, and `road`): the pair's switch (`zwrkukrx`, duplicated here) checked a client's dump on screen state and turned it after, so under bytes every `pardes --attach` to a session with a terminal was refused as "loaded as another session" (daemon.py:544 client C, a far client's first frame never drawn); the pair's own boot takes the road from its environment (its session is its child) and the welcome confirms it; the predicted echo stays on the one road: echo.zig's overlay was already drawn over the frame, only its arming (gated on screen state) and its retirement (a delta's version) were the old road's: armed whenever a replica has an echo, retired at each confirmed unit that fed a terminal (`Echo.fed`, the grid's active top), echo.zig's tests run on the bytes road (17/17 under the filter); the pump-lag test (a session's own step reading a terminal right after its output, in one pump, through `Peers`) passes here: there is no flush to be behind; test/process.zig and test/daemon.py keep PARDES_TERM_SCREEN (`KEEP`) for the way back's row; measured against screen state (reports/pardes-term-join-7.md, its table): typing at a far prompt 16 KB against 22 KB, a full-screen program 80 KB against 103 KB, a 1 MiB `cat` through 1 Mbit 607 KB and 5.2 s with one 2.2 s rejoin against 27 KB and 0.4 s, the echo predicted on both (10 ms at 200 ms RTT, 222 ms unpredicted); gated: core-test 904/1068, shell-test 1110/1113, term-test 19/19, process-test 0 of 145 and as pairs 0 of 145, the bytes soak 3 of 3 clean, daemon.py every mode on Debug and ReleaseSafe (--restore the base's), --upgrade from the installed build 3 of 3 and between the two builds both ways, --far whole 7 of 7 on ReleaseSafe, the frame and perf gate against tree3 PASS (77/77, corpus2x -0.053%, 121 counts within 0.1%, client cells within +0.045%), the cross-builds
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
| -rw-r--r-- | abi/wire.zig | 15 | ||||
| -rw-r--r-- | core/echo.zig | 39 | ||||
| -rw-r--r-- | core/replica.zig | 148 | ||||
| -rw-r--r-- | core/root.zig | 2 | ||||
| -rw-r--r-- | runtime/session.zig | 6 | ||||
| -rw-r--r-- | test/daemon.py | 63 | ||||
| -rw-r--r-- | test/process.zig | 5 |
7 files changed, 202 insertions, 76 deletions
diff --git a/abi/wire.zig b/abi/wire.zig index d7df7bc3..f87131bf 100644 --- a/abi/wire.zig +++ b/abi/wire.zig @@ -10,6 +10,10 @@ const pardes = @import("core"); const config = @import("pardes_options"); const build_info = @import("build_info"); +/// 29: a session's terminals reach its clients as the pty's bytes in its +/// units, each client's emulator its own; a welcome says the road (`bytes`; +/// screen state under PARDES_TERM_SCREEN), which the client loads its dump +/// on (replica.fromDump); /// 28: whether a terminal holds a kitty image is the session's, taped /// after its output (tape site `images`), and a pane's (Pane.term_images) /// in its join's dump and its digest: a screen-state client's tag says @@ -50,7 +54,7 @@ const build_info = @import("build_info"); /// part B); 14: the hello names a session and /// carries the semantics hash, and a ping is answered (phase 5's /// groundwork); 13: the frames went (phase 3). -pub const version: u16 = 28; +pub const version: u16 = 29; /// The terminal's build and the window's step alike (`semantics`). const family = switch (config.platform) { @@ -223,7 +227,7 @@ pub const ServerMsg = union(ServerTag) { /// dump that follows is, and the session's offset from UTC (a replica /// guesses the session's time of day). A far client is told how many /// blobs the dump holds (`blobs`). - welcome: struct { pid: u32, session: []const u8, client: u16 = 0, view: pardes.Pardes.View.Id = .at(0), dump_len: u64 = 0, gmtoff: i32 = 0, digest: u64 = 0, semantics: u64 = 0, blobs: u32 = 0 }, + welcome: struct { pid: u32, session: []const u8, client: u16 = 0, view: pardes.Pardes.View.Id = .at(0), dump_len: u64 = 0, gmtoff: i32 = 0, digest: u64 = 0, semantics: u64 = 0, bytes: bool = false, blobs: u32 = 0 }, refused: []const u8, pong: u64, dump: []const u8, @@ -259,6 +263,7 @@ pub fn decodeServer(tag: u8, payload: []const u8) Error!ServerMsg { .gmtoff = try r.takeInt(i32, .little), .digest = try r.takeInt(u64, .little), .semantics = try r.takeInt(u64, .little), + .bytes = try r.takeByte() != 0, .blobs = try r.takeInt(u32, .little), } }, .refused => .{ .refused = try r.take(try r.takeInt(u16, .little)) }, @@ -290,6 +295,7 @@ pub fn encodeServer(out: []u8, msg: ServerMsg) Error![]const u8 { try w.writeInt(i32, h.gmtoff, .little); try w.writeInt(u64, h.digest, .little); try w.writeInt(u64, h.semantics, .little); + try w.writeByte(@intFromBool(h.bytes)); try w.writeInt(u32, h.blobs, .little); }, .refused => |words| try putSlice16(&w, words), @@ -733,13 +739,14 @@ test "detached wire: every Event variant round-trips" { try testing.expectEqual(@as(u64, 0xfeed_beef_0000_0001), (try roundClient(&buf, .{ .ping = 0xfeed_beef_0000_0001 })).ping); { // The other way: framed the same, its tag the ServerTag's number. - const bytes = try encodeServer(&buf, .{ .welcome = .{ .pid = 42, .session = "work" } }); + const bytes = try encodeServer(&buf, .{ .welcome = .{ .pid = 42, .session = "work", .bytes = true } }); const f = (try framed(bytes)).?; try testing.expectEqual(@as(u8, 0x01), f.tag); - try testing.expectEqualSlices(u8, &.{ 42, 0, 0, 0, 4, 0, 'w', 'o', 'r', 'k', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, f.payload); + try testing.expectEqualSlices(u8, &.{ 42, 0, 0, 0, 4, 0, 'w', 'o', 'r', 'k', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, f.payload); const back = (try decodeServer(f.tag, f.payload)).welcome; try testing.expectEqualStrings("work", back.session); try testing.expectEqual(@as(u32, 42), back.pid); + try testing.expect(back.bytes); try testing.expectEqual(@as(u8, 0x03), (try framed(try encodeServer(&buf, .{ .pong = 7 }))).?.tag); } diff --git a/core/echo.zig b/core/echo.zig index f35c9f9d..95127f55 100644 --- a/core/echo.zig +++ b/core/echo.zig @@ -1,7 +1,7 @@ //! Predicted echo for a replica's terminal panes, mosh's way //! (docs/next-daemon.md, "Phase 6: predicted echo notes"). A key typed into -//! a terminal goes to the authority, and its echo comes back as screen state -//! a round trip later: this shows it at once. +//! a terminal goes to the authority, and its echo comes back in the pty's +//! bytes a round trip later: this shows it at once. //! //! Presentation only. The overlay is the replica's own (`Pardes.echo`, a //! `.local` field the rollback copy skips), painted over a terminal's body @@ -368,6 +368,17 @@ pub const Echo = struct { e.catchUp(c); } + /// The pty's bytes road: the emulators were fed a unit's output (the + /// session's echo among it, perhaps): judged as at a delta, the active + /// area's first row its grid's. ponytail: at the history's cap that + /// row stops moving as the output scrolls; a guess there is judged + /// wrong and taken back, never kept. + pub fn fed(e: *Echo, c: *Pardes) void { + const pane = c.panes[e.pane] orelse return; + const g = Term.grid(pane.terminal orelse return); + e.delta(c, e.pane, g.total - g.len); + } + /// Once a frame: what is stale judged. Whether to draw. pub fn frame(e: *Echo, c: *Pardes) bool { if (e.n > 0 or e.cursor != null) e.judge(c, stale_ns); @@ -557,8 +568,6 @@ const replica = @import("replica.zig"); const Rig = struct { a: *replica.Authority, r: *replica.Replica, - screens: replica.Screens, - peer: u16, shell: u8, /// What the authority wrote its shell's pty. written: std.ArrayListUnmanaged(u8) = .empty, @@ -577,10 +586,11 @@ const Rig = struct { const gpa = testing.allocator; g.written = .empty; g.now = 1_000 * ms; - g.a = try replica.Authority.init(gpa, .{ .cols = 60, .rows = 16, .boot = .tty_shell }, .{ .ctx = g, .vtable = &vtable }, true); - g.screens = .init(gpa); - g.peer = try g.screens.addPeer(); - g.r = try replica.Replica.init(gpa, 1, try g.a.unit(0, 0), true); + // The one road: the shell's bytes in the units, fed to the + // replica's own emulator. + g.a = try replica.Authority.init(gpa, .{ .cols = 60, .rows = 16, .boot = .tty_shell }, .{ .ctx = g, .vtable = &vtable }, false); + g.r = try replica.Replica.init(gpa, 1, try g.a.unit(0, 0), false); + g.r.core().echo = &g.r.echo; g.shell = for (g.a.core.panes, 0..) |slot, id| { if (slot) |pane| if (pane.isTerminal()) break @intCast(id); } else return error.NoShell; @@ -589,7 +599,6 @@ const Rig = struct { fn deinit(g: *Rig) void { g.r.deinit(); - g.screens.deinit(g.a.core); g.a.deinit(); g.written.deinit(testing.allocator); } @@ -599,25 +608,15 @@ const Rig = struct { g.r.echo.now = g.now; } - /// The shell prints `bytes`; the replica gets the unit and the delta. + /// The shell prints `bytes`; the replica gets the unit. fn prints(g: *Rig, bytes: []const u8) !void { g.a.output(.{ .output = .{ .pane = .at(g.shell), .bytes = bytes } }); try g.sync(); } fn sync(g: *Rig) !void { - const gpa = testing.allocator; if (try g.a.pending()) |u| g.r.confirm(u); g.r.settle(); - var msgs: std.ArrayListUnmanaged([]u8) = .empty; - defer { - for (msgs.items) |m| gpa.free(m); - msgs.deinit(gpa); - } - try g.screens.flush(g.a.core, g.peer, &msgs); - for (msgs.items) |m| if (g.r.screen(m)) |reply| { - _ = try g.screens.take(g.a.core, g.peer, reply); - }; } /// The replica's client types `k`; the message for the authority. diff --git a/core/replica.zig b/core/replica.zig index e26a9f17..993d9e2c 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -912,7 +912,7 @@ pub const Replica = struct { /// can be, its echo predicted. pub fn applyPended(r: *Replica, ev: pardes.Event) void { r.settle(); - if (r.t.screen_state and r.diverged == null) r.echo.typed(r.core(), r.view, ev, r.next_seq - 1, r.applied == r.pending.items.len); + if (r.diverged == null and r.core().echo != null) r.echo.typed(r.core(), r.view, ev, r.next_seq - 1, r.applied == r.pending.items.len); } /// One unit of the authority's stream, in its order. @@ -922,6 +922,9 @@ pub const Replica = struct { r.stats.units += 1; r.since_check +|= 1; if (u.origin == r.id) if (r.t.core) |c| r.echo.confirmed(c, u.seq); + // The pty's bytes fed its emulators: its predicted echo judged + // against them, as a screen-state delta judges it (`screen`). + defer if (!r.t.screen_state and r.diverged == null and tape.feedsTerminal(u.tape)) if (r.t.core) |c| if (c.echo != null) r.echo.fed(c); // A copy taken ahead (`ready`), nothing on top: it stays the point a // rollback goes back to, the unit replayed on it and kept in `since`, // not let go and taken again (a megabyte walked) for each unit of @@ -2162,8 +2165,9 @@ pub const Peers = struct { /// of each terminal as each version left it (test/replicas.zig). flushed: ?struct { ctx: *anyopaque, f: *const fn (*anyopaque, *Pardes, *Screens) void } = null, /// Its clients' terminals cross as the pty's bytes in its units, each - /// client's emulator its own (P29, P32), not as screen state: the - /// soak's (test/replicas.zig `--bytes`), until the switch. + /// client's emulator its own (P29, P32), not as screen state: every + /// session's (runtime/session.zig) but under PARDES_TERM_SCREEN, the + /// soak's `--bytes`; its welcome says so to each client. bytes: bool = false, pub const Note = union(enum) { join: Joining, input: Msg, screen: Msg, gone: *Peer, check: *Peer, joined: *Peer }; @@ -2421,7 +2425,7 @@ pub const Peers = struct { // (a pair's client, its own boot: `writeJoin`). const digest = tape.digestOf(core); peer.digest = digest; - peer.welcome_len = (wire.encodeServer(&peer.welcome, .{ .welcome = .{ .pid = @intCast(libc.getpid()), .session = ps.name[0..@min(ps.name.len, wire.max_name)], .client = peer.id, .view = peer.view, .dump_len = whole, .gmtoff = gmtoff(), .digest = digest, .semantics = wire.semantics, .blobs = @intCast(blobs.items.len) } }) catch unreachable).len; + peer.welcome_len = (wire.encodeServer(&peer.welcome, .{ .welcome = .{ .pid = @intCast(libc.getpid()), .session = ps.name[0..@min(ps.name.len, wire.max_name)], .client = peer.id, .view = peer.view, .dump_len = whole, .gmtoff = gmtoff(), .digest = digest, .semantics = wire.semantics, .blobs = @intCast(blobs.items.len), .bytes = ps.bytes } }) catch unreachable).len; if (ps.threads) peer.writer = std.Thread.spawn(.{}, Peer.writeLoop, .{peer}) catch null; if (ps.threads) peer.reader = std.Thread.spawn(.{}, Peer.readLoop, .{peer}) catch null; if (ps.threads and (peer.writer == null or peer.reader == null)) { @@ -2755,6 +2759,9 @@ pub const Joined = struct { /// Its replica is its own boot, the welcome not read yet (`ownBoot`, /// `confirmBoot`). booted: bool = false, + /// Its session's terminals come as the pty's bytes, not screen state + /// (the welcome's word, Peers.bytes). + bytes: bool = false, }; /// A blob a far join was sent: where it is in the dump, and its hash. @@ -2835,6 +2842,7 @@ fn joinOn(gpa: Allocator, fd: c_int, session: ?[]const u8, why: []u8, have: ?*Ha r.j.gmtoff = w.gmtoff; r.j.digest = w.digest; r.j.semantics = w.semantics; + r.j.bytes = w.bytes; if (r.boot == w.digest) { r.done = true; return false; @@ -3248,10 +3256,19 @@ pub fn join(gpa: Allocator, j: *Joined, path: []const u8, session: []const u8, o if (have) |h| h.store(gpa, j) else gpa.free(j.dump); j.dump = &.{}; } + return fromDump(gpa, j, o, have, why, t0); +} + +/// The replica of the dump `j` brought, on the road its welcome says, its +/// load checked by the session's digest, and what it takes of `j`; null, +/// and why in `why`, when it does not load as the session. +fn fromDump(gpa: Allocator, j: *Joined, o: pardes.Options, have: ?*Have, why: []u8, t0: u64) ?*Replica { const r = Replica.initDump(gpa, j.client, j.view, j.dump, o) catch |err| { _ = std.fmt.bufPrint(why, "the session's dump would not load: {t}\x00", .{err}) catch {}; return null; }; + // Before the check: on the bytes road the digest covers its emulators. + road(r, j.bytes); if (!r.loaded(j.digest)) { r.deinit(); _ = std.fmt.bufPrint(why, "the session's dump loaded as another session (a build's dump is not complete)\x00", .{}) catch {}; @@ -3261,6 +3278,14 @@ pub fn join(gpa: Allocator, j: *Joined, path: []const u8, session: []const u8, o return r; } +/// Its terminals its own emulators, fed the pty's bytes its units carry +/// (`bytes`, its session's Peers.bytes), or the session's screen state; +/// its echo predicted on either (core/echo.zig). +fn road(r: *Replica, bytes: bool) void { + r.t.screen_state = !bytes; + r.core().echo = &r.echo; +} + /// What a replica joined by `j` takes of it, and of the environment. fn takeJoined(r: *Replica, j: *Joined, have: ?*Have, t0: u64) void { // PARDES_NO_ECHO: no predicted echo (the gates' baseline). @@ -3298,7 +3323,10 @@ fn ownBoot(gpa: Allocator, j: *Joined, fd: c_int, o: pardes.Options, why: *[600] _ = std.fmt.bufPrint(why, "the session hung up\x00", .{}) catch {}; return null; } - j.* = .{ .fd = fd, .pid = 0, .client = r.id, .view = r.view, .gmtoff = gmtoff(), .dump = &.{}, .digest = digest, .semantics = wire.semantics, .booted = true }; + // Its session is this process's child, on the road this environment + // says (runtime/session.zig): the welcome says it again. + j.* = .{ .fd = fd, .pid = 0, .client = r.id, .view = r.view, .gmtoff = gmtoff(), .dump = &.{}, .digest = digest, .semantics = wire.semantics, .booted = true, .bytes = std.c.getenv("PARDES_TERM_SCREEN") == null }; + road(r, j.bytes); takeJoined(r, j, null, t0); return r; } @@ -3317,22 +3345,14 @@ pub fn confirmBoot(gpa: Allocator, j: *Joined, r: *Replica, o: pardes.Options, w if (j.dump.len == 0) { r.id = j.client; r.view = j.view; + road(r, j.bytes); return r; } defer { gpa.free(j.dump); j.dump = &.{}; } - const loaded = Replica.initDump(gpa, j.client, j.view, j.dump, o) catch |err| { - _ = std.fmt.bufPrint(why, "the session's dump would not load: {t}\x00", .{err}) catch {}; - return null; - }; - if (!loaded.loaded(j.digest)) { - loaded.deinit(); - _ = std.fmt.bufPrint(why, "the session's dump loaded as another session (a build's dump is not complete)\x00", .{}) catch {}; - return null; - } - takeJoined(loaded, j, null, t0); + const loaded = fromDump(gpa, j, o, null, why, t0) orelse return null; r.deinit(); return loaded; } @@ -5062,12 +5082,15 @@ fn firstOnPair(bytes: bool) !void { var j: Joined = undefined; var why: [600]u8 = @splat(0); const r = if (bytes) r: { + // Joined by its dump as any client loads one (`fromDump`): the + // welcome says the road, and its load is checked on it. j = joinOn(gpa, fds[1], null, &why, null, null, null) orelse return error.JoinFailed; defer gpa.free(j.dump); - const r = try Replica.initDump(gpa, j.client, j.view, j.dump, opts); - r.t.screen_state = false; - r.core().echo = null; - break :r r; + try std.testing.expect(j.bytes); + break :r fromDump(gpa, &j, opts, null, &why, nowNs()) orelse { + std.debug.print("the join: {s}\n", .{std.mem.sliceTo(&why, 0)}); + return error.JoinFailed; + }; } else r: { var o = opts; o.pair = fds[1]; @@ -6599,6 +6622,93 @@ test "a command typed into a shell with prompt marks under screen state: every s try agrees(a, r); } +test "a step of the session's own that reads a terminal right after its output, in one pump: its client replays it over the terminal as that output left it (the pty's bytes in the unit, fed in the tape's order)" { + if (pardes.Term.ops == null) return error.SkipZigTest; // a shell + const gpa = std.testing.allocator; + const ShellHost = struct { + fn taken(_: ?*anyopaque, _: pardes.Pane.Id) bool { + return false; + } + fn write(_: ?*anyopaque, _: pardes.Pane.Id, _: []const u8) void {} + const vtable: pardes.Host.VTable = .{ .watched = TestHost.watched, .tty_taken = taken, .pty_write = write }; + }; + const core = try Pardes.init(gpa, .{ .cols = 80, .rows = 24, .boot = .tty }); + defer core.deinit(); + core.host = .{ .vtable = &ShellHost.vtable }; + try core.pump(core.host); + const shell: u8 = for (core.panes, 0..) |slot, id| { + if (slot) |pane| if (pane.isTerminal()) break @intCast(id); + } else return error.NoShell; + core.view().active = shell; + // The session as runtime/session.zig runs it; the client's link in + // memory. + var ps: Peers = .{ .gpa = gpa, .io = std.testing.io, .threads = false, .bytes = true }; + defer ps.deinit(); + defer ps.dropAll(core); + var fds: [2]c_int = undefined; + if (libc.socketpair(libc.AF.UNIX, libc.SOCK.STREAM | libc.SOCK.CLOEXEC, 0, &fds) != 0) return error.NoSocket; + defer _ = libc.close(fds[1]); + ps.handed(fds[0], null); + ps.boundary(core); + const peer = for (ps.list) |slot| { + if (slot) |x| if (x.fd == fds[0]) break x; + } else return error.Refused; + const f = (try wire.framed(peer.welcome[0..peer.welcome_len])).?; + const w = (try wire.decodeServer(f.tag, f.payload)).welcome; + var word: [16]u8 = undefined; + const far = try wire.encodeClient(&word, .{ .far = false }); + _ = peer.take(far[0], far[wire.header_len..]); + ps.post(.{ .joined = peer }); + var whole: std.ArrayListUnmanaged(u8) = .empty; + defer whole.deinit(gpa); + var pos: usize = 0; + for (peer.blobs.items) |b| { + try whole.appendSlice(gpa, peer.dump[pos..b.at]); + try whole.appendSlice(gpa, b.bytes); + pos = b.at; + } + try whole.appendSlice(gpa, peer.dump[pos..]); + const r = try Replica.initDump(gpa, w.client, w.view.index(), whole.items, .{ .cols = 80, .rows = 24, .boot = .tty }); + defer r.deinit(); + road(r, w.bytes); + try std.testing.expect(r.loaded(w.digest)); + var link: Link = .{ .r = r, .fd = fds[1] }; + defer link.deinit(gpa); + const Down = struct { + // What the session queued for its client, taken in order. + fn all(from: *Peer, l: *Link) !void { + var at: usize = 0; + while (try wire.framed(from.out.items[at..])) |m| : (at += m.total) l.take(switch (std.enums.fromInt(wire.ServerTag, m.tag).?) { + .unit => .{ .unit = try std.heap.c_allocator.dupe(u8, m.payload) }, + .screen => .{ .screen = try std.heap.c_allocator.dupe(u8, m.payload) }, + else => return error.UnexpectedFrame, + }); + from.out.clearRetainingCapacity(); + } + }; + const prompt = "\x1b]133;A;cl=line;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07"; + core.update(.{ .output = .{ .pane = .at(shell), .bytes = prompt } }); + try core.pump(core.host); + ps.boundary(core); + try Down.all(peer, &link); + try std.testing.expect(r.diverged == null); + try std.testing.expectEqual(tape.digestOf(core), r.digest()); + // One pump: its shell echoes a line typed at the prompt, then an Exec of + // the session's own (a 9P ctl write, a timer's) asks whether the prompt + // is empty to type at. The session reads "no" and opens a command pane; + // the client must read the same. + core.update(.{ .output = .{ .pane = .at(shell), .bytes = "typed" } }); + core.update(.{ .command = "Exec true" }); + try core.pump(core.host); + ps.boundary(core); + try Down.all(peer, &link); + if (r.diverged) |why| { + std.debug.print("the client: {s}\n", .{why}); + return error.Diverged; + } + try std.testing.expectEqual(tape.digestOf(core), r.digest()); +} + test "a far client's own Del of a pane whose kind's state is not plain, rolled back by another's unit: the pane comes back whole, and is closed again with the session's order" { const gpa = std.testing.allocator; const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host(), false); diff --git a/core/root.zig b/core/root.zig index 5c91afd1..782c0040 100644 --- a/core/root.zig +++ b/core/root.zig @@ -632,7 +632,7 @@ const machine_lines = [_]struct { []const u8, usize, []const u8 }{ .{ "jj.zig", 9, "jj run under tape.site(.jj) on an io of its own (the tape's spawns nothing) with this process's environment, the signal mask cleared as Stream's children's: the session's, a replica replays its answer; or on a worker for `Changes`, its answer an input; a test's shell inbox (dev)" }, .{ "look.zig", 6, "openLink's fork (the host's: a view's frontend opens a link) and a remote's error name" }, .{ "memory.zig", 7, "the memory regions themselves (mmap, madvise, their locks)" }, - .{ "replica.zig", 75, "the client and session engines: sockets, threads, clocks, the blob cache, traces" }, + .{ "replica.zig", 76, "the client and session engines: sockets, threads, clocks, the blob cache, traces" }, .{ "rollback.zig", 1, "a test helper's directory" }, .{ "root.zig", 4, "dev's modules re-exported (host_io, file_watch, glide, fonts)" }, .{ "selection_pipe.zig", 14, "a pipe's child processes and their files: the host's `pipe` entry" }, diff --git a/runtime/session.zig b/runtime/session.zig index 75e8efcc..9499da9c 100644 --- a/runtime/session.zig +++ b/runtime/session.zig @@ -86,7 +86,11 @@ pub fn Loop(comptime Frontend: type) type { defer l.prompt_rcs.deinit(); l.fs = ninep_io.start(l.io, l.gpa, l.core); defer if (l.fs) |f| f.deinit(l.gpa); - l.peers = .{ .gpa = l.gpa, .io = l.io, .name = daemon.name() }; + // Its clients' terminals by the pty's bytes (Peers.bytes), each + // client's emulator its own; PARDES_TERM_SCREEN (a working name, + // the way back until the screen state's road is deleted): as + // screen state. Its welcome tells each client which. + l.peers = .{ .gpa = l.gpa, .io = l.io, .name = daemon.name(), .bytes = std.c.getenv("PARDES_TERM_SCREEN") == null }; l.inbox = .{ .io = l.io, .gpa = l.gpa, .lsp_allocator = l.allocs.lsp }; defer l.inbox.deinit(); // A search's worker may be waiting on the queue for room. diff --git a/test/daemon.py b/test/daemon.py index e334b6e8..2e666ad1 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -69,6 +69,11 @@ from pathlib import Path sys.path.insert(0, str(Path(__file__).parent)) from ninep import Client # noqa: E402 +# The caller's PARDES_* is dropped (a session of the user's), these kept: a +# road for every session the run starts (PARDES_TERM_SCREEN: its terminals to +# its clients as screen state, the way back). +KEEP = ('PARDES_TERM_SCREEN',) + def wait_for(what, check, timeout=10): deadline = time.monotonic() + timeout @@ -258,7 +263,7 @@ class Replica: """A replica's connection (abi/wire.zig): length-prefixed messages, a tag byte and a little-endian u32 length. It is a near client: its first word after the hello says so.""" - WIRE = 28 + WIRE = 29 def __init__(self, path, timeout=10): self.path, self.timeout = path, timeout @@ -436,7 +441,7 @@ def clients(binary): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rc-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -578,7 +583,7 @@ def launch(binary): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rl-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -646,7 +651,7 @@ def pair(binary): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rp-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1', PARDES_PAIR='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -720,7 +725,7 @@ def pair_rows(binary): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rq-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1', PARDES_PAIR='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -910,7 +915,7 @@ def attach_upgrading(binary, rounds=6, dump=True): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='ru-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -1001,7 +1006,7 @@ def kept_views(binary): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rk-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -1059,7 +1064,7 @@ def pair_upgrade_views(binary): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rv-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1', PARDES_PAIR='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -1165,7 +1170,7 @@ def pair_exec_reaps(old, new): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rpx-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1', PARDES_PAIR='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -1229,7 +1234,7 @@ def far_exec(old, new): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rfx-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -1295,7 +1300,7 @@ def pair_window_geometry(gui_binary, new_gui): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rgg-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), SHELL='/bin/bash', PARDES_NOTIME='1', PARDES_DAEMON='on', TERM='xterm-256color', PARDES_PAIR='1', SDL_VIDEO_DRIVER='offscreen') @@ -1367,7 +1372,7 @@ def manage(binary): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rm-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -1471,7 +1476,7 @@ def relink(binary): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rr-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -1577,7 +1582,7 @@ def answer_late(binary): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='ra-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -1695,7 +1700,7 @@ def pdf_window(binary, gui_binary): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='pdfw-', dir=os.environ.get('TMPDIR') or scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') env.pop('XDG_DATA_HOME', None) @@ -1761,7 +1766,7 @@ def window_clients(binary, gui_binary): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='wc-', dir=os.environ.get('TMPDIR') or scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -1983,7 +1988,7 @@ def far(binary): scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rf-', dir=scratch)) cache = root / 'cache' - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), XDG_CACHE_HOME=str(cache), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1', PARDES_REPLICA_FAR='1') @@ -2150,7 +2155,7 @@ def far_flood(binary): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='fl-', dir=os.environ.get('TMPDIR') or scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), XDG_CACHE_HOME=str(root / 'cache'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') @@ -2225,7 +2230,7 @@ def by_hash(binary): scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rh-', dir=scratch)) cache = root / 'cache' - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), XDG_CACHE_HOME=str(cache), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -2311,7 +2316,7 @@ def games(binary, libs, secs=10): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rg-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), XDG_DATA_HOME=str(root / 'data'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -2422,7 +2427,7 @@ def far_find(binary): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rq-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), XDG_DATA_HOME=str(root / 'data'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1', PARDES_REPLICA_FAR='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -2489,7 +2494,7 @@ def restore_client(binary): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rr-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), XDG_DATA_HOME=str(root / 'data'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -2623,7 +2628,7 @@ def kitty_image(binary, secs=5): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='ri-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -2684,7 +2689,7 @@ def main(binary, cycles): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rt-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -2918,7 +2923,7 @@ def gui(binary, cycles): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rtg-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} (root / 'caps').mkdir() env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), SHELL='/bin/bash', PARDES_NOTIME='1', PARDES_TEST='1', PARDES_TEST_CAPTURE_DIR=str(root / 'caps'), @@ -3013,7 +3018,7 @@ def gui_pair(gui_binary): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rgp-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), SHELL='/bin/bash', PARDES_NOTIME='1', PARDES_DAEMON='on', TERM='xterm-256color', PARDES_PAIR='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -3184,7 +3189,7 @@ def upgrades(old, new): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='rtu-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -3493,7 +3498,7 @@ def upgrade_clients(old, new): scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' scratch.mkdir(parents=True, exist_ok=True) root = Path(tempfile.mkdtemp(prefix='ruc-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') (root / 'config' / 'pardes').mkdir(parents=True) @@ -3595,7 +3600,7 @@ def gui_upgrades(old, new): another build.""" scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' root = Path(tempfile.mkdtemp(prefix='rtgu-', dir=scratch)) - env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env = {k: v for k, v in os.environ.items() if (not k.startswith('PARDES_') or k in KEEP) and 'PAGER' not in k} display = Path(os.environ.get('WAYLAND_DISPLAY', 'wayland-0')) if not display.is_absolute(): display = Path(os.environ.get('XDG_RUNTIME_DIR', f'/run/user/{os.getuid()}')) / display diff --git a/test/process.zig b/test/process.zig index 791a5b8e..a1647ff1 100644 --- a/test/process.zig +++ b/test/process.zig @@ -945,8 +945,9 @@ pub const Child = struct { while (environ[i]) |kv| { const entry = std.mem.span(kv); const eq = std.mem.indexOfScalar(u8, entry, '=') orelse entry.len; - // PARDES_PAIR kept: the suite run as pairs (main.zig `pair`). - if ((std.mem.startsWith(u8, entry, "PARDES_") and !std.mem.startsWith(u8, entry, "PARDES_PAIR=")) or std.mem.indexOf(u8, entry[0..eq], "PAGER") != null) { + // PARDES_PAIR kept: the suite run as pairs (main.zig `pair`); + // PARDES_TERM_SCREEN, their terminals as screen state. + if ((std.mem.startsWith(u8, entry, "PARDES_") and !std.mem.startsWith(u8, entry, "PARDES_PAIR=") and !std.mem.startsWith(u8, entry, "PARDES_TERM_SCREEN=")) or std.mem.indexOf(u8, entry[0..eq], "PAGER") != null) { var name: [256]u8 = undefined; const n = std.fmt.bufPrintSentinel(&name, "{s}", .{entry[0..@min(eq, 255)]}, 0) catch _exit(126); _ = unsetenv(n); |
