From ad7781f065ba3bbda1041d187c53f220da243131 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 30 Sep 2026 21:58:22 -0300 Subject: A link looked at in a detached session with no frontend attached opens no browser and says so in a msg With no frontend to send it to, the link was kept and nothing said, so a script could not tell the look had landed or why nothing opened. It still opens nothing on the session's own desktop, and now leaves "look: : no frontend attached to open it in a browser", logged as a msg. Co-Authored-By: Claude Opus 5.5 --- src/detached/server.zig | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/detached') diff --git a/src/detached/server.zig b/src/detached/server.zig index 2b87bd60..78b85836 100644 --- a/src/detached/server.zig +++ b/src/detached/server.zig @@ -627,7 +627,11 @@ pub const Session = struct { fn openLink(ctx: ?*anyopaque, url: []const u8) void { const s = of(ctx); if (s.origins()) |c| return s.send(c, .{ .open_link = url }); + // No frontend: the session's own desktop is nobody's to open a + // browser on. Kept, and said, so a script sees the look land. s.core.fallback.setLink(url); + var said: [320]u8 = undefined; + s.core.setMessage(s.core.active, std.fmt.bufPrint(&said, "look: {s}: no frontend attached to open it in a browser", .{url}) catch "look: no frontend attached to open a link"); } fn detach(ctx: ?*anyopaque) void { @@ -1309,6 +1313,24 @@ pub fn run(init: std.process.Init, opts: pardes.Options, name: []const u8) !void } } +test "a link looked at with no frontend attached opens no browser, and says so" { + const gpa = std.testing.allocator; + var s: Session = .{ + .gpa = gpa, + .worker_gpa = gpa, + .io = std.testing.io, + .core = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }), + .cols = 40, + .rows = 12, + }; + defer s.core.deinit(); + defer s.deinit(); + Session.openLink(&s, "https://example.com/x"); + try std.testing.expectEqualStrings("https://example.com/x", s.core.fallback.link.items); + const pane = s.core.panes[s.core.active].?; + try std.testing.expectEqualStrings("look: https://example.com/x: no frontend attached to open it in a browser", pane.msg[0..pane.msg_len]); +} + test "detached queued results preserve current requests and are discarded before Restore" { const gpa = std.testing.allocator; var s: Session = .{ -- cgit v1.3