@agentprojectcontext/apx 1.15.5 → 1.16.0
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/package.json +40 -5
- package/src/cli/commands/log.js +113 -0
- package/src/cli/commands/overlay.js +253 -0
- package/src/cli/commands/sys.js +88 -16
- package/src/cli/index.js +23 -1
- package/src/cli/terminal-chat/renderer.js +71 -56
- package/src/cli-ts/commands/agent.ts +173 -0
- package/src/cli-ts/commands/chat.ts +119 -0
- package/src/cli-ts/commands/daemon.ts +112 -0
- package/src/cli-ts/commands/exec.ts +109 -0
- package/src/cli-ts/commands/mcp.ts +235 -0
- package/src/cli-ts/commands/session.ts +224 -0
- package/src/cli-ts/commands/status.ts +61 -0
- package/src/cli-ts/http.ts +36 -0
- package/src/cli-ts/index.ts +73 -0
- package/src/cli-ts/ui.ts +107 -0
- package/src/core/logging.js +81 -0
- package/src/daemon/api.js +58 -0
- package/src/daemon/engines/anthropic.js +60 -1
- package/src/daemon/engines/index.js +2 -1
- package/src/daemon/engines/ollama.js +70 -3
- package/src/daemon/index.js +58 -0
- package/src/daemon/overlay-ws.js +40 -0
- package/src/daemon/plugins/index.js +2 -1
- package/src/daemon/plugins/overlay.js +177 -0
- package/src/daemon/plugins/telegram.js +15 -3
- package/src/daemon/super-agent.js +102 -19
- package/src/daemon/transcription.js +262 -59
- package/src/daemon/wakeup.js +14 -19
- package/src/daemon/whisper-server.py +57 -6
- package/src/overlay/index.html +44 -0
- package/src/overlay/main.js +480 -0
- package/src/overlay/package.json +3 -0
- package/src/overlay/preload.js +34 -0
- package/src/overlay/renderer.js +371 -0
- package/src/overlay/style.css +250 -0
- package/src/tui/_shims/cli-error.ts +6 -0
- package/src/tui/_shims/cli-logo.ts +18 -0
- package/src/tui/_shims/cli-ui.ts +1 -0
- package/src/tui/_shims/config-console-state.ts +7 -0
- package/src/tui/_shims/core-any.ts +30 -0
- package/src/tui/_shims/core-binary.ts +13 -0
- package/src/tui/_shims/core-flag.ts +3 -0
- package/src/tui/_shims/core-log.ts +14 -0
- package/src/tui/_shims/lsp-language.ts +1 -0
- package/src/tui/_shims/opencode-any.ts +135 -0
- package/src/tui/_shims/opencode-sdk-v2.ts +48 -0
- package/src/tui/_shims/plugin-tui.ts +13 -0
- package/src/tui/_shims/provider-provider.ts +10 -0
- package/src/tui/_shims/session-retry.ts +1 -0
- package/src/tui/_shims/session-schema.ts +15 -0
- package/src/tui/_shims/session-session.ts +3 -0
- package/src/tui/_shims/snapshot.ts +4 -0
- package/src/tui/_shims/tool-any.ts +18 -0
- package/src/tui/_shims/util-error.ts +7 -0
- package/src/tui/_shims/util-filesystem.ts +79 -0
- package/src/tui/_shims/util-format.ts +7 -0
- package/src/tui/_shims/util-iife.ts +3 -0
- package/src/tui/_shims/util-locale.ts +10 -0
- package/src/tui/_shims/util-process.ts +38 -0
- package/src/tui/app.tsx +783 -0
- package/src/tui/asset/charge.wav +0 -0
- package/src/tui/asset/pulse-a.wav +0 -0
- package/src/tui/asset/pulse-b.wav +0 -0
- package/src/tui/asset/pulse-c.wav +0 -0
- package/src/tui/attach.ts +100 -0
- package/src/tui/component/bg-pulse-render.ts +436 -0
- package/src/tui/component/bg-pulse.tsx +99 -0
- package/src/tui/component/border.tsx +21 -0
- package/src/tui/component/dialog-agent.tsx +31 -0
- package/src/tui/component/dialog-console-org.tsx +103 -0
- package/src/tui/component/dialog-mcp.tsx +85 -0
- package/src/tui/component/dialog-model.tsx +175 -0
- package/src/tui/component/dialog-provider.tsx +456 -0
- package/src/tui/component/dialog-retry-action.tsx +160 -0
- package/src/tui/component/dialog-session-delete-failed.tsx +99 -0
- package/src/tui/component/dialog-session-list.tsx +323 -0
- package/src/tui/component/dialog-session-rename.tsx +31 -0
- package/src/tui/component/dialog-skill.tsx +36 -0
- package/src/tui/component/dialog-stash.tsx +87 -0
- package/src/tui/component/dialog-status.tsx +168 -0
- package/src/tui/component/dialog-tag.tsx +44 -0
- package/src/tui/component/dialog-theme-list.tsx +50 -0
- package/src/tui/component/dialog-variant.tsx +39 -0
- package/src/tui/component/dialog-workspace-create.tsx +302 -0
- package/src/tui/component/dialog-workspace-file-changes.tsx +138 -0
- package/src/tui/component/dialog-workspace-unavailable.tsx +69 -0
- package/src/tui/component/error-component.tsx +92 -0
- package/src/tui/component/logo.tsx +896 -0
- package/src/tui/component/plugin-route-missing.tsx +14 -0
- package/src/tui/component/prompt/autocomplete.tsx +869 -0
- package/src/tui/component/prompt/cwd.ts +0 -0
- package/src/tui/component/prompt/frecency.tsx +90 -0
- package/src/tui/component/prompt/history.tsx +108 -0
- package/src/tui/component/prompt/index.tsx +1809 -0
- package/src/tui/component/prompt/part.ts +16 -0
- package/src/tui/component/prompt/stash.tsx +101 -0
- package/src/tui/component/prompt/traits.ts +35 -0
- package/src/tui/component/spinner.tsx +24 -0
- package/src/tui/component/startup-loading.tsx +63 -0
- package/src/tui/component/todo-item.tsx +32 -0
- package/src/tui/component/use-connected.tsx +9 -0
- package/src/tui/component/workspace-label.tsx +19 -0
- package/src/tui/config/cwd.ts +5 -0
- package/src/tui/config/keybind.ts +432 -0
- package/src/tui/config/tui-migrate.ts +154 -0
- package/src/tui/config/tui-schema.ts +34 -0
- package/src/tui/config/tui.ts +46 -0
- package/src/tui/context/aggregate-failures.ts +34 -0
- package/src/tui/context/args.tsx +15 -0
- package/src/tui/context/command-palette.tsx +163 -0
- package/src/tui/context/directory.ts +15 -0
- package/src/tui/context/editor-zed.ts +283 -0
- package/src/tui/context/editor.ts +468 -0
- package/src/tui/context/event-apx.ts +22 -0
- package/src/tui/context/event.ts +6 -0
- package/src/tui/context/exit.tsx +60 -0
- package/src/tui/context/helper.tsx +25 -0
- package/src/tui/context/kv.tsx +81 -0
- package/src/tui/context/local.tsx +608 -0
- package/src/tui/context/path-format.tsx +39 -0
- package/src/tui/context/project-apx.tsx +48 -0
- package/src/tui/context/project.tsx +7 -0
- package/src/tui/context/prompt.tsx +18 -0
- package/src/tui/context/route.tsx +52 -0
- package/src/tui/context/sdk-apx.tsx +185 -0
- package/src/tui/context/sdk.tsx +6 -0
- package/src/tui/context/sync-apx.tsx +178 -0
- package/src/tui/context/sync-v2.tsx +16 -0
- package/src/tui/context/sync.tsx +118 -0
- package/src/tui/context/theme/aura.json +69 -0
- package/src/tui/context/theme/ayu.json +80 -0
- package/src/tui/context/theme/carbonfox.json +248 -0
- package/src/tui/context/theme/catppuccin-frappe.json +230 -0
- package/src/tui/context/theme/catppuccin-macchiato.json +230 -0
- package/src/tui/context/theme/catppuccin.json +112 -0
- package/src/tui/context/theme/cobalt2.json +225 -0
- package/src/tui/context/theme/cursor.json +249 -0
- package/src/tui/context/theme/dracula.json +219 -0
- package/src/tui/context/theme/everforest.json +241 -0
- package/src/tui/context/theme/flexoki.json +237 -0
- package/src/tui/context/theme/github.json +233 -0
- package/src/tui/context/theme/gruvbox.json +242 -0
- package/src/tui/context/theme/kanagawa.json +77 -0
- package/src/tui/context/theme/lucent-orng.json +234 -0
- package/src/tui/context/theme/material.json +235 -0
- package/src/tui/context/theme/matrix.json +77 -0
- package/src/tui/context/theme/mercury.json +252 -0
- package/src/tui/context/theme/monokai.json +221 -0
- package/src/tui/context/theme/nightowl.json +221 -0
- package/src/tui/context/theme/nord.json +223 -0
- package/src/tui/context/theme/one-dark.json +84 -0
- package/src/tui/context/theme/opencode.json +245 -0
- package/src/tui/context/theme/orng.json +249 -0
- package/src/tui/context/theme/osaka-jade.json +93 -0
- package/src/tui/context/theme/palenight.json +222 -0
- package/src/tui/context/theme/rosepine.json +234 -0
- package/src/tui/context/theme/solarized.json +223 -0
- package/src/tui/context/theme/synthwave84.json +226 -0
- package/src/tui/context/theme/tokyonight.json +243 -0
- package/src/tui/context/theme/vercel.json +245 -0
- package/src/tui/context/theme/vesper.json +218 -0
- package/src/tui/context/theme/zenburn.json +223 -0
- package/src/tui/context/theme.tsx +1247 -0
- package/src/tui/context/tui-config.tsx +9 -0
- package/src/tui/event.ts +16 -0
- package/src/tui/feature-plugins/home/footer.tsx +94 -0
- package/src/tui/feature-plugins/home/tips-view.tsx +166 -0
- package/src/tui/feature-plugins/home/tips.tsx +59 -0
- package/src/tui/feature-plugins/sidebar/context.tsx +65 -0
- package/src/tui/feature-plugins/sidebar/files.tsx +63 -0
- package/src/tui/feature-plugins/sidebar/footer.tsx +94 -0
- package/src/tui/feature-plugins/sidebar/lsp.tsx +65 -0
- package/src/tui/feature-plugins/sidebar/mcp.tsx +97 -0
- package/src/tui/feature-plugins/sidebar/todo.tsx +49 -0
- package/src/tui/feature-plugins/system/plugins.tsx +269 -0
- package/src/tui/feature-plugins/system/session-v2.tsx +1143 -0
- package/src/tui/feature-plugins/system/which-key.tsx +608 -0
- package/src/tui/keymap.tsx +166 -0
- package/src/tui/layer.ts +6 -0
- package/src/tui/plugin/api.tsx +381 -0
- package/src/tui/plugin/command-shim.ts +109 -0
- package/src/tui/plugin/internal.ts +33 -0
- package/src/tui/plugin/runtime.ts +1069 -0
- package/src/tui/plugin/slots.tsx +60 -0
- package/src/tui/routes/home.tsx +96 -0
- package/src/tui/routes/session/dialog-fork-from-timeline.tsx +76 -0
- package/src/tui/routes/session/dialog-message.tsx +108 -0
- package/src/tui/routes/session/dialog-subagent.tsx +26 -0
- package/src/tui/routes/session/dialog-timeline.tsx +47 -0
- package/src/tui/routes/session/footer.tsx +91 -0
- package/src/tui/routes/session/index.tsx +188 -0
- package/src/tui/routes/session/permission.tsx +722 -0
- package/src/tui/routes/session/question.tsx +490 -0
- package/src/tui/routes/session/sidebar.tsx +102 -0
- package/src/tui/routes/session/subagent-footer.tsx +133 -0
- package/src/tui/run.ts +84 -0
- package/src/tui/thread.ts +261 -0
- package/src/tui/tsconfig.json +40 -0
- package/src/tui/ui/dialog-alert.tsx +66 -0
- package/src/tui/ui/dialog-confirm.tsx +108 -0
- package/src/tui/ui/dialog-export-options.tsx +217 -0
- package/src/tui/ui/dialog-help.tsx +40 -0
- package/src/tui/ui/dialog-prompt.tsx +101 -0
- package/src/tui/ui/dialog-select.tsx +553 -0
- package/src/tui/ui/dialog.tsx +211 -0
- package/src/tui/ui/link.tsx +34 -0
- package/src/tui/ui/spinner.ts +368 -0
- package/src/tui/ui/toast.tsx +111 -0
- package/src/tui/util/clipboard.ts +217 -0
- package/src/tui/util/editor.ts +37 -0
- package/src/tui/util/model.ts +23 -0
- package/src/tui/util/provider-origin.ts +7 -0
- package/src/tui/util/revert-diff.ts +18 -0
- package/src/tui/util/scroll.ts +25 -0
- package/src/tui/util/selection.ts +65 -0
- package/src/tui/util/signal.ts +41 -0
- package/src/tui/util/sound.ts +156 -0
- package/src/tui/util/transcript.ts +112 -0
- package/src/tui/validate-session.ts +29 -0
- package/src/tui/win32.ts +130 -0
- package/src/tui/worker.ts +104 -0
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
import { createStore } from "solid-js/store"
|
|
2
|
+
import { createMemo, createSignal, For, Show } from "solid-js"
|
|
3
|
+
import type { TextareaRenderable } from "@opentui/core"
|
|
4
|
+
import { selectedForeground, tint, useTheme } from "../../context/theme"
|
|
5
|
+
import type { QuestionAnswer, QuestionRequest } from "@opencode-ai/sdk/v2"
|
|
6
|
+
import { useSDK } from "../../context/sdk"
|
|
7
|
+
import { SplitBorder } from "../../component/border"
|
|
8
|
+
import { useDialog } from "../../ui/dialog"
|
|
9
|
+
import { useTuiConfig } from "../../context/tui-config"
|
|
10
|
+
import { useBindings } from "../../keymap"
|
|
11
|
+
|
|
12
|
+
export function QuestionPrompt(props: { request: QuestionRequest }) {
|
|
13
|
+
const sdk = useSDK()
|
|
14
|
+
const { theme } = useTheme()
|
|
15
|
+
const tuiConfig = useTuiConfig()
|
|
16
|
+
|
|
17
|
+
const questions = createMemo(() => props.request.questions)
|
|
18
|
+
const single = createMemo(() => questions().length === 1 && questions()[0]?.multiple !== true)
|
|
19
|
+
const tabs = createMemo(() => (single() ? 1 : questions().length + 1)) // questions + confirm tab (no confirm for single select)
|
|
20
|
+
const [tabHover, setTabHover] = createSignal<number | "confirm" | null>(null)
|
|
21
|
+
const [store, setStore] = createStore({
|
|
22
|
+
tab: 0,
|
|
23
|
+
answers: [] as QuestionAnswer[],
|
|
24
|
+
custom: [] as string[],
|
|
25
|
+
selected: 0,
|
|
26
|
+
editing: false,
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
let textarea: TextareaRenderable | undefined
|
|
30
|
+
|
|
31
|
+
const question = createMemo(() => questions()[store.tab])
|
|
32
|
+
const confirm = createMemo(() => !single() && store.tab === questions().length)
|
|
33
|
+
const options = createMemo(() => question()?.options ?? [])
|
|
34
|
+
const custom = createMemo(() => question()?.custom !== false)
|
|
35
|
+
const other = createMemo(() => custom() && store.selected === options().length)
|
|
36
|
+
const input = createMemo(() => store.custom[store.tab] ?? "")
|
|
37
|
+
const multi = createMemo(() => question()?.multiple === true)
|
|
38
|
+
const customPicked = createMemo(() => {
|
|
39
|
+
const value = input()
|
|
40
|
+
if (!value) return false
|
|
41
|
+
return store.answers[store.tab]?.includes(value) ?? false
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
function submit() {
|
|
45
|
+
const answers = questions().map((_, i) => store.answers[i] ?? [])
|
|
46
|
+
void sdk.client.question.reply({
|
|
47
|
+
requestID: props.request.id,
|
|
48
|
+
answers,
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function reject() {
|
|
53
|
+
void sdk.client.question.reject({
|
|
54
|
+
requestID: props.request.id,
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function pick(answer: string, custom: boolean = false) {
|
|
59
|
+
const answers = [...store.answers]
|
|
60
|
+
answers[store.tab] = [answer]
|
|
61
|
+
setStore("answers", answers)
|
|
62
|
+
if (custom) {
|
|
63
|
+
const inputs = [...store.custom]
|
|
64
|
+
inputs[store.tab] = answer
|
|
65
|
+
setStore("custom", inputs)
|
|
66
|
+
}
|
|
67
|
+
if (single()) {
|
|
68
|
+
void sdk.client.question.reply({
|
|
69
|
+
requestID: props.request.id,
|
|
70
|
+
answers: [[answer]],
|
|
71
|
+
})
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
setStore("tab", store.tab + 1)
|
|
75
|
+
setStore("selected", 0)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function toggle(answer: string) {
|
|
79
|
+
const existing = store.answers[store.tab] ?? []
|
|
80
|
+
const next = [...existing]
|
|
81
|
+
const index = next.indexOf(answer)
|
|
82
|
+
if (index === -1) next.push(answer)
|
|
83
|
+
if (index !== -1) next.splice(index, 1)
|
|
84
|
+
const answers = [...store.answers]
|
|
85
|
+
answers[store.tab] = next
|
|
86
|
+
setStore("answers", answers)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function moveTo(index: number) {
|
|
90
|
+
setStore("selected", index)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function selectTab(index: number) {
|
|
94
|
+
setStore("tab", index)
|
|
95
|
+
setStore("selected", 0)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function selectOption() {
|
|
99
|
+
if (other()) {
|
|
100
|
+
if (!multi()) {
|
|
101
|
+
setStore("editing", true)
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
const value = input()
|
|
105
|
+
if (value && customPicked()) {
|
|
106
|
+
toggle(value)
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
setStore("editing", true)
|
|
110
|
+
return
|
|
111
|
+
}
|
|
112
|
+
const opt = options()[store.selected]
|
|
113
|
+
if (!opt) return
|
|
114
|
+
if (multi()) {
|
|
115
|
+
toggle(opt.label)
|
|
116
|
+
return
|
|
117
|
+
}
|
|
118
|
+
pick(opt.label)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const dialog = useDialog()
|
|
122
|
+
|
|
123
|
+
useBindings(() => ({
|
|
124
|
+
enabled: store.editing && !confirm(),
|
|
125
|
+
commands: [
|
|
126
|
+
{
|
|
127
|
+
name: "prompt.clear",
|
|
128
|
+
title: "Clear answer edit",
|
|
129
|
+
category: "Question",
|
|
130
|
+
run() {
|
|
131
|
+
const text = textarea?.plainText ?? ""
|
|
132
|
+
if (!text) {
|
|
133
|
+
setStore("editing", false)
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
textarea?.setText("")
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
bindings: [
|
|
141
|
+
{
|
|
142
|
+
key: "escape",
|
|
143
|
+
desc: "Cancel answer edit",
|
|
144
|
+
group: "Question",
|
|
145
|
+
cmd: () => {
|
|
146
|
+
setStore("editing", false)
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
...tuiConfig.keybinds.get("prompt.clear"),
|
|
150
|
+
{
|
|
151
|
+
key: "return",
|
|
152
|
+
desc: "Submit answer edit",
|
|
153
|
+
group: "Question",
|
|
154
|
+
cmd: () => {
|
|
155
|
+
const text = textarea?.plainText?.trim() ?? ""
|
|
156
|
+
const prev = store.custom[store.tab]
|
|
157
|
+
|
|
158
|
+
if (!text) {
|
|
159
|
+
if (prev) {
|
|
160
|
+
const inputs = [...store.custom]
|
|
161
|
+
inputs[store.tab] = ""
|
|
162
|
+
setStore("custom", inputs)
|
|
163
|
+
|
|
164
|
+
const answers = [...store.answers]
|
|
165
|
+
answers[store.tab] = (answers[store.tab] ?? []).filter((x) => x !== prev)
|
|
166
|
+
setStore("answers", answers)
|
|
167
|
+
}
|
|
168
|
+
setStore("editing", false)
|
|
169
|
+
return
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (multi()) {
|
|
173
|
+
const inputs = [...store.custom]
|
|
174
|
+
inputs[store.tab] = text
|
|
175
|
+
setStore("custom", inputs)
|
|
176
|
+
|
|
177
|
+
const existing = store.answers[store.tab] ?? []
|
|
178
|
+
const next = [...existing]
|
|
179
|
+
if (prev) {
|
|
180
|
+
const index = next.indexOf(prev)
|
|
181
|
+
if (index !== -1) next.splice(index, 1)
|
|
182
|
+
}
|
|
183
|
+
if (!next.includes(text)) next.push(text)
|
|
184
|
+
const answers = [...store.answers]
|
|
185
|
+
answers[store.tab] = next
|
|
186
|
+
setStore("answers", answers)
|
|
187
|
+
setStore("editing", false)
|
|
188
|
+
return
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
pick(text, true)
|
|
192
|
+
setStore("editing", false)
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
}))
|
|
197
|
+
|
|
198
|
+
useBindings(() => {
|
|
199
|
+
const opts = options()
|
|
200
|
+
const total = opts.length + (custom() ? 1 : 0)
|
|
201
|
+
const max = Math.min(total, 9)
|
|
202
|
+
|
|
203
|
+
return {
|
|
204
|
+
enabled: dialog.stack.length === 0 && !store.editing,
|
|
205
|
+
commands: [
|
|
206
|
+
{
|
|
207
|
+
name: "app.exit",
|
|
208
|
+
title: "Reject question",
|
|
209
|
+
category: "Question",
|
|
210
|
+
run() {
|
|
211
|
+
reject()
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
],
|
|
215
|
+
bindings: [
|
|
216
|
+
{
|
|
217
|
+
key: "left",
|
|
218
|
+
desc: "Previous question",
|
|
219
|
+
group: "Question",
|
|
220
|
+
cmd: () => selectTab((store.tab - 1 + tabs()) % tabs()),
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
key: "h",
|
|
224
|
+
desc: "Previous question",
|
|
225
|
+
group: "Question",
|
|
226
|
+
cmd: () => selectTab((store.tab - 1 + tabs()) % tabs()),
|
|
227
|
+
},
|
|
228
|
+
{ key: "right", desc: "Next question", group: "Question", cmd: () => selectTab((store.tab + 1) % tabs()) },
|
|
229
|
+
{ key: "l", desc: "Next question", group: "Question", cmd: () => selectTab((store.tab + 1) % tabs()) },
|
|
230
|
+
{
|
|
231
|
+
key: "tab",
|
|
232
|
+
desc: "Next question",
|
|
233
|
+
group: "Question",
|
|
234
|
+
cmd: ({ event }: { event: { shift: boolean } }) => {
|
|
235
|
+
selectTab((store.tab + (event.shift ? -1 : 1) + tabs()) % tabs())
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
...(confirm()
|
|
239
|
+
? [
|
|
240
|
+
{ key: "return", desc: "Submit answer", group: "Question", cmd: () => submit() },
|
|
241
|
+
{ key: "escape", desc: "Reject question", group: "Question", cmd: () => reject() },
|
|
242
|
+
...tuiConfig.keybinds.get("app.exit"),
|
|
243
|
+
]
|
|
244
|
+
: [
|
|
245
|
+
...Array.from({ length: max }, (_, index) => ({
|
|
246
|
+
key: String(index + 1),
|
|
247
|
+
desc: `Select answer ${index + 1}`,
|
|
248
|
+
group: "Question",
|
|
249
|
+
cmd: () => {
|
|
250
|
+
moveTo(index)
|
|
251
|
+
selectOption()
|
|
252
|
+
},
|
|
253
|
+
})),
|
|
254
|
+
{
|
|
255
|
+
key: "up",
|
|
256
|
+
desc: "Previous answer",
|
|
257
|
+
group: "Question",
|
|
258
|
+
cmd: () => moveTo((store.selected - 1 + total) % total),
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
key: "k",
|
|
262
|
+
desc: "Previous answer",
|
|
263
|
+
group: "Question",
|
|
264
|
+
cmd: () => moveTo((store.selected - 1 + total) % total),
|
|
265
|
+
},
|
|
266
|
+
{ key: "down", desc: "Next answer", group: "Question", cmd: () => moveTo((store.selected + 1) % total) },
|
|
267
|
+
{ key: "j", desc: "Next answer", group: "Question", cmd: () => moveTo((store.selected + 1) % total) },
|
|
268
|
+
{ key: "return", desc: "Select answer", group: "Question", cmd: () => selectOption() },
|
|
269
|
+
{ key: "escape", desc: "Reject question", group: "Question", cmd: () => reject() },
|
|
270
|
+
...tuiConfig.keybinds.get("app.exit"),
|
|
271
|
+
]),
|
|
272
|
+
],
|
|
273
|
+
}
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
return (
|
|
277
|
+
<box
|
|
278
|
+
backgroundColor={theme.backgroundPanel}
|
|
279
|
+
border={["left"]}
|
|
280
|
+
borderColor={theme.accent}
|
|
281
|
+
customBorderChars={SplitBorder.customBorderChars}
|
|
282
|
+
>
|
|
283
|
+
<box gap={1} paddingLeft={1} paddingRight={3} paddingTop={1} paddingBottom={1}>
|
|
284
|
+
<Show when={!single()}>
|
|
285
|
+
<box flexDirection="row" gap={1} paddingLeft={1}>
|
|
286
|
+
<For each={questions()}>
|
|
287
|
+
{(q, index) => {
|
|
288
|
+
const isActive = () => index() === store.tab
|
|
289
|
+
const isAnswered = () => {
|
|
290
|
+
return (store.answers[index()]?.length ?? 0) > 0
|
|
291
|
+
}
|
|
292
|
+
return (
|
|
293
|
+
<box
|
|
294
|
+
paddingLeft={1}
|
|
295
|
+
paddingRight={1}
|
|
296
|
+
backgroundColor={
|
|
297
|
+
isActive()
|
|
298
|
+
? theme.accent
|
|
299
|
+
: tabHover() === index()
|
|
300
|
+
? theme.backgroundElement
|
|
301
|
+
: theme.backgroundPanel
|
|
302
|
+
}
|
|
303
|
+
onMouseOver={() => setTabHover(index())}
|
|
304
|
+
onMouseOut={() => setTabHover(null)}
|
|
305
|
+
onMouseUp={() => selectTab(index())}
|
|
306
|
+
>
|
|
307
|
+
<text
|
|
308
|
+
fg={
|
|
309
|
+
isActive()
|
|
310
|
+
? selectedForeground(theme, theme.accent)
|
|
311
|
+
: isAnswered()
|
|
312
|
+
? theme.text
|
|
313
|
+
: theme.textMuted
|
|
314
|
+
}
|
|
315
|
+
>
|
|
316
|
+
{q.header}
|
|
317
|
+
</text>
|
|
318
|
+
</box>
|
|
319
|
+
)
|
|
320
|
+
}}
|
|
321
|
+
</For>
|
|
322
|
+
<box
|
|
323
|
+
paddingLeft={1}
|
|
324
|
+
paddingRight={1}
|
|
325
|
+
backgroundColor={
|
|
326
|
+
confirm() ? theme.accent : tabHover() === "confirm" ? theme.backgroundElement : theme.backgroundPanel
|
|
327
|
+
}
|
|
328
|
+
onMouseOver={() => setTabHover("confirm")}
|
|
329
|
+
onMouseOut={() => setTabHover(null)}
|
|
330
|
+
onMouseUp={() => selectTab(questions().length)}
|
|
331
|
+
>
|
|
332
|
+
<text fg={confirm() ? selectedForeground(theme, theme.accent) : theme.textMuted}>Confirm</text>
|
|
333
|
+
</box>
|
|
334
|
+
</box>
|
|
335
|
+
</Show>
|
|
336
|
+
|
|
337
|
+
<Show when={!confirm()}>
|
|
338
|
+
<box paddingLeft={1} gap={1}>
|
|
339
|
+
<box>
|
|
340
|
+
<text fg={theme.text}>
|
|
341
|
+
{question()?.question}
|
|
342
|
+
{multi() ? " (select all that apply)" : ""}
|
|
343
|
+
</text>
|
|
344
|
+
</box>
|
|
345
|
+
<box>
|
|
346
|
+
<For each={options()}>
|
|
347
|
+
{(opt, i) => {
|
|
348
|
+
const active = () => i() === store.selected
|
|
349
|
+
const picked = () => store.answers[store.tab]?.includes(opt.label) ?? false
|
|
350
|
+
return (
|
|
351
|
+
<box
|
|
352
|
+
onMouseOver={() => moveTo(i())}
|
|
353
|
+
onMouseDown={() => moveTo(i())}
|
|
354
|
+
onMouseUp={() => selectOption()}
|
|
355
|
+
>
|
|
356
|
+
<box flexDirection="row">
|
|
357
|
+
<box backgroundColor={active() ? theme.backgroundElement : undefined} paddingRight={1}>
|
|
358
|
+
<text fg={active() ? tint(theme.textMuted, theme.secondary, 0.6) : theme.textMuted}>
|
|
359
|
+
{`${i() + 1}.`}
|
|
360
|
+
</text>
|
|
361
|
+
</box>
|
|
362
|
+
<box backgroundColor={active() ? theme.backgroundElement : undefined}>
|
|
363
|
+
<text fg={active() ? theme.secondary : picked() ? theme.success : theme.text}>
|
|
364
|
+
{multi() ? `[${picked() ? "✓" : " "}] ${opt.label}` : opt.label}
|
|
365
|
+
</text>
|
|
366
|
+
</box>
|
|
367
|
+
<Show when={!multi()}>
|
|
368
|
+
<text fg={theme.success}>{picked() ? "✓" : ""}</text>
|
|
369
|
+
</Show>
|
|
370
|
+
</box>
|
|
371
|
+
|
|
372
|
+
<box paddingLeft={3}>
|
|
373
|
+
<text fg={theme.textMuted}>{opt.description}</text>
|
|
374
|
+
</box>
|
|
375
|
+
</box>
|
|
376
|
+
)
|
|
377
|
+
}}
|
|
378
|
+
</For>
|
|
379
|
+
<Show when={custom()}>
|
|
380
|
+
<box
|
|
381
|
+
onMouseOver={() => moveTo(options().length)}
|
|
382
|
+
onMouseDown={() => moveTo(options().length)}
|
|
383
|
+
onMouseUp={() => selectOption()}
|
|
384
|
+
>
|
|
385
|
+
<box flexDirection="row">
|
|
386
|
+
<box backgroundColor={other() ? theme.backgroundElement : undefined} paddingRight={1}>
|
|
387
|
+
<text fg={other() ? tint(theme.textMuted, theme.secondary, 0.6) : theme.textMuted}>
|
|
388
|
+
{`${options().length + 1}.`}
|
|
389
|
+
</text>
|
|
390
|
+
</box>
|
|
391
|
+
<box backgroundColor={other() ? theme.backgroundElement : undefined}>
|
|
392
|
+
<text fg={other() ? theme.secondary : customPicked() ? theme.success : theme.text}>
|
|
393
|
+
{multi() ? `[${customPicked() ? "✓" : " "}] Type your own answer` : "Type your own answer"}
|
|
394
|
+
</text>
|
|
395
|
+
</box>
|
|
396
|
+
|
|
397
|
+
<Show when={!multi()}>
|
|
398
|
+
<text fg={theme.success}>{customPicked() ? "✓" : ""}</text>
|
|
399
|
+
</Show>
|
|
400
|
+
</box>
|
|
401
|
+
<Show when={store.editing}>
|
|
402
|
+
<box paddingLeft={3}>
|
|
403
|
+
<textarea
|
|
404
|
+
ref={(val: TextareaRenderable) => {
|
|
405
|
+
textarea = val
|
|
406
|
+
val.traits = { status: "ANSWER" }
|
|
407
|
+
queueMicrotask(() => {
|
|
408
|
+
val.focus()
|
|
409
|
+
val.gotoLineEnd()
|
|
410
|
+
})
|
|
411
|
+
}}
|
|
412
|
+
initialValue={input()}
|
|
413
|
+
placeholder="Type your own answer"
|
|
414
|
+
placeholderColor={theme.textMuted}
|
|
415
|
+
minHeight={1}
|
|
416
|
+
maxHeight={6}
|
|
417
|
+
textColor={theme.text}
|
|
418
|
+
focusedTextColor={theme.text}
|
|
419
|
+
cursorColor={theme.primary}
|
|
420
|
+
/>
|
|
421
|
+
</box>
|
|
422
|
+
</Show>
|
|
423
|
+
<Show when={!store.editing && input()}>
|
|
424
|
+
<box paddingLeft={3}>
|
|
425
|
+
<text fg={theme.textMuted}>{input()}</text>
|
|
426
|
+
</box>
|
|
427
|
+
</Show>
|
|
428
|
+
</box>
|
|
429
|
+
</Show>
|
|
430
|
+
</box>
|
|
431
|
+
</box>
|
|
432
|
+
</Show>
|
|
433
|
+
|
|
434
|
+
<Show when={confirm() && !single()}>
|
|
435
|
+
<box paddingLeft={1}>
|
|
436
|
+
<text fg={theme.text}>Review</text>
|
|
437
|
+
</box>
|
|
438
|
+
<For each={questions()}>
|
|
439
|
+
{(q, index) => {
|
|
440
|
+
const value = () => store.answers[index()]?.join(", ") ?? ""
|
|
441
|
+
const answered = () => Boolean(value())
|
|
442
|
+
return (
|
|
443
|
+
<box paddingLeft={1}>
|
|
444
|
+
<text>
|
|
445
|
+
<span style={{ fg: theme.textMuted }}>{q.header}:</span>{" "}
|
|
446
|
+
<span style={{ fg: answered() ? theme.text : theme.error }}>
|
|
447
|
+
{answered() ? value() : "(not answered)"}
|
|
448
|
+
</span>
|
|
449
|
+
</text>
|
|
450
|
+
</box>
|
|
451
|
+
)
|
|
452
|
+
}}
|
|
453
|
+
</For>
|
|
454
|
+
</Show>
|
|
455
|
+
</box>
|
|
456
|
+
<box
|
|
457
|
+
flexDirection="row"
|
|
458
|
+
flexShrink={0}
|
|
459
|
+
gap={1}
|
|
460
|
+
paddingLeft={2}
|
|
461
|
+
paddingRight={3}
|
|
462
|
+
paddingBottom={1}
|
|
463
|
+
justifyContent="space-between"
|
|
464
|
+
>
|
|
465
|
+
<box flexDirection="row" gap={2}>
|
|
466
|
+
<Show when={!single()}>
|
|
467
|
+
<text fg={theme.text}>
|
|
468
|
+
{"⇆"} <span style={{ fg: theme.textMuted }}>tab</span>
|
|
469
|
+
</text>
|
|
470
|
+
</Show>
|
|
471
|
+
<Show when={!confirm()}>
|
|
472
|
+
<text fg={theme.text}>
|
|
473
|
+
{"↑↓"} <span style={{ fg: theme.textMuted }}>select</span>
|
|
474
|
+
</text>
|
|
475
|
+
</Show>
|
|
476
|
+
<text fg={theme.text}>
|
|
477
|
+
enter{" "}
|
|
478
|
+
<span style={{ fg: theme.textMuted }}>
|
|
479
|
+
{confirm() ? "submit" : multi() ? "toggle" : single() ? "submit" : "confirm"}
|
|
480
|
+
</span>
|
|
481
|
+
</text>
|
|
482
|
+
|
|
483
|
+
<text fg={theme.text}>
|
|
484
|
+
esc <span style={{ fg: theme.textMuted }}>dismiss</span>
|
|
485
|
+
</text>
|
|
486
|
+
</box>
|
|
487
|
+
</box>
|
|
488
|
+
</box>
|
|
489
|
+
)
|
|
490
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { useProject } from "@tui/context/project"
|
|
2
|
+
import { useSync } from "@tui/context/sync"
|
|
3
|
+
import { createMemo, Show } from "solid-js"
|
|
4
|
+
import { useTheme } from "../../context/theme"
|
|
5
|
+
import { useTuiConfig } from "../../context/tui-config"
|
|
6
|
+
import { InstallationChannel, InstallationVersion } from "@opencode-ai/core/installation/version"
|
|
7
|
+
import { TuiPluginRuntime } from "@/cli/cmd/tui/plugin/runtime"
|
|
8
|
+
|
|
9
|
+
import { getScrollAcceleration } from "../../util/scroll"
|
|
10
|
+
import { WorkspaceLabel } from "../../component/workspace-label"
|
|
11
|
+
|
|
12
|
+
export function Sidebar(props: { sessionID: string; overlay?: boolean }) {
|
|
13
|
+
const project = useProject()
|
|
14
|
+
const sync = useSync()
|
|
15
|
+
const { theme } = useTheme()
|
|
16
|
+
const tuiConfig = useTuiConfig()
|
|
17
|
+
const session = createMemo(() => sync.session.get(props.sessionID))
|
|
18
|
+
const workspace = () => {
|
|
19
|
+
const workspaceID = session()?.workspaceID
|
|
20
|
+
if (!workspaceID) return
|
|
21
|
+
return project.workspace.get(workspaceID)
|
|
22
|
+
}
|
|
23
|
+
const scrollAcceleration = createMemo(() => getScrollAcceleration(tuiConfig))
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Show when={session()}>
|
|
27
|
+
<box
|
|
28
|
+
backgroundColor={theme.backgroundPanel}
|
|
29
|
+
width={42}
|
|
30
|
+
height="100%"
|
|
31
|
+
paddingTop={1}
|
|
32
|
+
paddingBottom={1}
|
|
33
|
+
paddingLeft={2}
|
|
34
|
+
paddingRight={2}
|
|
35
|
+
position={props.overlay ? "absolute" : "relative"}
|
|
36
|
+
>
|
|
37
|
+
<scrollbox
|
|
38
|
+
flexGrow={1}
|
|
39
|
+
scrollAcceleration={scrollAcceleration()}
|
|
40
|
+
verticalScrollbarOptions={{
|
|
41
|
+
trackOptions: {
|
|
42
|
+
backgroundColor: theme.background,
|
|
43
|
+
foregroundColor: theme.borderActive,
|
|
44
|
+
},
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
<box flexShrink={0} gap={1} paddingRight={1}>
|
|
48
|
+
<TuiPluginRuntime.Slot
|
|
49
|
+
name="sidebar_title"
|
|
50
|
+
mode="single_winner"
|
|
51
|
+
session_id={props.sessionID}
|
|
52
|
+
title={session()!.title}
|
|
53
|
+
share_url={session()!.share?.url}
|
|
54
|
+
>
|
|
55
|
+
<box paddingRight={1}>
|
|
56
|
+
<text fg={theme.text}>
|
|
57
|
+
<b>{session()!.title}</b>
|
|
58
|
+
</text>
|
|
59
|
+
<Show when={InstallationChannel !== "latest"}>
|
|
60
|
+
<text fg={theme.textMuted}>{props.sessionID}</text>
|
|
61
|
+
</Show>
|
|
62
|
+
<Show when={session()!.workspaceID}>
|
|
63
|
+
<text fg={theme.textMuted}>
|
|
64
|
+
<Show
|
|
65
|
+
when={workspace()}
|
|
66
|
+
fallback={<WorkspaceLabel type="unknown" name={session()!.workspaceID!} status="error" icon />}
|
|
67
|
+
>
|
|
68
|
+
{(item) => (
|
|
69
|
+
<WorkspaceLabel
|
|
70
|
+
type={item().type}
|
|
71
|
+
name={item().name}
|
|
72
|
+
status={project.workspace.status(item().id) ?? "error"}
|
|
73
|
+
icon
|
|
74
|
+
/>
|
|
75
|
+
)}
|
|
76
|
+
</Show>
|
|
77
|
+
</text>
|
|
78
|
+
</Show>
|
|
79
|
+
<Show when={session()!.share?.url}>
|
|
80
|
+
<text fg={theme.textMuted}>{session()!.share!.url}</text>
|
|
81
|
+
</Show>
|
|
82
|
+
</box>
|
|
83
|
+
</TuiPluginRuntime.Slot>
|
|
84
|
+
<TuiPluginRuntime.Slot name="sidebar_content" session_id={props.sessionID} />
|
|
85
|
+
</box>
|
|
86
|
+
</scrollbox>
|
|
87
|
+
|
|
88
|
+
<box flexShrink={0} gap={1} paddingTop={1}>
|
|
89
|
+
<TuiPluginRuntime.Slot name="sidebar_footer" mode="single_winner" session_id={props.sessionID}>
|
|
90
|
+
<text fg={theme.textMuted}>
|
|
91
|
+
<span style={{ fg: theme.success }}>•</span> <b>Open</b>
|
|
92
|
+
<span style={{ fg: theme.text }}>
|
|
93
|
+
<b>Code</b>
|
|
94
|
+
</span>{" "}
|
|
95
|
+
<span>{InstallationVersion}</span>
|
|
96
|
+
</text>
|
|
97
|
+
</TuiPluginRuntime.Slot>
|
|
98
|
+
</box>
|
|
99
|
+
</box>
|
|
100
|
+
</Show>
|
|
101
|
+
)
|
|
102
|
+
}
|