fix(desktop): open workspace links from the terminal in the app

HU
1h ago
+573-13

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. TerminalLinkManager set allowNonHttpProtocols: false on its OSC 8 handler, so xterm never created a superset:// link.
  • TerminalPane's onUrlClick sent every URL through the URL link actions, so the web workspace URL went to a browser.

What changed:

  • renderer/lib/parseWorkspaceLinkUrl (new, same layout as parseSupersetPageUrl): returns the workspace id for ${PROTOCOL_SCHEME}://workspace/<id> (and the legacy v2-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 optional isOscAppLink predicate on TerminalLinkHandlers. xterm 6.1's OscLinkProvider creates non-http(s) links only when allowNonHttpProtocols is true, and then passes every scheme to activate/hover. So the handler turns the flag on only when the predicate is given, and filters activate itself: http(s) and links the predicate recognizes go to onUrlClick. file:, javascript: and every other unknown scheme never reach onUrlClick, whose fallback is external.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. a cursor:// or file:// link over a visible path). For those (including an unrecognized superset://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 visible path:line:col works 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: sets isOscAppLink: isWorkspaceLink, and calls navigateToWorkspace when terminalWorkspaceLinkTarget returns 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:

LinkPlain clickShift-clickCmd/Ctrl-click
superset://workspace/<id> or superset://v2-workspace/<id>switch to workspaceswitch to workspaceswitch to workspace
https://app…/workspaces/<id>switch to workspacesystem 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= (what superset sessions prints 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 bare superset://… printed without OSC 8 is still not clickable.
  • A dev build uses superset-<workspace>:// as its scheme, so it does not activate the superset:// 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. isOscAppLink is 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.ts now covers allowNonHttpProtocols (still false without the predicate), activation of app links and http(s), that file:, javascript:, an unrecognized superset: link and non-URLs never reach the URL handler, and that a non-app OSC link over a visible path:line:col opens 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.ts covers the click matrix above.
  • bun run lint (clean, no warnings) and bun run typecheck in apps/desktop pass. bun test on renderer/lib/parseWorkspaceLinkUrl, renderer/lib/terminal, renderer/lib/clickPolicy and usePaneRegistry: 5028 pass, 0 fail, on top of main at 627d60635a.
  • Full apps/desktop bun test: 9380 pass, 5 fail. The failures are in branch-detached-worktree.test.ts and native-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.sh failed at "Apply migrations": drizzle-kit migrate only finds @neondatabase/serverless in packages/db, so it opens a TLS WebSocket to the local Postgres and fails with self-signed certificate. I then replayed the migration SQL with psql, and that stopped at 0122_webhook_events_swap_to_short_retention on 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 lint and bun run typecheck pass (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)

https://claude.ai/code/session_011eciYLpAxuPY6JEVQwGpw2