summaryrefslogtreecommitdiff
path: root/dev
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 /dev
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 'dev')
-rw-r--r--dev/fonts.zig6
-rw-r--r--dev/gui/gui.zig32
-rw-r--r--dev/tui/tui.zig47
3 files changed, 69 insertions, 16 deletions
diff --git a/dev/fonts.zig b/dev/fonts.zig
index 540e3a60..3d69c8a1 100644
--- a/dev/fonts.zig
+++ b/dev/fonts.zig
@@ -4,9 +4,9 @@
//! because the core has no font and the shells have no builtin dispatch.
//!
//! It lives at src/ rather than under gui/ because two shells draw their own
-//! text. It is compiled only behind `pardes.font_picker` (gui or macos), so
-//! the tui binary never opens a font directory, and the browser has none to
-//! open.
+//! text. It is compiled behind `builtins.capabilities.font_picker` (a
+//! desktop build, whose terminal steps a window's Fonts and Font as the
+//! window does, or the Mac's): the browser has none to open.
//!
//! No fontconfig and no CoreText. Enumerating fonts is a walk over a handful
//! of well-known directories, and the one thing the picker must know about
diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig
index cf384238..3193d966 100644
--- a/dev/gui/gui.zig
+++ b/dev/gui/gui.zig
@@ -1132,6 +1132,9 @@ const Client = struct {
titled: bool = false,
moving: bool = false,
blink: ?Blink = null,
+ /// The session's WindowOpacity this window last took (P47: each
+ /// window applies it to the view it draws; none answers the core).
+ opacity: ?u8 = null,
fn deinit(cl: *Client) void {
cl.pending.deinit(cl.gpa);
@@ -1173,6 +1176,7 @@ const Client = struct {
const g = cl.g;
const core = l.link.r.core();
g.session_font_request = null;
+ cl.opacity = null;
cl.shell.core = core;
cl.shell.gview = cl.joins.joined.view;
cl.shell.surface = null;
@@ -1206,6 +1210,14 @@ const Client = struct {
const link = &l.link;
l.frames.period_ns = refreshNs(g);
if (syncReplicaFont(g, &cl.in.core.settings.font, gpa)) link.dirty = true;
+ const opacity = cl.in.core.settings.window_opacity;
+ if (cl.opacity != opacity) {
+ cl.opacity = opacity;
+ if (applyWindowOpacity(g, opacity) catch return false) |why| {
+ log.warn("WindowOpacity: {s}", .{why});
+ } else g.applied_window_opacity = opacity;
+ link.dirty = true;
+ }
if (scrollRows(g, &cl.in, gpa)) link.dirty = true;
if (fitTaglineFont(g, g.facts.tagline_percent)) link.dirty = true;
const geom = windowCells(g);
@@ -3025,12 +3037,24 @@ fn finishWindowOpacity(core: *pardes.Pardes, applied: *u8, failure: ?[]const u8)
fn syncWindowOpacity(g: *Gui, core: *pardes.Pardes) void {
if (!core.settings.window_opacity_pending) return;
+ const failure = applyWindowOpacity(g, core.settings.window_opacity) catch blk: {
+ core.quit = true;
+ break :blk null;
+ };
+ finishWindowOpacity(core, &g.applied_window_opacity, failure);
+}
+
+/// What the window does at a WindowOpacity, the own window's and a
+/// client's (P47: a window's facts are the process's that draws it): why
+/// it cannot, or null; error.NoWindow when it was made again and could
+/// not be.
+fn applyWindowOpacity(g: *Gui, opacity: u8) error{NoWindow}!?[]const u8 {
// The first opacity under 100 on Wayland: the window made again,
// transparent, presenting through SDL_Renderer from then on (the
// capture's format, the swapchain's, is one it uploads). At a start's
// own WindowOpacity this is before its first frame, so unseen.
const unorm = g.present.swapchain_format == c.SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM or g.present.swapchain_format == c.SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM;
- if (g.wayland and !g.present.surface_opacity and core.settings.window_opacity < 100 and unorm) {
+ if (g.wayland and !g.present.surface_opacity and opacity < 100 and unorm) {
// A `--detach` session's window stays hidden.
const hidden = c.SDL_GetWindowFlags(g.window) & c.SDL_WINDOW_HIDDEN;
const mode = g.present.present_mode;
@@ -3046,16 +3070,16 @@ fn syncWindowOpacity(g: *Gui, core: *pardes.Pardes) void {
g.present.surface_opacity = false;
g.present.present_mode = mode;
g.win_flags &= ~@as(c.SDL_WindowFlags, c.SDL_WINDOW_TRANSPARENT);
- if (!reopenWindow(g)) core.quit = true;
+ if (!reopenWindow(g)) return error.NoWindow;
}
g.win_flags &= ~hidden;
}
// Offscreen captures also support per-pixel alpha. Never approximate this
// with SDL_SetWindowOpacity: that would make foreground text translucent.
- finishWindowOpacity(core, &g.applied_window_opacity, if (g.present.surface_opacity or g.present.capture or core.settings.window_opacity == 100)
+ return if (g.present.surface_opacity or g.present.capture or opacity == 100)
null
else
- "background transparency requires a native Wayland or alpha-capable SDL window");
+ "background transparency requires a native Wayland or alpha-capable SDL window";
}
fn present(ctx: ?*anyopaque, surface: *const pardes.Surface) bool {
diff --git a/dev/tui/tui.zig b/dev/tui/tui.zig
index 2f731e68..9117d54d 100644
--- a/dev/tui/tui.zig
+++ b/dev/tui/tui.zig
@@ -559,8 +559,12 @@ fn surfaceHasKittyKey(surface: *const pardes.Surface, key: u64) bool {
/// opens it; one open already (a session forked off its stub,
/// daemon.forkSession); or none, detached from the start (`--detach`).
/// The terminal a session starts on: /dev/tty, one its stub opened (an
-/// upgraded session's is raw already, `termios` the cooked one), or none.
-pub const Term = union(enum) { open, fd: struct { fd: posix.fd_t, termios: ?posix.termios = null }, detached };
+/// upgraded session's is raw already, `termios` the cooked one), or none:
+/// a pair's (main.zig `pair`) draws on none, and keeps its client's, with
+/// its modes before the client took it, to put back if that client dies
+/// with no word (P48: `Own.sent`).
+pub const Term = union(enum) { open, fd: struct { fd: posix.fd_t, termios: ?posix.termios = null }, detached, pair: Kept };
+pub const Kept = struct { fd: posix.fd_t, termios: posix.termios };
pub fn run(init: std.process.Init, opts: pardes.Options, term: Term) !void {
const io = init.io;
@@ -583,7 +587,7 @@ pub fn run(init: std.process.Init, opts: pardes.Options, term: Term) !void {
switch (term) {
.open => try screen.enter(try vaxis.Tty.init(io, &tty_buf)),
.fd => |t| try screen.enter(try Screen.ttyOn(io, &tty_buf, t.fd, t.termios)),
- .detached => {},
+ .detached, .pair => {},
}
defer screen.leave();
@@ -591,7 +595,7 @@ pub fn run(init: std.process.Init, opts: pardes.Options, term: Term) !void {
defer paste_buf.deinit();
var loop: Loop = .init(io, &screen.tty, &screen.vx);
- var own: Own = .{ .screen = &screen, .loop = &loop, .paste_buf = &paste_buf };
+ var own: Own = .{ .screen = &screen, .loop = &loop, .paste_buf = &paste_buf, .kept = if (term == .pair) term.pair else null };
try session_loop.Loop(Own).run(init, opts, &own);
}
@@ -929,7 +933,9 @@ const Screen = struct {
const Killed = struct {
var fd: posix.fd_t = -1;
var cooked: posix.termios = undefined;
- const reset = "\x1b[<u\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l\x1b[?1004l\x1b[?2004l\x1b[0m\x1b[?25h\x1b[?1049l";
+ /// Every mode it may have turned on off (the in-band resize its
+ /// terminal query asks for, vaxis's `in_band_resize_set`, too).
+ const reset = "\x1b[<u\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l\x1b[?1004l\x1b[?2004l\x1b[?2048l\x1b[0m\x1b[?25h\x1b[?1049l";
fn arm(tty_fd: posix.fd_t, termios: posix.termios) void {
cooked = termios;
fd = tty_fd;
@@ -939,6 +945,11 @@ const Killed = struct {
if (daemon.link < 0) posix.sigaction(.HUP, &on, null);
}
+ fn putBack(tty: posix.fd_t, termios: *const posix.termios) void {
+ _ = std.c.write(tty, reset, reset.len);
+ _ = std.c.tcsetattr(tty, .FLUSH, termios);
+ }
+
/// The terminal gone (put back, or detached): a TERM still takes the
/// socket, the prompt files and the shells with it, and leaves the
/// terminal alone.
@@ -947,10 +958,7 @@ const Killed = struct {
}
fn handle(sig: posix.SIG) callconv(.c) void {
- if (fd >= 0) {
- _ = std.c.write(fd, reset, reset.len);
- _ = std.c.tcsetattr(fd, .FLUSH, &cooked);
- }
+ if (fd >= 0) putBack(fd, &cooked);
// The 9P socket and private prompt files go too: a killed editor
// leaves none behind. Its shells too, the daemon's dups let go.
ninep_io.unlinkOwnSocket();
@@ -971,6 +979,9 @@ const Own = struct {
paste_buf: *std.Io.Writer.Allocating,
frame_arena: std.heap.ArenaAllocator = undefined,
sh: Shell = undefined,
+ /// A pair's: its client's terminal (Term.pair), until that client
+ /// leaves.
+ kept: ?Kept = null,
const Session = session_loop.Loop(Own);
@@ -1007,6 +1018,12 @@ const Own = struct {
if (comptime !builtin.is_test) if (upgrade.resumed) |*rec| sh.resumeTerminals(rec);
// Nobody to see it, and nobody to size it: `size` sets it (ctl.zig).
sh.setAttended(!sh.detached());
+ // An upgraded pair's client joins again at once: what the session
+ // says meanwhile ("Upgrade: now") waits for it, as at a Restore
+ // (session.zig `restore`), not 800 ms on an unattended clock.
+ if (comptime !builtin.is_test) if (upgrade.resumed) |rec| if (rec.state == .pair) {
+ l.core.unattended = false;
+ };
return host;
}
@@ -1027,6 +1044,7 @@ const Own = struct {
o.screen.art.deinit(gpa);
o.screen.glide.deinit(gpa);
o.frame_arena.deinit();
+ if (o.kept) |k| _ = libc.close(k.fd);
}
pub fn start(o: *Own, l: *Session) !void {
@@ -1051,6 +1069,17 @@ const Own = struct {
pub fn sent(o: *Own) void {
const sh = &o.sh;
if (sh.peers.recording and sh.detached()) sh.drawn_ns = @intCast(std.Io.Clock.awake.now(sh.io).nanoseconds);
+ // A pair's client gone: dead with no word (a kill -9), its
+ // terminal put back as the own path's survivor puts it back (a
+ // forked session's when its stub is killed), from the alternate
+ // screen and raw; with a word, it did that itself. Let go either
+ // way: a terminal held open keeps an ssh, or its emulator, waiting.
+ const lost = sh.peers.pair_left orelse return;
+ sh.peers.pair_left = null;
+ const k = o.kept orelse return;
+ o.kept = null;
+ if (lost) Killed.putBack(k.fd, &k.termios);
+ _ = libc.close(k.fd);
}
pub fn upgradeAsked(o: *Own) void {