fix: open external links in VS Code runtime
Route shared URL opening through VS Code host instead of webview window APIs Add a VS Code runtime URL-open API and bridge handler using vscode.env.openExternal Keep shared URL helper behavior unchanged for desktop and web
This commit is contained in:
@@ -619,6 +619,7 @@ export interface EditorAPI {
|
||||
export interface VSCodeAPI {
|
||||
executeCommand(command: string, ...args: unknown[]): Promise<unknown>;
|
||||
openAgentManager(): Promise<void>;
|
||||
openExternalUrl(url: string): Promise<void>;
|
||||
}
|
||||
|
||||
export interface PushSubscribePayload {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { getRegisteredRuntimeAPIs } from '@/contexts/runtimeAPIRegistry';
|
||||
|
||||
/**
|
||||
* Utility for opening external URLs with Tauri shell support.
|
||||
* In desktop runtime, uses tauri.shell.open() for proper system browser handling.
|
||||
@@ -55,6 +57,16 @@ export const openExternalUrl = async (url: string): Promise<boolean> => {
|
||||
|
||||
const normalizedTarget = parsed.toString();
|
||||
|
||||
const runtimeApis = getRegisteredRuntimeAPIs();
|
||||
if (runtimeApis?.runtime?.isVSCode && runtimeApis.vscode?.openExternalUrl) {
|
||||
try {
|
||||
await runtimeApis.vscode.openExternalUrl(normalizedTarget);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const tauri = (window as unknown as { __TAURI__?: TauriShell }).__TAURI__;
|
||||
if (tauri?.shell?.open) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user