summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-22 16:57:59 -0300
committerGabriel Schneider <[email protected]>2026-11-22 18:52:03 -0300
commitb3c38ea198e1fe915f029d7e41b469b8a53d2338 (patch)
treed6db809889ae1412146ca9dc806fb7d61f8e2bd2 /core
parent9863a63b614d200852853825031189364dcacfdc (diff)
parent6401b327a217c144895e22fb7ad24d986af97d86 (diff)
downloadpardes-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 'core')
-rw-r--r--core/Addon.zig18
-rw-r--r--core/Effect.zig7
-rw-r--r--core/Kind.zig2
-rw-r--r--core/exec.zig3
-rw-r--r--core/replica.zig27
-rw-r--r--core/root.zig4
-rw-r--r--core/tape.zig3
7 files changed, 48 insertions, 16 deletions
diff --git a/core/Addon.zig b/core/Addon.zig
index c60f2430..aa3195f9 100644
--- a/core/Addon.zig
+++ b/core/Addon.zig
@@ -567,9 +567,11 @@ pub fn loadedOf(ops: *const Kind.Ops, path: []const u8, hash: [32]u8, words: *[6
/// This process's code for a kind a session's core lists, which a client
/// runs itself: PA_PLAIN, of the same name, version, ABI and functions (a
-/// compiled-in addon's library hash is 0: never by the hash), and not
-/// caught breaking its promise here (`distrusted`, the client's). Null: its
-/// panes say so.
+/// compiled-in addon's library hash is 0: never by the hash), or else the
+/// library at the session's path when its bytes are the session's (P51: a
+/// client on its machine; never bytes the session sent), and not caught
+/// breaking its promise here (`distrusted`, the client's). Null: its panes
+/// say so.
pub fn plainOps(e: *const Kind.Entry, distrusted: ?*const Distrusted) ?*const Kind.Ops {
if (!e.caps.plain or e.refused) return null;
// A client scans for its addons only when its session has a plain kind.
@@ -582,6 +584,16 @@ pub fn plainOps(e: *const Kind.Entry, distrusted: ?*const Distrusted) ?*const Ki
if (l.ops == 0) l.ops = loadListed(i, &why) orelse return null;
return @ptrFromInt(l.ops);
};
+ var words: [64]LoadedWord = undefined;
+ var why: Why = .{};
+ var data_buf: [4096]u8 = undefined;
+ const l = read(dataDir(&data_buf), e.path.slice(), &words, &why);
+ if (l.why.len > 0) return null;
+ const ops: *const Kind.Ops = @ptrFromInt(l.ops);
+ if (std.mem.eql(u8, &l.hash, &e.hash)) return ops;
+ const lib = libOf(ops).?;
+ lib.refs -= 1;
+ closeIdle(lib);
return null;
}
diff --git a/core/Effect.zig b/core/Effect.zig
index abfe4711..bdf41e66 100644
--- a/core/Effect.zig
+++ b/core/Effect.zig
@@ -256,9 +256,10 @@ fn performInner(p: *Pardes, e: Effect) void {
.dump_themes => |d| _ = p.tape.host(p, .dump_themes, .{d.pane}),
.detach => |d| p.tape.host(p, .detach, .{}) orelse p.reportError(d.pane, "detach", error.NotAttached),
// dlopen is the same on every host, so none has a method of its
- // own; a replica's core holds no library (what it brought comes in
- // the event this taped).
- .addon => |a| if (!p.tape.replaying()) @import("Addon.zig").perform(p, a.op, a.pane.index(), a.arg.slice()),
+ // own; a replica's core holds no library: what it brought is the
+ // event inside this call, recorded there and applied by a replay
+ // (its code a client's own, Addon.plainOps); a speculation waits.
+ .addon => |a| if (!p.tape.authorityOnly("an addon's load")) p.tape.value(.landing, @import("Addon.zig").perform, .{ p, a.op, a.pane.index(), a.arg.slice() }),
.job => |j| p.tape.host(p, .job, .{ j.pane, j.serial, j.token }) orelse if (!p.tape.replaying()) host_io.KindJob.runHere(p, j.pane.index(), j.serial, j.token),
// the loop's own condition; a host tears down after its own loop
.quit => p.endSession(),
diff --git a/core/Kind.zig b/core/Kind.zig
index 81997afb..49076f78 100644
--- a/core/Kind.zig
+++ b/core/Kind.zig
@@ -424,7 +424,7 @@ pub fn draw(p: *Pardes, s: *surface.Surface, arena: std.mem.Allocator, pane: *Pa
if (slot.ops == null and slot.live) {
// A client: a plain kind runs where it is shown, and this one lacks
// it; any other runs in its session alone.
- const why = if (caps(p, slot).plain) "it is not in its addons, or it broke its promise here" else "its state is not plain (PA_PLAIN), so it runs in the session alone";
+ const why = if (caps(p, slot).plain) "it is not in its addons nor the session's library at its path here, or it broke its promise here" else "its state is not plain (PA_PLAIN), so it runs in the session alone";
var line: [200]u8 = undefined;
_ = s.print(x, y, cols, std.fmt.bufPrint(&line, "addon {s} {d} does not run in this client: {s}", .{ slot.nameOf(), slot.version, why }) catch &line, .{ .fg = fg, .bg = bg });
return;
diff --git a/core/exec.zig b/core/exec.zig
index 52f54541..99868434 100644
--- a/core/exec.zig
+++ b/core/exec.zig
@@ -20,7 +20,6 @@ const python_lang = blk: {
@setEvalBranchQuota(20_000);
break :blk @import("grammar_manifest.zig").byName("python").?;
};
-const font_picker = pardes.font_picker;
const fonts = pardes.fonts;
const Pane = panes.Pane;
const MAX_COLS = pardes.MAX_COLS;
@@ -1014,7 +1013,7 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Settings.Setting, arg: ?[
return p.reportFailure(v.active, text.print("Theme: no theme \"{s}\"; like it: {s}; Themes lists all", .{ shown, colors.themesNear(near[0..@min(room, near.len)], want) }));
},
.font => {
- if (comptime !font_picker) return;
+ if (comptime !pardes.builtins.capabilities.font_picker) return;
const spec = config.Settings.FontSpec.parse(arg orelse return) orelse return;
// The session's machine's fonts, a question to its disk: a
// client's replay takes the session's answer, never its own.
diff --git a/core/replica.zig b/core/replica.zig
index 3aac5e82..71a8de71 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -1361,6 +1361,12 @@ pub const Peer = struct {
again: bool = false,
/// ...or that its window was closed (Peers.closed).
close: bool = false,
+ /// It said a bye: none, and the session let it go with no word of its
+ /// own (`closing`, `cut`), is a client that died (killed: P48).
+ bye: bool = false,
+ /// A pair's first client (`Joining.own`): the terminal its session
+ /// keeps is its (`Peers.pair_left`).
+ pair: bool = false,
/// Inputs read (each one's seq, as the client numbered them).
seq: u32 = 0,
/// The `stamp` frame its next input came with (its reader's).
@@ -1643,6 +1649,7 @@ pub const Peer = struct {
const b = (wire.decodeClient(tag, payload) catch return false).bye;
peer.again = b.again;
peer.close = b.close;
+ peer.bye = true;
return false;
},
.ping => {
@@ -1775,6 +1782,14 @@ pub const Peers = struct {
/// hung up) and the session is a pair's not kept (daemon.sessionState): it
/// ends there (runtime/session.zig).
closed: bool = false,
+ /// Its pair's first client left (P48): with no word at all (killed),
+ /// true; its session's frontend puts the user's terminal back then,
+ /// and lets it go either way (tui.zig `Own.sent`), and clears this.
+ pair_left: ?bool = null,
+ /// Its pair's first client's terminal or window found again (a focus
+ /// in): the session asks whether a newer build is installed, as its own
+ /// frontend asks at its own (runtime/session.zig), and clears this.
+ pair_focused: bool = false,
/// An Upgrade told its clients so (`refuseAll`): a connection handed
/// over before its exec is told the same, never closed by the exec
/// unanswered. Its exec failed: the next boundary takes joins again.
@@ -1896,6 +1911,7 @@ pub const Peers = struct {
const t0 = nowNs();
defer if (ps.samples) ps.input_ns.append(ps.gpa, nowNs() - t0) catch {};
core.toView(peer.view);
+ if (peer.pair and in.event == .focus and in.event.focus) ps.pair_focused = true;
ps.t.stamp = stampOf(in);
core.update(in.event);
core.step();
@@ -2000,7 +2016,7 @@ pub const Peers = struct {
core.gpa.free(bytes);
return daemon.refuseReplica(fd, "out of memory");
};
- peer.* = .{ .peers = ps, .fd = fd, .id = ps.next_id, .view = .at(k), .dump = bytes, .blobs = blobs, .dump_gpa = core.gpa };
+ peer.* = .{ .peers = ps, .fd = fd, .id = ps.next_id, .view = .at(k), .dump = bytes, .blobs = blobs, .dump_gpa = core.gpa, .pair = joining.own };
ps.next_id +%= 1;
if (ps.next_id == 0) ps.next_id = 1;
// The session's digest as dumped, for the joiner to check its load by
@@ -2075,6 +2091,7 @@ pub const Peers = struct {
ps.closeViewOf(core, peer, peer.again or peer.cut);
if (ps.count() == 0) core.unattended = ps.detached;
if (ps.count() == 0 and peer.close and daemon.sessionState() == .pair) ps.closed = true;
+ if (peer.pair) ps.pair_left = !peer.bye and !peer.closing and !peer.cut;
ps.seq += 1;
ps.unit(0, ps.seq);
ps.letGo(peer);
@@ -6169,12 +6186,10 @@ const may_wait = [_]Wait{
.{ .what = "*", .on = .addon, .stop = "a kind's close", .why = "a kind's pane closed: its state let go on the session" },
.{ .what = "*", .on = .addon, .stop = "a kind's word", .why = "a word to a kind (a key it takes as one): its own state" },
.{ .what = "*", .on = .addon, .stop = "a kind's open", .why = "a kind's pane opened (`Life`): its state made on the session" },
-} ++ (if (pardes.font_picker) [_]Wait{
- // A window's view (the font words are a window's).
+} ++ (if (pardes.builtins.capabilities.font_picker) [_]Wait{
+ // A window's view's words, which a terminal's build has too: a window
+ // client of its session runs them.
.{ .what = "Font *", .on = .any, .stop = "fonts", .why = "the session's machine's fonts, its disk" },
-} else [_]Wait{}) ++ (if (pardes.builtins.capabilities.font_picker) [_]Wait{
- // ...and Fonts a terminal's build has too, which a window client of its
- // session runs (exec.zig's Font, a window build's alone, does not).
.{ .what = "Fonts", .on = .any, .stop = "fonts", .why = "the session's machine's fonts, its disk" },
} else [_]Wait{});
diff --git a/core/root.zig b/core/root.zig
index 3cc9a90f..3bca5e03 100644
--- a/core/root.zig
+++ b/core/root.zig
@@ -118,7 +118,9 @@ const Loc = Jump.Loc;
pub const can_attach = platform == .tui or platform == .gui;
-pub const fonts = if (font_picker) @import("dev").fonts else struct {};
+/// The machine's fonts: every desktop build's, which steps a window's Font
+/// as the window does (builtins.capabilities), and the Mac's.
+pub const fonts = if (builtins.capabilities.font_picker) @import("dev").fonts else struct {};
pub const Pane = panes.Pane;
const Text = panes.Text;
diff --git a/core/tape.zig b/core/tape.zig
index 1cbf8aed..dc53a7c9 100644
--- a/core/tape.zig
+++ b/core/tape.zig
@@ -140,6 +140,9 @@ pub const Site = enum(u16) {
/// A kitty image's medium as a terminal's emulator read it (a file, a
/// temporary file, shared memory: Term.media), its bytes or its failure.
medium,
+ /// An addon's library loaded or let go (Addon.perform): what it brought
+ /// is the `addon` event inside it, which a replica applies from here.
+ landing,
};
/// What the sites return. wire.semantics hashes their shape with the