Merge branch 'dev' into opentui

This commit is contained in:
Dax Raad 2025-10-02 00:09:30 -04:00
commit 0d36150f19
2 changed files with 11 additions and 3 deletions

View file

@ -132,7 +132,7 @@ export default function Home() {
<button data-copy data-slot="command" onClick={handleCopyClick}>
<span>
<span data-slot="protocol">npm i -g </span>
<span data-slot="highlight">opencode</span>
<span data-slot="highlight">opencode-ai</span>
</span>
<CopyStatus />
</button>
@ -141,7 +141,7 @@ export default function Home() {
<button data-copy data-slot="command" onClick={handleCopyClick}>
<span>
<span data-slot="protocol">bun add -g </span>
<span data-slot="highlight">opencode</span>
<span data-slot="highlight">opencode-ai</span>
</span>
<CopyStatus />
</button>

View file

@ -88,6 +88,7 @@ export namespace File {
let current = file
while (true) {
const dir = path.dirname(current)
if (dir === ".") break
if (dir === current) break
current = dir
if (set.has(dir)) continue
@ -113,6 +114,10 @@ export namespace File {
}
})
export function init() {
state()
}
export async function status() {
const project = Instance.project
if (project.vcs !== "git") return []
@ -244,10 +249,13 @@ export namespace File {
}
export async function search(input: { query: string; limit?: number }) {
log.info("search", { query: input.query })
const limit = input.limit ?? 100
const result = await state().then((x) => x.files())
const items = input.query ? [...result.files, ...result.dirs] : [...result.dirs]
if (!input.query) return result.dirs.toSorted()
const items = [...result.files, ...result.dirs]
const sorted = fuzzysort.go(input.query, items, { limit: limit }).map((r) => r.target)
log.info("search", { query: input.query, results: sorted.length })
return sorted
}
}