diff options
| author | Hegyi Áron Ferenc <[email protected]> | 2026-01-29 08:09:53 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-01-29 15:09:53 +0800 |
| commit | 2af326606c936380c303bf56506e3c8bed04b0eb (patch) | |
| tree | 2c1fe35b7f5f77f88869291168e01e7ab220b566 /packages/desktop/src | |
| parent | 7c0067d59d318bfd6ecd473c36a9e673a4f68ff9 (diff) | |
| download | opencode-2af326606c936380c303bf56506e3c8bed04b0eb.tar.gz opencode-2af326606c936380c303bf56506e3c8bed04b0eb.zip | |
feat(desktop): Add desktop deep link (#10072)
Co-authored-by: Brendan Allan <[email protected]>
Diffstat (limited to 'packages/desktop/src')
| -rw-r--r-- | packages/desktop/src/index.tsx | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/desktop/src/index.tsx b/packages/desktop/src/index.tsx index 344c6be8d..2e7ca136a 100644 --- a/packages/desktop/src/index.tsx +++ b/packages/desktop/src/index.tsx @@ -3,6 +3,7 @@ import "./webview-zoom" import { render } from "solid-js/web" import { AppBaseProviders, AppInterface, PlatformProvider, Platform } from "@opencode-ai/app" import { open, save } from "@tauri-apps/plugin-dialog" +import { getCurrent, onOpenUrl } from "@tauri-apps/plugin-deep-link" import { open as shellOpen } from "@tauri-apps/plugin-shell" import { type as ostype } from "@tauri-apps/plugin-os" import { check, Update } from "@tauri-apps/plugin-updater" @@ -42,6 +43,22 @@ window.getComputedStyle = ((elt: Element, pseudoElt?: string | null) => { let update: Update | null = null +const deepLinkEvent = "opencode:deep-link" + +const emitDeepLinks = (urls: string[]) => { + if (urls.length === 0) return + window.__OPENCODE__ ??= {} + const pending = window.__OPENCODE__.deepLinks ?? [] + window.__OPENCODE__.deepLinks = [...pending, ...urls] + window.dispatchEvent(new CustomEvent(deepLinkEvent, { detail: { urls } })) +} + +const listenForDeepLinks = async () => { + const startUrls = await getCurrent().catch(() => null) + if (startUrls?.length) emitDeepLinks(startUrls) + await onOpenUrl((urls) => emitDeepLinks(urls)).catch(() => undefined) +} + const createPlatform = (password: Accessor<string | null>): Platform => ({ platform: "desktop", os: (() => { @@ -332,6 +349,7 @@ const createPlatform = (password: Accessor<string | null>): Platform => ({ }) createMenu() +void listenForDeepLinks() render(() => { const [serverPassword, setServerPassword] = createSignal<string | null>(null) |
