diff options
Diffstat (limited to 'src/detached/server.zig')
| -rw-r--r-- | src/detached/server.zig | 22 |
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 = .{ |
