@sixb/app 0.1.17 → 0.1.18
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/dist/agent/agent-chat.d.ts.map +1 -1
- package/dist/agent/bash/interpret.d.ts +6 -2
- package/dist/agent/bash/interpret.d.ts.map +1 -1
- package/dist/agent/components/approval-mode-icons.d.ts +5 -0
- package/dist/agent/components/approval-mode-icons.d.ts.map +1 -0
- package/dist/agent/components/composer-add-menu.d.ts +15 -0
- package/dist/agent/components/composer-add-menu.d.ts.map +1 -0
- package/dist/agent/components/composer-commands.d.ts +37 -0
- package/dist/agent/components/composer-commands.d.ts.map +1 -0
- package/dist/agent/components/composer-menu.d.ts +18 -15
- package/dist/agent/components/composer-menu.d.ts.map +1 -1
- package/dist/agent/components/composer-settings.d.ts +34 -0
- package/dist/agent/components/composer-settings.d.ts.map +1 -0
- package/dist/agent/components/composer.d.ts +10 -3
- package/dist/agent/components/composer.d.ts.map +1 -1
- package/dist/agent/components/context-chips.d.ts +5 -0
- package/dist/agent/components/context-chips.d.ts.map +1 -1
- package/dist/agent/components/conversation-panel.d.ts +3 -1
- package/dist/agent/components/conversation-panel.d.ts.map +1 -1
- package/dist/agent/components/dictation-bar.d.ts +7 -3
- package/dist/agent/components/dictation-bar.d.ts.map +1 -1
- package/dist/agent/components/model-picker-row.d.ts +1 -3
- package/dist/agent/components/model-picker-row.d.ts.map +1 -1
- package/dist/agent/components/reasoning-effort-slider.d.ts.map +1 -1
- package/dist/agent/components/shared-thread-notice.d.ts +4 -2
- package/dist/agent/components/shared-thread-notice.d.ts.map +1 -1
- package/dist/agent/delegation/use-children.d.ts.map +1 -1
- package/dist/agent/hooks/use-agent-conversation.d.ts +2 -0
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-lists.d.ts +8 -0
- package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
- package/dist/agent/i18n/en.d.ts +69 -8
- package/dist/agent/i18n/en.d.ts.map +1 -1
- package/dist/agent/i18n/fr.d.ts.map +1 -1
- package/dist/agent/i18n/index.d.ts +126 -12
- package/dist/agent/i18n/index.d.ts.map +1 -1
- package/dist/agent/model-selection.d.ts +1 -0
- package/dist/agent/model-selection.d.ts.map +1 -1
- package/dist/agent/run-sounds.d.ts +18 -0
- package/dist/agent/run-sounds.d.ts.map +1 -0
- package/dist/chunk-6n5pdqp0.js.map +1 -1
- package/dist/{chunk-12v6y89k.js → chunk-btky7c9w.js} +11678 -11190
- package/dist/{chunk-12v6y89k.js.map → chunk-btky7c9w.js.map} +59 -57
- package/dist/{chunk-bpj9mg5c.js → chunk-gq6xek89.js} +1 -1
- package/dist/{chunk-bpj9mg5c.js.map → chunk-gq6xek89.js.map} +1 -1
- package/dist/{chunk-hzy2g13h.js → chunk-hdbmj6f0.js} +1 -1
- package/dist/{chunk-hzy2g13h.js.map → chunk-hdbmj6f0.js.map} +1 -1
- package/dist/chunk-md3p7qdt.js.map +1 -1
- package/dist/{chunk-2a69ge8h.js → chunk-pkcm8rn8.js} +1 -1
- package/dist/{chunk-2a69ge8h.js.map → chunk-pkcm8rn8.js.map} +1 -1
- package/dist/chunk-yvhzn4ye.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +3 -3
- package/dist/pages/settings/messages.d.ts +16 -0
- package/dist/pages/settings/messages.d.ts.map +1 -1
- package/dist/pages/settings/personal.d.ts +2 -2
- package/dist/pages/settings/personal.d.ts.map +1 -1
- package/dist/pages.js +49 -3
- package/dist/pages.js.map +4 -4
- package/dist/server.js.map +1 -1
- package/package.json +3 -3
- package/src/agent/agent-chat.tsx +6 -1
- package/src/agent/agent.css +145 -14
- package/src/agent/bash/interpret.ts +41 -5
- package/src/agent/components/approval-mode-icons.ts +9 -0
- package/src/agent/components/composer-add-menu.tsx +126 -0
- package/src/agent/components/composer-commands.tsx +165 -0
- package/src/agent/components/composer-menu.tsx +33 -46
- package/src/agent/components/composer-settings.tsx +437 -0
- package/src/agent/components/composer.tsx +312 -153
- package/src/agent/components/context-chips.tsx +21 -8
- package/src/agent/components/conversation-panel.tsx +16 -9
- package/src/agent/components/dictation-bar.tsx +28 -23
- package/src/agent/components/model-picker-row.tsx +14 -24
- package/src/agent/components/reasoning-effort-slider.tsx +14 -10
- package/src/agent/components/shared-thread-notice.tsx +7 -2
- package/src/agent/components/transcript.tsx +2 -1
- package/src/agent/hooks/use-agent-conversation.ts +18 -6
- package/src/agent/i18n/en.ts +58 -15
- package/src/agent/i18n/fr.ts +77 -13
- package/src/agent/model-selection.ts +4 -0
- package/src/agent/publish-artifact/publish-artifact-tool-view.tsx +3 -2
- package/src/agent/run-sounds.ts +171 -0
- package/src/index.ts +5 -1
- package/src/pages/settings/messages.ts +8 -0
- package/src/pages/settings/personal.tsx +60 -3
- package/dist/agent/components/approval-mode-chip.d.ts +0 -15
- package/dist/agent/components/approval-mode-chip.d.ts.map +0 -1
- package/dist/agent/components/auto-model-chip.d.ts +0 -23
- package/dist/agent/components/auto-model-chip.d.ts.map +0 -1
- package/dist/agent/components/model-controls.d.ts +0 -41
- package/dist/agent/components/model-controls.d.ts.map +0 -1
- package/src/agent/components/approval-mode-chip.tsx +0 -120
- package/src/agent/components/auto-model-chip.tsx +0 -219
- package/src/agent/components/model-controls.tsx +0 -238
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
import { LANGUAGE_MODEL_TIERS, type ModelReasoningLevel } from "@sixb/core/models"
|
|
2
|
+
import { cn } from "@sixb/ui/lib/utils"
|
|
3
|
+
import { ChevronDown, Search } from "lucide-react"
|
|
4
|
+
import { Fragment, useEffect, useId, useMemo, useState } from "react"
|
|
5
|
+
import { AGENT_APPROVAL_MODES, type AgentApprovalMode } from "../approvals"
|
|
6
|
+
import { useAgentMessages } from "../i18n"
|
|
7
|
+
import type { AgentMessages } from "../i18n/en"
|
|
8
|
+
import { defaultLanguageModel, hasTiers, sameModel } from "../model-selection"
|
|
9
|
+
import type { LanguageModel } from "../types"
|
|
10
|
+
import { moveRadioFocus } from "../utils/radio-group"
|
|
11
|
+
import { APPROVAL_MODE_ICONS } from "./approval-mode-icons"
|
|
12
|
+
import {
|
|
13
|
+
COMPOSER_MENU_ROW_CLASS_NAME,
|
|
14
|
+
COMPOSER_MENU_ROW_SELECTED_CLASS_NAME,
|
|
15
|
+
COMPOSER_MENU_SECTION_CLASS_NAME,
|
|
16
|
+
ComposerMenu,
|
|
17
|
+
ComposerMenuDivider,
|
|
18
|
+
ComposerMenuHeader,
|
|
19
|
+
ComposerMenuRowText,
|
|
20
|
+
ComposerMenuScroll,
|
|
21
|
+
} from "./composer-menu"
|
|
22
|
+
import { ModelPickerRow } from "./model-picker-row"
|
|
23
|
+
import { ProviderLogo } from "./provider-logo"
|
|
24
|
+
import { ReasoningEffortSlider } from "./reasoning-effort-slider"
|
|
25
|
+
|
|
26
|
+
/** The same names as the `Composer` props they come from, so a composer can pass them through. */
|
|
27
|
+
export interface ComposerSettingsProps {
|
|
28
|
+
readonly models?: readonly LanguageModel[]
|
|
29
|
+
readonly selectedModel?: LanguageModel
|
|
30
|
+
readonly selectedReasoning?: ModelReasoningLevel
|
|
31
|
+
readonly modelsLoading?: boolean
|
|
32
|
+
readonly modelsError?: boolean
|
|
33
|
+
/** With `onSelectReasoning`, the model section shows. */
|
|
34
|
+
readonly onSelectModel?: (model: LanguageModel) => void
|
|
35
|
+
readonly onSelectReasoning?: (reasoning: ModelReasoningLevel) => void
|
|
36
|
+
/** Back to the selected model's default thinking. */
|
|
37
|
+
readonly onResetReasoning?: () => void
|
|
38
|
+
/** The selection follows the project defaults: nothing was chosen explicitly. */
|
|
39
|
+
readonly usingDefaultModel?: boolean
|
|
40
|
+
/** Follow the project defaults again. With tiers, this is Auto, shown when no model is pinned. */
|
|
41
|
+
readonly onResetModelSelection?: () => void
|
|
42
|
+
/** With tiers: a decision model picks each message's model on Auto. */
|
|
43
|
+
readonly modelRouting?: boolean
|
|
44
|
+
/** With `onApprovalModeChange`, the permissions section shows. */
|
|
45
|
+
readonly approvalMode?: AgentApprovalMode
|
|
46
|
+
readonly onApprovalModeChange?: (mode: AgentApprovalMode) => void
|
|
47
|
+
/** Keeps the model as it is, as while an answer is under way. The permissions stay open. */
|
|
48
|
+
readonly disabled?: boolean
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* How the agent works on the next message, as one quiet chip that names it: "Auto", or the pinned
|
|
53
|
+
* model with its provider's mark, then the permissions' icon unless the agent has full access. Its
|
|
54
|
+
* menu holds the model, with the chosen model's thinking under it, and the permissions.
|
|
55
|
+
*/
|
|
56
|
+
export function ComposerSettings(props: ComposerSettingsProps) {
|
|
57
|
+
const {
|
|
58
|
+
models = [],
|
|
59
|
+
selectedModel,
|
|
60
|
+
selectedReasoning,
|
|
61
|
+
modelsLoading,
|
|
62
|
+
modelsError,
|
|
63
|
+
onSelectModel,
|
|
64
|
+
onSelectReasoning,
|
|
65
|
+
onResetModelSelection,
|
|
66
|
+
approvalMode,
|
|
67
|
+
onApprovalModeChange,
|
|
68
|
+
disabled,
|
|
69
|
+
} = props
|
|
70
|
+
const agentMessages = useAgentMessages()
|
|
71
|
+
const [open, setOpen] = useState(false)
|
|
72
|
+
const choosesModel = onSelectModel !== undefined && onSelectReasoning !== undefined
|
|
73
|
+
const choosesMode = approvalMode !== undefined && onApprovalModeChange !== undefined
|
|
74
|
+
if (!choosesModel && !choosesMode) return null
|
|
75
|
+
|
|
76
|
+
const auto = choosesModel && autoModels(models, onResetModelSelection) && !selectedModel
|
|
77
|
+
const modeLabel = approvalMode ? agentMessages.approvalModes.modes[approvalMode].label : undefined
|
|
78
|
+
const ModeIcon = approvalMode ? APPROVAL_MODE_ICONS[approvalMode] : undefined
|
|
79
|
+
const name = !choosesModel
|
|
80
|
+
? modeLabel
|
|
81
|
+
: auto
|
|
82
|
+
? agentMessages.models.auto
|
|
83
|
+
: (selectedModel?.name ??
|
|
84
|
+
(modelsError ? agentMessages.models.unavailable : agentMessages.models.defaultModel))
|
|
85
|
+
const level = auto
|
|
86
|
+
? undefined
|
|
87
|
+
: reasoningLabel(selectedModel, selectedReasoning, agentMessages.reasoning)
|
|
88
|
+
const summary = [name, level, choosesModel ? modeLabel : undefined].filter(Boolean)
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<ComposerMenu
|
|
92
|
+
open={open}
|
|
93
|
+
onOpenChange={setOpen}
|
|
94
|
+
title={agentMessages.settings.title}
|
|
95
|
+
align="end"
|
|
96
|
+
trigger={
|
|
97
|
+
<button
|
|
98
|
+
type="button"
|
|
99
|
+
disabled={!choosesMode && (disabled || modelsLoading || models.length === 0)}
|
|
100
|
+
aria-label={agentMessages.settings.chip(summary.join(", "))}
|
|
101
|
+
aria-haspopup="dialog"
|
|
102
|
+
aria-expanded={open}
|
|
103
|
+
title={summary.join(" · ")}
|
|
104
|
+
data-approval-mode={approvalMode}
|
|
105
|
+
className="group/settings mb-0.5 flex h-9 min-w-0 shrink-0 items-center gap-1.5 rounded-full pr-[9px] pl-[11px] text-[13.5px] font-medium text-foreground/80 outline-none transition-colors hover:bg-black/[0.05] focus-visible:ring-2 focus-visible:ring-ring/40 disabled:cursor-default disabled:opacity-60 aria-expanded:bg-black/[0.05] dark:hover:bg-white/[0.08] dark:aria-expanded:bg-white/[0.08]"
|
|
106
|
+
>
|
|
107
|
+
{choosesModel && !auto && selectedModel ? (
|
|
108
|
+
<ProviderLogo model={selectedModel} className="size-3.5" />
|
|
109
|
+
) : null}
|
|
110
|
+
{!choosesModel && ModeIcon ? (
|
|
111
|
+
<ModeIcon className="size-[15px] shrink-0" strokeWidth={1.9} aria-hidden="true" />
|
|
112
|
+
) : null}
|
|
113
|
+
<span className="max-w-[11rem] truncate max-sm:max-w-[7rem]">{name}</span>
|
|
114
|
+
{choosesModel && choosesMode && approvalMode !== "auto" && ModeIcon ? (
|
|
115
|
+
<>
|
|
116
|
+
<span aria-hidden="true" className="mx-px h-[13px] w-px bg-current opacity-20" />
|
|
117
|
+
<ModeIcon className="size-[15px] shrink-0" strokeWidth={1.9} aria-hidden="true" />
|
|
118
|
+
</>
|
|
119
|
+
) : null}
|
|
120
|
+
<ChevronDown
|
|
121
|
+
className="-ml-px size-3 shrink-0 text-muted-foreground transition-transform group-aria-expanded/settings:rotate-180"
|
|
122
|
+
strokeWidth={2.6}
|
|
123
|
+
aria-hidden="true"
|
|
124
|
+
/>
|
|
125
|
+
</button>
|
|
126
|
+
}
|
|
127
|
+
>
|
|
128
|
+
{choosesModel && models.length > 0 ? (
|
|
129
|
+
<ModelSection {...props} models={models} onClose={() => setOpen(false)} />
|
|
130
|
+
) : null}
|
|
131
|
+
{choosesMode ? (
|
|
132
|
+
<PermissionsSection
|
|
133
|
+
mode={approvalMode}
|
|
134
|
+
onChange={onApprovalModeChange}
|
|
135
|
+
divided={choosesModel && models.length > 0}
|
|
136
|
+
/>
|
|
137
|
+
) : null}
|
|
138
|
+
</ComposerMenu>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Tiers with a way back to Auto: the list opens on Auto, and choosing a model pins it. */
|
|
143
|
+
function autoModels(models: readonly LanguageModel[], onResetModelSelection?: () => void) {
|
|
144
|
+
return hasTiers(models) && onResetModelSelection !== undefined
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
interface ModelEntry {
|
|
148
|
+
readonly model: LanguageModel
|
|
149
|
+
/** Named at the end of the first model of each tier. */
|
|
150
|
+
readonly tier?: { readonly id: string; readonly label: string }
|
|
151
|
+
/** The label naming this model's tier, on its tier's first row. */
|
|
152
|
+
readonly describedBy?: string
|
|
153
|
+
/** A hairline above: this model starts a tier. */
|
|
154
|
+
readonly divided: boolean
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function ModelSection({
|
|
158
|
+
models,
|
|
159
|
+
selectedModel,
|
|
160
|
+
selectedReasoning,
|
|
161
|
+
usingDefaultModel = false,
|
|
162
|
+
onSelectModel,
|
|
163
|
+
onSelectReasoning,
|
|
164
|
+
onResetReasoning,
|
|
165
|
+
onResetModelSelection,
|
|
166
|
+
modelRouting = false,
|
|
167
|
+
disabled,
|
|
168
|
+
onClose,
|
|
169
|
+
}: ComposerSettingsProps & {
|
|
170
|
+
readonly models: readonly LanguageModel[]
|
|
171
|
+
readonly onClose: () => void
|
|
172
|
+
}) {
|
|
173
|
+
const agentMessages = useAgentMessages()
|
|
174
|
+
const messages = agentMessages.models
|
|
175
|
+
const groupId = useId()
|
|
176
|
+
const [query, setQuery] = useState("")
|
|
177
|
+
const auto = autoModels(models, onResetModelSelection)
|
|
178
|
+
const defaultModel = defaultLanguageModel(models)
|
|
179
|
+
const standard = auto ? defaultModel : undefined
|
|
180
|
+
const autoDescription =
|
|
181
|
+
modelRouting || !standard ? messages.autoRouting : messages.autoStandard(standard.name)
|
|
182
|
+
const normalizedQuery = query.trim().toLowerCase()
|
|
183
|
+
const listId = `${groupId}-list`
|
|
184
|
+
|
|
185
|
+
// A long list opens on the chosen model, with its thinking in view.
|
|
186
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: once, when the menu opens
|
|
187
|
+
useEffect(() => {
|
|
188
|
+
document
|
|
189
|
+
.getElementById(listId)
|
|
190
|
+
?.querySelector("[aria-checked=true]")
|
|
191
|
+
?.closest("[data-model-choice]")
|
|
192
|
+
?.scrollIntoView({ block: "nearest" })
|
|
193
|
+
}, [])
|
|
194
|
+
|
|
195
|
+
const entries = useMemo((): ModelEntry[] => {
|
|
196
|
+
const matching = normalizedQuery
|
|
197
|
+
? models.filter((model) =>
|
|
198
|
+
[model.name, model.publisher.name, model.modelId, model.via].some((value) =>
|
|
199
|
+
value?.toLowerCase().includes(normalizedQuery)
|
|
200
|
+
)
|
|
201
|
+
)
|
|
202
|
+
: models
|
|
203
|
+
if (!auto) return matching.map((model) => ({ model, divided: false }))
|
|
204
|
+
return LANGUAGE_MODEL_TIERS.flatMap((tier, tierIndex) =>
|
|
205
|
+
matching
|
|
206
|
+
.filter((model) => model.tier === tier)
|
|
207
|
+
.map((model, index) => {
|
|
208
|
+
const id = `${groupId}-${tier}`
|
|
209
|
+
return {
|
|
210
|
+
model,
|
|
211
|
+
...(index === 0
|
|
212
|
+
? { tier: { id, label: agentMessages.delegation.tiers[tier] } }
|
|
213
|
+
: { describedBy: id }),
|
|
214
|
+
divided: index === 0 && tierIndex > 0,
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
).map((entry, index) => (index === 0 ? { ...entry, divided: false } : entry))
|
|
218
|
+
}, [agentMessages.delegation.tiers, auto, groupId, models, normalizedQuery])
|
|
219
|
+
|
|
220
|
+
// Without tiers, the default model's row follows the project default instead of pinning it.
|
|
221
|
+
const choose = (model: LanguageModel) => {
|
|
222
|
+
if (
|
|
223
|
+
!auto &&
|
|
224
|
+
onResetModelSelection &&
|
|
225
|
+
!usingDefaultModel &&
|
|
226
|
+
defaultModel &&
|
|
227
|
+
sameModel(model, defaultModel)
|
|
228
|
+
) {
|
|
229
|
+
onResetModelSelection()
|
|
230
|
+
} else {
|
|
231
|
+
onSelectModel?.(model)
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const chooseAuto = () => {
|
|
236
|
+
onClose()
|
|
237
|
+
onResetModelSelection?.()
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return (
|
|
241
|
+
<>
|
|
242
|
+
<ComposerMenuHeader>{messages.title}</ComposerMenuHeader>
|
|
243
|
+
{/* A short catalog is a list to scan; a long one is searched. */}
|
|
244
|
+
{models.length > 10 ? (
|
|
245
|
+
<div className="mx-2.5 mb-1 flex h-9 shrink-0 items-center gap-2 border-b-[0.5px] border-black/[0.08] text-muted-foreground focus-within:border-foreground/30 dark:border-white/[0.1]">
|
|
246
|
+
<Search className="size-3.5 shrink-0" aria-hidden="true" />
|
|
247
|
+
<input
|
|
248
|
+
value={query}
|
|
249
|
+
onChange={(event) => setQuery(event.target.value)}
|
|
250
|
+
placeholder={messages.search}
|
|
251
|
+
aria-label={messages.search}
|
|
252
|
+
className="min-w-0 flex-1 bg-transparent text-[13.5px] text-foreground outline-none placeholder:text-muted-foreground"
|
|
253
|
+
/>
|
|
254
|
+
</div>
|
|
255
|
+
) : null}
|
|
256
|
+
{/* Only radios belong to the radio group: each describes itself with its tier's label. */}
|
|
257
|
+
<ComposerMenuScroll
|
|
258
|
+
id={listId}
|
|
259
|
+
role="radiogroup"
|
|
260
|
+
aria-label={messages.title}
|
|
261
|
+
onKeyDown={(event) => moveRadioFocus(event)}
|
|
262
|
+
// Short enough beside the permissions for the menu to fit under a composer in the middle
|
|
263
|
+
// of the page; a long list scrolls, fading out where it continues.
|
|
264
|
+
className="flex-1 overscroll-contain pb-1.5 md:max-h-[max(15rem,min(22rem,calc(100dvh-36rem)))]"
|
|
265
|
+
>
|
|
266
|
+
{auto ? (
|
|
267
|
+
<>
|
|
268
|
+
<AutoRow
|
|
269
|
+
selected={!selectedModel}
|
|
270
|
+
description={autoDescription}
|
|
271
|
+
disabled={disabled}
|
|
272
|
+
onChoose={chooseAuto}
|
|
273
|
+
/>
|
|
274
|
+
<ComposerMenuDivider strong />
|
|
275
|
+
</>
|
|
276
|
+
) : null}
|
|
277
|
+
{entries.map((entry) => {
|
|
278
|
+
const selected = sameModel(entry.model, selectedModel)
|
|
279
|
+
return (
|
|
280
|
+
<Fragment key={`${entry.model.provider}:${entry.model.modelId}`}>
|
|
281
|
+
{entry.divided ? <ComposerMenuDivider /> : null}
|
|
282
|
+
<div
|
|
283
|
+
data-model-choice=""
|
|
284
|
+
className={cn("rounded-xl", selected && COMPOSER_MENU_ROW_SELECTED_CLASS_NAME)}
|
|
285
|
+
>
|
|
286
|
+
<ModelPickerRow
|
|
287
|
+
model={entry.model}
|
|
288
|
+
selected={selected}
|
|
289
|
+
disabled={disabled}
|
|
290
|
+
radio
|
|
291
|
+
tier={entry.tier}
|
|
292
|
+
describedBy={entry.describedBy}
|
|
293
|
+
onSelect={choose}
|
|
294
|
+
/>
|
|
295
|
+
{selected && selectedModel && selectedReasoning && onSelectReasoning ? (
|
|
296
|
+
<div className="pr-3 pb-2.5 pl-[39px]">
|
|
297
|
+
<ReasoningEffortSlider
|
|
298
|
+
model={selectedModel}
|
|
299
|
+
value={selectedReasoning}
|
|
300
|
+
disabled={disabled}
|
|
301
|
+
onChange={onSelectReasoning}
|
|
302
|
+
onReset={onResetReasoning}
|
|
303
|
+
/>
|
|
304
|
+
</div>
|
|
305
|
+
) : null}
|
|
306
|
+
</div>
|
|
307
|
+
</Fragment>
|
|
308
|
+
)
|
|
309
|
+
})}
|
|
310
|
+
{entries.length === 0 ? (
|
|
311
|
+
<p className="px-3 py-8 text-center text-xs text-muted-foreground">{messages.empty}</p>
|
|
312
|
+
) : null}
|
|
313
|
+
</ComposerMenuScroll>
|
|
314
|
+
</>
|
|
315
|
+
)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function AutoRow({
|
|
319
|
+
selected,
|
|
320
|
+
description,
|
|
321
|
+
disabled,
|
|
322
|
+
onChoose,
|
|
323
|
+
}: {
|
|
324
|
+
readonly selected: boolean
|
|
325
|
+
readonly description: string
|
|
326
|
+
readonly disabled?: boolean
|
|
327
|
+
readonly onChoose: () => void
|
|
328
|
+
}) {
|
|
329
|
+
const messages = useAgentMessages().models
|
|
330
|
+
const descriptionId = useId()
|
|
331
|
+
return (
|
|
332
|
+
<button
|
|
333
|
+
type="button"
|
|
334
|
+
role="radio"
|
|
335
|
+
aria-checked={selected}
|
|
336
|
+
tabIndex={selected ? 0 : -1}
|
|
337
|
+
aria-describedby={descriptionId}
|
|
338
|
+
disabled={disabled}
|
|
339
|
+
onClick={onChoose}
|
|
340
|
+
className={cn(
|
|
341
|
+
COMPOSER_MENU_ROW_CLASS_NAME,
|
|
342
|
+
"items-start",
|
|
343
|
+
selected && COMPOSER_MENU_ROW_SELECTED_CLASS_NAME
|
|
344
|
+
)}
|
|
345
|
+
>
|
|
346
|
+
{/* Solid, as the provider marks under it are. */}
|
|
347
|
+
<span className="mt-px flex size-[18px] shrink-0 items-center justify-center text-foreground">
|
|
348
|
+
<AutoMark />
|
|
349
|
+
</span>
|
|
350
|
+
<ComposerMenuRowText
|
|
351
|
+
title={messages.auto}
|
|
352
|
+
description={description}
|
|
353
|
+
descriptionId={descriptionId}
|
|
354
|
+
/>
|
|
355
|
+
</button>
|
|
356
|
+
)
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/** Auto's mark: a four-pointed star with narrow waists, filled as the provider marks are. */
|
|
360
|
+
function AutoMark() {
|
|
361
|
+
return (
|
|
362
|
+
<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" className="size-4">
|
|
363
|
+
<path d="M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z" />
|
|
364
|
+
</svg>
|
|
365
|
+
)
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/** What the agent may do without asking: three choices side by side, the chosen one explained. */
|
|
369
|
+
function PermissionsSection({
|
|
370
|
+
mode,
|
|
371
|
+
onChange,
|
|
372
|
+
divided,
|
|
373
|
+
}: {
|
|
374
|
+
readonly mode: AgentApprovalMode
|
|
375
|
+
readonly onChange: (mode: AgentApprovalMode) => void
|
|
376
|
+
/** A hairline above, under the model section. */
|
|
377
|
+
readonly divided: boolean
|
|
378
|
+
}) {
|
|
379
|
+
const agentMessages = useAgentMessages()
|
|
380
|
+
const messages = agentMessages.approvalModes
|
|
381
|
+
const descriptionId = useId()
|
|
382
|
+
|
|
383
|
+
return (
|
|
384
|
+
<div
|
|
385
|
+
className={cn(COMPOSER_MENU_SECTION_CLASS_NAME, "-mx-1.5 -mb-1.5", !divided && "border-t-0")}
|
|
386
|
+
>
|
|
387
|
+
<div className="text-xs text-muted-foreground">{agentMessages.settings.permissions}</div>
|
|
388
|
+
<div
|
|
389
|
+
role="radiogroup"
|
|
390
|
+
aria-label={messages.title}
|
|
391
|
+
aria-describedby={descriptionId}
|
|
392
|
+
title={messages.shortcut}
|
|
393
|
+
onKeyDown={(event) => moveRadioFocus(event, { select: true })}
|
|
394
|
+
className="mt-2 grid grid-cols-3 gap-0.5 rounded-[14px] bg-black/[0.055] p-[3px] dark:bg-white/[0.08]"
|
|
395
|
+
>
|
|
396
|
+
{AGENT_APPROVAL_MODES.map((option) => {
|
|
397
|
+
const selected = option === mode
|
|
398
|
+
const Icon = APPROVAL_MODE_ICONS[option]
|
|
399
|
+
return (
|
|
400
|
+
<button
|
|
401
|
+
key={option}
|
|
402
|
+
type="button"
|
|
403
|
+
role="radio"
|
|
404
|
+
aria-checked={selected}
|
|
405
|
+
tabIndex={selected ? 0 : -1}
|
|
406
|
+
onClick={() => {
|
|
407
|
+
if (!selected) onChange(option)
|
|
408
|
+
}}
|
|
409
|
+
className={cn(
|
|
410
|
+
"flex h-14 min-w-0 flex-col items-center justify-center gap-[5px] rounded-[11px] px-1 text-xs text-foreground/75 outline-none transition-[background-color,box-shadow] duration-150 hover:bg-white/50 focus-visible:ring-2 focus-visible:ring-ring/40 dark:hover:bg-white/[0.06]",
|
|
411
|
+
selected &&
|
|
412
|
+
"bg-background font-medium text-foreground shadow-[0_0_0_0.5px_rgb(0_0_0/0.06),0_2px_8px_-2px_rgb(0_0_0/0.16)] hover:bg-background dark:bg-white/[0.14] dark:hover:bg-white/[0.14]"
|
|
413
|
+
)}
|
|
414
|
+
>
|
|
415
|
+
<Icon className="size-[18px]" strokeWidth={1.75} aria-hidden="true" />
|
|
416
|
+
<span className="max-w-full truncate">{messages.modes[option].label}</span>
|
|
417
|
+
</button>
|
|
418
|
+
)
|
|
419
|
+
})}
|
|
420
|
+
</div>
|
|
421
|
+
<p id={descriptionId} className="px-0.5 pt-2.5 text-xs leading-4 text-muted-foreground">
|
|
422
|
+
{messages.modes[mode].description}
|
|
423
|
+
</p>
|
|
424
|
+
</div>
|
|
425
|
+
)
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/** The chip's thinking level, in its tooltip: an explicit one the model offers a choice of. */
|
|
429
|
+
function reasoningLabel(
|
|
430
|
+
model: LanguageModel | undefined,
|
|
431
|
+
reasoning: ModelReasoningLevel | undefined,
|
|
432
|
+
messages: AgentMessages["reasoning"]
|
|
433
|
+
): string | undefined {
|
|
434
|
+
if (!model || model.reasoningLevels.length <= 1 || !reasoning) return undefined
|
|
435
|
+
if (reasoning === "none" || reasoning === "provider-default") return undefined
|
|
436
|
+
return messages.levels[reasoning]
|
|
437
|
+
}
|