GeezerVison is showing github.com — fix(desktop): open projects and new sessions from opencode:// links again by Hona · Pull Request #65332 · anomalyco/opencode
Conversation
Hona
commented
Nov 21, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Screenshots
The app window, on a dev build. Each link was handed to the app the way Windows does it: a second launch with the link on its command line (the running app gets it on second-instance), or, for the last row, the launch that starts the app.
| Link |
Before |
After |
opencode://open-project?directory=C:\demo\billing-api, app running |
 |
 |
opencode://new-session?directory=C:\demo\billing-api&prompt=Add a refund endpoint to the invoices API |
 |
 |
| The open-project link starts the app |
 |
 |
Issue for this PR
No linked issue. The routing was lost in #40947 (a1b4843a33, "refactor(app): remove legacy layout", Aug 7): handleDeepLinks lived only in the legacy layout (packages/app/src/pages/layout.tsx), which listened for opencode:deep-link. The new layout never had a listener, so links already did nothing there. #43789 (9be3aa92b5) then deleted the unused parser (pages/layout/deep-links.ts).
Since then the desktop still receives the link, delivers it to a window and focuses that window, and nothing opens.
Type of change
What does this PR do?
Restores the two links from #10072 and #15322, with the same URLs:
opencode://open-project?directory=<folder> adds the folder as a project on the app's own server and opens a new session in it.
opencode://new-session?directory=<folder>&prompt=<text> does the same with the prompt typed into the composer. The prompt is not sent.
How it works:
- App: a small state machine (
src/shell/deep-links/machine.ts) parses the links and holds them until the app's own server is connected and has its project list. Then it opens them in order. A folder the server can't open shows the server's error, as Open project does. The shell runs it through a new optional platform.onDeepLinks. The web platform doesn't define it, so the web app is unchanged.
- Desktop renderer: links that reach the window before the app listens wait in
startup/deep-links.ts and go to the first listener. That replaces the unused window.__OPENCODE__.deepLinks array and opencode:deep-link event.
- Desktop main, cold start: the entry module now keeps the links the app was started with and hands them to the
DeepLinks router once it exists. Until now these were never read:
- On Windows and Linux they are on the command line (
process.argv), which nothing read; only second-instance argv was read.
- On macOS they arrive as
open-url while the app finishes launching. The router's listener is installed only after the main bundle loads, so the link could arrive before it.
Platforms: this fixes every platform where the scheme is registered, which is all three desktop platforms:
- Windows:
app.setAsDefaultProtocolClient("opencode") at startup writes the per-user registration.
- macOS: the bundle's
CFBundleURLTypes, from electron-builder's protocols.
- Linux: the same
protocols entry in the package's desktop file, plus setAsDefaultProtocolClient at startup.
How did you verify your code works?
bun test src/shell/deep-links in packages/app with its usual preloads (12 pass, new):
- parsing: Windows and POSIX folders, an optional prompt, missing or control-character folders, other hosts and schemes, a malformed URL;
- a link that started the app waits for the server, then all open in order;
- a link opens at once while the server is ready and waits again after it drops;
- links the app doesn't open change nothing.
bun test src/renderer/startup/deep-links.test.ts src/main/deep-links in packages/desktop (9 pass). The new case checks that links that came before the app listened reach its first listener once, and that later links reach the current listeners.
bun typecheck in packages/app, bun run typecheck:tsc in packages/desktop, bun run lint:changed origin/dev clean.
- On Windows, links handed to a dev build while it runs and as the launch that starts it (screenshots above).
- Not tested: clicking a link in a browser, which needs an installed build that owns the scheme, and macOS and Linux.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Added by the opencode bot (AI-generated).
Fixes #55106
Related: #44167, #53529
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks sound to me. I read it against the main-process deep-link router and the app's projects.add / tabs.newDraft. I also ran the new tests: 12 pass in packages/app and 9 in packages/desktop. The TypeScript check (tsc -b) is clean in both packages. I couldn't click a real opencode:// link, because that needs an installed desktop build that owns the scheme. Please confirm it by hand on at least one platform, both with the app closed and with it running.
Public API is unchanged. onDeepLinks is an optional addition to the internal platform type, the link formats match v1, and the removed window.__OPENCODE__.deepLinks / opencode:deep-link had no other users.
One small inline note: queued links don't necessarily open in the order they came in.
Fixes #55106
Related: #44167, #53529
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new commit fixes the earlier ordering point: queued links now open one after another, and a link that fails doesn't block the ones after it. I re-ran the deep-link tests in both packages and the packages/app type check after the merge, and all pass. I didn't re-run the desktop type check because the new commit only changes app code. I still couldn't click a real opencode:// link, so please check it by hand on an installed build, both with the app closed and with it running. Public API is unchanged. Nothing new to raise.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|