Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions packages/desktop/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +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 { open as shellOpen } from "@tauri-apps/plugin-shell"
import { openUrl } from "@tauri-apps/plugin-opener"
import { type as ostype } from "@tauri-apps/plugin-os"
import { check, Update } from "@tauri-apps/plugin-updater"
import { invoke } from "@tauri-apps/api/core"
Expand Down Expand Up @@ -77,7 +77,7 @@ const createPlatform = (password: Accessor<string | null>): Platform => ({
},

openLink(url: string) {
void shellOpen(url).catch(() => undefined)
void openUrl(url).catch(() => undefined)
},

back() {
Expand Down Expand Up @@ -337,11 +337,31 @@ render(() => {
const platform = createPlatform(() => serverPassword())

function handleClick(e: MouseEvent) {
const link = (e.target as HTMLElement).closest("a.external-link") as HTMLAnchorElement | null
if (link?.href) {
e.preventDefault()
platform.openLink(link.href)
}
if (e.defaultPrevented) return
if (e.button !== 0) return
if (!(e.target instanceof Element)) return

const link = e.target.closest("a[href]")
if (!(link instanceof HTMLAnchorElement)) return

const href = link.getAttribute("href")
if (!href) return

const url = (() => {
try {
return new URL(href, window.location.href)
} catch {
return
}
})()
if (!url) return

const http = url.protocol === "http:" || url.protocol === "https:"
if (!http) return
if (url.origin === window.location.origin) return

e.preventDefault()
platform.openLink(url.toString())
}

onMount(() => {
Expand Down