Skip to content

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.

fix(outputs): open artifacts in the real default browser from the desktop

Ruben Lütke69316d076ba4
diff --git a/jarvis/ui/web/frontend/src/views/OutputsView.openbrowser.test.tsx b/jarvis/ui/web/frontend/src/views/OutputsView.openbrowser.test.tsx
new file mode 100644
index 0000000000..6134510d2a
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/OutputsView.openbrowser.test.tsx
@@ -0,0 +1,138 @@
+/**
+ * Outputs view — the "Browser" opener must reach the user's REAL browser.
+ *
+ * Regression for the "Browser does nothing" bug: the desktop app embeds
+ * WebView2, which silently drops `window.open` / `target="_blank"`. The "Browser"
+ * opener (and the ExternalLink open button) therefore must route through the
+ * open-external bridge (`openExternalUrl` -> `open_url`, the OS default browser
+ * on every OS), NOT a bare `window.open`. The url handed to the bridge must be
+ * ABSOLUTE, because `open_url` validates an http(s) absolute url.
+ */
+import { afterEach, describe, expect, it, vi } from "vitest";
+import {
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from "@testing-library/react";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+
+import { OutputsView } from "@/views/OutputsView";
+import type { ArtifactSummary, OutputSummary } from "@/hooks/useOutputs";
+
+vi.mock("@/hooks/useWebSocket", () => ({
+ getWSClient: () => null,
+}));
+
+// Spy on the bridge helper; the real implementation hits fetch + window.open.
+vi.mock("@/lib/openExternal", () => ({
+ openExternalUrl: vi.fn(async () => {}),
+}));
+import { openExternalUrl } from "@/lib/openExternal";
+
+afterEach(() => {
+ cleanup();
+ vi.restoreAllMocks();
+ vi.clearAllMocks();
+});
+
+const SLUG = "mission_019f0fa6-4ff6";
+
+function installFetchMock(artifacts: ArtifactSummary[]) {
+ const sessions: OutputSummary[] = [
+ {
+ slug: SLUG,
+ utterance: "Some task",
+ status: "success",
+ mission_id: "m-1",
+ started_at: 1_750_000_000,
+ },
+ ];
+ const fetchMock = vi.fn(async (input: RequestInfo | URL) => {
+ const url = String(input);
+ if (url.includes("/artifacts")) {
+ return { ok: true, status: 200, json: async () => ({ files: artifacts }) };
+ }
+ if (url.includes("/plan")) {
+ return { ok: true, status: 200, json: async () => ({ plan: null, steps: [] }) };
+ }
+ if (url.includes("/capabilities")) {
+ // Desktop run (WebView2) — this is the context that drops window.open.
+ return {
+ ok: true,
+ status: 200,
+ json: async () => ({ native_file_actions: true, platform: "win32" }),
+ };
+ }
+ if (url.includes("/openers")) {
+ return {
+ ok: true,
+ status: 200,
+ json: async () => ({
+ openers: [
+ { id: "default", label: "System default app" },
+ { id: "browser", label: "Browser" },
+ ],
+ }),
+ };
+ }
+ if (url.includes("/preferred-opener")) {
+ return { ok: true, status: 200, json: async () => ({ opener: "" }) };
+ }
+ if (url.includes("/api/outputs")) {
+ return { ok: true, status: 200, json: async () => ({ sessions }) };
+ }
+ return { ok: true, status: 200, json: async () => ({}) };
+ });
+ vi.stubGlobal("fetch", fetchMock);
+}
+
+function renderView() {
+ const client = new QueryClient({
+ defaultOptions: { queries: { retry: false, gcTime: 0, staleTime: 0 } },
+ });
+ return render(
+ <QueryClientProvider client={client}>
+ <OutputsView />
+ </QueryClientProvider>,
+ );
+}
+
+const REPORT: ArtifactSummary = {
+ path: "tasks/019e3288/artifacts/files/report.md",
+ size: 64,
+ mtime: 1_750_000_100,
+ is_text: true,
+ preview: "# Report",
+};
+
+describe("OutputsView — Browser opener reaches the real browser", () => {
+ it("routes the 'Browser' pick through openExternalUrl, not window.open", async () => {
+ const winOpen = vi.spyOn(window, "open").mockReturnValue(null);
+ installFetchMock([REPORT]);
+ renderView();
+
+ // The single session auto-selects, so its artifact row is on screen.
+ await waitFor(() =>
+ expect(screen.getByText(REPORT.path)).toBeTruthy(),
+ );
+
+ // Open the "Open with…" chooser (the ChevronDown next to the open button).
+ fireEvent.click(screen.getByTitle("Change how this opens"));
+ // Pick "Browser".
+ fireEvent.click(await screen.findByRole("button", { name: "Browser" }));
+
+ await waitFor(() =>
+ expect(openExternalUrl).toHaveBeenCalledTimes(1),
+ );
+ const calledWith = vi.mocked(openExternalUrl).mock.calls[0][0];
+ // Absolute http(s) url ending at the artifact's render endpoint.
+ expect(calledWith).toMatch(/^https?:\/\//);
+ expect(calledWith).toContain(
+ `/api/outputs/${SLUG}/files/tasks/019e3288/artifacts/files/report.md/view`,
+ );
+ // The WebView2-dropped bare window.open must NOT be used for the browser pick.
+ expect(winOpen).not.toHaveBeenCalled();
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/views/OutputsView.rerun.test.tsx b/jarvis/ui/web/frontend/src/views/OutputsView.rerun.test.tsx
index 9dadaec5e3..7f94bf69ff 100644
--- a/jarvis/ui/web/frontend/src/views/OutputsView.rerun.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/OutputsView.rerun.test.tsx
@@ -19,9 +19,17 @@ vi.mock("@/hooks/useWebSocket", () => ({
getWSClient: () => null,
}));
+// The "Browser" opener must reach the user's real browser via the open-external
+// bridge (WebView2 drops a bare window.open) — spy on it, not on window.open.
+vi.mock("@/lib/openExternal", () => ({
+ openExternalUrl: vi.fn(async () => {}),
+}));
+import { openExternalUrl } from "@/lib/openExternal";
+
afterEach(() => {
cleanup();
vi.restoreAllMocks();
+ vi.clearAllMocks();
});
function installFetchMock(
@@ -216,7 +224,7 @@ describe("OutputsView artifact actions", () => {
expect(screen.queryByTitle("Open in browser")).toBeNull();
});
- it("opens the browser chooser option via the rendered artifact URL", async () => {
+ it("routes the browser chooser option through the open-external bridge", async () => {
const fetchMock = installFetchMock(
[session({ slug: "artifact-slug", status: "success", mission_id: "m-a" })],
[
@@ -247,17 +255,21 @@ describe("OutputsView artifact actions", () => {
fireEvent.click(screen.getByTitle("Change how this opens"));
fireEvent.click(await screen.findByText("Browser"));
- expect(openSpy).toHaveBeenCalledWith(
+ // Absolute render URL handed to the bridge (open_url needs http(s) absolute),
+ // never a bare window.open (WebView2 drops it) and never /open-with.
+ await waitFor(() => expect(openExternalUrl).toHaveBeenCalledTimes(1));
+ const url = vi.mocked(openExternalUrl).mock.calls[0][0];
+ expect(url).toMatch(/^https?:\/\//);
+ expect(url).toContain(
"/api/outputs/artifact-slug/files/tasks/019edf/artifacts/files/report.md/view",
- "_blank",
- "noopener,noreferrer",
);
+ expect(openSpy).not.toHaveBeenCalled();
expect(
fetchMock.mock.calls.some(([input]) => String(input).includes("/open-with")),
).toBe(false);
});
- it("opens a remembered browser preference via the rendered artifact URL", async () => {
+ it("routes a remembered browser preference through the open-external bridge", async () => {
const fetchMock = installFetchMock(
[session({ slug: "artifact-slug", status: "success", mission_id: "m-a" })],
[
@@ -287,11 +299,13 @@ describe("OutputsView artifact actions", () => {
fireEvent.click(screen.getByTitle("Open"));
- expect(openSpy).toHaveBeenCalledWith(
+ await waitFor(() => expect(openExternalUrl).toHaveBeenCalledTimes(1));
+ const url = vi.mocked(openExternalUrl).mock.calls[0][0];
+ expect(url).toMatch(/^https?:\/\//);
+ expect(url).toContain(
"/api/outputs/artifact-slug/files/tasks/019edf/artifacts/files/report.md/view",
- "_blank",
- "noopener,noreferrer",
);
+ expect(openSpy).not.toHaveBeenCalled();
expect(
fetchMock.mock.calls.some(([input]) => String(input).includes("/open-with")),
).toBe(false);
diff --git a/jarvis/ui/web/frontend/src/views/OutputsView.tsx b/jarvis/ui/web/frontend/src/views/OutputsView.tsx
index 9815fd5c0a..316f0822f8 100644
--- a/jarvis/ui/web/frontend/src/views/OutputsView.tsx
+++ b/jarvis/ui/web/frontend/src/views/OutputsView.tsx
@@ -33,6 +33,7 @@ import {
type ArtifactSummary,
} from "@/hooks/useOutputs";
import { OpenWithDialog } from "@/components/OpenWithDialog";
+import { openExternalUrl } from "@/lib/openExternal";
import { useT } from "@/i18n";
import { applyMissionDragImage } from "@/lib/missionDragImage";
import { useMissionDrag } from "@/store/missionDrag";
@@ -617,9 +618,26 @@ function ArtifactRow({
const preferred = usePreferredOpener();
const setPreferred = useSetPreferredOpener();
+ // The render endpoint as an ABSOLUTE url. The open-external bridge resolves it
+ // through `open_url`, which validates an http(s) absolute url — a relative path
+ // would 400 there and leave only the (WebView2-dropped) window.open fallback.
+ const absoluteOpenUrl = openUrl
+ ? new URL(openUrl, window.location.origin).toString()
+ : null;
+
+ // Open the artifact's render url in the user's real default browser. Routes
+ // through openExternalUrl (the backend open-external bridge), NOT a bare
+ // window.open — the embedded WebView2 desktop shell silently drops
+ // window.open / target="_blank", which is exactly why the "Browser" opener did
+ // nothing on the desktop. The bridge opens the OS default browser on every OS
+ // and falls back to a window.open tab on a headless/remote host.
+ const openInBrowser = () => {
+ if (absoluteOpenUrl) void openExternalUrl(absoluteOpenUrl);
+ };
+
const openWithOpener = (opener: string) => {
- if (opener === "browser" && openUrl) {
- window.open(openUrl, "_blank", "noopener,noreferrer");
+ if (opener === "browser" && absoluteOpenUrl) {
+ openInBrowser();
return;
}
void openArtifactWith(slug, file.path, opener).catch(() => {});
@@ -635,9 +653,10 @@ function ArtifactRow({
const handleOpen = () => {
if (!nativeActions) {
- // Headless VPS: the UI is already a real browser tab — open the render
- // URL there (no local apps to launch).
- if (openUrl) window.open(openUrl, "_blank", "noopener,noreferrer");
+ // Headless VPS / web: the UI is already a real browser tab. openExternalUrl
+ // asks the backend first (no display there -> opened:false) and falls back
+ // to a window.open tab, so the render URL opens in the user's own browser.
+ openInBrowser();
return;
}
const pref = preferred.data ?? "";