mirror of
https://github.com/aljazceru/opencode.git
synced 2026-01-30 05:05:03 +01:00
wip: desktop work
This commit is contained in:
@@ -72,7 +72,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const { flat, active, onInput, onKeyDown, refetch } = useFilteredList<string>({
|
const { flat, active, onInput, onKeyDown, refetch } = useFilteredList<string>({
|
||||||
items: local.file.search,
|
items: local.file.searchFilesAndDirectories,
|
||||||
key: (x) => x,
|
key: (x) => x,
|
||||||
onSelect: (path) => {
|
onSelect: (path) => {
|
||||||
if (!path) return
|
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">
|
<div class="relative size-full _max-h-[320px] flex flex-col gap-3">
|
||||||
<Show when={store.popoverIsOpen}>
|
<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">
|
<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()}>
|
<Show when={flat().length > 0} fallback={<div class="text-text-weak px-2">No matching files</div>}>
|
||||||
{(i) => (
|
<For each={flat()}>
|
||||||
<div
|
{(i) => (
|
||||||
classList={{
|
<div
|
||||||
"w-full flex items-center justify-between rounded-md": true,
|
classList={{
|
||||||
"bg-surface-raised-base-hover": active() === i,
|
"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 gap-x-2 grow min-w-0">
|
||||||
<div class="flex items-center text-14-regular">
|
<FileIcon node={{ path: i, type: "file" }} class="shrink-0 size-4" />
|
||||||
<span class="text-text-weak whitespace-nowrap overflow-hidden overflow-ellipsis truncate min-w-0">
|
<div class="flex items-center text-14-regular">
|
||||||
{getDirectory(i)}
|
<span class="text-text-weak whitespace-nowrap overflow-hidden overflow-ellipsis truncate min-w-0">
|
||||||
</span>
|
{getDirectory(i)}
|
||||||
<span class="text-text-strong whitespace-nowrap">{getFilename(i)}</span>
|
</span>
|
||||||
|
<span class="text-text-strong whitespace-nowrap">{getFilename(i)}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex items-center gap-x-1 text-text-muted/40 shrink-0"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-x-1 text-text-muted/40 shrink-0"></div>
|
)}
|
||||||
</div>
|
</For>
|
||||||
)}
|
</Show>
|
||||||
</For>
|
|
||||||
</div>
|
</div>
|
||||||
</Show>
|
</Show>
|
||||||
<form
|
<form
|
||||||
|
|||||||
@@ -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) => {
|
sdk.event.listen((e) => {
|
||||||
const event = e.details
|
const event = e.details
|
||||||
@@ -411,7 +414,8 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({
|
|||||||
!x.path.replace(new RegExp(`^${path + "/"}`), "").includes("/"),
|
!x.path.replace(new RegExp(`^${path + "/"}`), "").includes("/"),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
search,
|
searchFiles,
|
||||||
|
searchFilesAndDirectories,
|
||||||
relative,
|
relative,
|
||||||
// active,
|
// active,
|
||||||
// opened,
|
// opened,
|
||||||
|
|||||||
@@ -827,7 +827,7 @@ export default function Page() {
|
|||||||
title="Select file"
|
title="Select file"
|
||||||
placeholder="Search files"
|
placeholder="Search files"
|
||||||
emptyMessage="No files found"
|
emptyMessage="No files found"
|
||||||
items={local.file.search}
|
items={local.file.searchFiles}
|
||||||
key={(x) => x}
|
key={(x) => x}
|
||||||
onOpenChange={(open) => setStore("fileSelectOpen", open)}
|
onOpenChange={(open) => setStore("fileSelectOpen", open)}
|
||||||
onSelect={(x) => (x ? local.session.open(x) : undefined)}
|
onSelect={(x) => (x ? local.session.open(x) : undefined)}
|
||||||
|
|||||||
Reference in New Issue
Block a user