diff options
Diffstat (limited to 'packages/desktop/src/context')
| -rw-r--r-- | packages/desktop/src/context/platform.tsx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/packages/desktop/src/context/platform.tsx b/packages/desktop/src/context/platform.tsx new file mode 100644 index 000000000..21be49cbd --- /dev/null +++ b/packages/desktop/src/context/platform.tsx @@ -0,0 +1,25 @@ +import { createSimpleContext } from "@opencode-ai/ui/context" + +export type Platform = { + /** Platform discriminator */ + platform: "web" | "tauri" + + /** Open native directory picker dialog (Tauri only) */ + openDirectoryPickerDialog?(opts?: { title?: string; multiple?: boolean }): Promise<string | string[] | null> + + /** Open native file picker dialog (Tauri only) */ + openFilePickerDialog?(opts?: { title?: string; multiple?: boolean }): Promise<string | string[] | null> + + /** Save file picker dialog (Tauri only) */ + saveFilePickerDialog?(opts?: { title?: string; defaultPath?: string }): Promise<string | null> + + /** Open a URL in the default browser */ + openLink(url: string): void +} + +export const { use: usePlatform, provider: PlatformProvider } = createSimpleContext({ + name: "Platform", + init: (props: { value: Platform }) => { + return props.value + }, +}) |
