- add `dialogs.confirm` to native IPC/contracts and desktop preload/main bridge - switch sidebar worktree deletion prompt from `window.confirm` to native API - add `showDesktopConfirmDialog` helper with unit tests for dialog behavior
17 lines
824 B
TypeScript
17 lines
824 B
TypeScript
import { contextBridge, ipcRenderer } from "electron";
|
|
|
|
const PICK_FOLDER_CHANNEL = "desktop:pick-folder";
|
|
const CONFIRM_CHANNEL = "desktop:confirm";
|
|
const CONTEXT_MENU_CHANNEL = "desktop:context-menu";
|
|
const OPEN_EXTERNAL_CHANNEL = "desktop:open-external";
|
|
const wsUrl = process.env.T3CODE_DESKTOP_WS_URL ?? null;
|
|
|
|
contextBridge.exposeInMainWorld("desktopBridge", {
|
|
getWsUrl: () => wsUrl,
|
|
pickFolder: () => ipcRenderer.invoke(PICK_FOLDER_CHANNEL) as Promise<string | null>,
|
|
confirm: (message: string) => ipcRenderer.invoke(CONFIRM_CHANNEL, message) as Promise<boolean>,
|
|
showContextMenu: (items: { id: string; label: string }[]) =>
|
|
ipcRenderer.invoke(CONTEXT_MENU_CHANNEL, items) as Promise<string | null>,
|
|
openExternal: (url: string) => ipcRenderer.invoke(OPEN_EXTERNAL_CHANNEL, url) as Promise<boolean>,
|
|
});
|