Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/tui/.changes/local-file-links.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Added support for opening file links from the fullscreen terminal UI.
2 changes: 1 addition & 1 deletion packages/tui/src/tui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ export class TUI extends Container {
let href: string;
try {
const parsed = new URL(url);
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return;
if (parsed.protocol !== "http:" && parsed.protocol !== "https:" && parsed.protocol !== "file:") return;
href = parsed.href;
} catch {
return;
Expand Down
10 changes: 7 additions & 3 deletions packages/tui/test/fullscreen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1066,9 +1066,11 @@ describe("TUI fullscreen mode", () => {
tui.stop();
});

it("ignores clicked hyperlinks with non-http schemes", async () => {
it("opens file hyperlinks and ignores unsupported schemes", async () => {
const transcript = lines(20);
transcript[12] = "\x1b]8;;file:///etc/passwd\x1b\\secrets\x1b]8;;\x1b\\";
transcript[12] =
"\x1b]8;;file:///tmp/example%20file.txt\x1b\\file\x1b]8;;\x1b\\ " +
"\x1b]8;;ssh://example.com\x1b\\remote\x1b]8;;\x1b\\";
const { terminal, tui, chat, dock } = setup(transcript);
const opened: string[] = [];
tui.onOpenUrl = (url) => opened.push(url);
Expand All @@ -1077,8 +1079,10 @@ describe("TUI fullscreen mode", () => {

terminal.sendInput("\x1b[<0;3;1M");
terminal.sendInput("\x1b[<0;3;1m");
terminal.sendInput("\x1b[<0;7;1M");
terminal.sendInput("\x1b[<0;7;1m");
await terminal.waitForRender();
assert.deepStrictEqual(opened, []);
assert.deepStrictEqual(opened, ["file:///tmp/example%20file.txt"]);

tui.stop();
});
Expand Down
Loading