Skip to content

refactor(desktop): simplify deep links and open sessions by id - #64180

Open
Brendonovich wants to merge 1 commit into
devfrom
deeplink-session
Open

Brendonovich wants to merge 1 commit into
devfrom
deeplink-session

Conversation

@Brendonovich

@Brendonovich Brendonovich commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Simplifies how Desktop main hands deep links to the renderer, and adds opencode://session/<id>. Rebased on #65332, which brought back open-project and new-session in the app (packages/app/src/shell/deep-links); this PR keeps those links working and routes session links through the same machine.

Deep links after this PR:

Link Handled by What it does
opencode://open-project?directory=<path> app Adds the folder as a project on the app's own server and opens a new session in it (unchanged from #65332)
opencode://new-session?directory=<path>&prompt=<text> app Same, with the prompt typed into the composer, not sent (unchanged from #65332)
opencode://session/<id> app New. Opens the session as a tab: from the app's own server first, then each other connected server in list order
opencode://console/authorized?window=<id> main Focuses the window that started the Console sign-in; never queued (unchanged)

What changes:

  • Pull, not push. Main keeps the waiting links in order and renderers take them with AppTakeDeepLinks, once when the app starts listening and again on each DeepLinkReceived. The first app window to take them gets them. This replaces AppReadyDeepLinks, AppAcknowledgeDeepLinks, DeepLinksOpened and main's delivery/acknowledgement machine (src/main/deep-links/machine.ts).
  • Launch links still come from fix(desktop): open projects and new sessions from opencode:// links again #65332's captureLaunchLinks (argv on Windows/Linux, early open-url on macOS).
  • Session links go through the app's deep-link machine with the others, so all links open in the order they came. The machine now also waits for the window's tabs to hydrate and for plugin servers to be listed: tabs opened before hydration would be replaced, and the session lookup needs plugin servers.
  • The desktop renderer's onDeepLinks is now a small bridge over takeDeepLinks / onDeepLink (src/renderer/startup/deep-links.ts).
  • src/shared/deep-links.ts keeps only the Console return parser that main uses.

Not behind a feature flag: session links only act when an external opencode://session/... link is opened.

Known limits (agreed as edge cases): servers are checked one after another, so a slow remote delays later ones; a session found nowhere only logs a console warning.

Recording

Recorded before the rebase. The session behavior is the same; it now runs through the app's deep-link machine.

Cold launch with opencode://session/<local id> opens the local session:

1-cold-launch-local.mp4

App running on Home: a link to a session that only exists on a second server ("Remote box") opens it; a local session link opens a second tab; an unknown ID opens nothing:

2-running-multi-server.mp4

Validation

  • bun typecheck and bun run typecheck:tsc in packages/desktop; bun typecheck in packages/app
  • bun test in packages/desktop; bun test src/shell/deep-links in packages/app

Added by the opencode bot (AI-generated).

Fixes #44167

Related: #53529, #55106

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sound. I couldn't run it: it's Desktop/Electron-only, and there's no way to launch the app or send it opencode:// links here. So I read the code and ran the package checks. bun test in packages/desktop passes. tsc -b is clean. bun typecheck couldn't run because this sandbox has bun 1.4.2 and the repo wants 1.4.4.

The launch link is captured at the top of the entry module and handed over to the lifecycle listener in the same synchronous step, so no open-url can fall between the two. The console return keeps its old targeting: the originating window, else the last focused one. No references to the removed RPCs, events or modules are left.

Public API: no SDK, server, plugin, config or CLI surface changes. The Desktop IPC is internal: AppReadyDeepLinks and AppAcknowledgeDeepLinks become AppTakeDeepLink, and the DeepLinksOpened event becomes DeepLinkReceived. The URL scheme gains opencode://session/<id> and drops open-project and new-session, which nothing handled since #43789.

No blocking concerns.

Fixes #44167
Related: #53529, #55106

@jonathanbabec5-hash

Copy link
Copy Markdown

How

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a deep link to open a specific Desktop session

2 participants