GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@Hona Hona commented Nov 21, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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 Before: nothing opens After: billing-api opens in a new session
opencode://new-session?directory=C:\demo\billing-api&prompt=Add a refund endpoint to the invoices API Before: nothing opens After: a new session with the prompt typed in, not sent
The open-project link starts the app Before: the app opens on Home After: the app opens on the project's new session

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

  • Bug fix

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.

All reactions
@Hona
fix(desktop): open projects and new sessions from opencode:// links a…
3b299b3
…gain
opencodejr[bot]
opencodejr Bot reviewed Nov 21, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

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.

All reactions
Comment thread packages/app/src/shell/deep-links/deep-links.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@alextrepa alextrepa mentioned this pull request Nov 21, 2026
Agent handoff opens OpenCode threads in the OpenCode desktop app, once it opens sessions by link les-cabochons/ajour#858
Open
Hona added 2 commits November 21, 2026 17:53
@Hona
Merge remote-tracking branch 'origin/dev' into deep-link-routing
ba4282f
@Hona
fix(app): open queued opencode:// links one after another, in order
d85a18d
opencodejr[bot]
opencodejr Bot reviewed Nov 21, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

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.

All reactions
@Hona
Hona merged commit b310a05 into dev Nov 21, 2026
12 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@Hona
Hona deleted the deep-link-routing branch November 21, 2026 10:28
@opencodejr opencodejr Bot mentioned this pull request Nov 21, 2026
feat(desktop): add New Session and New Window to the Windows jump list #65327
Merged
3 tasks done
@BrewTestBot BrewTestBot mentioned this pull request Nov 23, 2026
opencode 2.4.0 Homebrew/homebrew-core#327368
Merged
@amrkmn amrkmn mentioned this pull request Nov 23, 2026
opencode 2.4.0 amrkmn/homebrew-tap#1251
Closed
1 task
@github-actions github-actions Bot mentioned this pull request Nov 23, 2026
feat: opencode release v2.4.0 sprisa/opencode-server#95
Merged
@opencode-agent opencode-agent Bot mentioned this pull request Nov 24, 2026
refactor(desktop): simplify deep links and open sessions by id #64180
Open
@scottames-github-bot scottames-github-bot Bot mentioned this pull request Nov 27, 2026
chore(deps): update ⬆️ mise-packages scottames/dots#1181
Merged
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[FEATURE]: opencode://new-session in OpenCode 2's desktop app, as in OpenCode 1

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@Hona
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.