chad-code 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +27 -0
- package/Dockerfile +18 -0
- package/README.md +15 -0
- package/README.npm.md +64 -0
- package/bin/chad-code +84 -0
- package/bunfig.toml +7 -0
- package/eslint.config.js +29 -0
- package/package.json +107 -0
- package/parsers-config.ts +253 -0
- package/script/build.ts +167 -0
- package/script/postinstall.mjs +122 -0
- package/script/publish-registries.ts +187 -0
- package/script/publish.ts +93 -0
- package/script/schema.ts +47 -0
- package/src/acp/README.md +164 -0
- package/src/acp/agent.ts +1086 -0
- package/src/acp/session.ts +101 -0
- package/src/acp/types.ts +22 -0
- package/src/agent/agent.ts +253 -0
- package/src/agent/generate.txt +75 -0
- package/src/agent/prompt/compaction.txt +12 -0
- package/src/agent/prompt/explore.txt +18 -0
- package/src/agent/prompt/summary.txt +11 -0
- package/src/agent/prompt/title.txt +36 -0
- package/src/auth/index.ts +70 -0
- package/src/bun/index.ts +130 -0
- package/src/bus/bus-event.ts +43 -0
- package/src/bus/global.ts +10 -0
- package/src/bus/index.ts +105 -0
- package/src/cli/bootstrap.ts +17 -0
- package/src/cli/cmd/acp.ts +69 -0
- package/src/cli/cmd/agent.ts +257 -0
- package/src/cli/cmd/auth.ts +132 -0
- package/src/cli/cmd/cmd.ts +7 -0
- package/src/cli/cmd/debug/agent.ts +28 -0
- package/src/cli/cmd/debug/config.ts +15 -0
- package/src/cli/cmd/debug/file.ts +91 -0
- package/src/cli/cmd/debug/index.ts +45 -0
- package/src/cli/cmd/debug/lsp.ts +48 -0
- package/src/cli/cmd/debug/ripgrep.ts +83 -0
- package/src/cli/cmd/debug/scrap.ts +15 -0
- package/src/cli/cmd/debug/skill.ts +15 -0
- package/src/cli/cmd/debug/snapshot.ts +48 -0
- package/src/cli/cmd/export.ts +88 -0
- package/src/cli/cmd/generate.ts +38 -0
- package/src/cli/cmd/github.ts +32 -0
- package/src/cli/cmd/import.ts +98 -0
- package/src/cli/cmd/mcp.ts +670 -0
- package/src/cli/cmd/models.ts +42 -0
- package/src/cli/cmd/pr.ts +112 -0
- package/src/cli/cmd/run.ts +374 -0
- package/src/cli/cmd/serve.ts +16 -0
- package/src/cli/cmd/session.ts +135 -0
- package/src/cli/cmd/stats.ts +402 -0
- package/src/cli/cmd/tui/app.tsx +705 -0
- package/src/cli/cmd/tui/attach.ts +32 -0
- package/src/cli/cmd/tui/component/border.tsx +21 -0
- package/src/cli/cmd/tui/component/dialog-agent.tsx +31 -0
- package/src/cli/cmd/tui/component/dialog-command.tsx +124 -0
- package/src/cli/cmd/tui/component/dialog-mcp.tsx +86 -0
- package/src/cli/cmd/tui/component/dialog-model.tsx +232 -0
- package/src/cli/cmd/tui/component/dialog-provider.tsx +228 -0
- package/src/cli/cmd/tui/component/dialog-session-list.tsx +115 -0
- package/src/cli/cmd/tui/component/dialog-session-rename.tsx +31 -0
- package/src/cli/cmd/tui/component/dialog-stash.tsx +86 -0
- package/src/cli/cmd/tui/component/dialog-status.tsx +162 -0
- package/src/cli/cmd/tui/component/dialog-tag.tsx +44 -0
- package/src/cli/cmd/tui/component/dialog-theme-list.tsx +50 -0
- package/src/cli/cmd/tui/component/did-you-know.tsx +85 -0
- package/src/cli/cmd/tui/component/logo.tsx +43 -0
- package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +654 -0
- package/src/cli/cmd/tui/component/prompt/history.tsx +108 -0
- package/src/cli/cmd/tui/component/prompt/index.tsx +1078 -0
- package/src/cli/cmd/tui/component/prompt/stash.tsx +101 -0
- package/src/cli/cmd/tui/component/textarea-keybindings.ts +73 -0
- package/src/cli/cmd/tui/component/tips.ts +92 -0
- package/src/cli/cmd/tui/component/todo-item.tsx +32 -0
- package/src/cli/cmd/tui/context/args.tsx +14 -0
- package/src/cli/cmd/tui/context/directory.ts +13 -0
- package/src/cli/cmd/tui/context/exit.tsx +23 -0
- package/src/cli/cmd/tui/context/helper.tsx +25 -0
- package/src/cli/cmd/tui/context/keybind.tsx +101 -0
- package/src/cli/cmd/tui/context/kv.tsx +49 -0
- package/src/cli/cmd/tui/context/local.tsx +392 -0
- package/src/cli/cmd/tui/context/prompt.tsx +18 -0
- package/src/cli/cmd/tui/context/route.tsx +46 -0
- package/src/cli/cmd/tui/context/sdk.tsx +75 -0
- package/src/cli/cmd/tui/context/sync.tsx +384 -0
- package/src/cli/cmd/tui/context/theme/aura.json +69 -0
- package/src/cli/cmd/tui/context/theme/ayu.json +80 -0
- package/src/cli/cmd/tui/context/theme/catppuccin-frappe.json +233 -0
- package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +233 -0
- package/src/cli/cmd/tui/context/theme/catppuccin.json +112 -0
- package/src/cli/cmd/tui/context/theme/chad.json +245 -0
- package/src/cli/cmd/tui/context/theme/cobalt2.json +228 -0
- package/src/cli/cmd/tui/context/theme/cursor.json +249 -0
- package/src/cli/cmd/tui/context/theme/dracula.json +219 -0
- package/src/cli/cmd/tui/context/theme/everforest.json +241 -0
- package/src/cli/cmd/tui/context/theme/flexoki.json +237 -0
- package/src/cli/cmd/tui/context/theme/github.json +233 -0
- package/src/cli/cmd/tui/context/theme/gruvbox.json +95 -0
- package/src/cli/cmd/tui/context/theme/kanagawa.json +77 -0
- package/src/cli/cmd/tui/context/theme/lucent-orng.json +227 -0
- package/src/cli/cmd/tui/context/theme/material.json +235 -0
- package/src/cli/cmd/tui/context/theme/matrix.json +77 -0
- package/src/cli/cmd/tui/context/theme/mercury.json +252 -0
- package/src/cli/cmd/tui/context/theme/monokai.json +221 -0
- package/src/cli/cmd/tui/context/theme/nightowl.json +221 -0
- package/src/cli/cmd/tui/context/theme/nord.json +223 -0
- package/src/cli/cmd/tui/context/theme/one-dark.json +84 -0
- package/src/cli/cmd/tui/context/theme/orng.json +245 -0
- package/src/cli/cmd/tui/context/theme/osaka-jade.json +93 -0
- package/src/cli/cmd/tui/context/theme/palenight.json +222 -0
- package/src/cli/cmd/tui/context/theme/rosepine.json +234 -0
- package/src/cli/cmd/tui/context/theme/solarized.json +223 -0
- package/src/cli/cmd/tui/context/theme/synthwave84.json +226 -0
- package/src/cli/cmd/tui/context/theme/tokyonight.json +243 -0
- package/src/cli/cmd/tui/context/theme/vercel.json +245 -0
- package/src/cli/cmd/tui/context/theme/vesper.json +218 -0
- package/src/cli/cmd/tui/context/theme/zenburn.json +223 -0
- package/src/cli/cmd/tui/context/theme.tsx +1137 -0
- package/src/cli/cmd/tui/event.ts +46 -0
- package/src/cli/cmd/tui/routes/home.tsx +138 -0
- package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +64 -0
- package/src/cli/cmd/tui/routes/session/dialog-message.tsx +109 -0
- package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +26 -0
- package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +47 -0
- package/src/cli/cmd/tui/routes/session/footer.tsx +88 -0
- package/src/cli/cmd/tui/routes/session/header.tsx +125 -0
- package/src/cli/cmd/tui/routes/session/index.tsx +1814 -0
- package/src/cli/cmd/tui/routes/session/permission.tsx +416 -0
- package/src/cli/cmd/tui/routes/session/sidebar.tsx +318 -0
- package/src/cli/cmd/tui/spawn.ts +48 -0
- package/src/cli/cmd/tui/thread.ts +111 -0
- package/src/cli/cmd/tui/ui/dialog-alert.tsx +57 -0
- package/src/cli/cmd/tui/ui/dialog-confirm.tsx +83 -0
- package/src/cli/cmd/tui/ui/dialog-export-options.tsx +204 -0
- package/src/cli/cmd/tui/ui/dialog-help.tsx +38 -0
- package/src/cli/cmd/tui/ui/dialog-prompt.tsx +77 -0
- package/src/cli/cmd/tui/ui/dialog-select.tsx +345 -0
- package/src/cli/cmd/tui/ui/dialog.tsx +171 -0
- package/src/cli/cmd/tui/ui/link.tsx +28 -0
- package/src/cli/cmd/tui/ui/spinner.ts +368 -0
- package/src/cli/cmd/tui/ui/toast.tsx +100 -0
- package/src/cli/cmd/tui/util/clipboard.ts +127 -0
- package/src/cli/cmd/tui/util/editor.ts +32 -0
- package/src/cli/cmd/tui/util/signal.ts +7 -0
- package/src/cli/cmd/tui/util/terminal.ts +114 -0
- package/src/cli/cmd/tui/util/transcript.ts +98 -0
- package/src/cli/cmd/tui/worker.ts +68 -0
- package/src/cli/cmd/uninstall.ts +344 -0
- package/src/cli/cmd/upgrade.ts +67 -0
- package/src/cli/cmd/web.ts +73 -0
- package/src/cli/error.ts +56 -0
- package/src/cli/network.ts +53 -0
- package/src/cli/ui.ts +87 -0
- package/src/cli/upgrade.ts +25 -0
- package/src/command/index.ts +131 -0
- package/src/command/template/initialize.txt +10 -0
- package/src/command/template/review.txt +97 -0
- package/src/config/config.ts +1124 -0
- package/src/config/markdown.ts +41 -0
- package/src/env/index.ts +26 -0
- package/src/file/ignore.ts +83 -0
- package/src/file/index.ts +411 -0
- package/src/file/ripgrep.ts +402 -0
- package/src/file/time.ts +64 -0
- package/src/file/watcher.ts +117 -0
- package/src/flag/flag.ts +52 -0
- package/src/format/formatter.ts +359 -0
- package/src/format/index.ts +137 -0
- package/src/global/index.ts +55 -0
- package/src/id/id.ts +73 -0
- package/src/ide/index.ts +77 -0
- package/src/index.ts +159 -0
- package/src/installation/index.ts +198 -0
- package/src/lsp/client.ts +252 -0
- package/src/lsp/index.ts +485 -0
- package/src/lsp/language.ts +119 -0
- package/src/lsp/server.ts +2023 -0
- package/src/mcp/auth.ts +135 -0
- package/src/mcp/index.ts +874 -0
- package/src/mcp/oauth-callback.ts +200 -0
- package/src/mcp/oauth-provider.ts +154 -0
- package/src/patch/index.ts +622 -0
- package/src/permission/arity.ts +163 -0
- package/src/permission/index.ts +210 -0
- package/src/permission/next.ts +268 -0
- package/src/plugin/index.ts +106 -0
- package/src/project/bootstrap.ts +31 -0
- package/src/project/instance.ts +78 -0
- package/src/project/project.ts +263 -0
- package/src/project/state.ts +65 -0
- package/src/project/vcs.ts +76 -0
- package/src/provider/auth.ts +143 -0
- package/src/provider/models-macro.ts +4 -0
- package/src/provider/models.ts +77 -0
- package/src/provider/provider.ts +516 -0
- package/src/provider/transform.ts +114 -0
- package/src/pty/index.ts +212 -0
- package/src/server/error.ts +36 -0
- package/src/server/mdns.ts +57 -0
- package/src/server/project.ts +79 -0
- package/src/server/server.ts +2866 -0
- package/src/server/tui.ts +71 -0
- package/src/session/compaction.ts +225 -0
- package/src/session/index.ts +469 -0
- package/src/session/llm.ts +213 -0
- package/src/session/message-v2.ts +742 -0
- package/src/session/message.ts +189 -0
- package/src/session/processor.ts +402 -0
- package/src/session/prompt/anthropic-20250930.txt +166 -0
- package/src/session/prompt/anthropic.txt +105 -0
- package/src/session/prompt/anthropic_spoof.txt +1 -0
- package/src/session/prompt/beast.txt +147 -0
- package/src/session/prompt/build-switch.txt +5 -0
- package/src/session/prompt/codex.txt +318 -0
- package/src/session/prompt/copilot-gpt-5.txt +143 -0
- package/src/session/prompt/gemini.txt +155 -0
- package/src/session/prompt/max-steps.txt +16 -0
- package/src/session/prompt/plan-reminder-anthropic.txt +67 -0
- package/src/session/prompt/plan.txt +26 -0
- package/src/session/prompt/qwen.txt +109 -0
- package/src/session/prompt.ts +1621 -0
- package/src/session/retry.ts +90 -0
- package/src/session/revert.ts +108 -0
- package/src/session/status.ts +76 -0
- package/src/session/summary.ts +194 -0
- package/src/session/system.ts +108 -0
- package/src/session/todo.ts +37 -0
- package/src/share/share-next.ts +194 -0
- package/src/share/share.ts +23 -0
- package/src/shell/shell.ts +67 -0
- package/src/skill/index.ts +1 -0
- package/src/skill/skill.ts +124 -0
- package/src/snapshot/index.ts +197 -0
- package/src/storage/storage.ts +226 -0
- package/src/tool/bash.ts +262 -0
- package/src/tool/bash.txt +116 -0
- package/src/tool/batch.ts +175 -0
- package/src/tool/batch.txt +24 -0
- package/src/tool/codesearch.ts +132 -0
- package/src/tool/codesearch.txt +12 -0
- package/src/tool/edit.ts +655 -0
- package/src/tool/edit.txt +10 -0
- package/src/tool/glob.ts +75 -0
- package/src/tool/glob.txt +6 -0
- package/src/tool/grep.ts +132 -0
- package/src/tool/grep.txt +8 -0
- package/src/tool/invalid.ts +17 -0
- package/src/tool/ls.ts +119 -0
- package/src/tool/ls.txt +1 -0
- package/src/tool/lsp.ts +94 -0
- package/src/tool/lsp.txt +19 -0
- package/src/tool/multiedit.ts +46 -0
- package/src/tool/multiedit.txt +41 -0
- package/src/tool/patch.ts +210 -0
- package/src/tool/patch.txt +1 -0
- package/src/tool/read.ts +191 -0
- package/src/tool/read.txt +12 -0
- package/src/tool/registry.ts +137 -0
- package/src/tool/skill.ts +77 -0
- package/src/tool/task.ts +167 -0
- package/src/tool/task.txt +60 -0
- package/src/tool/todo.ts +53 -0
- package/src/tool/todoread.txt +14 -0
- package/src/tool/todowrite.txt +167 -0
- package/src/tool/tool.ts +73 -0
- package/src/tool/webfetch.ts +182 -0
- package/src/tool/webfetch.txt +13 -0
- package/src/tool/websearch.ts +144 -0
- package/src/tool/websearch.txt +11 -0
- package/src/tool/write.ts +84 -0
- package/src/tool/write.txt +8 -0
- package/src/util/archive.ts +16 -0
- package/src/util/color.ts +19 -0
- package/src/util/context.ts +25 -0
- package/src/util/defer.ts +12 -0
- package/src/util/eventloop.ts +20 -0
- package/src/util/filesystem.ts +83 -0
- package/src/util/fn.ts +11 -0
- package/src/util/iife.ts +3 -0
- package/src/util/keybind.ts +102 -0
- package/src/util/lazy.ts +18 -0
- package/src/util/locale.ts +81 -0
- package/src/util/lock.ts +98 -0
- package/src/util/log.ts +180 -0
- package/src/util/queue.ts +32 -0
- package/src/util/rpc.ts +42 -0
- package/src/util/scrap.ts +10 -0
- package/src/util/signal.ts +12 -0
- package/src/util/timeout.ts +14 -0
- package/src/util/token.ts +7 -0
- package/src/util/wildcard.ts +54 -0
- package/src/worktree/index.ts +217 -0
- package/sst-env.d.ts +9 -0
- package/test/agent/agent.test.ts +448 -0
- package/test/bun.test.ts +53 -0
- package/test/cli/github-action.test.ts +129 -0
- package/test/cli/github-remote.test.ts +80 -0
- package/test/cli/tui/transcript.test.ts +297 -0
- package/test/config/agent-color.test.ts +66 -0
- package/test/config/config.test.ts +870 -0
- package/test/config/markdown.test.ts +89 -0
- package/test/file/ignore.test.ts +10 -0
- package/test/file/path-traversal.test.ts +115 -0
- package/test/fixture/fixture.ts +45 -0
- package/test/fixture/lsp/fake-lsp-server.js +77 -0
- package/test/ide/ide.test.ts +82 -0
- package/test/keybind.test.ts +421 -0
- package/test/lsp/client.test.ts +95 -0
- package/test/mcp/headers.test.ts +153 -0
- package/test/patch/patch.test.ts +348 -0
- package/test/permission/arity.test.ts +33 -0
- package/test/permission/next.test.ts +652 -0
- package/test/preload.ts +63 -0
- package/test/project/project.test.ts +120 -0
- package/test/provider/amazon-bedrock.test.ts +236 -0
- package/test/provider/provider.test.ts +2127 -0
- package/test/provider/transform.test.ts +980 -0
- package/test/server/session-select.test.ts +78 -0
- package/test/session/compaction.test.ts +251 -0
- package/test/session/message-v2.test.ts +570 -0
- package/test/session/retry.test.ts +131 -0
- package/test/session/revert-compact.test.ts +285 -0
- package/test/session/session.test.ts +71 -0
- package/test/skill/skill.test.ts +185 -0
- package/test/snapshot/snapshot.test.ts +939 -0
- package/test/tool/__snapshots__/tool.test.ts.snap +9 -0
- package/test/tool/bash.test.ts +232 -0
- package/test/tool/grep.test.ts +109 -0
- package/test/tool/patch.test.ts +261 -0
- package/test/tool/read.test.ts +167 -0
- package/test/util/iife.test.ts +36 -0
- package/test/util/lazy.test.ts +50 -0
- package/test/util/timeout.test.ts +21 -0
- package/test/util/wildcard.test.ts +55 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,654 @@
|
|
|
1
|
+
import type { BoxRenderable, TextareaRenderable, KeyEvent, ScrollBoxRenderable } from "@opentui/core"
|
|
2
|
+
import fuzzysort from "fuzzysort"
|
|
3
|
+
import { firstBy } from "remeda"
|
|
4
|
+
import { createMemo, createResource, createEffect, onMount, onCleanup, For, Show, createSignal } from "solid-js"
|
|
5
|
+
import { createStore } from "solid-js/store"
|
|
6
|
+
import { useSDK } from "@tui/context/sdk"
|
|
7
|
+
import { useSync } from "@tui/context/sync"
|
|
8
|
+
import { useTheme, selectedForeground } from "@tui/context/theme"
|
|
9
|
+
import { SplitBorder } from "@tui/component/border"
|
|
10
|
+
import { useCommandDialog } from "@tui/component/dialog-command"
|
|
11
|
+
import { useTerminalDimensions } from "@opentui/solid"
|
|
12
|
+
import { Locale } from "@/util/locale"
|
|
13
|
+
import type { PromptInfo } from "./history"
|
|
14
|
+
|
|
15
|
+
function removeLineRange(input: string) {
|
|
16
|
+
const hashIndex = input.lastIndexOf("#")
|
|
17
|
+
return hashIndex !== -1 ? input.substring(0, hashIndex) : input
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function extractLineRange(input: string) {
|
|
21
|
+
const hashIndex = input.lastIndexOf("#")
|
|
22
|
+
if (hashIndex === -1) {
|
|
23
|
+
return { baseQuery: input }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const baseName = input.substring(0, hashIndex)
|
|
27
|
+
const linePart = input.substring(hashIndex + 1)
|
|
28
|
+
const lineMatch = linePart.match(/^(\d+)(?:-(\d*))?$/)
|
|
29
|
+
|
|
30
|
+
if (!lineMatch) {
|
|
31
|
+
return { baseQuery: baseName }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const startLine = Number(lineMatch[1])
|
|
35
|
+
const endLine = lineMatch[2] && startLine < Number(lineMatch[2]) ? Number(lineMatch[2]) : undefined
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
lineRange: {
|
|
39
|
+
baseName,
|
|
40
|
+
startLine,
|
|
41
|
+
endLine,
|
|
42
|
+
},
|
|
43
|
+
baseQuery: baseName,
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type AutocompleteRef = {
|
|
48
|
+
onInput: (value: string) => void
|
|
49
|
+
onKeyDown: (e: KeyEvent) => void
|
|
50
|
+
visible: false | "@" | "/"
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type AutocompleteOption = {
|
|
54
|
+
display: string
|
|
55
|
+
aliases?: string[]
|
|
56
|
+
disabled?: boolean
|
|
57
|
+
description?: string
|
|
58
|
+
onSelect?: () => void
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function Autocomplete(props: {
|
|
62
|
+
value: string
|
|
63
|
+
sessionID?: string
|
|
64
|
+
setPrompt: (input: (prompt: PromptInfo) => void) => void
|
|
65
|
+
setExtmark: (partIndex: number, extmarkId: number) => void
|
|
66
|
+
anchor: () => BoxRenderable
|
|
67
|
+
input: () => TextareaRenderable
|
|
68
|
+
ref: (ref: AutocompleteRef) => void
|
|
69
|
+
fileStyleId: number
|
|
70
|
+
agentStyleId: number
|
|
71
|
+
promptPartTypeId: () => number
|
|
72
|
+
}) {
|
|
73
|
+
const sdk = useSDK()
|
|
74
|
+
const sync = useSync()
|
|
75
|
+
const command = useCommandDialog()
|
|
76
|
+
const { theme } = useTheme()
|
|
77
|
+
const dimensions = useTerminalDimensions()
|
|
78
|
+
|
|
79
|
+
const [store, setStore] = createStore({
|
|
80
|
+
index: 0,
|
|
81
|
+
selected: 0,
|
|
82
|
+
visible: false as AutocompleteRef["visible"],
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
const [positionTick, setPositionTick] = createSignal(0)
|
|
86
|
+
|
|
87
|
+
createEffect(() => {
|
|
88
|
+
if (store.visible) {
|
|
89
|
+
let lastPos = { x: 0, y: 0, width: 0 }
|
|
90
|
+
const interval = setInterval(() => {
|
|
91
|
+
const anchor = props.anchor()
|
|
92
|
+
if (anchor.x !== lastPos.x || anchor.y !== lastPos.y || anchor.width !== lastPos.width) {
|
|
93
|
+
lastPos = { x: anchor.x, y: anchor.y, width: anchor.width }
|
|
94
|
+
setPositionTick((t) => t + 1)
|
|
95
|
+
}
|
|
96
|
+
}, 50)
|
|
97
|
+
|
|
98
|
+
onCleanup(() => clearInterval(interval))
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
const position = createMemo(() => {
|
|
103
|
+
if (!store.visible) return { x: 0, y: 0, width: 0 }
|
|
104
|
+
const dims = dimensions()
|
|
105
|
+
positionTick()
|
|
106
|
+
const anchor = props.anchor()
|
|
107
|
+
const parent = anchor.parent
|
|
108
|
+
const parentX = parent?.x ?? 0
|
|
109
|
+
const parentY = parent?.y ?? 0
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
x: anchor.x - parentX,
|
|
113
|
+
y: anchor.y - parentY,
|
|
114
|
+
width: anchor.width,
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
const filter = createMemo(() => {
|
|
119
|
+
if (!store.visible) return
|
|
120
|
+
// Track props.value to make memo reactive to text changes
|
|
121
|
+
props.value // <- there surely is a better way to do this, like making .input() reactive
|
|
122
|
+
|
|
123
|
+
return props.input().getTextRange(store.index + 1, props.input().cursorOffset)
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
function insertPart(text: string, part: PromptInfo["parts"][number]) {
|
|
127
|
+
const input = props.input()
|
|
128
|
+
const currentCursorOffset = input.cursorOffset
|
|
129
|
+
|
|
130
|
+
const charAfterCursor = props.value.at(currentCursorOffset)
|
|
131
|
+
const needsSpace = charAfterCursor !== " "
|
|
132
|
+
const append = "@" + text + (needsSpace ? " " : "")
|
|
133
|
+
|
|
134
|
+
input.cursorOffset = store.index
|
|
135
|
+
const startCursor = input.logicalCursor
|
|
136
|
+
input.cursorOffset = currentCursorOffset
|
|
137
|
+
const endCursor = input.logicalCursor
|
|
138
|
+
|
|
139
|
+
input.deleteRange(startCursor.row, startCursor.col, endCursor.row, endCursor.col)
|
|
140
|
+
input.insertText(append)
|
|
141
|
+
|
|
142
|
+
const virtualText = "@" + text
|
|
143
|
+
const extmarkStart = store.index
|
|
144
|
+
const extmarkEnd = extmarkStart + Bun.stringWidth(virtualText)
|
|
145
|
+
|
|
146
|
+
const styleId = part.type === "file" ? props.fileStyleId : part.type === "agent" ? props.agentStyleId : undefined
|
|
147
|
+
|
|
148
|
+
const extmarkId = input.extmarks.create({
|
|
149
|
+
start: extmarkStart,
|
|
150
|
+
end: extmarkEnd,
|
|
151
|
+
virtual: true,
|
|
152
|
+
styleId,
|
|
153
|
+
typeId: props.promptPartTypeId(),
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
props.setPrompt((draft) => {
|
|
157
|
+
if (part.type === "file" && part.source?.text) {
|
|
158
|
+
part.source.text.start = extmarkStart
|
|
159
|
+
part.source.text.end = extmarkEnd
|
|
160
|
+
part.source.text.value = virtualText
|
|
161
|
+
} else if (part.type === "agent" && part.source) {
|
|
162
|
+
part.source.start = extmarkStart
|
|
163
|
+
part.source.end = extmarkEnd
|
|
164
|
+
part.source.value = virtualText
|
|
165
|
+
}
|
|
166
|
+
const partIndex = draft.parts.length
|
|
167
|
+
draft.parts.push(part)
|
|
168
|
+
props.setExtmark(partIndex, extmarkId)
|
|
169
|
+
})
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const [files] = createResource(
|
|
173
|
+
() => filter(),
|
|
174
|
+
async (query) => {
|
|
175
|
+
if (!store.visible || store.visible === "/") return []
|
|
176
|
+
|
|
177
|
+
const { lineRange, baseQuery } = extractLineRange(query ?? "")
|
|
178
|
+
|
|
179
|
+
// Get files from SDK
|
|
180
|
+
const result = await sdk.client.find.files({
|
|
181
|
+
query: baseQuery,
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
const options: AutocompleteOption[] = []
|
|
185
|
+
|
|
186
|
+
// Add file options
|
|
187
|
+
if (!result.error && result.data) {
|
|
188
|
+
const width = props.anchor().width - 4
|
|
189
|
+
options.push(
|
|
190
|
+
...result.data.map((item): AutocompleteOption => {
|
|
191
|
+
let url = `file://${process.cwd()}/${item}`
|
|
192
|
+
let filename = item
|
|
193
|
+
if (lineRange && !item.endsWith("/")) {
|
|
194
|
+
filename = `${item}#${lineRange.startLine}${lineRange.endLine ? `-${lineRange.endLine}` : ""}`
|
|
195
|
+
const urlObj = new URL(url)
|
|
196
|
+
urlObj.searchParams.set("start", String(lineRange.startLine))
|
|
197
|
+
if (lineRange.endLine !== undefined) {
|
|
198
|
+
urlObj.searchParams.set("end", String(lineRange.endLine))
|
|
199
|
+
}
|
|
200
|
+
url = urlObj.toString()
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return {
|
|
204
|
+
display: Locale.truncateMiddle(filename, width),
|
|
205
|
+
onSelect: () => {
|
|
206
|
+
insertPart(filename, {
|
|
207
|
+
type: "file",
|
|
208
|
+
mime: "text/plain",
|
|
209
|
+
filename,
|
|
210
|
+
url,
|
|
211
|
+
source: {
|
|
212
|
+
type: "file",
|
|
213
|
+
text: {
|
|
214
|
+
start: 0,
|
|
215
|
+
end: 0,
|
|
216
|
+
value: "",
|
|
217
|
+
},
|
|
218
|
+
path: item,
|
|
219
|
+
},
|
|
220
|
+
})
|
|
221
|
+
},
|
|
222
|
+
}
|
|
223
|
+
}),
|
|
224
|
+
)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return options
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
initialValue: [],
|
|
231
|
+
},
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
const mcpResources = createMemo(() => {
|
|
235
|
+
if (!store.visible || store.visible === "/") return []
|
|
236
|
+
|
|
237
|
+
const options: AutocompleteOption[] = []
|
|
238
|
+
const width = props.anchor().width - 4
|
|
239
|
+
|
|
240
|
+
for (const res of Object.values(sync.data.mcp_resource)) {
|
|
241
|
+
options.push({
|
|
242
|
+
display: Locale.truncateMiddle(`${res.name} (${res.uri})`, width),
|
|
243
|
+
description: res.description,
|
|
244
|
+
onSelect: () => {
|
|
245
|
+
insertPart(res.name, {
|
|
246
|
+
type: "file",
|
|
247
|
+
mime: res.mimeType ?? "text/plain",
|
|
248
|
+
filename: res.name,
|
|
249
|
+
url: res.uri,
|
|
250
|
+
source: {
|
|
251
|
+
type: "resource",
|
|
252
|
+
text: {
|
|
253
|
+
start: 0,
|
|
254
|
+
end: 0,
|
|
255
|
+
value: "",
|
|
256
|
+
},
|
|
257
|
+
clientName: res.client,
|
|
258
|
+
uri: res.uri,
|
|
259
|
+
},
|
|
260
|
+
})
|
|
261
|
+
},
|
|
262
|
+
})
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return options
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
const agents = createMemo(() => {
|
|
269
|
+
const agents = sync.data.agent
|
|
270
|
+
return agents
|
|
271
|
+
.filter((agent) => !agent.hidden && agent.mode !== "primary")
|
|
272
|
+
.map(
|
|
273
|
+
(agent): AutocompleteOption => ({
|
|
274
|
+
display: "@" + agent.name,
|
|
275
|
+
onSelect: () => {
|
|
276
|
+
insertPart(agent.name, {
|
|
277
|
+
type: "agent",
|
|
278
|
+
name: agent.name,
|
|
279
|
+
source: {
|
|
280
|
+
start: 0,
|
|
281
|
+
end: 0,
|
|
282
|
+
value: "",
|
|
283
|
+
},
|
|
284
|
+
})
|
|
285
|
+
},
|
|
286
|
+
}),
|
|
287
|
+
)
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
const session = createMemo(() => (props.sessionID ? sync.session.get(props.sessionID) : undefined))
|
|
291
|
+
const commands = createMemo((): AutocompleteOption[] => {
|
|
292
|
+
const results: AutocompleteOption[] = []
|
|
293
|
+
const s = session()
|
|
294
|
+
for (const command of sync.data.command) {
|
|
295
|
+
results.push({
|
|
296
|
+
display: "/" + command.name + (command.mcp ? " (MCP)" : ""),
|
|
297
|
+
description: command.description,
|
|
298
|
+
onSelect: () => {
|
|
299
|
+
const newText = "/" + command.name + " "
|
|
300
|
+
const cursor = props.input().logicalCursor
|
|
301
|
+
props.input().deleteRange(0, 0, cursor.row, cursor.col)
|
|
302
|
+
props.input().insertText(newText)
|
|
303
|
+
props.input().cursorOffset = Bun.stringWidth(newText)
|
|
304
|
+
},
|
|
305
|
+
})
|
|
306
|
+
}
|
|
307
|
+
if (s) {
|
|
308
|
+
results.push(
|
|
309
|
+
{
|
|
310
|
+
display: "/undo",
|
|
311
|
+
description: "undo the last message",
|
|
312
|
+
onSelect: () => {
|
|
313
|
+
command.trigger("session.undo")
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
display: "/redo",
|
|
318
|
+
description: "redo the last message",
|
|
319
|
+
onSelect: () => command.trigger("session.redo"),
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
display: "/compact",
|
|
323
|
+
aliases: ["/summarize"],
|
|
324
|
+
description: "compact the session",
|
|
325
|
+
onSelect: () => command.trigger("session.compact"),
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
display: "/unshare",
|
|
329
|
+
disabled: !s.share,
|
|
330
|
+
description: "unshare a session",
|
|
331
|
+
onSelect: () => command.trigger("session.unshare"),
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
display: "/rename",
|
|
335
|
+
description: "rename session",
|
|
336
|
+
onSelect: () => command.trigger("session.rename"),
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
display: "/copy",
|
|
340
|
+
description: "copy session transcript to clipboard",
|
|
341
|
+
onSelect: () => command.trigger("session.copy"),
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
display: "/export",
|
|
345
|
+
description: "export session transcript to file",
|
|
346
|
+
onSelect: () => command.trigger("session.export"),
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
display: "/timeline",
|
|
350
|
+
description: "jump to message",
|
|
351
|
+
onSelect: () => command.trigger("session.timeline"),
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
display: "/fork",
|
|
355
|
+
description: "fork from message",
|
|
356
|
+
onSelect: () => command.trigger("session.fork"),
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
display: "/thinking",
|
|
360
|
+
description: "toggle thinking visibility",
|
|
361
|
+
onSelect: () => command.trigger("session.toggle.thinking"),
|
|
362
|
+
},
|
|
363
|
+
)
|
|
364
|
+
if (sync.data.config.share !== "disabled") {
|
|
365
|
+
results.push({
|
|
366
|
+
display: "/share",
|
|
367
|
+
disabled: !!s.share?.url,
|
|
368
|
+
description: "share a session",
|
|
369
|
+
onSelect: () => command.trigger("session.share"),
|
|
370
|
+
})
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
results.push(
|
|
375
|
+
{
|
|
376
|
+
display: "/new",
|
|
377
|
+
aliases: ["/clear"],
|
|
378
|
+
description: "create a new session",
|
|
379
|
+
onSelect: () => command.trigger("session.new"),
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
display: "/models",
|
|
383
|
+
description: "list models",
|
|
384
|
+
onSelect: () => command.trigger("model.list"),
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
display: "/agents",
|
|
388
|
+
description: "list agents",
|
|
389
|
+
onSelect: () => command.trigger("agent.list"),
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
display: "/session",
|
|
393
|
+
aliases: ["/resume", "/continue"],
|
|
394
|
+
description: "list sessions",
|
|
395
|
+
onSelect: () => command.trigger("session.list"),
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
display: "/status",
|
|
399
|
+
description: "show status",
|
|
400
|
+
onSelect: () => command.trigger("opencode.status"),
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
display: "/mcp",
|
|
404
|
+
description: "toggle MCPs",
|
|
405
|
+
onSelect: () => command.trigger("mcp.list"),
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
display: "/theme",
|
|
409
|
+
description: "toggle theme",
|
|
410
|
+
onSelect: () => command.trigger("theme.switch"),
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
display: "/editor",
|
|
414
|
+
description: "open editor",
|
|
415
|
+
onSelect: () => command.trigger("prompt.editor", "prompt"),
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
display: "/connect",
|
|
419
|
+
description: "connect to a provider",
|
|
420
|
+
onSelect: () => command.trigger("provider.connect"),
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
display: "/help",
|
|
424
|
+
description: "show help",
|
|
425
|
+
onSelect: () => command.trigger("help.show"),
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
display: "/commands",
|
|
429
|
+
description: "show all commands",
|
|
430
|
+
onSelect: () => command.show(),
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
display: "/exit",
|
|
434
|
+
aliases: ["/quit", "/q"],
|
|
435
|
+
description: "exit the app",
|
|
436
|
+
onSelect: () => command.trigger("app.exit"),
|
|
437
|
+
},
|
|
438
|
+
)
|
|
439
|
+
const max = firstBy(results, [(x) => x.display.length, "desc"])?.display.length
|
|
440
|
+
if (!max) return results
|
|
441
|
+
return results.map((item) => ({
|
|
442
|
+
...item,
|
|
443
|
+
display: item.display.padEnd(max + 2),
|
|
444
|
+
}))
|
|
445
|
+
})
|
|
446
|
+
|
|
447
|
+
const options = createMemo((prev: AutocompleteOption[] | undefined) => {
|
|
448
|
+
const filesValue = files()
|
|
449
|
+
const agentsValue = agents()
|
|
450
|
+
const commandsValue = commands()
|
|
451
|
+
|
|
452
|
+
const mixed: AutocompleteOption[] = (
|
|
453
|
+
store.visible === "@" ? [...agentsValue, ...(filesValue || []), ...mcpResources()] : [...commandsValue]
|
|
454
|
+
).filter((x) => x.disabled !== true)
|
|
455
|
+
|
|
456
|
+
const currentFilter = filter()
|
|
457
|
+
|
|
458
|
+
if (!currentFilter) {
|
|
459
|
+
return mixed
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
if (files.loading && prev && prev.length > 0) {
|
|
463
|
+
return prev
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
const result = fuzzysort.go(removeLineRange(currentFilter), mixed, {
|
|
467
|
+
keys: [(obj) => removeLineRange(obj.display.trimEnd()), "description", (obj) => obj.aliases?.join(" ") ?? ""],
|
|
468
|
+
limit: 10,
|
|
469
|
+
scoreFn: (objResults) => {
|
|
470
|
+
const displayResult = objResults[0]
|
|
471
|
+
if (displayResult && displayResult.target.startsWith(store.visible + currentFilter)) {
|
|
472
|
+
return objResults.score * 2
|
|
473
|
+
}
|
|
474
|
+
return objResults.score
|
|
475
|
+
},
|
|
476
|
+
})
|
|
477
|
+
|
|
478
|
+
return result.map((arr) => arr.obj)
|
|
479
|
+
})
|
|
480
|
+
|
|
481
|
+
createEffect(() => {
|
|
482
|
+
filter()
|
|
483
|
+
setStore("selected", 0)
|
|
484
|
+
})
|
|
485
|
+
|
|
486
|
+
function move(direction: -1 | 1) {
|
|
487
|
+
if (!store.visible) return
|
|
488
|
+
if (!options().length) return
|
|
489
|
+
let next = store.selected + direction
|
|
490
|
+
if (next < 0) next = options().length - 1
|
|
491
|
+
if (next >= options().length) next = 0
|
|
492
|
+
moveTo(next)
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
function moveTo(next: number) {
|
|
496
|
+
setStore("selected", next)
|
|
497
|
+
if (!scroll) return
|
|
498
|
+
const viewportHeight = Math.min(height(), options().length)
|
|
499
|
+
const scrollBottom = scroll.scrollTop + viewportHeight
|
|
500
|
+
if (next < scroll.scrollTop) {
|
|
501
|
+
scroll.scrollBy(next - scroll.scrollTop)
|
|
502
|
+
} else if (next + 1 > scrollBottom) {
|
|
503
|
+
scroll.scrollBy(next + 1 - scrollBottom)
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function select() {
|
|
508
|
+
const selected = options()[store.selected]
|
|
509
|
+
if (!selected) return
|
|
510
|
+
hide()
|
|
511
|
+
selected.onSelect?.()
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function show(mode: "@" | "/") {
|
|
515
|
+
command.keybinds(false)
|
|
516
|
+
setStore({
|
|
517
|
+
visible: mode,
|
|
518
|
+
index: props.input().cursorOffset,
|
|
519
|
+
})
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
function hide() {
|
|
523
|
+
const text = props.input().plainText
|
|
524
|
+
if (store.visible === "/" && !text.endsWith(" ") && text.startsWith("/")) {
|
|
525
|
+
const cursor = props.input().logicalCursor
|
|
526
|
+
props.input().deleteRange(0, 0, cursor.row, cursor.col)
|
|
527
|
+
// Sync the prompt store immediately since onContentChange is async
|
|
528
|
+
props.setPrompt((draft) => {
|
|
529
|
+
draft.input = props.input().plainText
|
|
530
|
+
})
|
|
531
|
+
}
|
|
532
|
+
command.keybinds(true)
|
|
533
|
+
setStore("visible", false)
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
onMount(() => {
|
|
537
|
+
props.ref({
|
|
538
|
+
get visible() {
|
|
539
|
+
return store.visible
|
|
540
|
+
},
|
|
541
|
+
onInput(value) {
|
|
542
|
+
if (store.visible) {
|
|
543
|
+
if (
|
|
544
|
+
// Typed text before the trigger
|
|
545
|
+
props.input().cursorOffset <= store.index ||
|
|
546
|
+
// There is a space between the trigger and the cursor
|
|
547
|
+
props.input().getTextRange(store.index, props.input().cursorOffset).match(/\s/) ||
|
|
548
|
+
// "/<command>" is not the sole content
|
|
549
|
+
(store.visible === "/" && value.match(/^\S+\s+\S+\s*$/))
|
|
550
|
+
) {
|
|
551
|
+
hide()
|
|
552
|
+
return
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
},
|
|
556
|
+
onKeyDown(e: KeyEvent) {
|
|
557
|
+
if (store.visible) {
|
|
558
|
+
const name = e.name?.toLowerCase()
|
|
559
|
+
const ctrlOnly = e.ctrl && !e.meta && !e.shift
|
|
560
|
+
const isNavUp = name === "up" || (ctrlOnly && name === "p")
|
|
561
|
+
const isNavDown = name === "down" || (ctrlOnly && name === "n")
|
|
562
|
+
|
|
563
|
+
if (isNavUp) {
|
|
564
|
+
move(-1)
|
|
565
|
+
e.preventDefault()
|
|
566
|
+
return
|
|
567
|
+
}
|
|
568
|
+
if (isNavDown) {
|
|
569
|
+
move(1)
|
|
570
|
+
e.preventDefault()
|
|
571
|
+
return
|
|
572
|
+
}
|
|
573
|
+
if (name === "escape") {
|
|
574
|
+
hide()
|
|
575
|
+
e.preventDefault()
|
|
576
|
+
return
|
|
577
|
+
}
|
|
578
|
+
if (name === "return" || name === "tab") {
|
|
579
|
+
select()
|
|
580
|
+
e.preventDefault()
|
|
581
|
+
return
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
if (!store.visible) {
|
|
585
|
+
if (e.name === "@") {
|
|
586
|
+
const cursorOffset = props.input().cursorOffset
|
|
587
|
+
const charBeforeCursor =
|
|
588
|
+
cursorOffset === 0 ? undefined : props.input().getTextRange(cursorOffset - 1, cursorOffset)
|
|
589
|
+
const canTrigger = charBeforeCursor === undefined || charBeforeCursor === "" || /\s/.test(charBeforeCursor)
|
|
590
|
+
if (canTrigger) show("@")
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
if (e.name === "/") {
|
|
594
|
+
if (props.input().cursorOffset === 0) show("/")
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
},
|
|
598
|
+
})
|
|
599
|
+
})
|
|
600
|
+
|
|
601
|
+
const height = createMemo(() => {
|
|
602
|
+
if (options().length) return Math.min(10, options().length)
|
|
603
|
+
return 1
|
|
604
|
+
})
|
|
605
|
+
|
|
606
|
+
let scroll: ScrollBoxRenderable
|
|
607
|
+
|
|
608
|
+
return (
|
|
609
|
+
<box
|
|
610
|
+
visible={store.visible !== false}
|
|
611
|
+
position="absolute"
|
|
612
|
+
top={position().y - height()}
|
|
613
|
+
left={position().x}
|
|
614
|
+
width={position().width}
|
|
615
|
+
zIndex={100}
|
|
616
|
+
{...SplitBorder}
|
|
617
|
+
borderColor={theme.border}
|
|
618
|
+
>
|
|
619
|
+
<scrollbox
|
|
620
|
+
ref={(r: ScrollBoxRenderable) => (scroll = r)}
|
|
621
|
+
backgroundColor={theme.backgroundMenu}
|
|
622
|
+
height={height()}
|
|
623
|
+
scrollbarOptions={{ visible: false }}
|
|
624
|
+
>
|
|
625
|
+
<For
|
|
626
|
+
each={options()}
|
|
627
|
+
fallback={
|
|
628
|
+
<box paddingLeft={1} paddingRight={1}>
|
|
629
|
+
<text fg={theme.textMuted}>No matching items</text>
|
|
630
|
+
</box>
|
|
631
|
+
}
|
|
632
|
+
>
|
|
633
|
+
{(option, index) => (
|
|
634
|
+
<box
|
|
635
|
+
paddingLeft={1}
|
|
636
|
+
paddingRight={1}
|
|
637
|
+
backgroundColor={index() === store.selected ? theme.primary : undefined}
|
|
638
|
+
flexDirection="row"
|
|
639
|
+
>
|
|
640
|
+
<text fg={index() === store.selected ? selectedForeground(theme) : theme.text} flexShrink={0}>
|
|
641
|
+
{option.display}
|
|
642
|
+
</text>
|
|
643
|
+
<Show when={option.description}>
|
|
644
|
+
<text fg={index() === store.selected ? selectedForeground(theme) : theme.textMuted} wrapMode="none">
|
|
645
|
+
{option.description}
|
|
646
|
+
</text>
|
|
647
|
+
</Show>
|
|
648
|
+
</box>
|
|
649
|
+
)}
|
|
650
|
+
</For>
|
|
651
|
+
</scrollbox>
|
|
652
|
+
</box>
|
|
653
|
+
)
|
|
654
|
+
}
|