Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

fix(desktop): let users choose where web links open

yxlyxf79c9a044207
diff --git a/apps/native/components/site/DesktopSettings.tsx b/apps/native/components/site/DesktopSettings.tsx
new file mode 100644
index 00000000..48c3dcb1
--- /dev/null
+++ b/apps/native/components/site/DesktopSettings.tsx
@@ -0,0 +1,64 @@
+"use client";
+import { useEffect, useRef, useState } from "react";
+import { createPortal } from "react-dom";
+import { desktop, type LinkDestination } from "@/lib/desktop";
+
+export default function DesktopSettings() {
+ const [available, setAvailable] = useState(false);
+ const [open, setOpen] = useState(false);
+ const [destination, setDestination] = useState<LinkDestination | null>(null);
+ const [saving, setSaving] = useState(false);
+ const [error, setError] = useState("");
+ const trigger = useRef<HTMLButtonElement>(null);
+ const panel = useRef<HTMLDivElement>(null);
+ useEffect(() => setAvailable(!!desktop()?.linkSettings), []);
+ useEffect(() => {
+ if (!open) return;
+ let alive = true;
+ setDestination(null); setError("");
+ void desktop()!.linkSettings!("load").then(value => { if (alive) setDestination(value); })
+ .catch(() => { if (alive) setError("Could not load link settings. Close Settings and try again."); });
+ panel.current?.querySelector<HTMLButtonElement>("button")?.focus();
+ const keys = (event: KeyboardEvent) => {
+ if (event.key === "Escape") { event.stopPropagation(); setOpen(false); trigger.current?.focus(); }
+ if (event.key === "Tab") {
+ const buttons = Array.from(panel.current?.querySelectorAll<HTMLButtonElement>("button:not(:disabled)") ?? []);
+ if (!buttons.length) return;
+ event.preventDefault();
+ const index = buttons.indexOf(document.activeElement as HTMLButtonElement);
+ buttons[(index + (event.shiftKey ? buttons.length - 1 : 1)) % buttons.length]?.focus();
+ }
+ };
+ document.addEventListener("keydown", keys);
+ return () => { alive = false; document.removeEventListener("keydown", keys); };
+ }, [open]);
+ const choose = async (value: LinkDestination) => {
+ setSaving(true); setError("");
+ try { setDestination(await desktop()!.linkSettings!("save", value)); }
+ catch { setError("Could not save link settings. Try again."); }
+ finally { setSaving(false); }
+ };
+ if (!available) return null;
+ return <>
+ <button ref={trigger} aria-label="Settings" title="Settings" aria-haspopup="dialog" aria-expanded={open}
+ onClick={() => setOpen(value => !value)} className="flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-3 hover:bg-hover hover:text-ink">
+ <svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7"><path d="m9 3-1 3-3 1 1 3-2 2 2 2-1 3 3 1 1 3h6l1-3 3-1-1-3 2-2-2-2 1-3-3-1-1-3Z"/><circle cx="12" cy="12" r="3"/></svg>
+ </button>
+ {open && createPortal(<div className="fixed inset-0 z-[200] flex items-center justify-center bg-black/20 p-4" onPointerDown={event => {
+ if (event.target === event.currentTarget) { setOpen(false); trigger.current?.focus(); }
+ }}>
+ <div ref={panel} role="dialog" aria-label="Settings" aria-modal="true" className="w-[380px] max-w-full rounded-xl border border-line bg-surface p-4 shadow-overlay">
+ <div className="mb-4 flex items-center justify-between"><strong className="text-sm font-medium">Settings</strong><button aria-label="Close settings" onClick={() => { setOpen(false); trigger.current?.focus(); }} className="rounded px-1.5 text-ink-3 hover:bg-hover">×</button></div>
+ <fieldset disabled={destination === null || saving}>
+ <legend className="mb-1 text-xs font-medium">Open web links in</legend>
+ <p className="mb-3 text-xs text-ink-3">Choose where links from conversations open. Graff keeps pages beside your chat.</p>
+ <div className="flex flex-col gap-2">{([['system', 'System default browser'], ['graff', 'Graff built-in Browser']] as const).map(([value, label]) =>
+ <button key={value} aria-pressed={destination === value} onClick={() => void choose(value)} className={`rounded-lg border px-3 py-2 text-left text-xs focus-visible:outline-2 focus-visible:outline-accent disabled:opacity-50 ${destination === value ? "border-accent bg-accent-tint" : "border-line hover:bg-hover"}`}>{label}</button>
+ )}</div>
+ </fieldset>
+ {saving && <p role="status" className="mt-3 text-xs text-ink-3">Saving…</p>}
+ {error && <p role="alert" className="mt-3 text-xs text-red">{error}</p>}
+ </div>
+ </div>, document.body)}
+ </>;
+}
diff --git a/apps/native/components/site/GraffHarness.tsx b/apps/native/components/site/GraffHarness.tsx
index b66ce529..df600512 100644
--- a/apps/native/components/site/GraffHarness.tsx
+++ b/apps/native/components/site/GraffHarness.tsx
@@ -109,8 +109,8 @@ export default function GraffHarness() {
// The sidecar browser: one Chrome tab per chat, and the pins the user
// drops on it, which ride ahead of the chat's next prompt.
const [browserOpen, setBrowserOpen] = useBrowserVisibility(BROWSER_OPEN_KEY, (chat) => {
- const target = chats.find(c => chatHandle(pageRef.current, c.id) === chat);
- if (target) { focusChat(target.id); setFilesOpen(false); } return !!target;
+ const target = chats.find(c => chat ? chatHandle(pageRef.current, c.id) === chat : c.id === activeId);
+ if (target) { focusChat(target.id); setFilesOpen(false); } return target ? chatHandle(pageRef.current, target.id) : false;
});
// The conversation library: every saved chat, paged and searchable. It takes
// the whole chat area, so opening it leaves the other side panes.
diff --git a/apps/native/components/site/HarnessChrome.tsx b/apps/native/components/site/HarnessChrome.tsx
index 70288698..5d873f4a 100644
--- a/apps/native/components/site/HarnessChrome.tsx
+++ b/apps/native/components/site/HarnessChrome.tsx
@@ -1,6 +1,7 @@
import { IconChat, IconFolder, IconGlobe } from "@/lib/icons";
import { useEffect, useRef } from "react";
import { ThemeToggle } from "./ThemeToggle";
+import DesktopSettings from "./DesktopSettings";
import type { Chat } from "./harness-types";
import reviewStyles from "./ChangesPane.module.css";
type Props = {
@@ -141,6 +142,7 @@ export default function HarnessChrome({chats, activeId, busyIds, focusChat, clos
<button aria-label="Toggle terminal" aria-pressed={terminalVisible} title="Terminal (⌘J)" onClick={toggleTerminal} className="rounded-lg px-2 py-1 text-xs text-ink-2 hover:bg-hover"><svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7"><rect x="3" y="4" width="18" height="16" rx="3"/><path d="m7 9 3 3-3 3m6 0h4"/></svg></button>
<button aria-label="Show agents" aria-pressed={agentsOpen} onClick={onAgents} className="flex items-center gap-1.5 rounded-lg px-2 py-1 text-xs text-ink-2 hover:bg-hover"><svg aria-hidden="true" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7"><circle cx="9" cy="7" r="3"/><path d="M3 20v-3a6 6 0 0 1 12 0v3M16 4a3 3 0 0 1 0 6M18 14a5 5 0 0 1 3 4v2"/></svg><span data-toolbar-label>Agents{workingAgents > 0 ? ` (${workingAgents})` : ""}</span>{workingAgents > 0 && <span className="size-1.5 shrink-0 animate-pulse rounded-full" style={{ background: "var(--accent)" }} aria-hidden />}</button>
<ThemeToggle />
+ <DesktopSettings />
</div>
</div>
);
diff --git a/apps/native/components/site/useBrowserVisibility.ts b/apps/native/components/site/useBrowserVisibility.ts
index d7e08b70..bfab581b 100644
--- a/apps/native/components/site/useBrowserVisibility.ts
+++ b/apps/native/components/site/useBrowserVisibility.ts
@@ -1,7 +1,7 @@
"use client";
import { useEffect, useRef, useState } from "react";
import { desktop } from "@/lib/desktop";
-export function useBrowserVisibility(key: string, onAgentOpen: (chat: string) => boolean) {
+export function useBrowserVisibility(key: string, onAgentOpen: (chat?: string) => string | false) {
const [open, setOpen] = useState(false);
const restored = useRef(false);
const callback = useRef(onAgentOpen); callback.current = onAgentOpen;
@@ -13,6 +13,14 @@ export function useBrowserVisibility(key: string, onAgentOpen: (chat: string) =>
}, [key, open]);
useEffect(() => desktop()?.subscribe(event => {
if (event.type === "show" && event.chat) { if (callback.current(event.chat)) setOpen(true); }
+ if (event.type === "open-link" && event.url) {
+ const chat = callback.current();
+ if (chat) {
+ setOpen(true);
+ // Electron already validated the link; navigation remains in the isolated side pane.
+ void desktop()?.browser(chat, "navigate", { url: event.url }).catch(() => {});
+ }
+ }
}), []);
return [open, setOpen] as const;
}
diff --git a/apps/native/electron/external-links.cjs b/apps/native/electron/external-links.cjs
index a785031d..9f16264d 100644
--- a/apps/native/electron/external-links.cjs
+++ b/apps/native/electron/external-links.cjs
@@ -4,9 +4,14 @@ function externalURL(raw) {
catch { return null; }
}
function installExternalLinks(contents, origin, open = url => require('electron').shell.openExternal(url)) {
- const launch = raw => { const url = externalURL(raw); if (url) void Promise.resolve(open(url)).catch(() => {}); };
+ const internal = raw => { try { return new URL(raw).origin === origin; } catch { return false; } };
+ const launch = raw => {
+ const url = externalURL(raw);
+ if (!url || internal(url)) return;
+ try { void Promise.resolve(open(url)).catch(() => {}); } catch { /* A failed destination must not navigate the app. */ }
+ };
contents.on('will-navigate', (event, url) => {
- if (new URL(url).origin === origin) return;
+ if (externalURL(url) && internal(url)) return;
event.preventDefault(); launch(url);
});
contents.setWindowOpenHandler(({ url }) => { launch(url); return { action: 'deny' }; });
diff --git a/apps/native/electron/external-links.test.cjs b/apps/native/electron/external-links.test.cjs
index 402ddda6..b5efc7f8 100644
--- a/apps/native/electron/external-links.test.cjs
+++ b/apps/native/electron/external-links.test.cjs
@@ -2,14 +2,183 @@ const { test } = require('node:test');
const assert = require('node:assert/strict');
const { EventEmitter } = require('node:events');
const { externalURL, installExternalLinks } = require('./external-links.cjs');
-test('clicked web links leave the shell; executable schemes cannot reach the OS', () => {
- const contents = new EventEmitter(); let popup; const opened = [];
+
+const APP_ORIGIN = 'http://127.0.0.1:3788';
+
+function harness(openCallback) {
+ const contents = new EventEmitter();
+ const opened = [];
+ let popup;
contents.setWindowOpenHandler = handler => { popup = handler; };
- installExternalLinks(contents, 'http://127.0.0.1:3788', url => opened.push(url));
- let prevented = false;
- contents.emit('will-navigate', { preventDefault() { prevented = true; } }, 'https://example.com/docs');
- assert.equal(prevented, true); assert.deepEqual(opened, ['https://example.com/docs']);
- popup({ url: 'https://example.com/help' }); popup({ url: 'file:///etc/passwd' });
- assert.equal(opened.length, 2);
- for (const url of ['javascript:alert(1)', 'data:text/html,hi', 'https://user:[email protected]', 'not a URL']) assert.equal(externalURL(url), null);
+ installExternalLinks(contents, APP_ORIGIN, openCallback || (url => opened.push(url)));
+ return {
+ opened,
+ navigate(url) {
+ let prevented = 0;
+ contents.emit('will-navigate', { preventDefault() { prevented += 1; } }, url);
+ return prevented;
+ },
+ popup(url) { return popup({ url }); },
+ };
+}
+
+const validURLs = [
+ ['HTTPS document', 'https://example.com/docs?x=1#section', 'https://example.com/docs?x=1#section'],
+ ['HTTP document', 'http://example.com/docs', 'http://example.com/docs'],
+ ['host and scheme case', 'HTTPS://EXAMPLE.COM/docs', 'https://example.com/docs'],
+ ['HTTPS default port', 'https://example.com:443', 'https://example.com/'],
+ ['HTTP default port', 'http://example.com:80', 'http://example.com/'],
+ ['nondefault port', 'https://example.com:8443/docs', 'https://example.com:8443/docs'],
+ ['dot segments', 'https://example.com/a/../b/./c', 'https://example.com/b/c'],
+ ['spaces in path', 'https://example.com/a b', 'https://example.com/a%20b'],
+ ['international host', 'https://bücher.example/', 'https://xn--bcher-kva.example/'],
+ ['IPv6 host', 'http://[::1]:8080/docs', 'http://[::1]:8080/docs'],
+ ['at sign in path and query', 'https://example.com/@name?email=a@b', 'https://example.com/@name?email=a@b'],
+ ['encoded separators remain encoded', 'https://example.com/a%2Fb?q=%23x', 'https://example.com/a%2Fb?q=%23x'],
+];
+
+const invalidURLs = [
+ ['undefined', undefined],
+ ['null', null],
+ ['number', 42],
+ ['empty string', ''],
+ ['whitespace', ' '],
+ ['plain text', 'not a URL'],
+ ['relative path', '/settings'],
+ ['relative fragment', '#section'],
+ ['protocol-relative URL', '//example.com/docs'],
+ ['missing host', 'https://'],
+ ['invalid IPv6', 'http://[::1'],
+ ['invalid port', 'https://example.com:abc/'],
+ ['out-of-range port', 'https://example.com:65536/'],
+ ['space in host', 'https://exa mple.com/'],
+ ['bad host escape', 'https://%zz/'],
+ ['JavaScript', 'javascript:alert(1)'],
+ ['mixed-case JavaScript', 'JaVaScRiPt:alert(1)'],
+ ['data document', 'data:text/html,<h1>hello</h1>'],
+ ['local file', 'file:///etc/passwd'],
+ ['email', 'mailto:[email protected]'],
+ ['telephone', 'tel:+15555550100'],
+ ['FTP', 'ftp://example.com/file'],
+ ['WebSocket', 'wss://example.com/'],
+ ['blob URL', 'blob:https://example.com/123'],
+ ['blank page', 'about:blank'],
+ ['custom application scheme', 'graff://settings'],
+ ['username and password', 'https://user:[email protected]/'],
+ ['username only', 'https://[email protected]/'],
+ ['password only', 'https://:[email protected]/'],
+ ['encoded username', 'https://%[email protected]/'],
+ ['encoded password', 'https://:%[email protected]/'],
+ ['credentials on app origin', `${APP_ORIGIN.replace('://', '://user:pass@')}/settings`],
+];
+
+for (const [label, raw, canonical] of validURLs) {
+ test(`externalURL canonicalizes ${label}`, () => {
+ assert.equal(externalURL(raw), canonical);
+ assert.equal(externalURL(canonical), canonical, 'canonicalization must be idempotent');
+ });
+ test(`regular click dispatches ${label} once and prevents shell navigation`, () => {
+ const links = harness();
+ assert.equal(links.navigate(raw), 1);
+ assert.deepEqual(links.opened, [canonical]);
+ });
+ test(`target blank dispatches ${label} once but denies the Electron popup`, () => {
+ const links = harness();
+ assert.deepEqual(links.popup(raw), { action: 'deny' });
+ assert.deepEqual(links.opened, [canonical]);
+ });
+}
+
+for (const [label, raw] of invalidURLs) {
+ test(`externalURL rejects ${label}`, () => {
+ assert.equal(externalURL(raw), null);
+ });
+ test(`regular click blocks ${label} without throwing or dispatching`, () => {
+ const links = harness();
+ assert.equal(links.navigate(raw), 1);
+ assert.deepEqual(links.opened, []);
+ });
+ test(`target blank denies ${label} without dispatching`, () => {
+ const links = harness();
+ assert.deepEqual(links.popup(raw), { action: 'deny' });
+ assert.deepEqual(links.opened, []);
+ });
+}
+
+const internalURLs = [
+ `${APP_ORIGIN}/`,
+ `${APP_ORIGIN}/settings?tab=browser`,
+ `${APP_ORIGIN}/workspace/project#file`,
+ `${APP_ORIGIN}/#settings`,
+ `${APP_ORIGIN}/redirect?next=https://example.com/`,
+ 'HTTP://127.0.0.1:3788/settings',
+];
+for (const url of internalURLs) {
+ test(`same-origin navigation remains internal: ${url}`, () => {
+ const links = harness();
+ assert.equal(links.navigate(url), 0);
+ assert.deepEqual(links.opened, []);
+ });
+ test(`same-origin popup is denied without exposing the app origin: ${url}`, () => {
+ const links = harness();
+ assert.deepEqual(links.popup(url), { action: 'deny' });
+ assert.deepEqual(links.opened, []);
+ });
+}
+
+for (const url of [
+ 'http://127.0.0.1:3789/settings',
+ 'http://127.0.0.1/settings',
+ 'https://127.0.0.1:3788/settings',
+ 'http://localhost:3788/settings',
+ 'http://127.0.0.1.example.com:3788/settings',
+]) {
+ test(`origin comparison dispatches a distinct origin: ${url}`, () => {
+ const links = harness();
+ assert.equal(links.navigate(url), 1);
+ assert.deepEqual(links.popup(url), { action: 'deny' });
+ assert.deepEqual(links.opened, [url, url]);
+ });
+}
+
+for (const kind of ['navigate', 'popup']) {
+ test(`${kind} contains synchronous callback throws and handles the next click`, () => {
+ const opened = [];
+ const links = harness(url => {
+ opened.push(url);
+ if (opened.length === 1) throw new Error('destination unavailable');
+ });
+ const expected = kind === 'navigate' ? 1 : { action: 'deny' };
+ assert.deepEqual(links[kind]('https://example.com/first'), expected);
+ assert.deepEqual(links[kind]('https://example.com/second'), expected);
+ assert.deepEqual(opened, ['https://example.com/first', 'https://example.com/second']);
+ });
+
+ test(`${kind} consumes callback rejection and handles subsequent clicks`, async () => {
+ const opened = [];
+ const links = harness(url => {
+ opened.push(url);
+ return Promise.reject(new Error('destination unavailable'));
+ });
+ const expected = kind === 'navigate' ? 1 : { action: 'deny' };
+ assert.deepEqual(links[kind]('https://example.com/first'), expected);
+ // Cross an event-loop turn: node:test reports any unhandled rejection as a failure.
+ await new Promise(resolve => setImmediate(resolve));
+ assert.deepEqual(links[kind]('https://example.com/second'), expected);
+ await new Promise(resolve => setImmediate(resolve));
+ assert.deepEqual(opened, ['https://example.com/first', 'https://example.com/second']);
+ });
+}
+
+test('the supplied callback can change destinations without reinstalling handlers', () => {
+ let destination = 'system';
+ const dispatched = [];
+ const links = harness(url => dispatched.push({ destination, url }));
+ assert.equal(links.navigate('https://example.com/first'), 1);
+ destination = 'built-in';
+ assert.deepEqual(links.popup('https://example.com/second'), { action: 'deny' });
+ assert.deepEqual(dispatched, [
+ { destination: 'system', url: 'https://example.com/first' },
+ { destination: 'built-in', url: 'https://example.com/second' },
+ ]);
});
diff --git a/apps/native/electron/link-destination-visual.cjs b/apps/native/electron/link-destination-visual.cjs
new file mode 100644
index 00000000..2e3b4c28
--- /dev/null
+++ b/apps/native/electron/link-destination-visual.cjs
@@ -0,0 +1,194 @@
+const { BrowserWindow, ipcMain } = require('electron');
+const { BrowserTabs } = require('./browser-tabs.cjs');
+const { installExternalLinks } = require('./external-links.cjs');
+const { installGalleryFixture } = require('./gallery-fixture.cjs');
+const { linkSettings } = require('./link-settings.cjs');
+const assert = require('node:assert/strict');
+const fs = require('node:fs');
+const path = require('node:path');
+const http = require('node:http');
+const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
+
+async function runLinkDestinationVisuals({ origin, output }) {
+ fs.mkdirSync(output, { recursive: true });
+ const directory = fs.mkdtempSync(path.join(output, 'link-settings-'));
+ let store = linkSettings(directory);
+ const fixture = http.createServer((_req, res) => {
+ res.setHeader('content-type', 'text/html');
+ res.end('<!doctype html><title>Link destination fixture</title><h1>Local browser destination</h1>');
+ });
+ await new Promise(resolve => fixture.listen(0, '127.0.0.1', resolve));
+ const destination = `http://127.0.0.1:${fixture.address().port}`;
+ const win = new BrowserWindow({ width: 1440, height: 900, show: true, webPreferences: {
+ preload: path.join(__dirname, 'preload.cjs'), partition: `link-destination-${path.basename(directory)}`,
+ sandbox: true, contextIsolation: true, nodeIntegration: false, backgroundThrottling: false,
+ } });
+ const wc = win.webContents, js = async code => {
+ try { return await wc.executeJavaScript(code); }
+ catch (error) { console.error('Link fixture expression:', code); throw error; }
+ };
+ wc.on('console-message', event => { if (event.level >= 2) console.error('Link renderer:', event.message); });
+ const browser = new BrowserTabs(win, event => wc.send('browser-event', event));
+ const system = [], routed = [], settings = [], blocked = [], errors = [];
+ // Neither session may reach the network or an engine endpoint. Only the app's
+ // static assets and our loopback HTML fixture are allowed through.
+ const guard = allowed => (details, callback) => {
+ const url = new URL(details.url);
+ const deny = !['about:', 'data:'].includes(url.protocol) && (url.origin !== allowed || url.pathname.startsWith('/api/'));
+ if (deny) blocked.push(details.url);
+ callback({ cancel: deny });
+ };
+ wc.session.webRequest.onBeforeRequest(guard(new URL(origin).origin));
+ browser.session.webRequest.onBeforeRequest(guard(destination));
+ ipcMain.handle('link-settings', async (_event, action, value) => {
+ assert.ok(['load', 'save'].includes(action));
+ const result = await (action === 'save' ? store.save(value) : store.load());
+ settings.push({ action, value, result }); return result;
+ });
+ ipcMain.handle('browser', async (_event, { chat, method, params }) => {
+ try { return await browser.command(chat, method, params); }
+ catch (error) { errors.push(error.message); throw error; }
+ });
+ const overlay = (event, value) => { if (event.sender === wc) browser.setOverlay(value); };
+ ipcMain.on('browser-overlay', overlay);
+ installExternalLinks(wc, new URL(origin).origin, async url => {
+ const choice = await store.load(); routed.push({ choice, url });
+ if (choice === 'graff') wc.send('browser-event', { type: 'open-link', url });
+ else system.push(url); // Deliberately never use shell.openExternal.
+ });
+ const wait = async (test, label) => {
+ for (let i = 0; i < 150; i++) { if (await (typeof test === 'string' ? js(test) : test())) return; await sleep(50); }
+ throw Error(`Link destination timeout: ${label || test}`);
+ };
+ const click = selector => js(`document.querySelector(${JSON.stringify(selector)}).click()`);
+ const dialog = '[role="dialog"][aria-label="Settings"]';
+ const labels = { system: 'System default browser', graff: 'Graff built-in Browser' };
+ const option = choice => `Array.from(document.querySelectorAll('${dialog} button')).find(b=>b.textContent.trim()===${JSON.stringify(labels[choice])})`;
+ const selected = async choice => {
+ await wait(`${option(choice)}?.getAttribute('aria-pressed')==='true'`);
+ assert.equal(await js(`${option(choice === 'system' ? 'graff' : 'system')}?.getAttribute('aria-pressed')`), 'false');
+ };
+ const openSettings = async () => {
+ await wait(`!!document.querySelector('[aria-label="Settings"]')`, 'Settings hydrated');
+ await click('[aria-label="Settings"]'); await wait(`!!document.querySelector('${dialog}')`);
+ await wait(() => browser.overlay === true, 'settings hide the native browser view');
+ };
+ const closeSettings = async () => { await click('[aria-label="Close settings"]'); await wait(`!document.querySelector('${dialog}')`); await wait(() => browser.overlay === false, 'closing settings releases the overlay'); };
+ const choose = async choice => {
+ const before = settings.filter(s => s.action === 'save').length;
+ await wait(`${option(choice)} && !${option(choice)}.matches(':disabled')`, 'preference loaded and ready to change');
+ await js(`${option(choice)}.click()`); await selected(choice);
+ await wait(() => settings.filter(s => s.action === 'save').length > before, 'setting saved through real preload');
+ assert.equal(await store.load(), choice);
+ assert.equal(await linkSettings(directory).load(), choice, 'a fresh store reads the UI selection');
+ };
+ // These anchors live inside the real conversation pane, not a test-only route.
+ // Injection also permits unsafe schemes that the markdown sanitizer removes.
+ const link = async (url, target = '', pane = '[data-chat][data-focused="true"]') => {
+ await js(`(()=>{const p=document.querySelector(${JSON.stringify(pane)}) || document.querySelector('[data-chat]');p.querySelector('[data-link-fixture]')?.remove();const a=document.createElement('a');a.dataset.linkFixture='';a.href=${JSON.stringify(url)};a.target=${JSON.stringify(target)};a.textContent='Conversation destination';p.append(a);a.click();})()`);
+ };
+ const screenshot = async name => {
+ await js('new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(() => resolve(true))))');
+ await sleep(100); // Allow Chromium to present the hydrated frame before capture.
+ fs.writeFileSync(path.join(output, name), (await wc.capturePage()).toPNG());
+ };
+ const closeBrowser = async () => {
+ if (await js(`!!document.querySelector('[aria-label="Close browser"]')`)) await click('[aria-label="Close browser"]');
+ await wait(`!document.querySelector('[aria-label="Close browser"]')`);
+ await wait(() => browser.visible === null, 'browser closed');
+ };
+ const route = async (choice, target, suffix) => {
+ const url = `${destination}/${suffix}`, before = routed.length, opened = system.length, appURL = wc.getURL();
+ await link(url, target);
+ await wait(() => routed.length === before + 1, 'conversation link intercepted exactly once');
+ assert.deepEqual(routed[before], { choice, url });
+ if (choice === 'system') {
+ await wait(() => system.length === opened + 1, 'fake system opener');
+ assert.equal(system.at(-1), url);
+ assert.equal(browser.liveCount, 0, 'system links do not create a browser page');
+ assert.equal(await js(`!!document.querySelector('[aria-label="Close browser"]')`), false);
+ } else {
+ await wait(`!!document.querySelector('[aria-label="Close browser"]')`);
+ await wait(() => { const tab = browser.tabs.get(browser.visible); return tab?.view?.webContents.getURL() === url && !tab.view.webContents.isLoading(); }, 'real BrowserTabs navigation');
+ const page = browser.tabs.get(browser.visible).view.webContents;
+ assert.equal(await page.executeJavaScript('document.querySelector("h1").textContent'), 'Local browser destination');
+ await wait(() => browser.tabs.get(browser.visible)?.view?.getVisible(), 'native browser revealed');
+ assert.equal(system.length, opened, 'Graff never invokes even the fake system opener');
+ }
+ assert.equal(wc.getURL(), appURL, 'external links preserve the main app URL');
+ assert.ok(await js(`!!document.querySelector('textarea[aria-label="Prompt"]')`), 'conversation survives routing');
+ };
+ try {
+ await wc.loadURL('about:blank'); wc.debugger.attach('1.3'); await wc.debugger.sendCommand('Page.enable');
+ await wc.debugger.sendCommand('Page.addScriptToEvaluateOnNewDocument', { source: `(${installGalleryFixture.toString()})();` });
+ await wc.loadURL(origin); win.focus(); await wait(`!!document.querySelector('textarea[aria-label="Prompt"]')`);
+ assert.equal(await js(`typeof window.graffDesktop.linkSettings`), 'function', 'real preload exposes linkSettings');
+ await openSettings(); await selected('system');
+ assert.equal(await store.load(), 'system');
+ await screenshot('link-destination-default.png');
+ await closeSettings();
+ await route('system', '', 'default-normal'); await route('system', '_blank', 'default-blank');
+ await openSettings(); await choose('graff'); await closeSettings();
+ await route('graff', '', 'graff-normal');
+ await openSettings();
+ assert.equal(browser.tabs.get(browser.visible).view.getVisible(), false, 'Settings covers the native page');
+ await selected('graff'); await closeSettings();
+ await closeBrowser(); await route('graff', '_blank', 'graff-blank');
+ await screenshot('link-destination-graff.png');
+ await closeBrowser();
+ await new Promise(resolve => { wc.once('did-finish-load', resolve); wc.reload(); });
+ await wait(`!!document.querySelector('textarea[aria-label="Prompt"]')`);
+ await openSettings(); await selected('graff'); await closeSettings();
+ store = linkSettings(directory);
+ await new Promise(resolve => { wc.once('did-finish-load', resolve); wc.reload(); });
+ await wait(`!!document.querySelector('textarea[aria-label="Prompt"]')`);
+ await openSettings(); await selected('graff'); await closeSettings();
+ await route('graff', '', 'persisted'); await closeBrowser();
+ await openSettings(); await choose('system'); await closeSettings();
+ await route('system', '', 'switched-normal'); await route('system', '_blank', 'switched-blank');
+ await openSettings(); await choose('graff'); await closeSettings();
+ await route('graff', '_blank', 'switched-back'); await closeBrowser();
+
+ for (const choice of ['system', 'graff']) {
+ if (await store.load() !== choice) { await openSettings(); await choose(choice); await closeSettings(); }
+ const before = routed.length, appURL = wc.getURL();
+ for (const url of ['file:///graff-link-fixture-denied', 'data:text/html,denied', `http://user:[email protected]:${fixture.address().port}/denied`]) {
+ for (const target of ['', '_blank']) await link(url, target);
+ }
+ await sleep(300);
+ assert.equal(routed.length, before, `${choice}: unsafe and credential-bearing links never reach either opener`);
+ assert.equal(browser.liveCount, 0); assert.equal(wc.getURL(), appURL);
+ }
+ // Split focus must choose a different real browser tab without moving panes.
+ await js(`document.querySelector('textarea').focus();document.activeElement.dispatchEvent(new KeyboardEvent('keydown',{key:'d',metaKey:true,bubbles:true,cancelable:true}))`);
+ await wait(`document.querySelectorAll('[data-chat]').length===2`);
+ const panes = await js(`Array.from(document.querySelectorAll('[data-chat]')).map(p=>p.dataset.chat)`);
+ const handles = [];
+ for (const id of panes) {
+ const selector = `[data-chat="${id}"] textarea`;
+ const point = await js(`(()=>{const r=document.querySelector(${JSON.stringify(selector)}).getBoundingClientRect();return {x:Math.round(r.x+r.width/2),y:Math.round(r.y+r.height/2)}})()`);
+ wc.sendInputEvent({ type: 'mouseDown', button: 'left', clickCount: 1, ...point });
+ wc.sendInputEvent({ type: 'mouseUp', button: 'left', clickCount: 1, ...point });
+ await wait(`document.querySelector('[data-chat][data-focused="true"]')?.dataset.chat===${JSON.stringify(id)}`);
+ await route('graff', '', `split-${id}`); handles.push(browser.visible);
+ assert.equal(await js(`document.querySelector('[data-chat][data-focused="true"]').dataset.chat`), id);
+ await closeBrowser();
+ }
+ assert.notEqual(handles[0], handles[1], 'focused split chats own distinct browser tabs');
+ assert.deepEqual(await js(`Array.from(document.querySelectorAll('[data-chat]')).map(p=>p.dataset.chat)`), panes);
+ const before = routed.length;
+ await link(`${origin}/#link-destination-local`);
+ await wait(() => wc.getURL() === `${origin}/#link-destination-local`, 'same-origin anchor retains native navigation');
+ assert.equal(routed.length, before, 'same-origin links bypass external routing');
+ assert.ok(await js(`!!document.querySelector('textarea[aria-label="Prompt"]')`));
+ assert.deepEqual(errors, [], 'browser IPC completes without errors');
+ assert.deepEqual(blocked, [], 'no external network or engine/model requests attempted');
+ console.log('Link destination visuals passed: default/save/switch, reload and fresh-store persistence, normal/blank links, closed-browser reveal, overlays, unsafe/same-origin links, split focus and preserved app.');
+ } finally {
+ ipcMain.removeHandler('link-settings'); ipcMain.removeHandler('browser'); ipcMain.removeListener('browser-overlay', overlay);
+ browser.closeAll(); win.destroy(); browser.session.webRequest.onBeforeRequest(null);
+ await new Promise(resolve => fixture.close(resolve));
+ fs.rmSync(directory, { recursive: true, force: true });
+ }
+}
+module.exports = { runLinkDestinationVisuals };
diff --git a/apps/native/electron/link-settings.cjs b/apps/native/electron/link-settings.cjs
new file mode 100644
index 00000000..ba5421d9
--- /dev/null
+++ b/apps/native/electron/link-settings.cjs
@@ -0,0 +1,32 @@
+const fs = require('node:fs/promises');
+const path = require('node:path');
+const { randomUUID } = require('node:crypto');
+function validate(value) {
+ if (value !== 'system' && value !== 'graff') throw Error('Invalid link preference');
+ return value;
+}
+function linkSettings(directory) {
+ const file = path.join(directory, 'web-links.json'); let pending = Promise.resolve();
+ return {
+ async load() {
+ await pending;
+ let data;
+ try { data = await fs.readFile(file, 'utf8'); } catch (error) { if (error.code === 'ENOENT') return 'system'; throw error; }
+ try { return validate(JSON.parse(data)); } catch { return 'system'; }
+ },
+ async save(value) {
+ const data = validate(value);
+ const write = pending.then(async () => {
+ await fs.mkdir(directory, { recursive: true });
+ const temporary = `${file}.${randomUUID()}.next`;
+ try {
+ await fs.writeFile(temporary, JSON.stringify(data), { mode: 0o600, flag: 'wx' });
+ await fs.rename(temporary, file);
+ } finally { await fs.unlink(temporary).catch(() => {}); }
+ return data;
+ });
+ pending = write.catch(() => {}); return write;
+ },
+ };
+}
+module.exports = { linkSettings };
diff --git a/apps/native/electron/link-settings.test.cjs b/apps/native/electron/link-settings.test.cjs
new file mode 100644
index 00000000..6dd73107
--- /dev/null
+++ b/apps/native/electron/link-settings.test.cjs
@@ -0,0 +1,114 @@
+const { test } = require('node:test');
+const assert = require('node:assert/strict');
+const fs = require('node:fs/promises'), os = require('node:os'), path = require('node:path');
+const { promisify } = require('node:util');
+const execFile = promisify(require('node:child_process').execFile);
+const { linkSettings } = require('./link-settings.cjs');
+async function fixture(t) {
+ const root = await fs.mkdtemp(path.join(os.tmpdir(), 'link-settings-'));
+ t.after(() => fs.rm(root, { recursive: true, force: true }));
+ return root;
+}
+test('missing directory defaults to system without creating files', async t => {
+ const directory = path.join(await fixture(t), 'nested', 'settings');
+ assert.equal(await linkSettings(directory).load(), 'system');
+ await assert.rejects(fs.stat(directory), { code: 'ENOENT' });
+});
+test('missing file defaults to system and leaves other settings alone', async t => {
+ const root = await fixture(t);
+ await fs.writeFile(path.join(root, 'projects.json'), '{"list":[]}');
+ const store = linkSettings(root);
+ assert.equal(await store.load(), 'system');
+ await store.save('graff');
+ assert.equal(await fs.readFile(path.join(root, 'projects.json'), 'utf8'), '{"list":[]}');
+ assert.deepEqual((await fs.readdir(root)).sort(), ['projects.json', 'web-links.json']);
+});
+for (const data of ['', '{', 'undefined', 'null', 'true', '42', '[]', '{}', '"GRAFF"', '"graff "', '{"preference":"graff"}']) {
+ test(`corrupt or invalid stored data defaults to system: ${JSON.stringify(data)}`, async t => {
+ const root = await fixture(t);
+ await fs.writeFile(path.join(root, 'web-links.json'), data);
+ const store = linkSettings(root);
+ assert.equal(await store.load(), 'system');
+ assert.equal(await store.save('graff'), 'graff');
+ assert.equal(await store.load(), 'graff');
+ });
+}
+for (const value of ['system', 'graff']) {
+ test(`${value} roundtrips through a new store and a new process`, async t => {
+ const directory = path.join(await fixture(t), 'nested');
+ const store = linkSettings(directory);
+ assert.equal(await store.save(value), value);
+ assert.equal(await store.load(), value);
+ assert.equal(await linkSettings(directory).load(), value);
+ assert.equal(JSON.parse(await fs.readFile(path.join(directory, 'web-links.json'), 'utf8')), value);
+ const { stdout } = await execFile(process.execPath, ['-e',
+ 'require(process.argv[1]).linkSettings(process.argv[2]).load().then(value => process.stdout.write(value));',
+ require.resolve('./link-settings.cjs'), directory]);
+ assert.equal(stdout, value);
+ });
+}
+test('invalid saves reject promises without changing the saved preference', async t => {
+ const root = await fixture(t), store = linkSettings(root);
+ await store.save('graff');
+ for (const value of [undefined, null, false, 0, '', 'SYSTEM', 'Graff', 'system ', ' graff', [], {}, new String('graff')]) {
+ await assert.rejects(store.save(value), /Invalid link preference/);
+ assert.equal(await store.load(), 'graff');
+ }
+ assert.equal(await store.save('system'), 'system');
+});
+test('concurrent saves resolve in call order and load waits for all queued writes', async t => {
+ const root = await fixture(t), store = linkSettings(root), completed = [];
+ const values = Array.from({ length: 40 }, (_, i) => i % 2 ? 'graff' : 'system');
+ const writes = values.map((value, i) => store.save(value).then(result => { completed.push(i); return result; }));
+ const read = store.load();
+ assert.equal(await read, 'graff');
+ assert.deepEqual(await Promise.all(writes), values);
+ assert.deepEqual(completed, values.map((_, i) => i));
+ assert.equal(await linkSettings(root).load(), 'graff');
+ assert.deepEqual(await fs.readdir(root), ['web-links.json']);
+});
+test('independent stores write complete JSON using separate temporary files', async t => {
+ const root = await fixture(t);
+ await Promise.all(Array.from({ length: 20 }, (_, i) => linkSettings(root).save(i % 2 ? 'graff' : 'system')));
+ assert.ok(['system', 'graff'].includes(await linkSettings(root).load()));
+ assert.deepEqual(await fs.readdir(root), ['web-links.json']);
+});
+test('directory creation failure rejects without poisoning subsequent saves', async t => {
+ const root = await fixture(t), directory = path.join(root, 'settings');
+ await fs.writeFile(directory, 'blocked');
+ const store = linkSettings(directory);
+ await assert.rejects(store.save('graff'));
+ await fs.unlink(directory);
+ assert.equal(await store.load(), 'system');
+ assert.equal(await store.save('graff'), 'graff');
+ assert.equal(await store.load(), 'graff');
+});
+test('rename failure cleans temporary files and allows recovery', async t => {
+ const root = await fixture(t), file = path.join(root, 'web-links.json');
+ await fs.mkdir(file);
+ const store = linkSettings(root);
+ await assert.rejects(store.save('graff'));
+ assert.deepEqual(await fs.readdir(root), ['web-links.json']);
+ await fs.rmdir(file);
+ assert.equal(await store.save('system'), 'system');
+ assert.equal(await store.load(), 'system');
+});
+test('saved files are private, including replacement of a permissive file', { skip: process.platform === 'win32' }, async t => {
+ const root = await fixture(t), file = path.join(root, 'web-links.json'), store = linkSettings(root);
+ await store.save('graff');
+ assert.equal((await fs.stat(file)).mode & 0o777, 0o600);
+ await fs.chmod(file, 0o644);
+ await store.save('system');
+ assert.equal((await fs.stat(file)).mode & 0o777, 0o600);
+});
+test('permission failure preserves the old preference and subsequent saves recover', { skip: process.platform === 'win32' || process.getuid?.() === 0 }, async t => {
+ const root = await fixture(t), store = linkSettings(root);
+ await store.save('system');
+ await fs.chmod(root, 0o500);
+ try {
+ await assert.rejects(store.save('graff'), { code: 'EACCES' });
+ assert.equal(await store.load(), 'system');
+ } finally { await fs.chmod(root, 0o700); }
+ assert.equal(await store.save('graff'), 'graff');
+ assert.equal(await store.load(), 'graff');
+});
diff --git a/apps/native/electron/main.cjs b/apps/native/electron/main.cjs
index 716f028a..5723d6e2 100644
--- a/apps/native/electron/main.cjs
+++ b/apps/native/electron/main.cjs
@@ -131,7 +131,18 @@ app.whenReady().then(async () => {
win.webContents.focus();
win.webContents.send('browser-event', { chat: tab.chat, type: 'pin', pin });
});
- installExternalLinks(win.webContents, backend.origin);
+ const linkSettings = require('./link-settings.cjs').linkSettings(app.getPath('userData'));
+ ipcMain.handle('link-settings', (event, action, value) => {
+ trusted(event);
+ if (action === 'load') return linkSettings.load();
+ if (action === 'save') return linkSettings.save(value);
+ throw new Error('Unknown link settings action');
+ });
+ installExternalLinks(win.webContents, backend.origin, async url => {
+ if (await linkSettings.load() === 'graff') {
+ if (!win.isDestroyed()) win.webContents.send('browser-event', { type: 'open-link', url });
+ } else await require('electron').shell.openExternal(url);
+ });
win.on('minimize', () => { if (browser.visible) browser.hide(browser.visible); });
win.on('restore', () => win.webContents.send('browser-event', { type: 'layout' }));
const updateMenu = require('./updates.cjs').installUpdates({ app, win, ipcMain, trusted, resources });
diff --git a/apps/native/electron/preload.cjs b/apps/native/electron/preload.cjs
index b8442405..39aafbfd 100644
--- a/apps/native/electron/preload.cjs
+++ b/apps/native/electron/preload.cjs
@@ -1,6 +1,7 @@
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('graffDesktop', {
projects: (action, value) => ipcRenderer.invoke('projects', { action, value }),
+ linkSettings: (action, value) => ipcRenderer.invoke('link-settings', action, value),
updates: (action, value) => ipcRenderer.invoke('updates', action, value),
updateSubscribe: callback => {
const listener = (_event, state) => callback(state);
diff --git a/apps/native/electron/visual-tests.cjs b/apps/native/electron/visual-tests.cjs
index 153138d8..0b6ddf61 100644
--- a/apps/native/electron/visual-tests.cjs
+++ b/apps/native/electron/visual-tests.cjs
@@ -37,6 +37,12 @@ app.whenReady().then(async () => {
assert.deepEqual(apiRequests, [], 'Overflow fixtures never call live APIs');
return;
}
+ if (process.env.GRAFF_VISUAL_SUITE === 'links') {
+ win.hide();
+ await require('./link-destination-visual.cjs').runLinkDestinationVisuals({ origin, output });
+ assert.deepEqual(apiRequests, [], 'Link fixtures never call engine or model APIs');
+ return;
+ }
if (process.env.GRAFF_VISUAL_SUITE === 'updates') {
await require('./updates-visual.cjs').runUpdateVisuals({ origin, output });
await require('./updates-transport.cjs').runUpdateTransport();
@@ -49,6 +55,7 @@ app.whenReady().then(async () => {
if (process.env.GRAFF_VISUAL_SUITE !== 'interactions') {
await require('./browser-visual.cjs').runBrowserVisuals({ win, origin, output });
await require('./dev-preview-visual.cjs').runDevPreview({ output });
+ await require('./link-destination-visual.cjs').runLinkDestinationVisuals({ origin, output });
}
assert.deepEqual(apiRequests, [], 'Project fixtures never call engine or model APIs');
fs.writeFileSync(path.join(output, 'results.json'), JSON.stringify({ passed: process.env.GRAFF_VISUAL_SUITE === 'interactions' ? ['keyboard, composer, files and reading'] : ['projects and navigation', 'browser'], apiRequests }, null, 2));
@@ -103,6 +110,7 @@ app.whenReady().then(async () => {
await require('./agents-visual.cjs').runAgentVisuals({ win, origin, output });
await require('./updates-visual.cjs').runUpdateVisuals({ origin, output });
await require('./updates-transport.cjs').runUpdateTransport();
+ await require('./link-destination-visual.cjs').runLinkDestinationVisuals({ origin, output });
if (process.env.GRAFF_PERFORMANCE_TESTS) await require('./performance-scenarios.cjs').runPerformance({ win, origin, output });
assert.deepEqual(apiRequests, [], 'Visual fixtures must not call the engine or model APIs');
fs.writeFileSync(path.join(output, 'results.json'), JSON.stringify({ passed: results, apiRequests }, null, 2));
diff --git a/apps/native/lib/desktop.ts b/apps/native/lib/desktop.ts
index 165080a6..b9914e5d 100644
--- a/apps/native/lib/desktop.ts
+++ b/apps/native/lib/desktop.ts
@@ -1,10 +1,12 @@
import type { BrowserPin, KuriHandle } from "./browser/annotations";
import type { PageInfo } from "./browser-client";
-export type DesktopEvent = { type: string; chat?: string; info?: PageInfo; pin?: BrowserPin };
+export type DesktopEvent = { type: string; chat?: string; url?: string; info?: PageInfo; pin?: BrowserPin };
+export type LinkDestination = 'system' | 'graff';
export type TerminalEvent = { id: string; seq: number; data?: string; exit?: number };
export type UpdateState = { status: 'idle' | 'unavailable' | 'checking' | 'current' | 'downloading' | 'ready' | 'installing' | 'error'; currentVersion: string; version?: string; percent?: number; automatic: boolean; interactive: boolean; message?: string };
export type DesktopBridge = {
+ linkSettings?(action: 'load' | 'save', value?: LinkDestination): Promise<LinkDestination>;
projects?(action: 'load' | 'save', value?: { list: import('./workspaces').Workspace[]; active: string | null }): Promise<{ list: import('./workspaces').Workspace[]; active: string | null } | null | void>;
updates?(action: 'state' | 'check' | 'restart' | 'automatic', value?: boolean): Promise<UpdateState>;
updateSubscribe?(callback: (state: UpdateState) => void): () => void;
diff --git a/apps/native/package.json b/apps/native/package.json
index bd921a53..3d262c3d 100644
--- a/apps/native/package.json
+++ b/apps/native/package.json
@@ -16,6 +16,7 @@
"test:desktop": "bun test lib ./electron/*.test.cjs",
"test:visual": "bun scripts/test-visual.mjs",
"test:updates": "GRAFF_VISUAL_SUITE=updates bun scripts/test-visual.mjs",
+ "test:links": "GRAFF_VISUAL_SUITE=links bun scripts/test-visual.mjs",
"test:interactions": "GRAFF_VISUAL_SUITE=interactions bun scripts/test-visual.mjs",
"test:projects": "GRAFF_VISUAL_SUITE=projects bun scripts/test-visual.mjs",
"test:splits": "GRAFF_VISUAL_SUITE=splits bun scripts/test-visual.mjs",
diff --git a/docs/adr/0096-desktop-link-destination.md b/docs/adr/0096-desktop-link-destination.md
new file mode 100644
index 00000000..878076bd
--- /dev/null
+++ b/docs/adr/0096-desktop-link-destination.md
@@ -0,0 +1,33 @@
+# 0096. Desktop web links share one destination policy
+
+Status: accepted 2026-09-10
+
+## Context
+
+Conversation links always opened in the system browser, even when users
+wanted to keep pages beside their chat (#824). The desktop server's origin
+can change between launches, so origin-scoped browser storage alone cannot
+reliably preserve this preference.
+
+## Decision
+
+Store the explicit `system` or `graff` choice atomically in desktop user data.
+Default missing or invalid preferences to the existing system-browser behavior.
+Expose the setting through trusted app-frame IPC, not to browser pages.
+
+Use Electron's shared navigation interception for both normal links and
+new-window links rather than adding handlers to individual Markdown renderers.
+Validate HTTP(S) URLs and reject credentials before routing either destination.
+Same-origin app navigation stays in the app; same-origin popups are denied.
+
+For Graff, send the validated link to the renderer, which resolves the focused
+chat and reveals its existing isolated Browser pane. Never replace the main
+application view or fall back to the system browser when Graff navigation fails.
+
+## Consequences
+
+The preference survives origin changes and restarts. All conversation renderers
+use the same routing policy without coupling Markdown to Electron. The renderer
+still owns chat focus and pane layout; Electron owns URL safety and OS opening.
+Persistence, routing edge cases, and real Electron interactions are covered by
+the desktop tests and `test:links`, also included in `test:projects`.
diff --git a/docs/adr/README.md b/docs/adr/README.md
index d08b5ce8..580e5de9 100644
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@ -105,6 +105,7 @@ record only when you need the evidence or the edge cases.
| [0092](0092-codedb-context-is-local-first.md) | Bare `codedb context` is `--local`; `--hybrid` / `--semantic` are opt-in remote rerank (and still refused under ADR 0084 policy). |
| [0093](0093-project-layout-breadth-and-directory-hints.md) | Project layout favors breadth under its caps; missing directories offer bounded sibling hints without changing confinement or ADR 0090 constraint policy. |
| [0094](0094-subagent-interrupt-is-a-cancel-file.md) | GUI Stop writes `{id}.cancel` in the activity dir; the child finishes failed even if the model returns. Not `session/cancel`. |
+| [0096](0096-desktop-link-destination.md) | Persist the desktop link destination outside origin-scoped storage; validate once and reveal the focused chat's Browser without navigating the app. |
## When to write one