Download packages/app/src/components/directory-picker.tsx from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 1.63 kB
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/app/src/components/directory-picker.tsx
- Command line
-
hf download hf://SaylorTwift/opencode/packages/app/src/components/directory-picker.tsx
-
curl -L -o directory-picker.tsx https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/app/src/components/directory-picker.tsx
1.63 kB
| import { useDialog } from "@opencode-ai/ui/context/dialog" | |
| import { ServerConnection } from "@/context/server" | |
| import { usePlatform } from "@/context/platform" | |
| import { useSettings } from "@/context/settings" | |
| import { lazy } from "solid-js" | |
| import { DialogSelectDirectory } from "./dialog-select-directory" | |
| import { directoryPickerKind } from "./directory-picker-policy" | |
| const DialogSelectDirectoryV2 = lazy(() => | |
| import("./dialog-select-directory-v2").then((module) => ({ default: module.DialogSelectDirectoryV2 })), | |
| ) | |
| type DirectoryPickerInput = { | |
| server: ServerConnection.Any | |
| title?: string | |
| multiple?: boolean | |
| onSelect: (result: string | string[] | null) => void | |
| } | |
| export function useDirectoryPicker() { | |
| const platform = usePlatform() | |
| const settings = useSettings() | |
| const dialog = useDialog() | |
| return (input: DirectoryPickerInput) => { | |
| if (directoryPickerKind(platform.platform, input.server) === "native" && platform.platform === "desktop") { | |
| void platform.openDirectoryPickerDialog({ title: input.title, multiple: input.multiple }).then(input.onSelect) | |
| return | |
| } | |
| let selected = false | |
| const onSelect = (result: string | string[] | null) => { | |
| selected = result !== null | |
| input.onSelect(result) | |
| } | |
| const cancel = () => { | |
| if (!selected) input.onSelect(null) | |
| } | |
| if (platform.platform === "desktop" && settings.general.newLayoutDesigns()) { | |
| dialog.show(() => <DialogSelectDirectoryV2 {...input} onSelect={onSelect} />, cancel) | |
| return | |
| } | |
| dialog.show(() => <DialogSelectDirectory {...input} onSelect={onSelect} />, cancel) | |
| } | |
| } | |