Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix: require modifier for terminal links
Ruben Lütkee665e0768304
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsxindex 1ccc96d7be..0d6e45fc01 100644--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx@@ -97,6 +97,10 @@ import {alignTerminalCells,syncTerminalFont,} from "@/lib/terminalFont";+import {+ activateTerminalLink,+ TERMINAL_OSC_LINK_HANDLER,+} from "@/lib/terminalLinks";import { installPasteBridge } from "./terminalPaste";import { createKeyEventChain } from "./terminalKeyChain";import { installNewlineBridge } from "./terminalNewline";@@ -440,6 +444,10 @@ export function AgenticTerminal({// Instant scrolling: an agent that redraws a live status line while// animating a scroll leaves visible tearing.smoothScrollDuration: 0,+ // Plain clicks belong to text selection. xterm otherwise treats an+ // ordinary click on an OSC-8 link as navigation and shows a native+ // warning dialog inside the desktop WebView.+ linkHandler: TERMINAL_OSC_LINK_HANDLER,// Windows only. ConPTY re-emits and re-wraps lines in a way a POSIX pty// never does; without telling xterm which backend it is talking to, those// re-emitted lines pile up as duplicated, half-overwritten rows. Harmless@@ -458,7 +466,7 @@ export function AgenticTerminal({const disposeQuerySuppression = installQuerySuppression(term.parser);const fit = new FitAddon();term.loadAddon(fit);- term.loadAddon(new WebLinksAddon());+ term.loadAddon(new WebLinksAddon(activateTerminalLink));// Character WIDTH, not appearance: without this xterm measures emoji and// many box/symbol glyphs as one cell while the agent on the other side// counted two, and every such glyph shifts the rest of the line one columndiff --git a/jarvis/ui/web/frontend/src/components/missions/PtyTerminal.tsx b/jarvis/ui/web/frontend/src/components/missions/PtyTerminal.tsxindex 5bf883f4dc..ddf10d2da9 100644--- a/jarvis/ui/web/frontend/src/components/missions/PtyTerminal.tsx+++ b/jarvis/ui/web/frontend/src/components/missions/PtyTerminal.tsx@@ -22,6 +22,10 @@ import { AlertCircle, Terminal as TerminalIcon } from "lucide-react";import { useT } from "@/i18n";import { buildMissionSocketUrl, fetchMissionToken } from "@/lib/missionAuth";import { TERMINAL_FONT_STACK, syncTerminalFont } from "@/lib/terminalFont";+import {+ activateTerminalLink,+ TERMINAL_OSC_LINK_HANDLER,+} from "@/lib/terminalLinks";import {disposeTerminal,getTerminal,@@ -78,6 +82,7 @@ export function PtyTerminal({ workerId }: PtyTerminalProps) {lineHeight: 1.2,cursorBlink: false,scrollback: 5000,+ linkHandler: TERMINAL_OSC_LINK_HANDLER,theme: {background: "#0b0d10",foreground: "#e6e6e6",@@ -87,7 +92,7 @@ export function PtyTerminal({ workerId }: PtyTerminalProps) {});const fit = new FitAddon();term.loadAddon(fit);- term.loadAddon(new WebLinksAddon());+ term.loadAddon(new WebLinksAddon(activateTerminalLink));term.loadAddon(new SearchAddon());term.open(containerRef.current);fit.fit();diff --git a/jarvis/ui/web/frontend/src/components/workspace/WorkspaceTerminal.tsx b/jarvis/ui/web/frontend/src/components/workspace/WorkspaceTerminal.tsxindex 291675d914..56c1375aaa 100644--- a/jarvis/ui/web/frontend/src/components/workspace/WorkspaceTerminal.tsx+++ b/jarvis/ui/web/frontend/src/components/workspace/WorkspaceTerminal.tsx@@ -15,6 +15,10 @@ import "@xterm/xterm/css/xterm.css";import { Terminal as TerminalIcon, AlertCircle } from "lucide-react";import { installNewlineBridge } from "../agentic/terminalNewline";import { TERMINAL_FONT_STACK, syncTerminalFont } from "@/lib/terminalFont";+import {+ activateTerminalLink,+ TERMINAL_OSC_LINK_HANDLER,+} from "@/lib/terminalLinks";type Status = "connecting" | "live" | "exited" | "error";@@ -58,6 +62,7 @@ export function WorkspaceTerminal({lineHeight: 1.15,cursorBlink: true,scrollback: 5000,+ linkHandler: TERMINAL_OSC_LINK_HANDLER,theme: {background: "#0b0d10",foreground: "#e6e6e6",@@ -67,7 +72,7 @@ export function WorkspaceTerminal({});const fit = new FitAddon();term.loadAddon(fit);- term.loadAddon(new WebLinksAddon());+ term.loadAddon(new WebLinksAddon(activateTerminalLink));term.open(container);// Shift+Enter breaks the line instead of sending a half-written// instruction — the same binding the Agentic IDE panes have, because it isdiff --git a/jarvis/ui/web/frontend/src/lib/terminalLinks.test.ts b/jarvis/ui/web/frontend/src/lib/terminalLinks.test.tsnew file mode 100644index 0000000000..9daad1bbf4--- /dev/null+++ b/jarvis/ui/web/frontend/src/lib/terminalLinks.test.ts@@ -0,0 +1,65 @@+import { beforeEach, describe, expect, it, vi } from "vitest";++vi.mock("@/lib/openExternal", () => ({+ openExternalUrl: vi.fn(async () => undefined),+}));++import { openExternalUrl } from "@/lib/openExternal";+import {+ activateTerminalLink,+ TERMINAL_OSC_LINK_HANDLER,+} from "./terminalLinks";++const openExternal = vi.mocked(openExternalUrl);++function click(options: MouseEventInit = {}): MouseEvent {+ return new MouseEvent("mouseup", { button: 0, ...options });+}++describe("terminal links", () => {+ beforeEach(() => {+ openExternal.mockClear();+ });++ it("leaves ordinary clicks available for selecting linked terminal text", () => {+ activateTerminalLink(click(), "https://startups.microsoft.com/");++ expect(openExternal).not.toHaveBeenCalled();+ });++ it("opens an HTTP link on an explicit Ctrl-click", () => {+ activateTerminalLink(+ click({ ctrlKey: true }),+ "https://startups.microsoft.com/",+ );++ expect(openExternal).toHaveBeenCalledWith(+ "https://startups.microsoft.com/",+ );+ });++ it("supports the macOS Cmd-click convention for OSC-8 links", () => {+ TERMINAL_OSC_LINK_HANDLER.activate(+ click({ metaKey: true }),+ "https://example.com/docs",+ );++ expect(openExternal).toHaveBeenCalledWith("https://example.com/docs");+ });++ it("refuses non-web protocols even with a modifier", () => {+ activateTerminalLink(click({ ctrlKey: true }), "javascript:alert(1)");+ activateTerminalLink(click({ ctrlKey: true }), "file:///private/data");++ expect(openExternal).not.toHaveBeenCalled();+ });++ it("does not open from a modified non-primary click", () => {+ activateTerminalLink(+ click({ button: 2, ctrlKey: true }),+ "https://example.com",+ );++ expect(openExternal).not.toHaveBeenCalled();+ });+});diff --git a/jarvis/ui/web/frontend/src/lib/terminalLinks.ts b/jarvis/ui/web/frontend/src/lib/terminalLinks.tsnew file mode 100644index 0000000000..f253b62b7d--- /dev/null+++ b/jarvis/ui/web/frontend/src/lib/terminalLinks.ts@@ -0,0 +1,30 @@+/**+ * Safe link activation shared by every embedded xterm terminal.+ *+ * Terminal output is untrusted and xterm's default OSC-8 handler opens a+ * native confirmation dialog on an ordinary click. That makes selecting text+ * which happens to carry a hyperlink look like a navigation attempt. Keep+ * ordinary clicks available for selection and require the conventional+ * Ctrl/Cmd modifier before opening an explicit HTTP(S) link.+ */+import { openExternalUrl } from "@/lib/openExternal";++function isHttpUrl(value: string): boolean {+ try {+ const protocol = new URL(value).protocol;+ return protocol === "http:" || protocol === "https:";+ } catch {+ return false;+ }+}++export function activateTerminalLink(event: MouseEvent, uri: string): void {+ if (event.button !== 0 || (!event.ctrlKey && !event.metaKey)) return;+ if (!isHttpUrl(uri)) return;+ void openExternalUrl(uri);+}++/** Handler for hyperlinks emitted through the terminal's OSC-8 protocol. */+export const TERMINAL_OSC_LINK_HANDLER = {+ activate: activateTerminalLink,+};