@justsilver/opencode-team 0.0.0-stage → 0.2.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/CHANGELOG.md +126 -0
- package/LICENSE +21 -0
- package/README.md +116 -3
- package/package.json +48 -4
- package/plugin/opencode-team/index.ts +41 -0
- package/plugin/opencode-team/legacy.ts +48 -0
- package/plugin/opencode-team/model-ref.ts +28 -0
- package/plugin/opencode-team/policy.ts +638 -0
- package/plugin/opencode-team/prompts.ts +138 -0
- package/plugin/opencode-team/rpc.ts +90 -0
- package/plugin/opencode-team/team-agents.ts +104 -0
- package/plugin/opencode-team/team-ids.ts +2 -0
- package/plugin/opencode-team/tui.ts +22 -0
- package/plugin/opencode-team/view/configure.tsx +71 -0
- package/plugin/opencode-team/view/dashboard.tsx +889 -0
- package/plugin/opencode-team/view/model-config.tsx +976 -0
- package/plugin/opencode-team/view/model.ts +502 -0
- package/plugin/opencode-team/view/team.ts +267 -0
- package/plugin/opencode-team/view/ui.tsx +165 -0
|
@@ -0,0 +1,976 @@
|
|
|
1
|
+
/** @jsxImportSource @opentui/solid */
|
|
2
|
+
import {
|
|
3
|
+
TextAttributes,
|
|
4
|
+
type InputRenderable,
|
|
5
|
+
type Renderable,
|
|
6
|
+
type ScrollBoxRenderable,
|
|
7
|
+
} from "@opentui/core"
|
|
8
|
+
import { useTerminalDimensions } from "@opentui/solid"
|
|
9
|
+
import type { ModelInfo, ProviderInfo } from "@opencode/client"
|
|
10
|
+
import {
|
|
11
|
+
createEffect,
|
|
12
|
+
createMemo,
|
|
13
|
+
createSignal,
|
|
14
|
+
For,
|
|
15
|
+
on,
|
|
16
|
+
onCleanup,
|
|
17
|
+
Show,
|
|
18
|
+
} from "solid-js"
|
|
19
|
+
|
|
20
|
+
import {
|
|
21
|
+
buildModelRef,
|
|
22
|
+
firstVisibleRef,
|
|
23
|
+
modelConfigLayoutFor,
|
|
24
|
+
modelGroups,
|
|
25
|
+
modelRefOf,
|
|
26
|
+
nextRegion,
|
|
27
|
+
parseModelRef,
|
|
28
|
+
resolveModel,
|
|
29
|
+
roleLabel,
|
|
30
|
+
variantsFor,
|
|
31
|
+
type ConfigRegion,
|
|
32
|
+
type DashboardAgent,
|
|
33
|
+
type Feedback,
|
|
34
|
+
} from "./model.ts"
|
|
35
|
+
import type { ModelSelectionResult } from "./team.ts"
|
|
36
|
+
import {
|
|
37
|
+
Badge,
|
|
38
|
+
ConfirmBar,
|
|
39
|
+
Divider,
|
|
40
|
+
FeedbackBar,
|
|
41
|
+
Hints,
|
|
42
|
+
providerTitleColor,
|
|
43
|
+
rowBackground,
|
|
44
|
+
rowForeground,
|
|
45
|
+
rowMarker,
|
|
46
|
+
rowSecondary,
|
|
47
|
+
scrollbarOptions,
|
|
48
|
+
selectedRowAccent,
|
|
49
|
+
statusTone,
|
|
50
|
+
type Hint,
|
|
51
|
+
type KeymapLayer,
|
|
52
|
+
type Theme,
|
|
53
|
+
} from "./ui.tsx"
|
|
54
|
+
|
|
55
|
+
type Focus = ConfigRegion
|
|
56
|
+
|
|
57
|
+
interface VariantOption {
|
|
58
|
+
readonly id?: string
|
|
59
|
+
readonly label: string
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface ModelConfigProps {
|
|
63
|
+
readonly agent: DashboardAgent
|
|
64
|
+
readonly models: readonly ModelInfo[]
|
|
65
|
+
readonly providers: readonly ProviderInfo[]
|
|
66
|
+
readonly currentOverride?: string
|
|
67
|
+
readonly modelError?: string
|
|
68
|
+
readonly theme: Theme
|
|
69
|
+
readonly layer: (factory: () => KeymapLayer) => void
|
|
70
|
+
readonly feedback?: Feedback
|
|
71
|
+
readonly onClose: () => void
|
|
72
|
+
readonly onSave: (model: string) => Promise<ModelSelectionResult>
|
|
73
|
+
readonly onRestore: () => Promise<ModelSelectionResult>
|
|
74
|
+
readonly notify: (feedback: Feedback) => void
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function ModelConfigView(props: ModelConfigProps) {
|
|
78
|
+
const theme = () => props.theme.surface("dialog")
|
|
79
|
+
const dimensions = useTerminalDimensions()
|
|
80
|
+
const layout = createMemo(() => modelConfigLayoutFor(dimensions().width, dimensions().height))
|
|
81
|
+
|
|
82
|
+
const current = createMemo(() => {
|
|
83
|
+
const ref = props.currentOverride ?? props.agent.hostModel
|
|
84
|
+
if (ref === undefined) return undefined
|
|
85
|
+
const parsed = parseModelRef(ref)
|
|
86
|
+
if (parsed === undefined) return undefined
|
|
87
|
+
return {
|
|
88
|
+
baseRef: `${parsed.providerID}/${parsed.id}`,
|
|
89
|
+
...(parsed.variant === undefined ? {} : { variant: parsed.variant }),
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
const initialGroups = modelGroups(props.models, props.providers, "")
|
|
94
|
+
const initialVisible = initialGroups.flatMap((group) => group.models)
|
|
95
|
+
const firstModel = initialVisible[0]
|
|
96
|
+
const initialCurrent = current()
|
|
97
|
+
const initialModel =
|
|
98
|
+
initialCurrent === undefined
|
|
99
|
+
? firstModel
|
|
100
|
+
: (initialVisible.find((model) => modelRefOf(model) === initialCurrent.baseRef) ?? firstModel)
|
|
101
|
+
const initialVariants = variantsFor(initialModel)
|
|
102
|
+
const initialVariant =
|
|
103
|
+
initialCurrent?.baseRef === (initialModel === undefined ? "" : modelRefOf(initialModel)) &&
|
|
104
|
+
initialCurrent.variant !== undefined &&
|
|
105
|
+
initialVariants.includes(initialCurrent.variant)
|
|
106
|
+
? initialCurrent.variant
|
|
107
|
+
: undefined
|
|
108
|
+
|
|
109
|
+
const [selectedRef, setSelectedRef] = createSignal(
|
|
110
|
+
initialModel === undefined ? "" : modelRefOf(initialModel),
|
|
111
|
+
)
|
|
112
|
+
const [variant, setVariant] = createSignal<string | undefined>(initialVariant)
|
|
113
|
+
const [variantCursor, setVariantCursor] = createSignal(
|
|
114
|
+
initialVariant === undefined ? 0 : initialVariants.indexOf(initialVariant) + 1,
|
|
115
|
+
)
|
|
116
|
+
const [query, setQuery] = createSignal("")
|
|
117
|
+
const [focus, setFocus] = createSignal<Focus>("models")
|
|
118
|
+
const [saving, setSaving] = createSignal(false)
|
|
119
|
+
const [saveFailed, setSaveFailed] = createSignal(false)
|
|
120
|
+
const [pendingRestore, setPendingRestore] = createSignal(false)
|
|
121
|
+
let disposed = false
|
|
122
|
+
|
|
123
|
+
const groups = createMemo(() => modelGroups(props.models, props.providers, query()))
|
|
124
|
+
const flatModels = createMemo(() => groups().flatMap((group) => group.models))
|
|
125
|
+
// 选中项必须仍在过滤后的列表里;搜索无结果时不能继续对旧模型执行保存。
|
|
126
|
+
const selectedModel = createMemo(() =>
|
|
127
|
+
flatModels().find((model) => modelRefOf(model) === selectedRef()),
|
|
128
|
+
)
|
|
129
|
+
const variants = createMemo(() => variantsFor(selectedModel()))
|
|
130
|
+
const variantRows = createMemo<VariantOption[]>(() => [
|
|
131
|
+
{ label: "默认" },
|
|
132
|
+
...variants().map((id) => ({ id, label: id })),
|
|
133
|
+
])
|
|
134
|
+
|
|
135
|
+
const pendingLabel = () => {
|
|
136
|
+
const model = selectedModel()
|
|
137
|
+
if (model === undefined) return "—"
|
|
138
|
+
return variant() === undefined ? `${model.name} · 默认` : `${model.name} · ${variant()}`
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
let modelScroll: ScrollBoxRenderable | undefined
|
|
142
|
+
let variantScroll: ScrollBoxRenderable | undefined
|
|
143
|
+
let searchInput: InputRenderable | undefined
|
|
144
|
+
let focusTimer: ReturnType<typeof setTimeout> | undefined
|
|
145
|
+
let scrollTimer: ReturnType<typeof setTimeout> | undefined
|
|
146
|
+
const modelNodes = new Map<string, Renderable>()
|
|
147
|
+
const variantNodes = new Map<number, Renderable>()
|
|
148
|
+
|
|
149
|
+
createEffect(() => {
|
|
150
|
+
const list = flatModels()
|
|
151
|
+
const next = firstVisibleRef(list, selectedRef())
|
|
152
|
+
if (next !== undefined && next !== selectedRef()) setSelectedRef(next)
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
createEffect(
|
|
156
|
+
on(
|
|
157
|
+
selectedRef,
|
|
158
|
+
(ref) => {
|
|
159
|
+
const model = resolveModel(props.models, ref)
|
|
160
|
+
const available = variantsFor(model)
|
|
161
|
+
const currentValue = current()
|
|
162
|
+
const next =
|
|
163
|
+
currentValue?.baseRef === ref &&
|
|
164
|
+
currentValue.variant !== undefined &&
|
|
165
|
+
available.includes(currentValue.variant)
|
|
166
|
+
? currentValue.variant
|
|
167
|
+
: undefined
|
|
168
|
+
setVariant(next)
|
|
169
|
+
setVariantCursor(next === undefined ? 0 : available.indexOf(next) + 1)
|
|
170
|
+
setSaveFailed(false)
|
|
171
|
+
},
|
|
172
|
+
{ defer: true },
|
|
173
|
+
),
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
createEffect(() => {
|
|
177
|
+
// 当前模型没有 Variant 时,不把焦点留在无法操作的第二栏。
|
|
178
|
+
if (focus() === "variants" && variants().length === 0) setFocus("models")
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
createEffect(on(selectedRef, (ref) => ensureModelVisible(ref)))
|
|
182
|
+
createEffect(on(query, () => ensureModelVisible(selectedRef())))
|
|
183
|
+
createEffect(on(variantCursor, (index) => ensureVariantVisible(index)))
|
|
184
|
+
onCleanup(() => {
|
|
185
|
+
disposed = true
|
|
186
|
+
if (focusTimer !== undefined) clearTimeout(focusTimer)
|
|
187
|
+
if (scrollTimer !== undefined) clearTimeout(scrollTimer)
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
/** 搜索框始终保持焦点,输入即过滤,与 /model 一致;确认恢复时临时失焦。 */
|
|
191
|
+
function focusSearchInput(): void {
|
|
192
|
+
if (searchInput === undefined || searchInput.isDestroyed) return
|
|
193
|
+
searchInput.focus()
|
|
194
|
+
searchInput.cursorOffset = searchInput.value.length
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function scheduleFocusSearch(): void {
|
|
198
|
+
if (focusTimer !== undefined) clearTimeout(focusTimer)
|
|
199
|
+
focusTimer = setTimeout(focusSearchInput, 1)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function ensureModelVisible(ref: string): void {
|
|
203
|
+
ensureVisible(modelScroll, modelNodes.get(ref))
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function ensureVariantVisible(index: number): void {
|
|
207
|
+
ensureVisible(variantScroll, variantNodes.get(index))
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function ensureVisible(scroll: ScrollBoxRenderable | undefined, node: Renderable | undefined): void {
|
|
211
|
+
if (scroll === undefined || node === undefined || node.isDestroyed) return
|
|
212
|
+
if (scrollTimer !== undefined) clearTimeout(scrollTimer)
|
|
213
|
+
scrollTimer = setTimeout(() => {
|
|
214
|
+
if (scroll === undefined || scroll.isDestroyed || node.isDestroyed) return
|
|
215
|
+
const top = node.y - scroll.y
|
|
216
|
+
if (top < 0) scroll.scrollBy(top - 1)
|
|
217
|
+
else if (top + node.height > scroll.height) {
|
|
218
|
+
scroll.scrollBy(top + node.height - scroll.height + 1)
|
|
219
|
+
}
|
|
220
|
+
}, 0)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function cycleRegion(): void {
|
|
224
|
+
setFocus(nextRegion(focus(), variants().length > 0))
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function focusModels(): void {
|
|
228
|
+
setFocus("models")
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function focusVariants(): void {
|
|
232
|
+
if (variants().length > 0) setFocus("variants")
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function moveModel(delta: number): void {
|
|
236
|
+
const list = flatModels()
|
|
237
|
+
if (list.length === 0) return
|
|
238
|
+
const index = list.findIndex((model) => modelRefOf(model) === selectedRef())
|
|
239
|
+
const next = index < 0 ? 0 : (index + delta + list.length) % list.length
|
|
240
|
+
setSelectedRef(modelRefOf(list[next]!))
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function setVariantAt(index: number): void {
|
|
244
|
+
const rows = variantRows()
|
|
245
|
+
const row = rows[index]
|
|
246
|
+
if (row === undefined) return
|
|
247
|
+
setVariantCursor(index)
|
|
248
|
+
setVariant(row.id)
|
|
249
|
+
setSaveFailed(false)
|
|
250
|
+
ensureVariantVisible(index)
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function moveVariant(delta: number): void {
|
|
254
|
+
if (variants().length === 0) return
|
|
255
|
+
const rows = variantRows()
|
|
256
|
+
const next = (variantCursor() + delta + rows.length) % rows.length
|
|
257
|
+
setVariantAt(next)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function first(): void {
|
|
261
|
+
if (focus() === "variants" && variants().length > 0) setVariantAt(0)
|
|
262
|
+
else {
|
|
263
|
+
const list = flatModels()
|
|
264
|
+
if (list.length > 0) setSelectedRef(modelRefOf(list[0]!))
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function last(): void {
|
|
269
|
+
if (focus() === "variants" && variants().length > 0) setVariantAt(variantRows().length - 1)
|
|
270
|
+
else {
|
|
271
|
+
const list = flatModels()
|
|
272
|
+
if (list.length > 0) setSelectedRef(modelRefOf(list[list.length - 1]!))
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function page(delta: number): void {
|
|
277
|
+
if (focus() === "variants") {
|
|
278
|
+
const scroll = variantScroll
|
|
279
|
+
if (scroll !== undefined && !scroll.isDestroyed) scroll.scrollBy(delta * 5)
|
|
280
|
+
return
|
|
281
|
+
}
|
|
282
|
+
const scroll = modelScroll
|
|
283
|
+
if (scroll !== undefined && !scroll.isDestroyed) scroll.scrollBy(delta * 10)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function enter(): void {
|
|
287
|
+
if (pendingRestore()) {
|
|
288
|
+
void restore()
|
|
289
|
+
return
|
|
290
|
+
}
|
|
291
|
+
// 有 Variant 时,先在模型列表按 Enter 进入思考等级面板,确认等级后再保存。
|
|
292
|
+
if (focus() === "models" && variants().length > 0) {
|
|
293
|
+
setFocus("variants")
|
|
294
|
+
return
|
|
295
|
+
}
|
|
296
|
+
void save()
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
async function save(): Promise<void> {
|
|
300
|
+
if (saving() || pendingRestore()) return
|
|
301
|
+
const model = selectedModel()
|
|
302
|
+
if (model === undefined) {
|
|
303
|
+
props.notify({
|
|
304
|
+
tone: "warning",
|
|
305
|
+
message: query().trim() !== "" ? "没有匹配的模型,无法保存。" : "请选择一个模型。",
|
|
306
|
+
})
|
|
307
|
+
return
|
|
308
|
+
}
|
|
309
|
+
setSaving(true)
|
|
310
|
+
setSaveFailed(false)
|
|
311
|
+
props.notify({ tone: "info", message: "正在保存模型配置…" })
|
|
312
|
+
if (searchInput !== undefined && !searchInput.isDestroyed) searchInput.blur()
|
|
313
|
+
try {
|
|
314
|
+
const result = await props.onSave(buildModelRef(selectedRef(), variant()))
|
|
315
|
+
if (disposed) return
|
|
316
|
+
setSaving(false)
|
|
317
|
+
if (result.saved) {
|
|
318
|
+
setSaveFailed(false)
|
|
319
|
+
scheduleFocusSearch()
|
|
320
|
+
} else {
|
|
321
|
+
setSaveFailed(true)
|
|
322
|
+
scheduleFocusSearch()
|
|
323
|
+
}
|
|
324
|
+
} catch (error) {
|
|
325
|
+
if (disposed) return
|
|
326
|
+
setSaving(false)
|
|
327
|
+
setSaveFailed(true)
|
|
328
|
+
scheduleFocusSearch()
|
|
329
|
+
props.notify({
|
|
330
|
+
tone: "error",
|
|
331
|
+
message: `保存模型失败:${error instanceof Error ? error.message : String(error)}`,
|
|
332
|
+
})
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function requestRestore(): void {
|
|
337
|
+
if (saving() || pendingRestore()) return
|
|
338
|
+
if (props.currentOverride === undefined) {
|
|
339
|
+
props.notify({
|
|
340
|
+
tone: "info",
|
|
341
|
+
message: `${props.agent.name} 没有团队模型覆盖,无需恢复。`,
|
|
342
|
+
})
|
|
343
|
+
return
|
|
344
|
+
}
|
|
345
|
+
setSaveFailed(false)
|
|
346
|
+
setPendingRestore(true)
|
|
347
|
+
if (searchInput !== undefined && !searchInput.isDestroyed) searchInput.blur()
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
async function restore(): Promise<void> {
|
|
351
|
+
if (saving()) return
|
|
352
|
+
setPendingRestore(false)
|
|
353
|
+
setSaving(true)
|
|
354
|
+
setSaveFailed(false)
|
|
355
|
+
props.notify({ tone: "info", message: "正在恢复原生模型选择…" })
|
|
356
|
+
try {
|
|
357
|
+
const result = await props.onRestore()
|
|
358
|
+
if (disposed) return
|
|
359
|
+
setSaving(false)
|
|
360
|
+
if (result.saved) {
|
|
361
|
+
setSaveFailed(false)
|
|
362
|
+
scheduleFocusSearch()
|
|
363
|
+
} else {
|
|
364
|
+
setSaveFailed(true)
|
|
365
|
+
scheduleFocusSearch()
|
|
366
|
+
}
|
|
367
|
+
} catch (error) {
|
|
368
|
+
if (disposed) return
|
|
369
|
+
setSaving(false)
|
|
370
|
+
setSaveFailed(true)
|
|
371
|
+
scheduleFocusSearch()
|
|
372
|
+
props.notify({
|
|
373
|
+
tone: "error",
|
|
374
|
+
message: `恢复原生模型失败:${error instanceof Error ? error.message : String(error)}`,
|
|
375
|
+
})
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function escape(): void {
|
|
380
|
+
if (saving()) return
|
|
381
|
+
if (pendingRestore()) {
|
|
382
|
+
setPendingRestore(false)
|
|
383
|
+
scheduleFocusSearch()
|
|
384
|
+
return
|
|
385
|
+
}
|
|
386
|
+
props.onClose()
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
props.layer(() => ({
|
|
390
|
+
mode: "modal",
|
|
391
|
+
priority: 20,
|
|
392
|
+
commands: [
|
|
393
|
+
{
|
|
394
|
+
id: "opencode-team.model.up",
|
|
395
|
+
bind: "up",
|
|
396
|
+
enabled: () => !pendingRestore(),
|
|
397
|
+
run: () => {
|
|
398
|
+
if (focus() === "variants") moveVariant(-1)
|
|
399
|
+
else moveModel(-1)
|
|
400
|
+
},
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
id: "opencode-team.model.down",
|
|
404
|
+
bind: "down",
|
|
405
|
+
enabled: () => !pendingRestore(),
|
|
406
|
+
run: () => {
|
|
407
|
+
if (focus() === "variants") moveVariant(1)
|
|
408
|
+
else moveModel(1)
|
|
409
|
+
},
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
id: "opencode-team.model.tab",
|
|
413
|
+
bind: "tab",
|
|
414
|
+
enabled: () => !pendingRestore(),
|
|
415
|
+
run: () => cycleRegion(),
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
id: "opencode-team.model.shift_tab",
|
|
419
|
+
bind: "shift+tab",
|
|
420
|
+
enabled: () => !pendingRestore(),
|
|
421
|
+
run: () => cycleRegion(),
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
id: "opencode-team.model.left",
|
|
425
|
+
bind: "left",
|
|
426
|
+
enabled: () => !pendingRestore(),
|
|
427
|
+
run: focusModels,
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
id: "opencode-team.model.right",
|
|
431
|
+
bind: "right",
|
|
432
|
+
enabled: () => !pendingRestore(),
|
|
433
|
+
run: focusVariants,
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
id: "opencode-team.model.enter",
|
|
437
|
+
bind: "enter",
|
|
438
|
+
run: enter,
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
id: "opencode-team.model.restore",
|
|
442
|
+
bind: "ctrl+r",
|
|
443
|
+
enabled: () => !pendingRestore(),
|
|
444
|
+
run: requestRestore,
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
id: "opencode-team.model.home",
|
|
448
|
+
bind: "home",
|
|
449
|
+
enabled: () => !pendingRestore(),
|
|
450
|
+
run: first,
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
id: "opencode-team.model.end",
|
|
454
|
+
bind: "end",
|
|
455
|
+
enabled: () => !pendingRestore(),
|
|
456
|
+
run: last,
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
id: "opencode-team.model.page_up",
|
|
460
|
+
bind: "pageup",
|
|
461
|
+
enabled: () => !pendingRestore(),
|
|
462
|
+
run: () => page(-1),
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
id: "opencode-team.model.page_down",
|
|
466
|
+
bind: "pagedown",
|
|
467
|
+
enabled: () => !pendingRestore(),
|
|
468
|
+
run: () => page(1),
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
id: "opencode-team.model.escape",
|
|
472
|
+
bind: "escape",
|
|
473
|
+
run: escape,
|
|
474
|
+
},
|
|
475
|
+
],
|
|
476
|
+
}))
|
|
477
|
+
|
|
478
|
+
const split = () => layout().split
|
|
479
|
+
const showModels = () => split() || focus() !== "variants"
|
|
480
|
+
const showVariants = () => split() || focus() === "variants"
|
|
481
|
+
|
|
482
|
+
return (
|
|
483
|
+
<box flexGrow={1} minHeight={0} flexDirection="column">
|
|
484
|
+
<box flexDirection="row" justifyContent="space-between" gap={2} flexShrink={0}>
|
|
485
|
+
<box flexDirection="row" gap={1}>
|
|
486
|
+
<text fg={theme().text.base} attributes={TextAttributes.BOLD}>
|
|
487
|
+
Agent Team
|
|
488
|
+
</text>
|
|
489
|
+
<text fg={theme().text.muted}>›</text>
|
|
490
|
+
<text fg={theme().text.base}>模型配置</text>
|
|
491
|
+
</box>
|
|
492
|
+
<text fg={theme().text.muted}>
|
|
493
|
+
{pendingRestore() ? "ESC 取消" : "ESC 返回"}
|
|
494
|
+
</text>
|
|
495
|
+
</box>
|
|
496
|
+
|
|
497
|
+
<box paddingTop={1} flexShrink={0}>
|
|
498
|
+
<AgentCard theme={theme()} agent={props.agent} compact={layout().compact} />
|
|
499
|
+
</box>
|
|
500
|
+
|
|
501
|
+
<box paddingTop={1} flexShrink={0}>
|
|
502
|
+
<SearchBox
|
|
503
|
+
theme={theme()}
|
|
504
|
+
query={query()}
|
|
505
|
+
focused={!pendingRestore()}
|
|
506
|
+
onFocus={() => {
|
|
507
|
+
if (!pendingRestore()) focusSearchInput()
|
|
508
|
+
}}
|
|
509
|
+
onInput={(value) => {
|
|
510
|
+
setQuery(value)
|
|
511
|
+
if (focus() === "variants") setFocus("models")
|
|
512
|
+
}}
|
|
513
|
+
inputRef={(value) => {
|
|
514
|
+
searchInput = value
|
|
515
|
+
scheduleFocusSearch()
|
|
516
|
+
}}
|
|
517
|
+
/>
|
|
518
|
+
</box>
|
|
519
|
+
|
|
520
|
+
<Show when={props.modelError !== undefined}>
|
|
521
|
+
<box paddingTop={1} flexShrink={0}>
|
|
522
|
+
<text fg={theme().text.feedback.warning.base} wrapMode="word">
|
|
523
|
+
! {props.modelError};模型目录不可用时仍可清除团队覆盖。
|
|
524
|
+
</text>
|
|
525
|
+
</box>
|
|
526
|
+
</Show>
|
|
527
|
+
|
|
528
|
+
<box flexGrow={1} minHeight={0} paddingTop={1} flexDirection="row">
|
|
529
|
+
<Show when={showModels()}>
|
|
530
|
+
<ModelList
|
|
531
|
+
theme={theme()}
|
|
532
|
+
groups={groups()}
|
|
533
|
+
selectedRef={selectedRef()}
|
|
534
|
+
currentBase={current()?.baseRef}
|
|
535
|
+
compact={layout().compact}
|
|
536
|
+
onSelect={(ref) => {
|
|
537
|
+
if (pendingRestore()) return
|
|
538
|
+
setSelectedRef(ref)
|
|
539
|
+
setFocus("models")
|
|
540
|
+
}}
|
|
541
|
+
onRef={(ref, node) => modelNodes.set(ref, node)}
|
|
542
|
+
onScrollRef={(value) => (modelScroll = value)}
|
|
543
|
+
/>
|
|
544
|
+
</Show>
|
|
545
|
+
<Show when={split()}>
|
|
546
|
+
<box width={1} flexShrink={0} backgroundColor={theme().border.base} />
|
|
547
|
+
</Show>
|
|
548
|
+
<Show when={showVariants()}>
|
|
549
|
+
<VariantPane
|
|
550
|
+
theme={theme()}
|
|
551
|
+
model={selectedModel()}
|
|
552
|
+
variants={variantRows()}
|
|
553
|
+
cursor={variantCursor()}
|
|
554
|
+
pending={pendingLabel()}
|
|
555
|
+
focused={focus() === "variants"}
|
|
556
|
+
empty={flatModels().length === 0}
|
|
557
|
+
width={split() ? layout().variantWidth : undefined}
|
|
558
|
+
saving={saving()}
|
|
559
|
+
failed={saveFailed()}
|
|
560
|
+
onSelect={(index) => {
|
|
561
|
+
if (pendingRestore()) return
|
|
562
|
+
setVariantAt(index)
|
|
563
|
+
setFocus("variants")
|
|
564
|
+
}}
|
|
565
|
+
onRef={(index, node) => variantNodes.set(index, node)}
|
|
566
|
+
onScrollRef={(value) => (variantScroll = value)}
|
|
567
|
+
/>
|
|
568
|
+
</Show>
|
|
569
|
+
</box>
|
|
570
|
+
|
|
571
|
+
<Show when={pendingRestore()}>
|
|
572
|
+
<ConfirmBar
|
|
573
|
+
theme={theme()}
|
|
574
|
+
message={
|
|
575
|
+
props.agent.hostModel === undefined
|
|
576
|
+
? `清除 ${props.agent.name} 的团队模型覆盖并恢复 OpenCode 原生选择?`
|
|
577
|
+
: `清除 ${props.agent.name} 的团队模型覆盖,回到 Agent 配置的 ${props.agent.hostModel}?`
|
|
578
|
+
}
|
|
579
|
+
/>
|
|
580
|
+
</Show>
|
|
581
|
+
<Show when={props.feedback}>
|
|
582
|
+
{(value) => <FeedbackBar theme={theme()} feedback={value()} />}
|
|
583
|
+
</Show>
|
|
584
|
+
|
|
585
|
+
<Foot
|
|
586
|
+
theme={theme()}
|
|
587
|
+
minimal={layout().minimal}
|
|
588
|
+
focus={focus()}
|
|
589
|
+
saving={saving()}
|
|
590
|
+
confirming={pendingRestore()}
|
|
591
|
+
hasVariants={variants().length > 0}
|
|
592
|
+
/>
|
|
593
|
+
</box>
|
|
594
|
+
)
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
function AgentCard(props: {
|
|
598
|
+
readonly theme: Theme
|
|
599
|
+
readonly agent: DashboardAgent
|
|
600
|
+
readonly compact: boolean
|
|
601
|
+
}) {
|
|
602
|
+
return (
|
|
603
|
+
<box
|
|
604
|
+
backgroundColor={props.theme.background.raised.high}
|
|
605
|
+
border={["left"]}
|
|
606
|
+
borderColor={selectedRowAccent(props.theme)}
|
|
607
|
+
paddingLeft={1}
|
|
608
|
+
paddingRight={1}
|
|
609
|
+
paddingTop={props.compact ? 0 : 1}
|
|
610
|
+
paddingBottom={props.compact ? 0 : 1}
|
|
611
|
+
flexDirection="row"
|
|
612
|
+
justifyContent="space-between"
|
|
613
|
+
gap={2}
|
|
614
|
+
>
|
|
615
|
+
<box flexDirection="column" flexGrow={1} minWidth={0}>
|
|
616
|
+
<box flexDirection="row" gap={1}>
|
|
617
|
+
<text fg={props.theme.text.base} attributes={TextAttributes.BOLD}>
|
|
618
|
+
{props.agent.name}
|
|
619
|
+
</text>
|
|
620
|
+
<Show when={props.compact}>
|
|
621
|
+
<text flexGrow={1} overflow="hidden" wrapMode="none">
|
|
622
|
+
<span style={{ fg: props.theme.text.muted }}>当前:</span><span style={{ fg: props.theme.text.base }}>{props.agent.modelLabel}</span>
|
|
623
|
+
</text>
|
|
624
|
+
</Show>
|
|
625
|
+
</box>
|
|
626
|
+
<Show when={!props.compact}>
|
|
627
|
+
<text overflow="hidden" wrapMode="none">
|
|
628
|
+
<span style={{ fg: props.theme.text.muted }}>当前模型:</span><span style={{ fg: props.theme.text.base }}>{props.agent.modelLabel}</span><span style={{ fg: props.theme.text.muted }}> · {props.agent.sourceLabel}</span>
|
|
629
|
+
</text>
|
|
630
|
+
</Show>
|
|
631
|
+
</box>
|
|
632
|
+
<box flexDirection="row" gap={1} flexShrink={0}>
|
|
633
|
+
<Badge theme={props.theme} text={roleLabel(props.agent.mode)} tone="neutral" />
|
|
634
|
+
<Badge
|
|
635
|
+
theme={props.theme}
|
|
636
|
+
text={props.agent.statusLabel}
|
|
637
|
+
tone={statusTone(props.agent.status)}
|
|
638
|
+
/>
|
|
639
|
+
</box>
|
|
640
|
+
</box>
|
|
641
|
+
)
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function SearchBox(props: {
|
|
645
|
+
readonly theme: Theme
|
|
646
|
+
readonly query: string
|
|
647
|
+
readonly focused: boolean
|
|
648
|
+
readonly onFocus: () => void
|
|
649
|
+
readonly onInput: (value: string) => void
|
|
650
|
+
readonly inputRef: (value: InputRenderable) => void
|
|
651
|
+
}) {
|
|
652
|
+
return (
|
|
653
|
+
<box
|
|
654
|
+
flexDirection="row"
|
|
655
|
+
gap={1}
|
|
656
|
+
paddingLeft={1}
|
|
657
|
+
paddingRight={1}
|
|
658
|
+
backgroundColor={
|
|
659
|
+
props.focused ? props.theme.background.formfield.focused : props.theme.background.raised.base
|
|
660
|
+
}
|
|
661
|
+
onMouseDown={props.onFocus}
|
|
662
|
+
>
|
|
663
|
+
<text fg={props.focused ? props.theme.text.formfield.focused : props.theme.text.muted}>
|
|
664
|
+
搜索
|
|
665
|
+
</text>
|
|
666
|
+
<input
|
|
667
|
+
flexGrow={1}
|
|
668
|
+
value={props.query}
|
|
669
|
+
onInput={props.onInput}
|
|
670
|
+
placeholder="输入以搜索模型 / Provider / ID…"
|
|
671
|
+
placeholderColor={props.theme.text.muted}
|
|
672
|
+
focusedBackgroundColor={props.theme.background.formfield.focused}
|
|
673
|
+
focusedTextColor={props.theme.text.formfield.focused}
|
|
674
|
+
cursorColor={props.theme.text.formfield.focused}
|
|
675
|
+
ref={props.inputRef}
|
|
676
|
+
/>
|
|
677
|
+
</box>
|
|
678
|
+
)
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
function ModelList(props: {
|
|
682
|
+
readonly theme: Theme
|
|
683
|
+
readonly groups: readonly { providerID: string; providerName: string; models: readonly ModelInfo[] }[]
|
|
684
|
+
readonly selectedRef: string
|
|
685
|
+
readonly currentBase?: string
|
|
686
|
+
readonly compact: boolean
|
|
687
|
+
readonly onSelect: (ref: string) => void
|
|
688
|
+
readonly onRef: (ref: string, node: Renderable) => void
|
|
689
|
+
readonly onScrollRef: (value: ScrollBoxRenderable) => void
|
|
690
|
+
}) {
|
|
691
|
+
return (
|
|
692
|
+
<box flexGrow={1} minWidth={0} minHeight={0}>
|
|
693
|
+
<Show
|
|
694
|
+
when={props.groups.length > 0}
|
|
695
|
+
fallback={
|
|
696
|
+
<box paddingLeft={1} paddingTop={1}>
|
|
697
|
+
<text fg={props.theme.text.muted}>没有匹配的模型。</text>
|
|
698
|
+
</box>
|
|
699
|
+
}
|
|
700
|
+
>
|
|
701
|
+
<scrollbox
|
|
702
|
+
flexGrow={1}
|
|
703
|
+
minHeight={0}
|
|
704
|
+
verticalScrollbarOptions={scrollbarOptions(props.theme)}
|
|
705
|
+
horizontalScrollbarOptions={{ visible: false }}
|
|
706
|
+
ref={props.onScrollRef}
|
|
707
|
+
>
|
|
708
|
+
<For each={props.groups}>
|
|
709
|
+
{(group, index) => (
|
|
710
|
+
<box flexDirection="column">
|
|
711
|
+
<Show when={index() > 0}>
|
|
712
|
+
<box paddingTop={1}>
|
|
713
|
+
<Divider theme={props.theme} />
|
|
714
|
+
</box>
|
|
715
|
+
</Show>
|
|
716
|
+
<box
|
|
717
|
+
flexDirection="row"
|
|
718
|
+
justifyContent="space-between"
|
|
719
|
+
gap={2}
|
|
720
|
+
paddingLeft={1}
|
|
721
|
+
paddingRight={1}
|
|
722
|
+
>
|
|
723
|
+
<text
|
|
724
|
+
flexGrow={1}
|
|
725
|
+
overflow="hidden"
|
|
726
|
+
wrapMode="none"
|
|
727
|
+
fg={providerTitleColor(props.theme)}
|
|
728
|
+
attributes={TextAttributes.BOLD}
|
|
729
|
+
>
|
|
730
|
+
{group.providerName.toUpperCase()}
|
|
731
|
+
</text>
|
|
732
|
+
<text flexShrink={0} fg={props.theme.text.muted}>
|
|
733
|
+
{group.models.length}
|
|
734
|
+
</text>
|
|
735
|
+
</box>
|
|
736
|
+
<For each={group.models}>
|
|
737
|
+
{(model) => {
|
|
738
|
+
const ref = modelRefOf(model)
|
|
739
|
+
const active = () => ref === props.selectedRef
|
|
740
|
+
const current = () => ref === props.currentBase
|
|
741
|
+
return (
|
|
742
|
+
<box
|
|
743
|
+
flexDirection="column"
|
|
744
|
+
paddingLeft={2}
|
|
745
|
+
paddingRight={1}
|
|
746
|
+
backgroundColor={rowBackground(props.theme, active())}
|
|
747
|
+
onMouseUp={() => props.onSelect(ref)}
|
|
748
|
+
ref={(node: Renderable) => props.onRef(ref, node)}
|
|
749
|
+
>
|
|
750
|
+
<box flexDirection="row" gap={1}>
|
|
751
|
+
<text
|
|
752
|
+
flexShrink={0}
|
|
753
|
+
fg={rowMarker(props.theme, active())}
|
|
754
|
+
>
|
|
755
|
+
{active() ? "▌" : " "}
|
|
756
|
+
</text>
|
|
757
|
+
<text
|
|
758
|
+
flexGrow={1}
|
|
759
|
+
overflow="hidden"
|
|
760
|
+
wrapMode="none"
|
|
761
|
+
fg={rowForeground(props.theme)}
|
|
762
|
+
attributes={active() ? TextAttributes.BOLD : undefined}
|
|
763
|
+
>
|
|
764
|
+
{model.name || model.id}
|
|
765
|
+
</text>
|
|
766
|
+
<Show when={current()}>
|
|
767
|
+
<text
|
|
768
|
+
flexShrink={0}
|
|
769
|
+
fg={selectedRowAccent(props.theme)}
|
|
770
|
+
>
|
|
771
|
+
当前
|
|
772
|
+
</text>
|
|
773
|
+
</Show>
|
|
774
|
+
</box>
|
|
775
|
+
<Show when={!props.compact}>
|
|
776
|
+
<text
|
|
777
|
+
paddingLeft={2}
|
|
778
|
+
wrapMode="word"
|
|
779
|
+
fg={rowSecondary(props.theme, active())}
|
|
780
|
+
>
|
|
781
|
+
{ref}
|
|
782
|
+
</text>
|
|
783
|
+
</Show>
|
|
784
|
+
</box>
|
|
785
|
+
)
|
|
786
|
+
}}
|
|
787
|
+
</For>
|
|
788
|
+
</box>
|
|
789
|
+
)}
|
|
790
|
+
</For>
|
|
791
|
+
</scrollbox>
|
|
792
|
+
</Show>
|
|
793
|
+
</box>
|
|
794
|
+
)
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
function VariantPane(props: {
|
|
798
|
+
readonly theme: Theme
|
|
799
|
+
readonly model?: ModelInfo
|
|
800
|
+
readonly variants: readonly VariantOption[]
|
|
801
|
+
readonly cursor: number
|
|
802
|
+
readonly pending: string
|
|
803
|
+
readonly focused: boolean
|
|
804
|
+
readonly empty: boolean
|
|
805
|
+
readonly width?: number
|
|
806
|
+
readonly saving: boolean
|
|
807
|
+
readonly failed: boolean
|
|
808
|
+
readonly onSelect: (index: number) => void
|
|
809
|
+
readonly onRef: (index: number, node: Renderable) => void
|
|
810
|
+
readonly onScrollRef: (value: ScrollBoxRenderable) => void
|
|
811
|
+
}) {
|
|
812
|
+
const hasChoices = () => props.variants.length > 1
|
|
813
|
+
return (
|
|
814
|
+
<box
|
|
815
|
+
width={props.width}
|
|
816
|
+
flexGrow={props.width === undefined ? 1 : undefined}
|
|
817
|
+
minHeight={0}
|
|
818
|
+
flexDirection="column"
|
|
819
|
+
paddingLeft={1}
|
|
820
|
+
paddingRight={1}
|
|
821
|
+
border={["left"]}
|
|
822
|
+
borderColor={
|
|
823
|
+
props.focused ? selectedRowAccent(props.theme) : props.theme.border.base
|
|
824
|
+
}
|
|
825
|
+
backgroundColor={props.theme.background.raised.base}
|
|
826
|
+
>
|
|
827
|
+
<Show
|
|
828
|
+
when={props.model}
|
|
829
|
+
fallback={
|
|
830
|
+
<box paddingTop={1}>
|
|
831
|
+
<text fg={props.theme.text.muted}>
|
|
832
|
+
{props.empty ? "没有匹配的模型。" : "从左侧选择模型。"}
|
|
833
|
+
</text>
|
|
834
|
+
</box>
|
|
835
|
+
}
|
|
836
|
+
>
|
|
837
|
+
{(model) => (
|
|
838
|
+
<>
|
|
839
|
+
<box flexShrink={0}>
|
|
840
|
+
<text fg={props.theme.text.base} attributes={TextAttributes.BOLD} wrapMode="word">
|
|
841
|
+
{model().name || model().id}
|
|
842
|
+
</text>
|
|
843
|
+
<text fg={props.theme.text.muted} wrapMode="none" overflow="hidden">
|
|
844
|
+
{modelRefOf(model())}
|
|
845
|
+
</text>
|
|
846
|
+
</box>
|
|
847
|
+
<Divider theme={props.theme} />
|
|
848
|
+
<text fg={props.theme.text.muted} attributes={TextAttributes.BOLD}>
|
|
849
|
+
思考等级 / Variant
|
|
850
|
+
</text>
|
|
851
|
+
<Show
|
|
852
|
+
when={hasChoices()}
|
|
853
|
+
fallback={
|
|
854
|
+
<text fg={props.theme.text.muted} wrapMode="word">
|
|
855
|
+
该模型不提供 Variant;保存时只写模型引用。
|
|
856
|
+
</text>
|
|
857
|
+
}
|
|
858
|
+
>
|
|
859
|
+
<scrollbox
|
|
860
|
+
flexGrow={1}
|
|
861
|
+
minHeight={0}
|
|
862
|
+
verticalScrollbarOptions={scrollbarOptions(props.theme)}
|
|
863
|
+
horizontalScrollbarOptions={{ visible: false }}
|
|
864
|
+
ref={props.onScrollRef}
|
|
865
|
+
>
|
|
866
|
+
<For each={props.variants}>
|
|
867
|
+
{(option, index) => {
|
|
868
|
+
const active = () => index() === props.cursor
|
|
869
|
+
return (
|
|
870
|
+
<box
|
|
871
|
+
flexDirection="row"
|
|
872
|
+
gap={1}
|
|
873
|
+
paddingLeft={1}
|
|
874
|
+
paddingRight={1}
|
|
875
|
+
backgroundColor={rowBackground(props.theme, active())}
|
|
876
|
+
onMouseUp={() => props.onSelect(index())}
|
|
877
|
+
ref={(node: Renderable) => props.onRef(index(), node)}
|
|
878
|
+
>
|
|
879
|
+
<text
|
|
880
|
+
flexShrink={0}
|
|
881
|
+
fg={rowMarker(props.theme, active())}
|
|
882
|
+
>
|
|
883
|
+
{active() ? "▌" : " "}
|
|
884
|
+
</text>
|
|
885
|
+
<text
|
|
886
|
+
flexGrow={1}
|
|
887
|
+
overflow="hidden"
|
|
888
|
+
wrapMode="none"
|
|
889
|
+
fg={rowForeground(props.theme)}
|
|
890
|
+
attributes={active() ? TextAttributes.BOLD : undefined}
|
|
891
|
+
>
|
|
892
|
+
{option.label}
|
|
893
|
+
</text>
|
|
894
|
+
</box>
|
|
895
|
+
)
|
|
896
|
+
}}
|
|
897
|
+
</For>
|
|
898
|
+
</scrollbox>
|
|
899
|
+
</Show>
|
|
900
|
+
<Divider theme={props.theme} />
|
|
901
|
+
<text fg={props.theme.text.muted} wrapMode="word">
|
|
902
|
+
待保存 <span style={{ fg: props.theme.text.base }}>{props.pending}</span>
|
|
903
|
+
</text>
|
|
904
|
+
<Show when={props.saving}>
|
|
905
|
+
<text fg={props.theme.text.feedback.warning.base}>处理中…</text>
|
|
906
|
+
</Show>
|
|
907
|
+
<Show when={props.failed}>
|
|
908
|
+
<text fg={props.theme.text.feedback.error.base}>操作失败,可重试。</text>
|
|
909
|
+
</Show>
|
|
910
|
+
</>
|
|
911
|
+
)}
|
|
912
|
+
</Show>
|
|
913
|
+
</box>
|
|
914
|
+
)
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
function Foot(props: {
|
|
918
|
+
readonly theme: Theme
|
|
919
|
+
readonly minimal: boolean
|
|
920
|
+
readonly focus: Focus
|
|
921
|
+
readonly saving: boolean
|
|
922
|
+
readonly confirming: boolean
|
|
923
|
+
readonly hasVariants: boolean
|
|
924
|
+
}) {
|
|
925
|
+
const enterLabel = () => {
|
|
926
|
+
if (props.saving) return "处理中…"
|
|
927
|
+
if (props.confirming) return "确认"
|
|
928
|
+
if (props.focus === "models" && props.hasVariants) return "思考等级"
|
|
929
|
+
return "保存"
|
|
930
|
+
}
|
|
931
|
+
const hints = (): Hint[] => {
|
|
932
|
+
if (props.confirming) {
|
|
933
|
+
return [
|
|
934
|
+
{ key: "Enter", label: "确认" },
|
|
935
|
+
{ key: "ESC", label: "取消" },
|
|
936
|
+
]
|
|
937
|
+
}
|
|
938
|
+
if (props.minimal) {
|
|
939
|
+
return [
|
|
940
|
+
{ key: "↑↓", label: "选择" },
|
|
941
|
+
{ key: "←→", label: "切换" },
|
|
942
|
+
{ key: "输入", label: "搜索" },
|
|
943
|
+
{ key: "Enter", label: enterLabel() },
|
|
944
|
+
{ key: "ESC", label: "返回" },
|
|
945
|
+
]
|
|
946
|
+
}
|
|
947
|
+
if (props.focus === "variants") {
|
|
948
|
+
return [
|
|
949
|
+
{ key: "↑↓", label: "思考等级" },
|
|
950
|
+
{ key: "←→", label: "切换" },
|
|
951
|
+
{ key: "输入", label: "搜索" },
|
|
952
|
+
{ key: "Enter", label: enterLabel() },
|
|
953
|
+
{ key: "Ctrl+R", label: "恢复原生" },
|
|
954
|
+
{ key: "ESC", label: "返回" },
|
|
955
|
+
]
|
|
956
|
+
}
|
|
957
|
+
return [
|
|
958
|
+
{ key: "↑↓", label: "模型" },
|
|
959
|
+
{ key: "←→", label: "切换" },
|
|
960
|
+
{ key: "输入", label: "搜索" },
|
|
961
|
+
{ key: "Enter", label: enterLabel() },
|
|
962
|
+
{ key: "Ctrl+R", label: "恢复原生" },
|
|
963
|
+
{ key: "ESC", label: "返回" },
|
|
964
|
+
]
|
|
965
|
+
}
|
|
966
|
+
return (
|
|
967
|
+
<box
|
|
968
|
+
flexShrink={0}
|
|
969
|
+
border={["top"]}
|
|
970
|
+
borderColor={props.theme.border.base}
|
|
971
|
+
paddingTop={1}
|
|
972
|
+
>
|
|
973
|
+
<Hints theme={props.theme} hints={hints()} />
|
|
974
|
+
</box>
|
|
975
|
+
)
|
|
976
|
+
}
|