Skip to content

feat(desktop): open existing sessions from deep links - #45103

Closed
filantus wants to merge 2 commits into
anomalyco:devfrom
filantus:session-deep-link
Closed

filantus wants to merge 2 commits into
anomalyco:devfrom
filantus:session-deep-link

Conversation

@filantus

@filantus filantus commented Aug 26, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #44167

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds opencode://open-session?server=...&session=... links for existing Desktop sessions. The app resolves the configured server plus canonical session lineage before navigating.

Adds Copy link to the custom session-tab context menu introduced by #46116. It copies the public URL on Desktop and an absolute web URL in the browser, with localized success/error feedback.

Desktop forwards protocol URLs from both initial startup arguments and second-instance delivery. Deep-link handling is serialized so launches are processed in delivery order, while a single argument batch uses its last supported URL.

This complements #44137: that PR creates a new session from an external URL, while this one opens an existing Desktop session.

How did you verify your code works?

  • bun test --conditions=solid --preload ./happydom.ts ./src/pages/layout/helpers.test.ts from packages/app (33 passed)
  • bun test ./src/main/deep-links.test.ts from packages/desktop (2 passed)
  • bun run typecheck from packages/app and packages/desktop (passed)
  • bun turbo typecheck via the pre-push hook after merging upstream dev (30 tasks passed)
  • Prettier check passed; targeted oxlint reported no errors, with five warnings on unchanged lines
  • Original deep-link routing was manually tested in an unpacked Windows build. The restored Copy link menu was manually tested in a separate local Desktop build.

Screenshots / recordings

The session-tab context menu now contains Rename, Copy link, and Close tab. No screenshot is attached.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@dekart

dekart commented Aug 28, 2026

Copy link
Copy Markdown

I'd love to see this feature added

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

@filantus

Copy link
Copy Markdown
Author

Hi @Brendonovich, could you consider reopening this PR? It addresses #44167, which is still open. The branch on my fork is updated against dev, and I verified the Desktop build locally, including opening an existing session via deep link. The closed PR still shows its previous head commit, so the link points to the updated code. Thanks!

Trance-0 added a commit to Trance-0/AGENTS.md that referenced this pull request Oct 3, 2026
The Info tab now opens on a Projects tree: every project opencode knows about,
with its sessions loaded only when the group is expanded.

Why the counts looked wrong: the status line reported index totals while
calling them sessions. The index only describes external transcripts, so it
could never agree with opencode's own session count, which also includes
natively created sessions this plugin never imported. Audited both directions
first - 0 dangling, 0 orphaned - so nothing was actually lost. The line now
reports sources / imported / pending alongside opencode sessions / native /
projects, each labelled for what it counts.

Panels gain a 	ree type (lib/registry.ts): collapsible groups plus a
children(groupID) resolver. snapshot() strips children before
serialising, so it stays server-side and runs only for a group the user
actually opened - a plugin listing hundreds of sessions would otherwise build
all of them on every five-second poll. Served by a new
GET /api/plugins/:id/panel/:key/children.

Sessions are read from opencode's own project/session tables rather than the
index, so native sessions appear beside imported ones, each card labelled
opencode / Claude Code / Codex / dsh from metadata.imported.source.

Project editing via a three-dot menu: rename, add a folder or remote URL, and
merge into another project. The menu is appended to document.body and
suppresses the poll while open, because a refresh rebuilds the pane wholesale
and would close it mid-click. Merging re-points session rows and cannot be
undone from the UI, so it snapshots the database with VACUUM INTO first - a
plain copy would risk a torn file, since WAL keeps committed pages in the -wal
sidecar. Each edit ends by asking for a restart, since opencode reads its
project list at startup.

Clicking a session opens its transcript here, not in the app. The desktop
app's deep-link parser accepts only open-project and new-session, with no
session-scoped route, so 'Open in opencode' opens the project and the
transcript is rendered in the dashboard rather than pretending to hand off.
A shared redirect-capable card for this and task-queue is deferred until
anomalyco/opencode#45103 lands; building it now would only encode the
current limitation.

Verified: 12 HTTP checks over a real server (snapshot shape, children
endpoint, 400s for missing group / unknown panel / unknown plugin, ':' in a
project id round-tripping, CSS shipped); 15 checks of rename/add/merge against
a copy of the real database, confirming no sessions are lost, the backup is a
valid database still holding the pre-merge state, and self/unknown merges are
refused; the deep link proven to leave no shell metacharacter unencoded. The
live database was never opened for writing and is unchanged at 349 sessions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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