From e6ea52e36cbb7c557681e6c7a55fa6f0d92f8754 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 02:00:44 -0300 Subject: 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 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/gui/gui.zig | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'src/gui') 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); +} -- cgit v1.3