summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 02:00:44 -0300
committerGabriel Schneider <[email protected]>2026-11-10 02:00:44 -0300
commite6ea52e36cbb7c557681e6c7a55fa6f0d92f8754 (patch)
tree4a9d799e1d8e04dae68e2132b3ca223f4bf018fa /src
parent75db3e84e24ee75626074d93927261249b646386 (diff)
downloadpardes-e6ea52e36cbb7c557681e6c7a55fa6f0d92f8754.tar.gz
pardes-e6ea52e36cbb7c557681e6c7a55fa6f0d92f8754.zip
macos: a windowless gui authority follows its terminals' directories (pollCwds before the no-window return, upstream's test ported onto forkShell's seven arguments), and a replica joined from a dump paints the restored theme's chrome (initDump runs finishThemeInitialization: Core.chrome is local and was never recomputed, so the join showed the default theme's tags until the next Theme, as the ported test showed before the line)
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src')
-rw-r--r--src/gui/gui.zig40
-rw-r--r--src/replica.zig33
2 files changed, 72 insertions, 1 deletions
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index 60cc6112..3eae658a 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -3193,6 +3193,8 @@ fn pollFrame(ctx: ?*anyopaque) void {
s.reconcilePtys();
const core = s.core;
if (s.fs) |f| if (f.tick().pending) s.queue.push(.fs_ready);
+ // The authority owns its terminals even with its window closed.
+ pollCwds(core, s.ptys);
const g = s.gui orelse {
if (core.settings.window_opacity_pending) {
var unchanged_opacity: u8 = 100;
@@ -3233,7 +3235,6 @@ fn pollFrame(ctx: ?*anyopaque) void {
refitFont(g, core);
acknowledgeGuiFont(g, core);
}
- pollCwds(core, s.ptys);
const geom = windowCells(g);
if (updateCoreResize(core, geom.cols, geom.rows, g.cell_w, g.cell_h, g.tagline_width, g.tagline_height)) resetScroll(g);
stepScroll(g, core, s.gpa);
@@ -8978,3 +8979,40 @@ test "trackpad rotation never types search keys into an insert-mode file or raw
try std.testing.expectEqualStrings("Back", client.pending.items[0].command);
try std.testing.expectEqualStrings("Forward", client.pending.items[1].command);
}
+
+test "a detached GUI authority follows terminal directory changes with no window" {
+ const gpa = std.testing.allocator;
+ const io = std.testing.io;
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ try tmp.dir.createDirPath(io, "child");
+ var start_buf: [4096]u8 = undefined;
+ const start = start_buf[0..try tmp.dir.realPath(io, &start_buf)];
+ var cwd_buf: [4096]u8 = undefined;
+ const expected = cwd_buf[0..try tmp.dir.realPathFile(io, "child", &cwd_buf)];
+ const core = try pardes.Pardes.init(gpa, .{ .tty_only = true });
+ defer core.deinit();
+ core.panes[0].?.shell_spoke = true;
+ _ = core.settings.shell.effective.set("/bin/sh");
+ var queue: Queue = .{ .io = io, .gpa = gpa, .lsp_allocator = gpa };
+ defer queue.deinit();
+ var ptys: [pardes.MAX_PANES]?Pty = @splat(null);
+ var gens: [pardes.MAX_PANES]u32 = @splat(1);
+ const rcs: host_io.Shell.PromptFiles = .{};
+ var pipes: PipeTasks = .{};
+ var watches: file_watch.Table = @splat(null);
+ var shell: Shell = .{ .core = core, .io = io, .gpa = gpa, .lsp_allocator = gpa, .prompt_rcs = &rcs, .ptys = &ptys, .gens = &gens, .queue = &queue, .pipe_tasks = &pipes, .inotify_fd = -1, .watches = &watches };
+ defer shell.shutdownPtys();
+ const child = try host_io.forkShell(null, 0, &rcs, "/bin/sh", start, 24, 80);
+ ptys[0] = .{ .fd = child.file.handle, .pid = child.pid, .serial = core.panes[0].?.serial };
+ try std.testing.expect(host_io.writeFd(child.file.handle, "cd child\n"));
+ const until = std.Io.Clock.awake.now(io).toMilliseconds() + 2_000;
+ var actual: [4096]u8 = undefined;
+ while (std.Io.Clock.awake.now(io).toMilliseconds() < until) {
+ if (host_io.shellCwd(child.pid, &actual)) |cwd| if (std.mem.eql(u8, cwd, expected)) break;
+ try io.sleep(.fromMilliseconds(1), .awake);
+ }
+ try std.testing.expectEqualStrings(expected, host_io.shellCwd(child.pid, &actual) orelse return error.MissingCwd);
+ pollFrame(&shell);
+ try std.testing.expectEqualStrings(expected, core.panes[0].?.cwd.owned);
+}
diff --git a/src/replica.zig b/src/replica.zig
index 330c3204..ef4ea39b 100644
--- a/src/replica.zig
+++ b/src/replica.zig
@@ -742,6 +742,8 @@ pub const Replica = struct {
pardes.dump.terminal_gpa = terminal.emulator_gpa;
defer pardes.dump.terminal_gpa = null;
const c = try pardes.dump.load(epoch, o, bytes, null);
+ // The chrome's colours are local, never dumped: the restored theme's.
+ pardes.colors.finishThemeInitialization(c);
// It runs no kind's code: its panes of a kind are Shadows.
c.kinds.ops = @splat(null);
// What loading queued (a watch, a theme asked for) is the
@@ -3741,6 +3743,37 @@ test "a replica joined from the session's dump replays the units after it" {
try std.testing.expectEqual(digestOf(a), r.digest());
}
+test "a replica joined from a themed dump paints its taglines in the restored theme" {
+ const gpa = std.testing.allocator;
+ const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "build.zig" }, TestHost.host(), false);
+ defer a.deinit();
+ _ = try a.local(.{ .command = "Theme rose_pine_moon" });
+ const was = Stepping.begin(&a.t, null);
+ const bytes = try pardes.dump.dumpBytes(a.core);
+ tape.resync(&a.t);
+ was.end();
+ defer a.core.gpa.free(bytes);
+ const r = try Replica.initDump(gpa, 1, 0, bytes, .{ .cols = 80, .rows = 24 });
+ defer r.deinit();
+ const expected = pardes.colors.ChromeTheme.fromTheme(a.core.theme());
+ try std.testing.expectEqualStrings("rose_pine_moon", r.core().theme().name);
+ try std.testing.expectEqual(expected.tag_bg, r.core().chromeTheme().tag_bg);
+ try std.testing.expectEqual(expected.tag_fg, r.core().chromeTheme().tag_fg);
+ r.draw(.{ .ctx = null, .f = null });
+ try std.testing.expectEqual(expected.tag_bg, r.core().surface.chrome.tag_bg);
+ try std.testing.expectEqual(expected.tag_fg, r.core().surface.chrome.tag_fg);
+ try std.testing.expectEqual(digestOf(a), r.digest());
+ // A later theme is an ordinary confirmed unit, its chrome set at once.
+ r.confirm(try a.local(.{ .command = "Theme monokai_pro_classic" }));
+ r.settle();
+ r.draw(.{ .ctx = null, .f = null });
+ const changed = pardes.colors.ChromeTheme.fromTheme(a.core.theme());
+ try std.testing.expectEqual(changed.tag_bg, r.core().surface.chrome.tag_bg);
+ try std.testing.expectEqual(changed.tag_fg, r.core().surface.chrome.tag_fg);
+ try std.testing.expect(r.diverged == null);
+ try std.testing.expectEqual(digestOf(a), r.digest());
+}
+
test "a host's Adopt and a terminal reader's failure are inputs: a replica makes the same pane" {
const gpa = std.testing.allocator;
// Its terminals as screen state, as a session's for its clients are.