summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-30 21:58:22 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commitad7781f065ba3bbda1041d187c53f220da243131 (patch)
tree63eb73ad6998b278737067a8bd012e916c31f007 /src
parent30011f7269d0febdefbb4c907f8a28d932f44f6f (diff)
downloadpardes-ad7781f065ba3bbda1041d187c53f220da243131.tar.gz
pardes-ad7781f065ba3bbda1041d187c53f220da243131.zip
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: <url>: no frontend attached to open it in a browser", logged as a msg. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/detached/server.zig22
1 files changed, 22 insertions, 0 deletions
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 = .{