@@ -3,6 +3,7 @@ import "./webview-zoom"
33import { render } from "solid-js/web"
44import { AppBaseProviders , AppInterface , PlatformProvider , Platform } from "@opencode-ai/app"
55import { open , save } from "@tauri-apps/plugin-dialog"
6+ import { getCurrent , onOpenUrl } from "@tauri-apps/plugin-deep-link"
67import { open as shellOpen } from "@tauri-apps/plugin-shell"
78import { type as ostype } from "@tauri-apps/plugin-os"
89import { check , Update } from "@tauri-apps/plugin-updater"
@@ -42,6 +43,22 @@ window.getComputedStyle = ((elt: Element, pseudoElt?: string | null) => {
4243
4344let update : Update | null = null
4445
46+ const deepLinkEvent = "opencode:deep-link"
47+
48+ const emitDeepLinks = ( urls : string [ ] ) => {
49+ if ( urls . length === 0 ) return
50+ window . __OPENCODE__ ??= { }
51+ const pending = window . __OPENCODE__ . deepLinks ?? [ ]
52+ window . __OPENCODE__ . deepLinks = [ ...pending , ...urls ]
53+ window . dispatchEvent ( new CustomEvent ( deepLinkEvent , { detail : { urls } } ) )
54+ }
55+
56+ const listenForDeepLinks = async ( ) => {
57+ const startUrls = await getCurrent ( ) . catch ( ( ) => null )
58+ if ( startUrls ?. length ) emitDeepLinks ( startUrls )
59+ await onOpenUrl ( ( urls ) => emitDeepLinks ( urls ) ) . catch ( ( ) => undefined )
60+ }
61+
4562const createPlatform = ( password : Accessor < string | null > ) : Platform => ( {
4663 platform : "desktop" ,
4764 os : ( ( ) => {
@@ -332,6 +349,7 @@ const createPlatform = (password: Accessor<string | null>): Platform => ({
332349} )
333350
334351createMenu ( )
352+ void listenForDeepLinks ( )
335353
336354render ( ( ) => {
337355 const [ serverPassword , setServerPassword ] = createSignal < string | null > ( null )
0 commit comments