diff options
| author | Adam <[email protected]> | 2025-11-03 15:42:01 -0600 |
|---|---|---|
| committer | Adam <[email protected]> | 2025-11-03 15:42:10 -0600 |
| commit | bd0a4f7bbef079265289e9a83f43273f489ca6f9 (patch) | |
| tree | 4d542c0a49c1d9c0971d574aef78a5f35e565789 | |
| parent | 3d43214075b1f4ba0a3c71d5fea799532bbb7bd9 (diff) | |
| download | opencode-bd0a4f7bbef079265289e9a83f43273f489ca6f9.tar.gz opencode-bd0a4f7bbef079265289e9a83f43273f489ca6f9.zip | |
wip: desktop work
| -rw-r--r-- | packages/desktop/src/components/prompt-input.tsx | 42 | ||||
| -rw-r--r-- | packages/desktop/src/context/local.tsx | 8 | ||||
| -rw-r--r-- | packages/desktop/src/pages/index.tsx | 2 |
3 files changed, 29 insertions, 23 deletions
diff --git a/packages/desktop/src/components/prompt-input.tsx b/packages/desktop/src/components/prompt-input.tsx index 9b2c10df7..3d9622cbe 100644 --- a/packages/desktop/src/components/prompt-input.tsx +++ b/packages/desktop/src/components/prompt-input.tsx @@ -72,7 +72,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => { }) const { flat, active, onInput, onKeyDown, refetch } = useFilteredList<string>({ - items: local.file.search, + items: local.file.searchFilesAndDirectories, key: (x) => x, onSelect: (path) => { if (!path) return @@ -307,27 +307,29 @@ export const PromptInput: Component<PromptInputProps> = (props) => { <div class="relative size-full _max-h-[320px] flex flex-col gap-3"> <Show when={store.popoverIsOpen}> <div class="absolute inset-x-0 -top-3 -translate-y-full origin-bottom-left max-h-[252px] min-h-10 overflow-y-auto flex flex-col p-2 pb-0 rounded-2xl border border-border-base bg-surface-raised-stronger-non-alpha shadow-md"> - <For each={flat()}> - {(i) => ( - <div - classList={{ - "w-full flex items-center justify-between rounded-md": true, - "bg-surface-raised-base-hover": active() === i, - }} - > - <div class="flex items-center gap-x-2 grow min-w-0"> - <FileIcon node={{ path: i, type: "file" }} class="shrink-0 size-4" /> - <div class="flex items-center text-14-regular"> - <span class="text-text-weak whitespace-nowrap overflow-hidden overflow-ellipsis truncate min-w-0"> - {getDirectory(i)} - </span> - <span class="text-text-strong whitespace-nowrap">{getFilename(i)}</span> + <Show when={flat().length > 0} fallback={<div class="text-text-weak px-2">No matching files</div>}> + <For each={flat()}> + {(i) => ( + <div + classList={{ + "w-full flex items-center justify-between rounded-md": true, + "bg-surface-raised-base-hover": active() === i, + }} + > + <div class="flex items-center gap-x-2 grow min-w-0"> + <FileIcon node={{ path: i, type: "file" }} class="shrink-0 size-4" /> + <div class="flex items-center text-14-regular"> + <span class="text-text-weak whitespace-nowrap overflow-hidden overflow-ellipsis truncate min-w-0"> + {getDirectory(i)} + </span> + <span class="text-text-strong whitespace-nowrap">{getFilename(i)}</span> + </div> </div> + <div class="flex items-center gap-x-1 text-text-muted/40 shrink-0"></div> </div> - <div class="flex items-center gap-x-1 text-text-muted/40 shrink-0"></div> - </div> - )} - </For> + )} + </For> + </Show> </div> </Show> <form diff --git a/packages/desktop/src/context/local.tsx b/packages/desktop/src/context/local.tsx index 283dddc2c..db4699150 100644 --- a/packages/desktop/src/context/local.tsx +++ b/packages/desktop/src/context/local.tsx @@ -325,7 +325,10 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({ }) } - const search = (query: string) => sdk.client.find.files({ query: { query } }).then((x) => x.data!) + const searchFiles = (query: string) => + sdk.client.find.files({ query: { query, dirs: false } }).then((x) => x.data!) + const searchFilesAndDirectories = (query: string) => + sdk.client.find.files({ query: { query, dirs: true } }).then((x) => x.data!) sdk.event.listen((e) => { const event = e.details @@ -411,7 +414,8 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({ !x.path.replace(new RegExp(`^${path + "/"}`), "").includes("/"), ) }, - search, + searchFiles, + searchFilesAndDirectories, relative, // active, // opened, diff --git a/packages/desktop/src/pages/index.tsx b/packages/desktop/src/pages/index.tsx index 7bba17cba..5f04c3dbe 100644 --- a/packages/desktop/src/pages/index.tsx +++ b/packages/desktop/src/pages/index.tsx @@ -827,7 +827,7 @@ export default function Page() { title="Select file" placeholder="Search files" emptyMessage="No files found" - items={local.file.search} + items={local.file.searchFiles} key={(x) => x} onOpenChange={(open) => setStore("fileSelectOpen", open)} onSelect={(x) => (x ? local.session.open(x) : undefined)} |
