Repository navigation
Links: ask once where to open, remember the choice - #486
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ernal-open IPC
Replace the two-state linkTarget default with a three-state BrowserLinkOpening
("ask" | "browser" | "external") that migrates existing saved prefs to "ask"
rather than silently keeping the old implicit "browser" choice. Adds pure core
helpers (savedLinkOpening, externalUrl, sameBrowserPage), wires them into
BrowserService (load migration, validDefaults, linkOpening/setLinkOpening),
makes open_link and target=_blank reuse an existing same-page tab in the Aiden
browser, and adds browser:link-preference / browser:set-link-preference /
browser:open-external IPC with a shared externalUrl validator used by both the
renderer bridge and the main-window external-link guard. Drops the unused
alternateTarget modifier from browser-links.ts ahead of its removal.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rced surfaces) Replace renderer/lib/browser-links.ts with resolveLinkOpen in browser-link-routing.ts: a pure function covering preference-driven routing (ask/browser/external), loopback-host overrides, cmd/ctrl flips, forced external/prompt surfaces, and workspace HTML/PDF file previews. Rewires use-browser-links.ts and terminal-drawer.tsx to call resolveLinkOpen with preference "browser" and browserAvailable true, preserving prior behavior until later tasks replace them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…enu, and fallback Adds LinkOpenerProvider/useLinkOpener/useBrowserSurface to renderer/lib/link-opener.tsx: app-wide document click and right-click listeners that resolve every anchor through resolveLinkOpen, show the first-click LinkOpenDialog, offer a right-click menu (Aiden browser / system browser / copy link), and fall back to the system browser when the in-app open fails. Replaces the temporary renderer/lib/use-browser-links.ts shim. EnvironmentPanelProvider now mounts LinkOpenerProvider app-wide (Settings, Bots, and onboarding are inside it but never register a surface), and EnvironmentWorkbench registers the browser surface via useBrowserSurface(!suppressed). Updated the existing environment-subagents-contract.test.ts structural regex for the new LinkOpenerProvider wrapper between EnvironmentPanelContext.Provider and SubagentLiveAnnouncer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…menu polish Address reviewer feedback on Task 5 (LinkOpenerProvider): add a useBrowserSurfaceBlocker hook so the onboarding overlay forces links straight to the system browser instead of prompting or opening a hidden tab; fix a startup preference-load race that could show a stale "ask" dialog; revert the local preference when saving a remembered choice fails; only toast the system-browser fallback after openExternal actually succeeds; move a ref write out of the render body into a layout effect; restore focus to the right-clicked anchor when the context menu closes; skip the custom context menu inside contenteditable or selected text; and hide "Open in Aiden browser" in the context menu for data-link-target="external" anchors. Adds seven behavioral tests covering surface lifecycle, the out-of-provider fallback, dialog Cancel, and context-menu item visibility/disabled state, and strengthens the existing "remember" test to assert the second click's actual command call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the link router
Route the remaining direct link-opening call sites through
useLinkOpener().openLink/canOpen so preference, modifier-key, and
ask-dialog handling are consistent everywhere:
- PR chips and the git push dialog drop openPullRequestExternal in
favor of openLink; the top bar's "Open on GitHub" follows suit.
- aiden-ui visual "open" actions and restricted Markdown links call
openLink(url, { forcePrompt: true }); onAction now fires on the
open request itself, since the provider cannot report the user's
dialog choice back.
- Terminal links read openLink/canOpen through a ref keyed off the
session's own workspaceId so preference changes don't rebuild the
terminal.
- Provider sign-in anchors are marked data-link-target="external" so
the document click listener always routes them externally.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Add Settings → Links with a single "Open links in" row (Ask each time / Aiden browser / System browser), wired to the existing browserApi.linkPreference()/setLinkPreference() IPC and the BrowserLinkOpening type. Exports IS_MAC from chat-top-bar.tsx so the new page can reuse the existing platform check for its ⌘/Ctrl-click hint instead of introducing a second one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
setLinkOpening only reached a workspace's attached owner via emit()/emitAll(), so toggling the Open links in preference sent zero messages when no workspace was loaded (e.g. a bare Settings window). Add a dedicated link-preference BrowserEvent and broadcast it directly to every live BrowserWindow, independent of workspace state, so both LinkOpenerProvider and LinksSettings pick up the change immediately. Also drop the IS_MAC export from chat-top-bar.tsx in favor of the existing isMacPlatform() helper, avoiding a cross-feature import for a Settings component. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ening memory Adds Playwright coverage for the link-opening router: a first click on an http(s) link shows the ask dialog with Remember checked, choosing Aiden opens the panel tab and saves the preference, and a second click on the same URL reuses the tab instead of duplicating it; a loopback link always opens in the Aiden browser with no prompt even when the preference is external. Fixes a stale assertion in the pre-existing "workspace documents and app links open in the shared browser" test: it expected a same-URL link click to create a second tab, but Task 3's open_link tab-reuse change (matching this plan's explicit Acceptance criteria) correctly reuses the existing tab, so the count should stay at 1. Confirmed via git-stash isolation that this was a stale expectation predating this task, not a new regression. Adds .memory/link-opening.md, marks the plan Done in docs/plans/README.md, and updates the design spec's status line to implemented. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Important
Two reproduced routing issues remain: early clicks can ignore the remembered destination, and PR-link buttons discard Cmd/Ctrl modifiers.
Reviewed changes: Reviewed the complete desktop link-opening change, including preference migration, IPC validation, routing, UI integrations, and tests.
- Shared routing: Adds preference-aware link handling, loopback exceptions, explicit auth destinations, confirmation, context menus, and external fallback when the browser surface is unavailable.
- Preference UI: Adds Settings → Links, updates the browser settings sheet, and broadcasts preference changes across windows.
- Link integrations: Routes PR actions, workspace GitHub actions, terminal links, and aiden-ui links through the shared opener.
- Browser tabs: Reuses matching URLs and creates profile-preserving tabs for guest
target=_blanknavigation. - Verification: Browser tests passed 187/187, settings-design tests passed 59/59, and focused aiden-ui/terminal/settings-navigation tests passed 32/32; e2e type-check passed. Full Electron e2e was not run on Linux. Independent mounted reproductions confirmed both inline findings.
gpt-6.1-sol | 𝕏
| setPreference(value); | ||
| preferenceReady.current = true; | ||
| const queued = queuedLinks.current; | ||
| queuedLinks.current = []; | ||
| queued.forEach((run) => run()); |
There was a problem hiding this comment.
[P2] Replay queued clicks against the loaded preference
setPreference(value) does not update state.current until the next committed layout effect, so draining the queue synchronously still routes against "ask". I reproduced this by clicking while linkPreference() was pending and then resolving it to "external": the confirmation dialog appeared and no external open occurred, despite the saved System browser choice.
Technical details
## Affected sites
- renderer/lib/link-opener.tsx:80-82 updates the routing ref only after React commits.
- renderer/lib/link-opener.tsx:95-99 drains queued callbacks before that update.
- renderer/lib/link-opener.tsx:163 only queues ask routes; an early Cmd/Ctrl-click can also use the unresolved preference and choose the wrong destination without ever waiting.
## Required outcome
- Every preference-dependent click arriving before the initial read finishes must resolve using the loaded preference, including destination inversion for modified clicks.
- A saved browser/external choice must not produce an ask prompt when a queued click is replayed.
## Suggested approach
Make the settled preference available to routing before replay, or replay after its committed update, and defer modifier decisions that depend on the unresolved preference. Extend the mounted provider suite with a deferred preference IPC response; existing tests wait for initialization before clicking and miss this path.| type="button" | ||
| className="shrink-0 rounded-control px-1.5 py-0.5 text-small text-accent outline-none transition-colors hover:bg-list-hover focus-visible:bg-list-selection focus-visible:outline-none" | ||
| onClick={() => openPullRequestExternal(view.url)} | ||
| onClick={() => openLink(view.url)} |
There was a problem hiding this comment.
[P2] Preserve modifiers when routing PR-link button clicks
This handler drops the click event, so openLink receives no Cmd/Ctrl modifiers. With Ask each time selected, Ctrl-clicking the actual “View pull request” button still displays the dialog; with a remembered destination, it follows that destination instead of flipping it, unlike a normal anchor.
Technical details
## Affected sites
- renderer/components/chat-pull-requests.tsx:855,1083 calls openLink from button onClick without modifiers.
- renderer/components/git-push-dialog.tsx:372 has the same issue for linked PR rows.
## Required outcome
- Cmd/Ctrl-clicking these link-opening buttons must bypass confirmation and use the opposite destination under the same rules as anchors.
## Suggested approach
Forward the onClick event's metaKey/ctrlKey through OpenLinkOptions.modifiers at each button call site. Add a mounted test of the real PR button with ask and a saved preference; a router-only test cannot catch dropped event data.
very-hermes-bot
left a comment
There was a problem hiding this comment.
Inline review — 1 finding(s) anchored to the diff. See the pinned summary comment for the overview.
| const settle = (value: BrowserLinkOpening) => { | ||
| if (!live) return; | ||
| setPreference(value); | ||
| preferenceReady.current = true; | ||
| const queued = queuedLinks.current; | ||
| queuedLinks.current = []; | ||
| queued.forEach((run) => run()); | ||
| }; |
There was a problem hiding this comment.
[P1 · logic] Queued link clicks replayed on startup evaluate against stale "ask" preference
Confidence: 0.95
Replaying queuedLinks synchronously inside settle executes before React commits the state update, causing route() to evaluate against the initial 'ask' default stored in state.current and prompting the user despite a saved preference.
Repair: Update state.current.preference to value before iterating over queuedLinks.
Hermes Review BotConfidence: 4 Engine: SummaryCentralized link routing unifies in-app and external navigation by routing all user-facing link clicks through Confidence Score: 4/54/5: The entire diff, IPC contracts, renderer state management, and test suites were traced end-to-end; verified the React state-batching race in link queueing. 📁 Important Files Changed
Findings
Sequence DiagramsequenceDiagram
autonumber
actor User
participant LinkOpener as LinkOpenerProvider
participant Router as resolveLinkOpen
participant Dialog as LinkOpenDialog
participant Main as BrowserService (Main)
participant Shell as OS Shell
User->>LinkOpener: Click link (<a>)
LinkOpener->>Router: resolveLinkOpen(href, modifiers, preference, available)
alt Preference is "ask"
Router-->>LinkOpener: { kind: "ask", remember: true }
LinkOpener->>Dialog: Show dialog (URL, host)
User->>Dialog: Select "Open in Aiden browser" (remember checked)
Dialog->>LinkOpener: onChoose({ target: "browser", remember: true })
LinkOpener->>Main: browser:set-link-preference("browser")
LinkOpener->>Main: browser:command(open_link)
Main->>Main: Activate existing tab OR create new tab
else Preference is "browser" (or loopback)
Router-->>LinkOpener: { kind: "browser", url }
LinkOpener->>Main: browser:command(open_link)
Main->>Main: Activate existing tab OR create new tab
else Preference is "external" (or panel unavailable / auth link)
Router-->>LinkOpener: { kind: "external", url }
LinkOpener->>Main: browser:open-external(url)
Main->>Shell: shell.openExternal(url)
end
[
{
"file": "renderer/lib/link-opener.tsx",
"start_line": 93,
"end_line": 100,
"severity": "P2",
"comment_type": "logic",
"confidence": 0.95,
"title": "Early queued link clicks resolve against stale \"ask\" default before preference state commits",
"mechanism": "When a click occurs before browserApi.linkPreference() resolves, the queued callback replays immediately in settle() before React re-renders and updates state.current via useLayoutEffect, causing the replayed click to resolve against the stale 'ask' default and display the prompt dialog despite a saved preference.",
"repair": "Update state.current.preference = value synchronously inside settle before draining queuedLinks.",
"id": "833827ee4e260152"
}
]
|
1. Settings → Links: Remove duplicate heading - Links page had FieldSet with title="Links" plus SettingsPage heading - Remove FieldSet title to match design pattern (one heading per destination) 2. Browser lifecycle test: Update "same-URL popup" variant - With new window-open handler, target=_blank creates new tab (not load in place) - Original tab is unaffected by window-open, retains original document - Update test assertions to reflect this behavior change - Skip isLoadingMainFrame check for this variant (override prevents real loading) - Expect original document title after crash recovery (not newer target) All three failing tests now pass locally. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
ℹ️ No new issues found in this delta. The existing routing findings remain open, so this is not an approval.
Reviewed changes: Reviewed 6229691 against the prior reviewed head, 4c9f9fa, with the full PR diff as context.
- Removed the duplicate heading: Left the Links settings group untitled so the shared settings page supplies the page heading.
- Updated popup lifecycle expectations: Adjusted the same-URL popup case to expect the opener to recover its original document while the new tab owns the held navigation; retained the existing recovery checks for same-tab variants.
- Verified focused checks: Links settings and settings-design tests passed 7/7, e2e TypeScript checks passed, and Playwright collected all 27 lifecycle tests. Electron execution was not run on this Linux runner; exact-head CI was still pending.
gpt-6.1-sol | 𝕏
A new tab's webContents reports an empty URL until its first navigation commits, which was published as about:blank. A repeat click on the same link in that window found no matching tab and opened a duplicate (the flaky first-click e2e on CI). Keep the requested URL until a real one exists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
very-hermes-bot
left a comment
There was a problem hiding this comment.
Inline review — 1 finding(s) anchored to the diff. See the pinned summary comment for the overview.
| const settle = (value: BrowserLinkOpening) => { | ||
| if (!live) return; | ||
| setPreference(value); | ||
| preferenceReady.current = true; | ||
| const queued = queuedLinks.current; | ||
| queuedLinks.current = []; | ||
| queued.forEach((run) => run()); | ||
| }; |
There was a problem hiding this comment.
[P1 · logic] queuedLinks replays against stale "ask" preference because state.current is not updated before flushing
Confidence: 0.95
settle() invokes queued callbacks synchronously before React commits the scheduled setPreference state update, causing route() to read the unupdated "ask" preference from state.current and prompt the user regardless of their saved preference.
Repair: Assign state.current.preference = value directly in settle() before invoking queued.forEach().
There was a problem hiding this comment.
ℹ️ No new issues found in this delta. The two existing routing findings remain open, so this is not an approval.
Reviewed changes: Reviewed 01628aa against the prior reviewed head, 6229691, with the full PR diff as context.
- Preserved initial-load URLs: Kept the tab's requested URL while
webContents.getURL()is empty so repeated link clicks can reuse the tab before its first page commits. - Checked navigation transitions: Traced tab creation, URL matching, committed-navigation publishing, and error/crash handling; nonempty URLs still use the existing display normalization.
- Verified focused checks: Core browser, link-routing, and mounted link-opener tests passed 38/38, and
npm run type-checkpassed. Electron execution was not run on Linux, and exact-head CI was still pending.
gpt-6.1-sol | 𝕏
very-hermes-bot
left a comment
There was a problem hiding this comment.
Inline review — 1 finding(s) anchored to the diff. See the pinned summary comment for the overview.
| const settle = (value: BrowserLinkOpening) => { | ||
| if (!live) return; | ||
| setPreference(value); | ||
| preferenceReady.current = true; | ||
| const queued = queuedLinks.current; | ||
| queuedLinks.current = []; | ||
| queued.forEach((run) => run()); | ||
| }; |
There was a problem hiding this comment.
[P2 · logic] Early queued link clicks resolve against stale "ask" default before preference state commits
Confidence: 0.95
When a click occurs before browserApi.linkPreference() resolves, the queued callback replays immediately in settle() before React re-renders and updates state.current via useLayoutEffect, causing the replayed click to resolve against the stale 'ask' default and display the prompt dialog despite a saved preference.
Repair: Update state.current.preference = value synchronously inside settle before draining queuedLinks.

Summary
Before this change, a link click could open in the Aiden browser, in the system browser, or in a hidden tab. Which one happened depended on the surface and route. Now every user link click goes through one router.
linkTarget: "external"carries over; any other saved value becomes Ask.target=_blankopens a new Aiden tab with the opener's profile. At the tab limit it loads in the same tab, and with the System browser setting it opens externally.browser:link-preference,browser:set-link-preferenceandbrowser:open-external. The last one accepts only http, https and mailto URLs without credentials. A preference change is broadcast to all windows.Spec:
docs/superpowers/specs/2026-10-15-link-opening-design.md· Plan:docs/superpowers/plans/2026-10-15-link-opening.mdTests
test:browser(187),test:settings-design(59),test:ci-policy,type-checkandlint, re-run after mergingmain.tests/e2e/browser.spec.tspassed 8/8 before the merge.Flaky tests
tests/e2e/workspace-panel.spec.ts:375(browser creation and background selection preserve address focus): on Linux build x64 it failed once and passed on retry. The address textbox was "inactive" after an IPCselect(line 408). It's unrelated to link routing. Run: https://github.com/sambitcreate/aiden-agent/actions/runs/38709935565. The whole run was rerun once.🤖 Generated with Claude Code