fix(desktop): open workspace links from the terminal in the app
What & why
I run many coding agents at once in Paradev, one workspace each, plus an orchestrator agent that reports on all of them. The orchestrator prints a board of links to the other workspaces: superset://v2-workspace/<id> (what superset ws open --local <id> --print returns), or the web form https://app.superset.sh/workspaces/<id>.
In Paradev's own terminal, neither link gets you to the workspace. The superset:// link does nothing, and the https:// link opens a browser tab. With this change, a click on one of those links in an agent's output switches the app to that workspace and its agent. Moving between workspaces, and the agents working in them, becomes one click from the board.
Why they failed:
- Claude Code prints markdown links as OSC 8 hyperlinks.
TerminalLinkManagersetallowNonHttpProtocols: falseon its OSC 8 handler, so xterm never created asuperset://link. TerminalPane'sonUrlClicksent every URL through the URL link actions, so the web workspace URL went to a browser.
What changed:
renderer/lib/parseWorkspaceLinkUrl(new, same layout asparseSupersetPageUrl): returns the workspace id for${PROTOCOL_SCHEME}://workspace/<id>(and the legacyv2-workspace/<id>the CLI still prints) and for<web origin or its twin>/workspaces/<id>. It ignores query and hash. It returns null for other deep links, other web pages, other origins, nested paths and non-URLs.TerminalLinkManager: new optionalisOscAppLinkpredicate onTerminalLinkHandlers. xterm 6.1'sOscLinkProvidercreates non-http(s) links only whenallowNonHttpProtocolsis true, and then passes every scheme toactivate/hover. So the handler turns the flag on only when the predicate is given, and filtersactivateitself: http(s) and links the predicate recognizes go toonUrlClick.file:,javascript:and every other unknown scheme never reachonUrlClick, whose fallback isexternal.openUrl. xterm's OSC provider runs before ours, so an OSC link we don't open as a URL would hide the text link under it (e.g. acursor://orfile://link over a visible path). For those (including an unrecognizedsuperset://tasks/<id>), the handler activates or hovers the one visible text link that our own providers find on any row of the OSC range, so a visiblepath:line:colworks exactly as when xterm dropped the OSC link. With none, or with two separate visible links, nothing happens, which is also the behaviour before this PR. URL hover stays http(s)-only, because it feeds the URL hint and the right-click "Open in" menu. Those would offer a browser pane for an app link.TerminalPane: setsisOscAppLink: isWorkspaceLink, and callsnavigateToWorkspacewhenterminalWorkspaceLinkTargetreturns an id.
Click behaviour (I followed the bare pull-request precedent in terminalUrlLinkAction). Only a primary-button click switches workspace, since xterm activates links on any mouseup:
| Link | Plain click | Shift-click | Cmd/Ctrl-click |
|---|---|---|---|
superset://workspace/<id> or superset://v2-workspace/<id> | switch to workspace | switch to workspace | switch to workspace |
https://app…/workspaces/<id> | switch to workspace | system browser (like a bare PR URL) | URL link settings, as before |
The deep link only makes sense in the app, so every click switches. Otherwise a modifier click would send superset:// into a browser pane. The web form keeps a way out to the browser.
Out of scope, possible follow-ups:
?sessionId=(whatsuperset sessionsprints for a chat) is ignored here: the click opens the workspace but does not focus that chat.- The plain-text URL detector only knows http(s) and
file://, so a baresuperset://…printed without OSC 8 is still not clickable. - A dev build uses
superset-<workspace>://as its scheme, so it does not activate thesuperset://links the released CLI prints.
Related
- Partly addresses #5972 and #9562: OSC 8 links with a non-http(s) scheme now activate, but only for the app's own
superset:scheme.isOscAppLinkis a hook #9562 could build its allow-list on; opening other schemes through the OS is left to that issue. - Overlaps the draft #5973, which touches the same OSC 8 handler.
How I tested it
- New unit tests:
parseWorkspaceLinkUrl.test.ts(both forms, the twin origin, the dev scheme, and the null cases above).terminal-link-manager.test.tsnow coversallowNonHttpProtocols(still false without the predicate), activation of app links and http(s), thatfile:,javascript:, an unrecognizedsuperset:link and non-URLs never reach the URL handler, and that a non-app OSC link over a visiblepath:line:colopens that path at that position (also on a later row of a wrapped span), reports it on hover, drops stale hovers, and does nothing when two separate links sit under it.runTerminalLinkAction.test.tscovers the click matrix above. bun run lint(clean, no warnings) andbun run typecheckinapps/desktoppass.bun testonrenderer/lib/parseWorkspaceLinkUrl,renderer/lib/terminal,renderer/lib/clickPolicyandusePaneRegistry: 5028 pass, 0 fail, on top ofmainat 627d60635a.- Full
apps/desktopbun test: 9380 pass, 5 fail. The failures are inbranch-detached-worktree.test.tsandnative-messaging-ports.test.ts, plus one unnamed 5 s timeout. None of them touches this change. Both files pass 13/13 when run alone, so they look like load or ordering flakes in the full run on my machine. - Not done: no before/after capture from the dev app. I could not get the local stack up.
./.paradev/setup.local.shfailed at "Apply migrations":drizzle-kit migrateonly finds@neondatabase/serverlessinpackages/db, so it opens a TLS WebSocket to the local Postgres and fails withself-signed certificate. I then replayed the migration SQL withpsql, and that stopped at0122_webhook_events_swap_to_short_retentionon the container's Postgres 17. So I have not clicked a link in the running app, and the end-to-end behaviour has not been checked by hand. Happy to add the capture if a maintainer can point me to the right local setup.
Checklist
- PR title follows conventional commits (
type(scope): subject) -
bun run lintandbun run typecheckpass (CI fails on lint warnings too) - "Allow edits from maintainers" is checked on fork PRs
- I have signed the CLA (the bot asks on your first PR)