@vvedantb/ui 0.64.0 → 0.65.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/README.md +1 -1
- package/dist/src/ai-elements/model-picker.js +258 -207
- package/package.json +1 -1
- package/src/ai-elements/model-picker.tsx +46 -12
package/README.md
CHANGED
|
@@ -1847,7 +1847,7 @@ AI surfaces that came from an app, exported from the root. Fills use `surface-se
|
|
|
1847
1847
|
- `ActivityQuestionCard` (`questions`, `answers`): the read-only record of a multiple-choice question and its answer.
|
|
1848
1848
|
- `AgentTrace`, `AgentTraceLine` (`status`: `AgentTraceStatus`, `running | error | pending`), `AgentTraceIcon` (`iconKey` crossfades a swap), `AgentTraceTitle` (`shimmer`), `AgentTraceDescription`, `AgentTraceCollapsible`, `AgentTraceCollapsibleTrigger` (`trailing`: controls beside the trigger), `AgentTraceCollapsibleContent`: one agent step as one line, with an optional fold.
|
|
1849
1849
|
- `AgentPlan*`, `TestResults*` / `TestSuite*` / `TestResult*` (one test: `TestResult`, `TestResultStatusIndicator`, `TestResultName`, `TestResultDuration`, `TestResultError`, `TestResultErrorMessage`, `TestResultErrorStack`), `WebPreview*` (with `useWebPreview`), `ContextUsage*` (context window usage in a hover card: `ContextUsage`, `ContextUsageTrigger`, `ContextUsageContent`, `ContextUsageContentHeader` / `Body` / `Footer`, `ContextUsageInput`, `ContextUsageOutput`, `ContextUsageCacheRead`, `ContextUsageCacheWrite`, deprecated `ContextUsageCache`).
|
|
1850
|
-
- `ModelPicker` (button and popover; `simpleLadder` opens on a discrete slider; the one model picker), `ModelPickerContent` (the searchable model and account list, for menus; pair it with `modelPickerSurfaceClass`), `ModelOption`, `ModelAccount`, `findModelOption`, `formatModelDisplayLabel`, `getProviderLabel`, `ProviderIcon` (`claude`, `codex`, `opencode`, `cursor`).
|
|
1850
|
+
- `ModelPicker` (button and popover; `simpleLadder` opens on a discrete slider; the one model picker). Its `traits` prop is required: the selected model's trait controls (`ModelPickerTraits`, the `TraitsPanel` props). The picker pins them above the list and sums them up on the trigger (`modelPickerTraitSummary`: reasoning level, "1M", "No thinking", and a bolt for Fast). Pass `null` only where runs take no traits. `ModelPickerContent` (the searchable model and account list, for menus; pair it with `modelPickerSurfaceClass`), `ModelOption`, `ModelAccount`, `findModelOption`, `formatModelDisplayLabel`, `getProviderLabel`, `ProviderIcon` (`claude`, `codex`, `opencode`, `cursor`).
|
|
1851
1851
|
- Deprecated, removed in the next minor release: `ModelSelector*` and `PromptInputModelSelect*` (use `ModelPicker`). Behaviour is unchanged, except `ModelSelectorLogo`: it now renders `ProviderIcon` and fetches nothing (it loaded `https://models.dev/logos/<provider>.svg`). `anthropic`, `google-vertex-anthropic` and `claude` show the Claude mark, `openai` and `codex` the OpenAI mark, `opencode` and `cursor` their marks; any other id shows a neutral CPU glyph. It takes SVG props and `size` (default 12) and keeps the `"<provider> logo"` name. `ModelSelectorLogoGroup` styles `svg` children.
|
|
1852
1852
|
|
|
1853
1853
|
### App config entries
|
|
@@ -7,6 +7,7 @@ import { useCn, useUiConfig } from "../ui/ui-config.js";
|
|
|
7
7
|
import { ProviderIcon } from "./provider-icon.js";
|
|
8
8
|
import { ModelPickerContent, buildPickerInstances, providerInstanceInitials, teamInstanceKey } from "./model-picker-content.js";
|
|
9
9
|
import { findModelOption, formatModelDisplayLabel, getProviderLabel } from "./model-picker-types.js";
|
|
10
|
+
import { TraitsPanel } from "./prompt-input-traits.js";
|
|
10
11
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
12
|
export { findModelOption, formatModelDisplayLabel, getProviderLabel };
|
|
12
13
|
/** Embeddable picker body — use in menus/submenus; use `ModelPicker` for button triggers. */
|
|
@@ -32,13 +33,42 @@ const TRIGGER_CLASS =
|
|
|
32
33
|
* sync so trigger vs embed surfaces cannot drift.
|
|
33
34
|
*/
|
|
34
35
|
export const modelPickerSurfaceClass = "w-100 max-w-[calc(100vw-1rem)] overflow-hidden rounded-menu border-0 bg-transparent p-0 shadow-none";
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The selected model's trait controls (reasoning, thinking, context window,
|
|
39
|
+
* Fast). `ModelPicker` pins them above the model list and sums them up on the
|
|
40
|
+
* trigger, so every picker shows traits the same way.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* What the trigger shows after the model name: the reasoning level, "1M" when
|
|
45
|
+
* the 1M context is on, "No thinking" when thinking is off, joined by " · ",
|
|
46
|
+
* and whether Fast is on (the bolt). Only traits the model supports count.
|
|
47
|
+
*/
|
|
48
|
+
export function modelPickerTraitSummary(traits) {
|
|
49
|
+
const {
|
|
50
|
+
config
|
|
51
|
+
} = traits;
|
|
52
|
+
const parts = [];
|
|
53
|
+
if (config.reasoning) {
|
|
54
|
+
parts.push(traits.getLevelLabel(traits.effortLevel ?? config.reasoning.default));
|
|
55
|
+
}
|
|
56
|
+
if (config.contextWindow1m && traits.use1mContext) parts.push("1M");
|
|
57
|
+
if (config.thinkingToggle && !traits.thinkingEnabled) {
|
|
58
|
+
parts.push("No thinking");
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
suffix: parts.length > 0 ? parts.join(" · ") : undefined,
|
|
62
|
+
fast: Boolean(config.fastMode && traits.fastMode)
|
|
63
|
+
};
|
|
64
|
+
}
|
|
35
65
|
/**
|
|
36
66
|
* Button + popover model picker (create modal, composers, toolbars).
|
|
37
67
|
* For context/dropdown menus, embed `ModelPickerContent` with
|
|
38
68
|
* `modelPickerSurfaceClass` instead of nesting this popover.
|
|
39
69
|
*/
|
|
40
70
|
export function ModelPicker(t0) {
|
|
41
|
-
const $ = _c(
|
|
71
|
+
const $ = _c(105);
|
|
42
72
|
const {
|
|
43
73
|
value,
|
|
44
74
|
onValueChange,
|
|
@@ -50,9 +80,7 @@ export function ModelPicker(t0) {
|
|
|
50
80
|
onAccountChange,
|
|
51
81
|
onSelectionChange,
|
|
52
82
|
canSelectTeamWhilePersonal: t2,
|
|
53
|
-
|
|
54
|
-
header,
|
|
55
|
-
showFastIcon,
|
|
83
|
+
traits,
|
|
56
84
|
simpleLadder,
|
|
57
85
|
simpleLadderSnap
|
|
58
86
|
} = t0;
|
|
@@ -60,6 +88,29 @@ export function ModelPicker(t0) {
|
|
|
60
88
|
const canSelectTeamWhilePersonal = t2 === undefined ? true : t2;
|
|
61
89
|
const merge = useCn();
|
|
62
90
|
const config = useUiConfig("ModelPicker");
|
|
91
|
+
let t3;
|
|
92
|
+
if ($[0] !== traits) {
|
|
93
|
+
t3 = traits === null ? null : modelPickerTraitSummary(traits);
|
|
94
|
+
$[0] = traits;
|
|
95
|
+
$[1] = t3;
|
|
96
|
+
} else {
|
|
97
|
+
t3 = $[1];
|
|
98
|
+
}
|
|
99
|
+
const summary = t3;
|
|
100
|
+
const triggerSuffix = summary?.suffix;
|
|
101
|
+
let t4;
|
|
102
|
+
if ($[2] !== disabled || $[3] !== traits) {
|
|
103
|
+
t4 = traits === null ? undefined : /*#__PURE__*/_jsx(TraitsPanel, {
|
|
104
|
+
...traits,
|
|
105
|
+
disabled: disabled
|
|
106
|
+
});
|
|
107
|
+
$[2] = disabled;
|
|
108
|
+
$[3] = traits;
|
|
109
|
+
$[4] = t4;
|
|
110
|
+
} else {
|
|
111
|
+
t4 = $[4];
|
|
112
|
+
}
|
|
113
|
+
const header = t4;
|
|
63
114
|
const [open, setOpen] = useState(false);
|
|
64
115
|
const [advanced, setAdvanced] = useState(false);
|
|
65
116
|
const [previewId, setPreviewId] = useState(null);
|
|
@@ -75,17 +126,17 @@ export function ModelPicker(t0) {
|
|
|
75
126
|
let t11;
|
|
76
127
|
let t12;
|
|
77
128
|
let t13;
|
|
78
|
-
let
|
|
79
|
-
let
|
|
129
|
+
let t14;
|
|
130
|
+
let t15;
|
|
80
131
|
let t5;
|
|
81
132
|
let t6;
|
|
82
133
|
let t7;
|
|
83
134
|
let t8;
|
|
84
135
|
let t9;
|
|
85
136
|
let triggerLabel;
|
|
86
|
-
if ($[
|
|
137
|
+
if ($[5] !== accountId || $[6] !== accounts || $[7] !== advanced || $[8] !== className || $[9] !== config?.badgeRing?.trigger || $[10] !== config?.classes?.trigger || $[11] !== disabled || $[12] !== displayValue || $[13] !== merge || $[14] !== onAccountChange || $[15] !== onSelectionChange || $[16] !== onValueChange || $[17] !== open || $[18] !== options || $[19] !== simpleLadder || $[20] !== simpleLadderSnap || $[21] !== summary?.fast || $[22] !== value) {
|
|
87
138
|
const selectedModel = findModelOption(displayValue, options);
|
|
88
|
-
if ($[
|
|
139
|
+
if ($[42] !== options || $[43] !== simpleLadder) {
|
|
89
140
|
ladderSteps = [];
|
|
90
141
|
if (simpleLadder) {
|
|
91
142
|
for (const id of simpleLadder) {
|
|
@@ -95,16 +146,16 @@ export function ModelPicker(t0) {
|
|
|
95
146
|
}
|
|
96
147
|
}
|
|
97
148
|
}
|
|
98
|
-
$[
|
|
99
|
-
$[
|
|
100
|
-
$[
|
|
149
|
+
$[42] = options;
|
|
150
|
+
$[43] = simpleLadder;
|
|
151
|
+
$[44] = ladderSteps;
|
|
101
152
|
} else {
|
|
102
|
-
ladderSteps = $[
|
|
153
|
+
ladderSteps = $[44];
|
|
103
154
|
}
|
|
104
155
|
showLadder = ladderSteps.length >= 2 && !advanced;
|
|
105
156
|
const preferredSnap = simpleLadderSnap ?? value;
|
|
106
157
|
snappedAmong = ladderSteps[0]?.id ?? value;
|
|
107
|
-
if ($[
|
|
158
|
+
if ($[45] !== ladderSteps || $[46] !== preferredSnap || $[47] !== value) {
|
|
108
159
|
for (const step of ladderSteps) {
|
|
109
160
|
if (step.id === value || step.id === preferredSnap) {
|
|
110
161
|
snappedAmong = step.id;
|
|
@@ -113,21 +164,21 @@ export function ModelPicker(t0) {
|
|
|
113
164
|
}
|
|
114
165
|
}
|
|
115
166
|
}
|
|
116
|
-
$[
|
|
117
|
-
$[
|
|
118
|
-
$[
|
|
119
|
-
$[
|
|
167
|
+
$[45] = ladderSteps;
|
|
168
|
+
$[46] = preferredSnap;
|
|
169
|
+
$[47] = value;
|
|
170
|
+
$[48] = snappedAmong;
|
|
120
171
|
} else {
|
|
121
|
-
snappedAmong = $[
|
|
172
|
+
snappedAmong = $[48];
|
|
122
173
|
}
|
|
123
174
|
triggerLabel = selectedModel ? selectedModel.label : "Select model";
|
|
124
175
|
const instances = buildPickerInstances(options, accounts);
|
|
125
176
|
const selectedAccount = accountId ? accounts?.find(account => account.id === accountId) : undefined;
|
|
126
177
|
const activeInstance = (selectedAccount ? instances.find(instance_0 => instance_0.key === selectedAccount.id) : undefined) ?? (selectedModel ? instances.find(instance => instance.key === teamInstanceKey(selectedModel.provider)) : undefined) ?? instances[0];
|
|
127
178
|
const showAccountBadge = Boolean(selectedAccount && instances.filter(instance_1 => instance_1.provider === selectedAccount.provider).length > 1);
|
|
128
|
-
let
|
|
129
|
-
if ($[
|
|
130
|
-
|
|
179
|
+
let t16;
|
|
180
|
+
if ($[49] !== onAccountChange || $[50] !== onSelectionChange || $[51] !== onValueChange) {
|
|
181
|
+
t16 = (modelId, nextAccountId) => {
|
|
131
182
|
if (onSelectionChange) {
|
|
132
183
|
onSelectionChange(modelId, nextAccountId);
|
|
133
184
|
} else {
|
|
@@ -135,14 +186,14 @@ export function ModelPicker(t0) {
|
|
|
135
186
|
onAccountChange?.(nextAccountId);
|
|
136
187
|
}
|
|
137
188
|
};
|
|
138
|
-
$[
|
|
139
|
-
$[
|
|
140
|
-
$[
|
|
141
|
-
$[
|
|
189
|
+
$[49] = onAccountChange;
|
|
190
|
+
$[50] = onSelectionChange;
|
|
191
|
+
$[51] = onValueChange;
|
|
192
|
+
$[52] = t16;
|
|
142
193
|
} else {
|
|
143
|
-
|
|
194
|
+
t16 = $[52];
|
|
144
195
|
}
|
|
145
|
-
commit =
|
|
196
|
+
commit = t16;
|
|
146
197
|
accountForModel = modelId_0 => {
|
|
147
198
|
const option_0 = options.find(entry_0 => entry_0.id === modelId_0);
|
|
148
199
|
if (!option_0) {
|
|
@@ -154,38 +205,38 @@ export function ModelPicker(t0) {
|
|
|
154
205
|
return null;
|
|
155
206
|
};
|
|
156
207
|
T1 = Popover;
|
|
157
|
-
|
|
158
|
-
if ($[
|
|
159
|
-
|
|
208
|
+
t14 = open;
|
|
209
|
+
if ($[53] === Symbol.for("react.memo_cache_sentinel")) {
|
|
210
|
+
t15 = next => {
|
|
160
211
|
setOpen(next);
|
|
161
212
|
if (!next) {
|
|
162
213
|
setAdvanced(false);
|
|
163
214
|
setPreviewId(null);
|
|
164
215
|
}
|
|
165
216
|
};
|
|
166
|
-
$[
|
|
217
|
+
$[53] = t15;
|
|
167
218
|
} else {
|
|
168
|
-
|
|
219
|
+
t15 = $[53];
|
|
169
220
|
}
|
|
170
221
|
T0 = PopoverTrigger;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
if ($[
|
|
178
|
-
|
|
179
|
-
$[
|
|
180
|
-
$[
|
|
181
|
-
$[
|
|
182
|
-
$[
|
|
222
|
+
t13 = true;
|
|
223
|
+
t5 = "button";
|
|
224
|
+
t6 = "combobox";
|
|
225
|
+
t7 = open;
|
|
226
|
+
t8 = "select-trigger";
|
|
227
|
+
const t17 = config?.classes?.trigger ?? TRIGGER_CLASS;
|
|
228
|
+
if ($[54] !== className || $[55] !== merge || $[56] !== t17) {
|
|
229
|
+
t9 = merge(t17, className);
|
|
230
|
+
$[54] = className;
|
|
231
|
+
$[55] = merge;
|
|
232
|
+
$[56] = t17;
|
|
233
|
+
$[57] = t9;
|
|
183
234
|
} else {
|
|
184
|
-
|
|
235
|
+
t9 = $[57];
|
|
185
236
|
}
|
|
186
|
-
|
|
187
|
-
if ($[
|
|
188
|
-
|
|
237
|
+
t10 = disabled;
|
|
238
|
+
if ($[58] !== summary?.fast) {
|
|
239
|
+
t11 = summary?.fast ? /*#__PURE__*/_jsx("span", {
|
|
189
240
|
title: "Fast",
|
|
190
241
|
className: "inline-flex shrink-0",
|
|
191
242
|
children: /*#__PURE__*/_jsx(IconBolt, {
|
|
@@ -193,12 +244,12 @@ export function ModelPicker(t0) {
|
|
|
193
244
|
"aria-hidden": true
|
|
194
245
|
})
|
|
195
246
|
}) : null;
|
|
196
|
-
$[
|
|
197
|
-
$[
|
|
247
|
+
$[58] = summary?.fast;
|
|
248
|
+
$[59] = t11;
|
|
198
249
|
} else {
|
|
199
|
-
|
|
250
|
+
t11 = $[59];
|
|
200
251
|
}
|
|
201
|
-
|
|
252
|
+
t12 = activeInstance && selectedAccount && showAccountBadge ? /*#__PURE__*/_jsxs("span", {
|
|
202
253
|
className: "relative isolate inline-flex size-4 shrink-0 items-center justify-center",
|
|
203
254
|
children: [/*#__PURE__*/_jsx(ProviderIcon, {
|
|
204
255
|
provider: selectedModel?.provider ?? "claude",
|
|
@@ -215,152 +266,152 @@ export function ModelPicker(t0) {
|
|
|
215
266
|
provider: selectedModel?.provider ?? "claude",
|
|
216
267
|
size: 14
|
|
217
268
|
});
|
|
218
|
-
$[
|
|
219
|
-
$[
|
|
220
|
-
$[
|
|
221
|
-
$[
|
|
222
|
-
$[
|
|
223
|
-
$[
|
|
224
|
-
$[
|
|
225
|
-
$[
|
|
226
|
-
$[
|
|
227
|
-
$[
|
|
228
|
-
$[
|
|
229
|
-
$[
|
|
230
|
-
$[
|
|
231
|
-
$[
|
|
232
|
-
$[
|
|
233
|
-
$[
|
|
234
|
-
$[
|
|
235
|
-
$[
|
|
236
|
-
$[
|
|
237
|
-
$[
|
|
238
|
-
$[
|
|
239
|
-
$[
|
|
240
|
-
$[
|
|
241
|
-
$[
|
|
242
|
-
$[
|
|
243
|
-
$[
|
|
244
|
-
$[
|
|
245
|
-
$[
|
|
246
|
-
$[
|
|
247
|
-
$[
|
|
248
|
-
$[
|
|
249
|
-
$[
|
|
250
|
-
$[
|
|
251
|
-
$[
|
|
252
|
-
$[
|
|
253
|
-
$[
|
|
254
|
-
$[
|
|
269
|
+
$[5] = accountId;
|
|
270
|
+
$[6] = accounts;
|
|
271
|
+
$[7] = advanced;
|
|
272
|
+
$[8] = className;
|
|
273
|
+
$[9] = config?.badgeRing?.trigger;
|
|
274
|
+
$[10] = config?.classes?.trigger;
|
|
275
|
+
$[11] = disabled;
|
|
276
|
+
$[12] = displayValue;
|
|
277
|
+
$[13] = merge;
|
|
278
|
+
$[14] = onAccountChange;
|
|
279
|
+
$[15] = onSelectionChange;
|
|
280
|
+
$[16] = onValueChange;
|
|
281
|
+
$[17] = open;
|
|
282
|
+
$[18] = options;
|
|
283
|
+
$[19] = simpleLadder;
|
|
284
|
+
$[20] = simpleLadderSnap;
|
|
285
|
+
$[21] = summary?.fast;
|
|
286
|
+
$[22] = value;
|
|
287
|
+
$[23] = T0;
|
|
288
|
+
$[24] = T1;
|
|
289
|
+
$[25] = accountForModel;
|
|
290
|
+
$[26] = commit;
|
|
291
|
+
$[27] = ladderSteps;
|
|
292
|
+
$[28] = showLadder;
|
|
293
|
+
$[29] = snappedAmong;
|
|
294
|
+
$[30] = t10;
|
|
295
|
+
$[31] = t11;
|
|
296
|
+
$[32] = t12;
|
|
297
|
+
$[33] = t13;
|
|
298
|
+
$[34] = t14;
|
|
299
|
+
$[35] = t15;
|
|
300
|
+
$[36] = t5;
|
|
301
|
+
$[37] = t6;
|
|
302
|
+
$[38] = t7;
|
|
303
|
+
$[39] = t8;
|
|
304
|
+
$[40] = t9;
|
|
305
|
+
$[41] = triggerLabel;
|
|
255
306
|
} else {
|
|
256
|
-
T0 = $[
|
|
257
|
-
T1 = $[
|
|
258
|
-
accountForModel = $[
|
|
259
|
-
commit = $[
|
|
260
|
-
ladderSteps = $[
|
|
261
|
-
showLadder = $[
|
|
262
|
-
snappedAmong = $[
|
|
263
|
-
t10 = $[
|
|
264
|
-
t11 = $[
|
|
265
|
-
t12 = $[
|
|
266
|
-
t13 = $[
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
t5 = $[
|
|
270
|
-
t6 = $[
|
|
271
|
-
t7 = $[
|
|
272
|
-
t8 = $[
|
|
273
|
-
t9 = $[
|
|
274
|
-
triggerLabel = $[
|
|
307
|
+
T0 = $[23];
|
|
308
|
+
T1 = $[24];
|
|
309
|
+
accountForModel = $[25];
|
|
310
|
+
commit = $[26];
|
|
311
|
+
ladderSteps = $[27];
|
|
312
|
+
showLadder = $[28];
|
|
313
|
+
snappedAmong = $[29];
|
|
314
|
+
t10 = $[30];
|
|
315
|
+
t11 = $[31];
|
|
316
|
+
t12 = $[32];
|
|
317
|
+
t13 = $[33];
|
|
318
|
+
t14 = $[34];
|
|
319
|
+
t15 = $[35];
|
|
320
|
+
t5 = $[36];
|
|
321
|
+
t6 = $[37];
|
|
322
|
+
t7 = $[38];
|
|
323
|
+
t8 = $[39];
|
|
324
|
+
t9 = $[40];
|
|
325
|
+
triggerLabel = $[41];
|
|
275
326
|
}
|
|
276
|
-
let
|
|
277
|
-
if ($[
|
|
278
|
-
|
|
327
|
+
let t16;
|
|
328
|
+
if ($[60] !== triggerSuffix) {
|
|
329
|
+
t16 = triggerSuffix ? /*#__PURE__*/_jsxs("span", {
|
|
279
330
|
className: "text-muted-foreground/70",
|
|
280
331
|
children: [" \xB7 ", triggerSuffix]
|
|
281
332
|
}) : null;
|
|
282
|
-
$[
|
|
283
|
-
$[
|
|
333
|
+
$[60] = triggerSuffix;
|
|
334
|
+
$[61] = t16;
|
|
284
335
|
} else {
|
|
285
|
-
|
|
336
|
+
t16 = $[61];
|
|
286
337
|
}
|
|
287
|
-
let
|
|
288
|
-
if ($[
|
|
289
|
-
|
|
338
|
+
let t17;
|
|
339
|
+
if ($[62] !== t16 || $[63] !== triggerLabel) {
|
|
340
|
+
t17 = /*#__PURE__*/_jsxs("span", {
|
|
290
341
|
className: "whitespace-nowrap text-left max-sm:min-w-0 max-sm:truncate",
|
|
291
|
-
children: [triggerLabel,
|
|
342
|
+
children: [triggerLabel, t16]
|
|
292
343
|
});
|
|
293
|
-
$[
|
|
294
|
-
$[
|
|
295
|
-
$[
|
|
344
|
+
$[62] = t16;
|
|
345
|
+
$[63] = triggerLabel;
|
|
346
|
+
$[64] = t17;
|
|
296
347
|
} else {
|
|
297
|
-
|
|
348
|
+
t17 = $[64];
|
|
298
349
|
}
|
|
299
|
-
let
|
|
300
|
-
if ($[
|
|
301
|
-
|
|
350
|
+
let t18;
|
|
351
|
+
if ($[65] === Symbol.for("react.memo_cache_sentinel")) {
|
|
352
|
+
t18 = /*#__PURE__*/_jsx(IconChevronDown, {
|
|
302
353
|
size: 12,
|
|
303
354
|
className: "shrink-0 opacity-60",
|
|
304
355
|
"aria-hidden": true
|
|
305
356
|
});
|
|
306
|
-
$[
|
|
357
|
+
$[65] = t18;
|
|
307
358
|
} else {
|
|
308
|
-
|
|
359
|
+
t18 = $[65];
|
|
309
360
|
}
|
|
310
|
-
let
|
|
311
|
-
if ($[
|
|
312
|
-
|
|
313
|
-
type:
|
|
314
|
-
role:
|
|
315
|
-
"aria-expanded":
|
|
316
|
-
"data-slot":
|
|
317
|
-
className:
|
|
318
|
-
disabled:
|
|
319
|
-
children: [
|
|
361
|
+
let t19;
|
|
362
|
+
if ($[66] !== t10 || $[67] !== t11 || $[68] !== t12 || $[69] !== t17 || $[70] !== t5 || $[71] !== t6 || $[72] !== t7 || $[73] !== t8 || $[74] !== t9) {
|
|
363
|
+
t19 = /*#__PURE__*/_jsxs("button", {
|
|
364
|
+
type: t5,
|
|
365
|
+
role: t6,
|
|
366
|
+
"aria-expanded": t7,
|
|
367
|
+
"data-slot": t8,
|
|
368
|
+
className: t9,
|
|
369
|
+
disabled: t10,
|
|
370
|
+
children: [t11, t12, t17, t18]
|
|
320
371
|
});
|
|
321
|
-
$[
|
|
322
|
-
$[
|
|
323
|
-
$[
|
|
324
|
-
$[
|
|
325
|
-
$[
|
|
326
|
-
$[
|
|
327
|
-
$[
|
|
328
|
-
$[
|
|
329
|
-
$[
|
|
330
|
-
$[
|
|
372
|
+
$[66] = t10;
|
|
373
|
+
$[67] = t11;
|
|
374
|
+
$[68] = t12;
|
|
375
|
+
$[69] = t17;
|
|
376
|
+
$[70] = t5;
|
|
377
|
+
$[71] = t6;
|
|
378
|
+
$[72] = t7;
|
|
379
|
+
$[73] = t8;
|
|
380
|
+
$[74] = t9;
|
|
381
|
+
$[75] = t19;
|
|
331
382
|
} else {
|
|
332
|
-
|
|
383
|
+
t19 = $[75];
|
|
333
384
|
}
|
|
334
|
-
let
|
|
335
|
-
if ($[
|
|
336
|
-
|
|
337
|
-
asChild:
|
|
338
|
-
children:
|
|
385
|
+
let t20;
|
|
386
|
+
if ($[76] !== T0 || $[77] !== t13 || $[78] !== t19) {
|
|
387
|
+
t20 = /*#__PURE__*/_jsx(T0, {
|
|
388
|
+
asChild: t13,
|
|
389
|
+
children: t19
|
|
339
390
|
});
|
|
340
|
-
$[
|
|
341
|
-
$[
|
|
342
|
-
$[
|
|
343
|
-
$[
|
|
391
|
+
$[76] = T0;
|
|
392
|
+
$[77] = t13;
|
|
393
|
+
$[78] = t19;
|
|
394
|
+
$[79] = t20;
|
|
344
395
|
} else {
|
|
345
|
-
|
|
396
|
+
t20 = $[79];
|
|
346
397
|
}
|
|
347
|
-
const
|
|
348
|
-
let
|
|
349
|
-
if ($[
|
|
350
|
-
|
|
398
|
+
const t21 = showLadder ? "w-56 p-3" : modelPickerSurfaceClass;
|
|
399
|
+
let t22;
|
|
400
|
+
if ($[80] !== showLadder) {
|
|
401
|
+
t22 = event => {
|
|
351
402
|
if (showLadder) {
|
|
352
403
|
return;
|
|
353
404
|
}
|
|
354
405
|
event.preventDefault();
|
|
355
406
|
};
|
|
356
|
-
$[
|
|
357
|
-
$[
|
|
407
|
+
$[80] = showLadder;
|
|
408
|
+
$[81] = t22;
|
|
358
409
|
} else {
|
|
359
|
-
|
|
410
|
+
t22 = $[81];
|
|
360
411
|
}
|
|
361
|
-
let
|
|
362
|
-
if ($[
|
|
363
|
-
|
|
412
|
+
let t23;
|
|
413
|
+
if ($[82] !== accountForModel || $[83] !== accountId || $[84] !== accounts || $[85] !== canSelectTeamWhilePersonal || $[86] !== commit || $[87] !== disabled || $[88] !== displayValue || $[89] !== header || $[90] !== ladderSteps || $[91] !== options || $[92] !== showLadder || $[93] !== snappedAmong) {
|
|
414
|
+
t23 = showLadder ? /*#__PURE__*/_jsx(SimpleModelLadder, {
|
|
364
415
|
value: displayValue,
|
|
365
416
|
steps: ladderSteps,
|
|
366
417
|
snappedId: snappedAmong,
|
|
@@ -382,52 +433,52 @@ export function ModelPicker(t0) {
|
|
|
382
433
|
},
|
|
383
434
|
header: header
|
|
384
435
|
});
|
|
385
|
-
$[
|
|
386
|
-
$[
|
|
387
|
-
$[
|
|
388
|
-
$[
|
|
389
|
-
$[
|
|
390
|
-
$[
|
|
391
|
-
$[
|
|
392
|
-
$[
|
|
393
|
-
$[
|
|
394
|
-
$[
|
|
395
|
-
$[
|
|
396
|
-
$[
|
|
397
|
-
$[
|
|
436
|
+
$[82] = accountForModel;
|
|
437
|
+
$[83] = accountId;
|
|
438
|
+
$[84] = accounts;
|
|
439
|
+
$[85] = canSelectTeamWhilePersonal;
|
|
440
|
+
$[86] = commit;
|
|
441
|
+
$[87] = disabled;
|
|
442
|
+
$[88] = displayValue;
|
|
443
|
+
$[89] = header;
|
|
444
|
+
$[90] = ladderSteps;
|
|
445
|
+
$[91] = options;
|
|
446
|
+
$[92] = showLadder;
|
|
447
|
+
$[93] = snappedAmong;
|
|
448
|
+
$[94] = t23;
|
|
398
449
|
} else {
|
|
399
|
-
|
|
450
|
+
t23 = $[94];
|
|
400
451
|
}
|
|
401
|
-
let
|
|
402
|
-
if ($[
|
|
403
|
-
|
|
452
|
+
let t24;
|
|
453
|
+
if ($[95] !== t21 || $[96] !== t22 || $[97] !== t23) {
|
|
454
|
+
t24 = /*#__PURE__*/_jsx(PopoverContent, {
|
|
404
455
|
align: "start",
|
|
405
|
-
className:
|
|
406
|
-
onOpenAutoFocus:
|
|
407
|
-
children:
|
|
456
|
+
className: t21,
|
|
457
|
+
onOpenAutoFocus: t22,
|
|
458
|
+
children: t23
|
|
408
459
|
});
|
|
409
|
-
$[
|
|
410
|
-
$[
|
|
411
|
-
$[
|
|
412
|
-
$[
|
|
460
|
+
$[95] = t21;
|
|
461
|
+
$[96] = t22;
|
|
462
|
+
$[97] = t23;
|
|
463
|
+
$[98] = t24;
|
|
413
464
|
} else {
|
|
414
|
-
|
|
465
|
+
t24 = $[98];
|
|
415
466
|
}
|
|
416
|
-
let
|
|
417
|
-
if ($[
|
|
418
|
-
|
|
419
|
-
open:
|
|
420
|
-
onOpenChange:
|
|
421
|
-
children: [
|
|
467
|
+
let t25;
|
|
468
|
+
if ($[99] !== T1 || $[100] !== t14 || $[101] !== t15 || $[102] !== t20 || $[103] !== t24) {
|
|
469
|
+
t25 = /*#__PURE__*/_jsxs(T1, {
|
|
470
|
+
open: t14,
|
|
471
|
+
onOpenChange: t15,
|
|
472
|
+
children: [t20, t24]
|
|
422
473
|
});
|
|
423
|
-
$[
|
|
424
|
-
$[
|
|
425
|
-
$[
|
|
426
|
-
$[
|
|
427
|
-
$[
|
|
428
|
-
$[
|
|
474
|
+
$[99] = T1;
|
|
475
|
+
$[100] = t14;
|
|
476
|
+
$[101] = t15;
|
|
477
|
+
$[102] = t20;
|
|
478
|
+
$[103] = t24;
|
|
479
|
+
$[104] = t25;
|
|
429
480
|
} else {
|
|
430
|
-
|
|
481
|
+
t25 = $[104];
|
|
431
482
|
}
|
|
432
|
-
return
|
|
483
|
+
return t25;
|
|
433
484
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Shared React 19 UI for web apps: one main JavaScript entry (primitives, shell pieces, app helpers including the Convex and Clerk provider, VITE env parsing and ensure-user, artifact viewers over the @vvedantb/server artifacts core, native tokens), third-party brand logos (also @vvedantb/ui/logos), motion-driven animated SVG icons (@vvedantb/ui/icons/animated), a client entry without @vvedantb/server, convex or Clerk for Chrome extensions, design-token CSS, shared Tailwind v4 CSS, a Tailwind preset and packaged Instrument Sans fonts.",
|
|
6
6
|
"type": "module",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState
|
|
1
|
+
import { useState } from "react";
|
|
2
2
|
import { IconBolt, IconChevronDown } from "@tabler/icons-react";
|
|
3
3
|
import { SimpleModelLadder } from "./simple-model-ladder";
|
|
4
4
|
import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover";
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
formatModelDisplayLabel,
|
|
18
18
|
getProviderLabel,
|
|
19
19
|
} from "./model-picker-types";
|
|
20
|
+
import { TraitsPanel, type TraitsMenuProps } from "./prompt-input-traits";
|
|
20
21
|
|
|
21
22
|
export type { ModelAccount, ModelOption };
|
|
22
23
|
export { findModelOption, formatModelDisplayLabel, getProviderLabel };
|
|
@@ -49,6 +50,39 @@ const TRIGGER_CLASS =
|
|
|
49
50
|
export const modelPickerSurfaceClass =
|
|
50
51
|
"w-100 max-w-[calc(100vw-1rem)] overflow-hidden rounded-menu border-0 bg-transparent p-0 shadow-none";
|
|
51
52
|
|
|
53
|
+
/**
|
|
54
|
+
* The selected model's trait controls (reasoning, thinking, context window,
|
|
55
|
+
* Fast). `ModelPicker` pins them above the model list and sums them up on the
|
|
56
|
+
* trigger, so every picker shows traits the same way.
|
|
57
|
+
*/
|
|
58
|
+
export type ModelPickerTraits = Omit<TraitsMenuProps, "className" | "disabled">;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* What the trigger shows after the model name: the reasoning level, "1M" when
|
|
62
|
+
* the 1M context is on, "No thinking" when thinking is off, joined by " · ",
|
|
63
|
+
* and whether Fast is on (the bolt). Only traits the model supports count.
|
|
64
|
+
*/
|
|
65
|
+
export function modelPickerTraitSummary(traits: ModelPickerTraits): {
|
|
66
|
+
suffix: string | undefined;
|
|
67
|
+
fast: boolean;
|
|
68
|
+
} {
|
|
69
|
+
const { config } = traits;
|
|
70
|
+
const parts: string[] = [];
|
|
71
|
+
if (config.reasoning) {
|
|
72
|
+
parts.push(
|
|
73
|
+
traits.getLevelLabel(traits.effortLevel ?? config.reasoning.default),
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
if (config.contextWindow1m && traits.use1mContext) parts.push("1M");
|
|
77
|
+
if (config.thinkingToggle && !traits.thinkingEnabled) {
|
|
78
|
+
parts.push("No thinking");
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
suffix: parts.length > 0 ? parts.join(" · ") : undefined,
|
|
82
|
+
fast: Boolean(config.fastMode && traits.fastMode),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
52
86
|
export interface ModelPickerProps<TModel extends string = string> {
|
|
53
87
|
value: TModel;
|
|
54
88
|
onValueChange: (model: TModel) => void;
|
|
@@ -77,14 +111,10 @@ export interface ModelPickerProps<TModel extends string = string> {
|
|
|
77
111
|
*/
|
|
78
112
|
canSelectTeamWhilePersonal?: boolean;
|
|
79
113
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
114
|
+
* The selected model's traits. Required so no picker drops them by
|
|
115
|
+
* accident: pass `null` only where runs take no traits.
|
|
82
116
|
*/
|
|
83
|
-
|
|
84
|
-
/** Pinned above the model list — typically trait controls. */
|
|
85
|
-
header?: ReactNode;
|
|
86
|
-
/** Bolt before the provider icon when Fast mode is on. */
|
|
87
|
-
showFastIcon?: boolean;
|
|
117
|
+
traits: ModelPickerTraits | null;
|
|
88
118
|
/**
|
|
89
119
|
* Simple-view capability ladder (cheapest → strongest). When at least two of
|
|
90
120
|
* these ids are in `options`, the popover opens on a discrete slider;
|
|
@@ -111,14 +141,18 @@ export function ModelPicker<TModel extends string>({
|
|
|
111
141
|
onAccountChange,
|
|
112
142
|
onSelectionChange,
|
|
113
143
|
canSelectTeamWhilePersonal = true,
|
|
114
|
-
|
|
115
|
-
header,
|
|
116
|
-
showFastIcon,
|
|
144
|
+
traits,
|
|
117
145
|
simpleLadder,
|
|
118
146
|
simpleLadderSnap,
|
|
119
147
|
}: ModelPickerProps<TModel>) {
|
|
120
148
|
const merge = useCn();
|
|
121
149
|
const config = useUiConfig("ModelPicker");
|
|
150
|
+
const summary = traits === null ? null : modelPickerTraitSummary(traits);
|
|
151
|
+
const triggerSuffix = summary?.suffix;
|
|
152
|
+
const header =
|
|
153
|
+
traits === null ? undefined : (
|
|
154
|
+
<TraitsPanel {...traits} disabled={disabled} />
|
|
155
|
+
);
|
|
122
156
|
const [open, setOpen] = useState(false);
|
|
123
157
|
const [advanced, setAdvanced] = useState(false);
|
|
124
158
|
const [previewId, setPreviewId] = useState<TModel | null>(null);
|
|
@@ -208,7 +242,7 @@ export function ModelPicker<TModel extends string>({
|
|
|
208
242
|
)}
|
|
209
243
|
disabled={disabled}
|
|
210
244
|
>
|
|
211
|
-
{
|
|
245
|
+
{summary?.fast ? (
|
|
212
246
|
<span title="Fast" className="inline-flex shrink-0">
|
|
213
247
|
<IconBolt size={12} aria-hidden />
|
|
214
248
|
</span>
|