The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 09:30 UTC
fix(web): model picker stays put with long names and agent options (#28409)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Theo Browne committed
Oct 31, 2026 at 16:19 UTC
575579d68ac4bae09f8426a345d4a3eac1e90c67
18 files changed
+506
-125
apps/server/src/provider/AcpRegistryProbe.test.ts
+1
@@ -229,6 +229,7 @@ describe("ACP Registry probe", () => {
229
{ id: "medium", label: "Medium" },
230
{ id: "high", label: "High" },
231
],
232
+ role: "reasoning",
233
},
234
]);
235
});
apps/server/src/provider/GrokProvider.test.ts
+2
-2
@@ -129,9 +129,9 @@ describe("buildGrokModelCapabilities", () => {
129
type: "select",
130
currentValue: "medium",
131
options: [
132
- { id: "xhigh", label: "Extra High Effort", isDefault: true },
133
- { id: "high", label: "High Effort" },
132
{ id: "medium", label: "Medium Effort" },
133
+ { id: "high", label: "High Effort" },
134
+ { id: "xhigh", label: "Extra High Effort", isDefault: true },
135
],
136
},
137
]);
apps/web/src/components/chat/ComposerModelEffort.browser.test.tsx
new
+125
@@ -0,0 +1,125 @@
1
+import {
2
+ ProviderDriverKind,
3
+ ProviderInstanceId,
4
+ type ProviderOptionSelection,
5
+ type ServerProviderModel,
6
+} from "@t3tools/contracts";
7
+import { createModelCapabilities } from "@t3tools/shared/model";
8
+import { useState } from "react";
9
+import { expect, it } from "vite-plus/test";
10
+import { page, userEvent } from "vite-plus/test/browser";
11
+
12
+import { render } from "../../../test/render";
13
+import { ComposerEffortColumn, describeComposerEffort } from "./ComposerModelEffort";
14
+import type { TraitsSelectionInput } from "./TraitsPicker";
15
+
16
+// Shaped like Devin over ACP: its session mode comes first, and its reasoning id is its own.
17
+const models: ReadonlyArray<ServerProviderModel> = [
18
+ {
19
+ slug: "fusion",
20
+ name: "Fusion (Claude Opus 5.5 Medium + SWE-2 High)",
21
+ isCustom: false,
22
+ capabilities: createModelCapabilities({
23
+ optionDescriptors: [
24
+ {
25
+ id: "mode",
26
+ label: "Session Mode",
27
+ type: "select",
28
+ currentValue: "bypass",
29
+ options: [
30
+ { id: "code", label: "Code" },
31
+ { id: "plan", label: "Plan" },
32
+ { id: "bypass", label: "Bypass Permissions" },
33
+ ],
34
+ },
35
+ {
36
+ id: "thought_level",
37
+ label: "Thinking",
38
+ type: "select",
39
+ role: "reasoning",
40
+ currentValue: "medium",
41
+ options: [
42
+ { id: "low", label: "Low" },
43
+ { id: "medium", label: "Medium" },
44
+ { id: "high", label: "High" },
45
+ ],
46
+ },
47
+ {
48
+ id: "speed",
49
+ label: "Speed",
50
+ type: "select",
51
+ currentValue: "standard",
52
+ options: [
53
+ { id: "standard", label: "Standard" },
54
+ { id: "fast", label: "Fast" },
55
+ ],
56
+ },
57
+ { id: "auto_approve", label: "Auto-approve tools", type: "boolean", currentValue: false },
58
+ ],
59
+ }),
60
+ },
61
+];
62
+
63
+function traitsInput(
64
+ modelOptions: ReadonlyArray<ProviderOptionSelection>,
65
+ onModelOptionsChange: (next: ReadonlyArray<ProviderOptionSelection> | undefined) => void,
66
+): TraitsSelectionInput {
67
+ return {
68
+ provider: ProviderDriverKind.make("acpRegistry"),
69
+ instanceId: ProviderInstanceId.make("devin"),
70
+ models,
71
+ model: "fusion",
72
+ modelOptions,
73
+ planModeEnabled: false,
74
+ onModelOptionsChange,
75
+ };
76
+}
77
+
78
+function Column() {
79
+ const [options, setOptions] = useState<ReadonlyArray<ProviderOptionSelection>>([]);
80
+ const traits = traitsInput(options, (next) => setOptions(next ?? []));
81
+ return (
82
+ <>
83
+ <div data-model-picker-effort>
84
+ <ComposerEffortColumn traits={traits} />
85
+ </div>
86
+ <p role="status">{describeComposerEffort(traits, "bars", "sm").suffix}</p>
87
+ </>
88
+ );
89
+}
90
+
91
+it("draws an agent's reasoning as bars and keeps its mode out of the levels", async () => {
92
+ await using screen = await render(<Column />, { router: false }); // no routes involved
93
+ const status = screen.getByRole("status");
94
+ expect(status.element().querySelector("[data-composer-effort-glyph]")).not.toBeNull();
95
+ await expect.element(status).toHaveTextContent("");
96
+
97
+ const levels = screen.getByRole("radiogroup", { name: "Thinking" });
98
+ await expect.element(levels.getByRole("radio")).toHaveLength(3);
99
+ await expect.element(screen.getByRole("radio", { name: "Plan" })).not.toBeInTheDocument();
100
+
101
+ // Up and Down walk from the levels through the option rows without opening their menus.
102
+ await userEvent.tab();
103
+ await expect.element(screen.getByRole("radio", { name: "Medium" })).toHaveFocus();
104
+ await userEvent.keyboard("{ArrowDown}{ArrowDown}{ArrowDown}");
105
+ const speed = screen.getByRole("button", { name: "Speed: Standard" });
106
+ await expect.element(speed).toHaveFocus();
107
+ await expect.element(page.getByRole("menuitemradio")).not.toBeInTheDocument();
108
+ await userEvent.keyboard("{ArrowRight}");
109
+ await expect.element(page.getByRole("menuitemradio", { name: "Standard" })).toHaveFocus();
110
+ await userEvent.keyboard("{ArrowLeft}");
111
+ await expect.element(page.getByRole("menuitemradio")).not.toBeInTheDocument();
112
+ await expect.element(speed).toHaveFocus();
113
+
114
+ await userEvent.click(screen.getByText("Auto-approve tools"));
115
+ await expect
116
+ .element(screen.getByRole("switch", { name: "Auto-approve tools" }))
117
+ .toHaveAttribute("aria-checked", "true");
118
+
119
+ await userEvent.click(screen.getByRole("button", { name: "Session Mode: Bypass Permissions" }));
120
+ await userEvent.click(page.getByRole("menuitemradio", { name: "Plan" }));
121
+ await expect
122
+ .element(screen.getByRole("button", { name: "Session Mode: Plan" }))
123
+ .toBeInTheDocument();
124
+ await expect.element(page.getByRole("menuitemradio")).not.toBeInTheDocument();
125
+});
apps/web/src/components/chat/ComposerModelEffort.tsx
+270
-80
@@ -1,16 +1,25 @@
1
import {
2
buildTraitsTriggerDisplay,
3
getDescriptorStringValue,
4
- REASONING_SELECT_DESCRIPTOR_IDS,
4
+ isReasoningControl,
5
selectableProviderOptionChoices,
6
} from "@t3tools/client-runtime/model-traits";
7
import type { ProviderOptionDescriptor, RuntimeMode } from "@t3tools/contracts";
8
import type { EffortDisplay } from "@t3tools/contracts/settings";
9
-import { CheckIcon, ChevronUpIcon } from "lucide-react";
10
-import { type KeyboardEvent, type ReactNode, use, useRef } from "react";
9
+import { getProviderOptionCurrentLabel } from "@t3tools/shared/model";
10
+import { CheckIcon, ChevronRightIcon, ChevronUpIcon } from "lucide-react";
11
+import { type KeyboardEvent, type ReactNode, use, useRef, useState } from "react";
12
13
import { cn } from "~/lib/utils";
13
-import { Menu, MenuPopup, MenuTrigger } from "../ui/menu";
14
+import {
15
+ Menu,
16
+ MenuPopup,
17
+ MenuRadioGroup,
18
+ MenuRadioItem,
19
+ MenuRadioItemIndicator,
20
+ MenuTrigger,
21
+} from "../ui/menu";
22
+import { Switch } from "../ui/switch";
23
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
24
import type { ComposerControlSize } from "./ComposerControl";
25
import { ComposerPermissionsSection, type RuntimeModeOption } from "./ComposerFooterControls";
@@ -51,8 +60,8 @@ type ColumnControl =
60
| { kind: "boolean"; descriptor: BooleanDescriptor };
61
62
/**
54
- * The column lists the model's reasoning control first, under the header that names it, then
55
- * its other options.
63
+ * The column lists the model's reasoning levels under the header that names it. Other options,
64
+ * such as an agent's session mode, sit below as one row each.
65
*/
66
function columnControls(
67
provider: TraitsSelectionInput["provider"],
@@ -64,8 +73,7 @@ function columnControls(
73
...columnSelects.map((descriptor) => ({ kind: "select" as const, descriptor })),
74
...columnToggles.map((descriptor) => ({ kind: "boolean" as const, descriptor })),
75
];
67
- const effort =
68
- controls.find((control) => REASONING_SELECT_DESCRIPTOR_IDS.has(control.descriptor.id)) ?? null;
76
+ const effort = controls.find((control) => isReasoningControl(control.descriptor)) ?? null;
77
return { effort, others: controls.filter((control) => control !== effort) };
78
}
79
@@ -94,20 +102,40 @@ export function describeComposerEffort(
102
modelSelection,
103
reportedModelSelection: traits.reportedModelSelection,
104
});
105
+ // The same reasoning control the column lists, wherever the agent put it among its options.
106
+ const reasoning =
107
+ columnControls(traits.provider, visibility.selectDescriptors, visibility.booleanDescriptors)
108
+ .effort?.descriptor ?? null;
109
+ const ultrathink = visibility.ultrathinkPromptControlled && reasoning === primary;
110
const glyph =
98
- primary && REASONING_SELECT_DESCRIPTOR_IDS.has(primary.id)
111
+ reasoning?.type === "select"
112
? resolveEffortGlyph(
100
- primary,
101
- visibility.ultrathinkPromptControlled
113
+ reasoning,
114
+ ultrathink
115
? "ultrathink"
103
- : getDescriptorStringValue(primary, modelSelection, traits.reportedModelSelection),
116
+ : getDescriptorStringValue(reasoning, modelSelection, traits.reportedModelSelection),
117
)
118
: null;
106
- // Without a reasoning select the whole label is the word; it already names speed and the rest.
119
// Workflow levels such as Ultracode always show their name; the setting names every level.
120
const word = glyph
121
? (glyph.special ?? (effortDisplay === "label" ? glyph.label : null))
110
- : display.label;
122
+ : !reasoning
123
+ ? null
124
+ : reasoning.type === "boolean"
125
+ ? `${reasoning.label} ${reasoning.currentValue === true ? "On" : "Off"}`
126
+ : ultrathink
127
+ ? "Ultrathink"
128
+ : getProviderOptionCurrentLabel(reasoning, modelSelection, traits.reportedModelSelection);
129
+ const fast = display.speedLabel === "Fast" || display.speedLabel === "Ultrafast";
130
+ // Agent options such as modes live in the picker; the trigger adds only the context window.
131
+ const contextWindow =
132
+ visibility.contextWindowDescriptor &&
133
+ getProviderOptionCurrentLabel(
134
+ visibility.contextWindowDescriptor,
135
+ modelSelection,
136
+ traits.reportedModelSelection,
137
+ );
138
+ if (!word && !glyph && !fast && !contextWindow) return { suffix: null, detail: display.label };
139
return {
140
detail: display.label,
141
suffix: (
@@ -118,22 +146,22 @@ export function describeComposerEffort(
146
size === "sm" && "-ms-0.5",
147
)}
148
>
121
- {word !== null ? (
122
- <span data-composer-control-label>{word}</span>
149
+ {word ? (
150
+ <span data-composer-control-label className="max-w-24 truncate">
151
+ {word}
152
+ </span>
153
) : glyph ? (
154
<EffortGlyph count={glyph.count} filled={glyph.filled} size={size} />
155
) : null}
126
- {glyph && (display.speedLabel === "Fast" || display.speedLabel === "Ultrafast") ? (
127
- <FastBolt ultra={display.speedLabel === "Ultrafast"} />
128
- ) : null}
129
- {glyph && display.otherLabels.length > 0 ? (
156
+ {fast ? <FastBolt ultra={display.speedLabel === "Ultrafast"} /> : null}
157
+ {contextWindow ? (
158
<span
159
// A label, so icon-only footers drop it; compacted rows drop it before the model.
160
data-composer-control-label
161
data-composer-secondary-trait
162
className="max-w-24 truncate text-xs"
163
>
136
- {display.otherLabels.join(" · ")}
164
+ {contextWindow}
165
</span>
166
) : null}
167
</span>
@@ -150,10 +178,10 @@ function ColumnRow(props: {
178
/** Shown on hover; the column is too narrow to print it under the label. */
179
description?: string | undefined;
180
selected: boolean;
181
+ /** The column's one tab stop: the selected level, else the first when none shows as selected. */
182
+ tabStop: boolean;
183
isDefault?: boolean | undefined;
184
disabled?: boolean;
155
- /** A level of the reasoning control, where focus lands after a model pick. */
156
- level: boolean;
185
onPick: () => void;
186
}) {
187
const rowProps = {
@@ -162,9 +190,10 @@ function ColumnRow(props: {
190
"aria-checked": props.selected,
191
disabled: props.disabled,
192
"data-effort-row": true,
165
- "data-effort-level": props.level || undefined,
166
- // The reasoning control holds the column's one tab stop; Up and Down move between rows.
167
- tabIndex: props.selected && props.level ? 0 : -1,
193
+ // Focus lands on a level after a model pick.
194
+ "data-effort-level": true,
195
+ // Up and Down move between rows.
196
+ tabIndex: props.tabStop ? 0 : -1,
197
className: COLUMN_ROW,
198
onClick: props.onPick,
199
} as const;
@@ -194,6 +223,8 @@ function ColumnRow(props: {
223
224
function moveBetweenRows(event: KeyboardEvent<HTMLElement>) {
225
if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
226
+ // An option's side menu is a React child here, but it moves through its own items.
227
+ if (!event.currentTarget.contains(event.target as Node)) return;
228
const rows = Array.from(
229
event.currentTarget.querySelectorAll<HTMLButtonElement>("[data-effort-row]:not(:disabled)"),
230
);
@@ -230,66 +261,222 @@ function EffortLevels(props: { traits: TraitsSelectionInput }) {
261
);
262
}
263
if (!effort && others.length === 0) return <NoEffortRow />;
233
- const renderControl = (control: ColumnControl) => {
234
- const isEffort = control === effort;
235
- const { descriptor } = control;
236
- if (control.kind === "boolean") {
237
- return (
264
+ // Ultrathink in the prompt locks the levels; the first option then holds the tab stop.
265
+ const locked =
266
+ effort?.descriptor.id === traits.primarySelectDescriptor?.id && traits.ultrathinkInBodyText;
267
+ return (
268
+ <>
269
+ {effort ? <EffortRows control={effort} traits={traits} locked={locked} /> : null}
270
+ {others.length > 0 ? (
271
<div
239
- key={descriptor.id}
240
- role="radiogroup"
241
- aria-label={descriptor.label}
242
- className="flex flex-col gap-0.5"
272
+ className={cn("flex flex-col gap-0.5", effort && "mt-1 border-t border-border/70 pt-1")}
273
>
244
- {isEffort ? null : <div className={COLUMN_LABEL}>{descriptor.label}</div>}
245
- {([true, false] as const).map((value) => (
246
- <ColumnRow
247
- key={String(value)}
248
- label={value ? "On" : "Off"}
249
- selected={(control.descriptor.currentValue === true) === value}
250
- level={isEffort}
251
- onPick={() => traits.changeBoolean(descriptor.id, value)}
252
- />
253
- ))}
274
+ {others.map((control, index) =>
275
+ control.kind === "boolean" ? (
276
+ <OptionSwitchRow
277
+ key={control.descriptor.id}
278
+ descriptor={control.descriptor}
279
+ traits={traits}
280
+ tabStop={(!effort || locked) && index === 0}
281
+ />
282
+ ) : (
283
+ <OptionMenuRow
284
+ key={control.descriptor.id}
285
+ descriptor={control.descriptor}
286
+ traits={traits}
287
+ tabStop={(!effort || locked) && index === 0}
288
+ />
289
+ ),
290
+ )}
291
</div>
255
- );
256
- }
257
- const locked =
258
- descriptor.id === traits.primarySelectDescriptor?.id && traits.ultrathinkInBodyText;
259
- const value = traits.selectValue(control.descriptor);
292
+ ) : null}
293
+ </>
294
+ );
295
+}
296
+
297
+type TraitsSelection = ReturnType<typeof useTraitsSelection>;
298
+
299
+function EffortRows(props: { control: ColumnControl; traits: TraitsSelection; locked: boolean }) {
300
+ const { control, traits } = props;
301
+ const { descriptor } = control;
302
+ if (control.kind === "boolean") {
303
return (
261
- <div
262
- key={descriptor.id}
263
- role="radiogroup"
264
- aria-label={descriptor.label}
265
- className="flex flex-col gap-0.5"
266
- >
267
- {isEffort ? null : <div className={COLUMN_LABEL}>{descriptor.label}</div>}
268
- {locked ? (
269
- <div className="px-2 pb-1.5 text-muted-foreground/80 text-xs">
270
- {ULTRATHINK_IN_BODY_NOTE}
271
- </div>
272
- ) : null}
273
- {selectableProviderOptionChoices(control.descriptor).map((option) => (
304
+ <div role="radiogroup" aria-label={descriptor.label} className="flex flex-col gap-0.5">
305
+ {([true, false] as const).map((value) => (
306
<ColumnRow
275
- key={option.id}
276
- label={option.label}
277
- selected={option.id === value}
278
- description={option.description}
279
- isDefault={option.isDefault}
280
- disabled={locked}
281
- level={isEffort}
282
- onPick={() => traits.changeSelect(control.descriptor, option.id)}
307
+ key={String(value)}
308
+ label={value ? "On" : "Off"}
309
+ selected={(control.descriptor.currentValue === true) === value}
310
+ tabStop={(control.descriptor.currentValue === true) === value}
311
+ onPick={() => traits.changeBoolean(descriptor.id, value)}
312
/>
313
))}
314
</div>
315
);
287
- };
316
+ }
317
+ const { locked } = props;
318
+ const value = traits.selectValue(control.descriptor);
319
+ const choices = selectableProviderOptionChoices(control.descriptor);
320
+ // An "Ultrathink:" prefix selects a level the column does not offer.
321
+ const shown = choices.some((option) => option.id === value);
322
return (
289
- <>
290
- {effort ? renderControl(effort) : null}
291
- {others.map(renderControl)}
292
- </>
323
+ <div role="radiogroup" aria-label={descriptor.label} className="flex flex-col gap-0.5">
324
+ {locked ? (
325
+ <div className="px-2 pb-1.5 text-muted-foreground/80 text-xs">
326
+ {ULTRATHINK_IN_BODY_NOTE}
327
+ </div>
328
+ ) : null}
329
+ {choices.map((option, index) => (
330
+ <ColumnRow
331
+ key={option.id}
332
+ label={option.label}
333
+ selected={option.id === value}
334
+ tabStop={shown ? option.id === value : index === 0}
335
+ description={option.description}
336
+ isDefault={option.isDefault}
337
+ disabled={locked}
338
+ onPick={() => traits.changeSelect(control.descriptor, option.id)}
339
+ />
340
+ ))}
341
+ </div>
342
+ );
343
+}
344
+
345
+const OPTION_ROW = cn(COLUMN_ROW, "h-auto py-1");
346
+
347
+/** An option's name over its current value. */
348
+function OptionRowText(props: { label: string; value: string }) {
349
+ return (
350
+ <span className="flex min-w-0 flex-1 flex-col">
351
+ <span className="truncate text-muted-foreground text-xs">{props.label}</span>
352
+ <span className="truncate">{props.value}</span>
353
+ </span>
354
+ );
355
+}
356
+
357
+/**
358
+ * One select besides reasoning, such as an agent's session mode. It names the current choice and
359
+ * opens the rest beside the column, so any number of options leaves the levels in place.
360
+ */
361
+function OptionMenuRow(props: {
362
+ descriptor: SelectDescriptor;
363
+ traits: TraitsSelection;
364
+ /** Holds the column's tab stop when the model has no levels. */
365
+ tabStop: boolean;
366
+}) {
367
+ const { descriptor, traits } = props;
368
+ const [open, setOpen] = useState(false);
369
+ const popupRef = useRef<HTMLDivElement>(null);
370
+ const choices = selectableProviderOptionChoices(descriptor);
371
+ const value = traits.selectValue(descriptor);
372
+ const current = choices.find((choice) => choice.id === value)?.label ?? "";
373
+ return (
374
+ <Menu
375
+ open={open}
376
+ // A modal menu would cover the picker, so the next click there would only close it.
377
+ modal={false}
378
+ onOpenChange={setOpen}
379
+ onOpenChangeComplete={(isOpen) => {
380
+ if (!isOpen) return;
381
+ const checked = popupRef.current?.querySelector<HTMLElement>(
382
+ '[role="menuitemradio"][aria-checked="true"]',
383
+ );
384
+ checked?.focus({ preventScroll: true });
385
+ checked?.scrollIntoView({ block: "nearest" });
386
+ }}
387
+ >
388
+ {/* No hover opening: an opened menu takes focus, which would steal typing from search. */}
389
+ <MenuTrigger
390
+ render={
391
+ <button
392
+ type="button"
393
+ data-effort-row
394
+ tabIndex={props.tabStop ? 0 : -1}
395
+ aria-label={`${descriptor.label}: ${current}`}
396
+ className={cn(OPTION_ROW, "data-popup-open:bg-foreground/[0.09]")}
397
+ onKeyDown={(event) => {
398
+ if (event.key !== "ArrowRight") return;
399
+ event.preventDefault();
400
+ event.stopPropagation();
401
+ setOpen(true);
402
+ }}
403
+ />
404
+ }
405
+ >
406
+ <OptionRowText label={descriptor.label} value={current} />
407
+ <ChevronRightIcon
408
+ aria-hidden="true"
409
+ className="-me-1 size-3.5 shrink-0 text-muted-foreground"
410
+ />
411
+ </MenuTrigger>
412
+ <MenuPopup
413
+ ref={popupRef}
414
+ side="right"
415
+ align="start"
416
+ sideOffset={6}
417
+ // A full-width column on phones leaves no room beside it, so fall below or above.
418
+ collisionAvoidance={{ fallbackAxisSide: "end" }}
419
+ className="max-w-72"
420
+ data-model-picker-option-menu
421
+ {...composerFloatingLayerProps}
422
+ onKeyDown={(event) => {
423
+ if (event.key !== "ArrowLeft") return;
424
+ event.preventDefault();
425
+ event.stopPropagation();
426
+ setOpen(false);
427
+ }}
428
+ >
429
+ <MenuRadioGroup
430
+ aria-label={descriptor.label}
431
+ value={value}
432
+ onValueChange={(next: string) => {
433
+ if (next !== value) traits.changeSelect(descriptor, next);
434
+ }}
435
+ >
436
+ {choices.map((choice) => (
437
+ <MenuRadioItem key={choice.id} value={choice.id} closeOnClick>
438
+ <span className="flex items-center gap-3">
439
+ <span className="flex min-w-0 flex-1 flex-col">
440
+ <span className="truncate">{choice.label}</span>
441
+ {choice.description ? (
442
+ <span className="line-clamp-2 text-muted-foreground text-xs">
443
+ {choice.description}
444
+ </span>
445
+ ) : null}
446
+ </span>
447
+ {choice.isDefault ? (
448
+ <span className="text-muted-foreground/70 text-xs">Default</span>
449
+ ) : null}
450
+ <MenuRadioItemIndicator />
451
+ </span>
452
+ </MenuRadioItem>
453
+ ))}
454
+ </MenuRadioGroup>
455
+ </MenuPopup>
456
+ </Menu>
457
+ );
458
+}
459
+
460
+/** A two-state option toggles in place; a menu would add a click for nothing. */
461
+function OptionSwitchRow(props: {
462
+ descriptor: BooleanDescriptor;
463
+ traits: TraitsSelection;
464
+ tabStop: boolean;
465
+}) {
466
+ const { descriptor, traits } = props;
467
+ const checked = descriptor.currentValue === true;
468
+ return (
469
+ <label className={cn(OPTION_ROW, "has-focus-visible:bg-foreground/[0.09]")}>
470
+ <OptionRowText label={descriptor.label} value={checked ? "On" : "Off"} />
471
+ <Switch
472
+ size="sm"
473
+ checked={checked}
474
+ onCheckedChange={(next) => traits.changeBoolean(descriptor.id, next)}
475
+ aria-label={descriptor.label}
476
+ data-effort-row
477
+ tabIndex={props.tabStop ? 0 : -1}
478
+ />
479
+ </label>
480
);
481
}
482
@@ -303,20 +490,22 @@ function NoEffortRow() {
490
export function ComposerEffortColumn(props: { traits: TraitsSelectionInput | null }) {
491
const picker = use(DockedPickerContext);
492
const visibility = props.traits ? getTraitsSectionVisibility(props.traits) : null;
306
- const effort =
493
+ const controls =
494
props.traits && visibility
495
? columnControls(
496
props.traits.provider,
497
visibility.selectDescriptors,
498
visibility.booleanDescriptors,
312
- ).effort
499
+ )
500
: null;
501
return (
502
<>
503
{/* Matches the search row's box, so one rule runs across the top of the popup. */}
504
<div className="shrink-0 px-3 pt-2.5">
505
<div className="flex h-8.25 -translate-y-px items-center gap-2 border-b border-border/70 pb-1.5 text-sm">
319
- <span className="text-muted-foreground">{effort?.descriptor.label ?? "Effort"}</span>
506
+ <span className="text-muted-foreground">
507
+ {controls?.effort?.descriptor.label ?? (controls?.others.length ? "Options" : "Effort")}
508
+ </span>
509
<span className="ms-auto min-w-0 truncate text-muted-foreground text-xs">
510
{picker.modelLabel}
511
</span>
@@ -325,7 +514,8 @@ export function ComposerEffortColumn(props: { traits: TraitsSelectionInput | nul
514
{/* pt-2.5 puts the first level on the same line as the first model. */}
515
<div
516
className="flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto overscroll-contain px-2 pt-2.5 pb-1.5"
328
- onKeyDown={moveBetweenRows}
517
+ // Capture, so Up and Down on an option row move rows instead of opening its menu.
518
+ onKeyDownCapture={moveBetweenRows}
519
>
520
{props.traits ? <EffortLevels traits={props.traits} /> : <NoEffortRow />}
521
</div>
apps/web/src/components/chat/EffortGlyph.test.ts
+3
-1
@@ -45,9 +45,11 @@ describe("resolveEffortGlyph", () => {
45
});
46
});
47
48
- it("falls back to the word when the value is unknown or the scale has one level", () => {
48
+ it("falls back to the word when the value is unknown or the scale is too short or long", () => {
49
expect(resolveEffortGlyph(claude, "unknown")).toBeNull();
50
expect(resolveEffortGlyph(descriptor(["high"]), "high")).toBeNull();
51
+ const levels = Array.from({ length: 8 }, (_, index) => `level${index}`);
52
+ expect(resolveEffortGlyph(descriptor(levels), "level0")).toBeNull();
53
});
54
});
55
apps/web/src/components/chat/EffortGlyph.tsx
+3
-1
@@ -14,6 +14,8 @@ type SelectDescriptor = Extract<ProviderOptionDescriptor, { type: "select" }>;
14
// Max is named too, so the full scale stops short of it.
15
const NAMED_LEVELS = new Set(["ultracode", "max"]);
16
const OFF_LEVELS = new Set(["off", "none"]);
17
+// More bars than this no longer fit the glyph's height in whole pixels.
18
+const MAX_BARS = 7;
19
20
/**
21
* Maps a reasoning select to bars: one per ordinary level, filled up to the current one, with an
@@ -22,7 +24,7 @@ const OFF_LEVELS = new Set(["off", "none"]);
24
export function resolveEffortGlyph(descriptor: SelectDescriptor, current: string | null) {
25
const special = new Set([...(descriptor.promptInjectedValues ?? []), ...NAMED_LEVELS]);
26
const levels = descriptor.options.filter((option) => !special.has(option.id));
25
- if (levels.length < 2 || current === null) return null;
27
+ if (levels.length < 2 || levels.length > MAX_BARS || current === null) return null;
28
const startsAtOff = OFF_LEVELS.has(levels[0]!.id);
29
const count = startsAtOff ? levels.length - 1 : levels.length;
30
if (special.has(current)) {
apps/web/src/components/chat/ModelListRow.tsx
+8
-1
@@ -67,7 +67,14 @@ export const ModelListRow = memo(function ModelListRow(props: {
67
badgeClassName="right-[-0.125rem] bottom-[-0.125rem] h-3 min-w-3 px-0.5 text-5xs"
68
/>
69
<div className="flex min-w-0 flex-1 items-center gap-2 text-left">
70
- <div className="min-w-0 truncate text-sm font-normal leading-snug">
70
+ <div
71
+ className="min-w-0 truncate text-sm font-normal leading-snug"
72
+ // Names the row in full on hover only when it is cut off.
73
+ onPointerEnter={(event) => {
74
+ const name = event.currentTarget;
75
+ name.title = name.scrollWidth > name.clientWidth ? getDisplayModelName(model) : "";
76
+ }}
77
+ >
78
{getDisplayModelName(model)}
79
{/* The logo is decorative, so name the provider for screen readers. */}
80
<span className="sr-only">, {props.providerDisplayName}</span>
apps/web/src/components/chat/ModelPickerContent.tsx
+12
-8
@@ -366,6 +366,8 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
366
docked?: boolean;
367
/** Right at the end of the search text moves into the popup's effort column. */
368
onFocusEffort?: () => void;
369
+ /** Closes the list column, inside the popup's fixed height. */
370
+ listFooter?: ReactNode;
371
}) {
372
const {
373
searchInputRef,
@@ -838,16 +840,17 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
840
ref={pickerContentRef}
841
className={cn(
842
"relative flex w-screen max-w-90 flex-row overflow-hidden",
841
- props.docked
842
- ? "max-sm:h-56 max-sm:min-h-0! max-sm:w-full max-sm:max-w-none"
843
- : "max-h-86.5",
843
+ props.docked ? "max-sm:h-56 max-sm:w-full max-sm:max-w-none" : "max-h-86.5",
844
)}
845
+ // Docked, the popup sets the height; a minimum here would overflow short windows.
846
style={
846
- isSearching
847
- ? { height: searchHeight }
848
- : {
849
- minHeight: `min(calc(var(--spacing) * ${tallestTabUnits + LIST_CHROME_UNITS} + 1px), calc(var(--spacing) * 86.5))`,
850
- }
847
+ props.docked
848
+ ? undefined
849
+ : isSearching
850
+ ? { height: searchHeight }
851
+ : {
852
+ minHeight: `min(calc(var(--spacing) * ${tallestTabUnits + LIST_CHROME_UNITS} + 1px), calc(var(--spacing) * 86.5))`,
853
+ }
854
}
855
data-model-picker-content="true"
856
>
@@ -1072,6 +1075,7 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
1075
onRequestClose={onRequestClose}
1076
onOpenProviderSetup={onOpenProviderSetup}
1077
/>
1078
+ {props.listFooter}
1079
</div>
1080
</Combobox>
1081
</div>
apps/web/src/components/chat/ProviderModelPicker.tsx
+35
-12
@@ -37,7 +37,9 @@ function lockBackgroundScroll(popup: HTMLElement | null) {
37
const shouldAllowOverlayScroll = (target: EventTarget | null) => {
38
return (
39
target instanceof Element &&
40
- target.closest("[data-model-picker-content], [data-model-picker-effort]")
40
+ target.closest(
41
+ "[data-model-picker-content], [data-model-picker-effort], [data-model-picker-option-menu]",
42
+ )
43
);
44
};
45
const preventBackgroundWheel = (event: WheelEvent) => {
@@ -154,16 +156,22 @@ export const ProviderModelPicker = memo(function ProviderModelPicker(props: {
156
157
/**
158
* Focuses the selected reasoning level, else the first level. With `rows: "any"` it falls back
157
- * to the column's other options. False when nothing took focus.
159
+ * to the column's first enabled option. False when nothing took focus.
160
*/
161
const focusEffort = (rows: "levels" | "any") => {
162
const column = popupRef.current?.querySelector("[data-model-picker-effort]");
161
- const first = (selector: string) =>
162
- column?.querySelector<HTMLElement>(`${selector}[aria-checked="true"]:not(:disabled)`) ??
163
- column?.querySelector<HTMLElement>(`${selector}:not(:disabled)`);
163
+ const level =
164
+ column?.querySelector<HTMLElement>(
165
+ '[data-effort-level][aria-checked="true"]:not(:disabled)',
166
+ ) ?? column?.querySelector<HTMLElement>("[data-effort-level]:not(:disabled)");
167
+ // No aria-checked here: an On switch is checked but is not where focus belongs.
168
const row =
165
- first("[data-effort-level]") ?? (rows === "any" ? first("[data-effort-row]") : null);
169
+ level ??
170
+ (rows === "any"
171
+ ? column?.querySelector<HTMLElement>("[data-effort-row]:not(:disabled)")
172
+ : null);
173
row?.focus({ preventScroll: true });
174
+ row?.scrollIntoView({ block: "nearest" });
175
return row != null;
176
};
177
const openTarget = (target: "effort" | "permissions") => {
@@ -230,7 +238,11 @@ export const ProviderModelPicker = memo(function ProviderModelPicker(props: {
238
239
const triggerText = props.triggerLabel ?? multipleLabel ?? triggerTitle;
240
const triggerTextProps = {
233
- className: "min-w-0 flex-1 overflow-hidden truncate",
241
+ className: cn(
242
+ "min-w-0 flex-1 overflow-hidden truncate",
243
+ // Long names such as "Fusion (Claude Opus 5.5 Medium + SWE-2 High)" would push the composer.
244
+ props.isComposerOwned && "max-w-56",
245
+ ),
246
"data-chat-provider-model-picker-label": "true",
247
} as const;
248
@@ -262,7 +274,16 @@ export const ProviderModelPicker = memo(function ProviderModelPicker(props: {
274
: (props.getModelDisabledReason?.(instanceId, model) ?? null)
275
}
276
onInstanceModelChange={handleInstanceModelChange}
265
- {...(docked ? { docked, onFocusEffort: () => void focusEffort("any") } : {})}
277
+ {...(docked
278
+ ? {
279
+ docked,
280
+ onFocusEffort: () => void focusEffort("any"),
281
+ // Inside the fixed height, so switching to or from a ChatGPT plan never resizes it.
282
+ ...(props.selectedModels === undefined
283
+ ? { listFooter: <ChatGptSharingControl provider={activeEntry?.snapshot ?? null} /> }
284
+ : {}),
285
+ }
286
+ : {})}
287
/>
288
);
289
@@ -401,12 +422,14 @@ export const ProviderModelPicker = memo(function ProviderModelPicker(props: {
422
>
423
{props.effortColumn ? (
424
<DockedPickerContext value={{ modelLabel: triggerTitle }}>
404
- <div className="flex flex-col">
405
- <div className="flex max-h-86.5 max-sm:max-h-none max-sm:flex-col">
425
+ <div className="flex max-h-(--available-height) flex-col">
426
+ {/* One fixed height, so a model with more options never resizes the popup. Short
427
+ windows shrink it and keep the footer. */}
428
+ <div className="flex h-86.5 min-h-0 max-sm:h-auto max-sm:flex-col">
429
{picker}
430
<div
431
data-model-picker-effort
409
- className="flex min-h-0 w-48 shrink-0 flex-col border-l border-border/70 bg-muted/40 max-sm:max-h-64 max-sm:w-full max-sm:border-t max-sm:border-l-0"
432
+ className="flex min-h-0 w-48 flex-col sm:shrink-0 border-l border-border/70 bg-muted/40 max-sm:h-64 max-sm:w-full max-sm:border-t max-sm:border-l-0"
433
onKeyDown={(event) => {
434
if (event.key !== "ArrowLeft" || event.altKey || event.ctrlKey || event.metaKey)
435
return;
@@ -424,7 +447,7 @@ export const ProviderModelPicker = memo(function ProviderModelPicker(props: {
447
) : (
448
picker
449
)}
427
- {props.selectedModels === undefined ? (
450
+ {props.selectedModels === undefined && !docked ? (
451
<ChatGptSharingControl provider={activeEntry?.snapshot ?? null} />
452
) : null}
453
</PopoverPopup>
apps/web/src/components/chat/TraitsPicker.tsx
+2
-4
@@ -4,7 +4,7 @@ import {
4
getTraitSelectChange,
5
replaceDescriptorCurrentValue,
6
selectableProviderOptionChoices,
7
- REASONING_SELECT_DESCRIPTOR_IDS,
7
+ isReasoningSelect,
8
} from "@t3tools/client-runtime/model-traits";
9
import {
10
type ModelSelection,
@@ -254,9 +254,7 @@ export function getReasoningTraitStep(input: {
254
input.planModeEnabled,
255
);
256
if (selected.modelIsUnavailable || selected.ultrathinkInBodyText) return null;
257
- const descriptor = selected.selectDescriptors.find((entry) =>
258
- REASONING_SELECT_DESCRIPTOR_IDS.has(entry.id),
259
- );
257
+ const descriptor = selected.selectDescriptors.find(isReasoningSelect);
258
const choices = descriptor ? selectableProviderOptionChoices(descriptor) : [];
259
if (!descriptor || choices.length < 2) return null;
260
const isPrimary = descriptor.id === selected.primarySelectDescriptor?.id;
apps/web/src/components/chat/restingComposerControlsMeasurement.ts
+11
-1
@@ -25,8 +25,18 @@ function providerModelPickerNaturalWidth(picker: HTMLElement): number {
25
const style = getComputedStyle(picker);
26
const label = picker.querySelector<HTMLElement>('[data-chat-provider-model-picker-label="true"]');
27
const labelIsCollapsed = label?.clientWidth === 0 && getComputedStyle(label).flexGrow === "0";
28
+ // A label with its own max width, such as a long model name, never grows past it.
29
+ const labelMaxWidth = label ? Number.parseFloat(getComputedStyle(label).maxWidth) : Number.NaN;
30
const hiddenLabelWidth =
29
- label && !labelIsCollapsed ? Math.max(0, label.scrollWidth - label.clientWidth) : 0;
31
+ label && !labelIsCollapsed
32
+ ? Math.max(
33
+ 0,
34
+ Math.min(
35
+ label.scrollWidth,
36
+ Number.isFinite(labelMaxWidth) ? labelMaxWidth : Number.POSITIVE_INFINITY,
37
+ ) - label.clientWidth,
38
+ )
39
+ : 0;
40
const maxWidth = Number.parseFloat(style.maxWidth);
41
const naturalWidth = Math.min(
42
renderedWidth + hiddenLabelWidth,
apps/web/src/components/settings/ProviderModelsSection.tsx
+2
-4
@@ -5,7 +5,7 @@ import {
5
type ProviderInstanceId,
6
type ServerProviderModel,
7
} from "@t3tools/contracts";
8
-import { REASONING_SELECT_DESCRIPTOR_IDS } from "@t3tools/client-runtime/model-traits";
8
+import { isReasoningControl } from "@t3tools/client-runtime/model-traits";
9
import { type CustomModelDefinition, normalizeCustomModelSlug } from "@t3tools/shared/model";
10
11
import { useStableCallback } from "../../hooks/useStableCallback";
@@ -31,9 +31,7 @@ const FILTER_THRESHOLD = 8;
31
const PROVIDER_ALIAS_SLUGS = new Set(["default", "auto"]);
32
33
function hasReasoningControl(model: ServerProviderModel): boolean {
34
- return (model.capabilities?.optionDescriptors ?? []).some((descriptor) =>
35
- REASONING_SELECT_DESCRIPTOR_IDS.has(descriptor.id),
36
- );
34
+ return (model.capabilities?.optionDescriptors ?? []).some(isReasoningControl);
35
}
36
37
// Reasoning is the norm, so only its absence is labeled, and only when other models have it.
apps/web/src/components/ui/menu.tsx
+3
@@ -25,6 +25,7 @@ function MenuPopup({
25
align = "center",
26
alignOffset,
27
side = "bottom",
28
+ collisionAvoidance,
29
anchor,
30
keepMounted = false,
31
width = "default",
@@ -34,6 +35,7 @@ function MenuPopup({
35
sideOffset?: MenuPrimitive.Positioner.Props["sideOffset"];
36
alignOffset?: MenuPrimitive.Positioner.Props["alignOffset"];
37
side?: MenuPrimitive.Positioner.Props["side"];
38
+ collisionAvoidance?: MenuPrimitive.Positioner.Props["collisionAvoidance"];
39
anchor?: MenuPrimitive.Positioner.Props["anchor"];
40
keepMounted?: boolean;
41
width?: "default" | "content";
@@ -44,6 +46,7 @@ function MenuPopup({
46
align={align}
47
alignOffset={alignOffset}
48
anchor={anchor}
49
+ collisionAvoidance={collisionAvoidance}
50
className="z-[130]"
51
data-slot="menu-positioner"
52
render={renderClosingPositioner}
packages/client-runtime/src/modelTraits.ts
+18
-11
@@ -11,11 +11,25 @@ import {
11
} from "@t3tools/shared/model";
12
import { REASONING_EFFORT_OPTION_IDS } from "./state/threadExecution.ts";
13
14
-export const REASONING_SELECT_DESCRIPTOR_IDS: ReadonlySet<string> = new Set([
14
+const REASONING_DESCRIPTOR_IDS: ReadonlySet<string> = new Set([
15
...REASONING_EFFORT_OPTION_IDS,
16
"thinking",
17
]);
18
19
+/** The model's reasoning control: a known effort id, or a select its agent marked as reasoning. */
20
+export function isReasoningControl(descriptor: ProviderOptionDescriptor): boolean {
21
+ return (
22
+ (descriptor.type === "select" && descriptor.role === "reasoning") ||
23
+ REASONING_DESCRIPTOR_IDS.has(descriptor.id)
24
+ );
25
+}
26
+
27
+export function isReasoningSelect(
28
+ descriptor: ProviderOptionDescriptor,
29
+): descriptor is Extract<ProviderOptionDescriptor, { type: "select" }> {
30
+ return descriptor.type === "select" && isReasoningControl(descriptor);
31
+}
32
+
33
export function replaceDescriptorCurrentValue(
34
descriptors: ReadonlyArray<ProviderOptionDescriptor>,
35
descriptorId: string,
@@ -106,8 +120,6 @@ export function buildTraitsTriggerDisplay(input: {
120
label: string;
121
/** "Fast" or "Ultrafast" when a speed option is on. */
122
speedLabel: string | null;
109
- /** Labels other than reasoning and speed, such as context window or thinking. */
110
- otherLabels: ReadonlyArray<string>;
123
} {
124
let fastModeFallbackLabel: string | null = null;
125
let speedLabel: string | null = null;
@@ -154,20 +166,15 @@ export function buildTraitsTriggerDisplay(input: {
166
input.reportedModelSelection,
167
);
168
if (typeof label === "string" && label.length > 0) {
157
- if (
158
- reasoningLabelIndex === -1 &&
159
- descriptor.type === "select" &&
160
- REASONING_SELECT_DESCRIPTOR_IDS.has(descriptor.id)
161
- ) {
169
+ if (reasoningLabelIndex === -1 && isReasoningSelect(descriptor)) {
170
reasoningLabelIndex = labels.length;
171
}
172
labels.push(label);
173
}
174
}
175
168
- const otherLabels = labels.filter((_, index) => index !== reasoningLabelIndex);
176
if (labels.length === 0 && fastModeFallbackLabel !== null) {
170
- return { label: fastModeFallbackLabel, speedLabel, otherLabels };
177
+ return { label: fastModeFallbackLabel, speedLabel };
178
}
179
if (speedLabel) {
180
if (reasoningLabelIndex >= 0) {
@@ -176,5 +183,5 @@ export function buildTraitsTriggerDisplay(input: {
183
labels.push(speedLabel);
184
}
185
}
179
- return { label: labels.join(" · "), speedLabel, otherLabels };
186
+ return { label: labels.join(" · "), speedLabel };
187
}
packages/contracts/src/model.ts
+2
@@ -27,6 +27,8 @@ export const SelectProviderOptionDescriptor = Schema.Struct({
27
options: Schema.Array(ProviderOptionChoice),
28
currentValue: Schema.optional(TrimmedNonEmptyString),
29
promptInjectedValues: Schema.optional(Schema.Array(TrimmedNonEmptyString)),
30
+ /** Marks the reasoning control when its id is an agent's own, such as an ACP `thought_level`. */
31
+ role: Schema.optional(Schema.Literal("reasoning")),
32
});
33
export type SelectProviderOptionDescriptor = typeof SelectProviderOptionDescriptor.Type;
34
packages/provider-acp/src/server/sessionConfig.test.ts
+1
@@ -50,6 +50,7 @@ describe("acpProviderOptionDescriptors", () => {
50
{ id: "medium", label: "Medium", description: "Balanced" },
51
],
52
currentValue: "medium",
53
+ role: "reasoning",
54
},
55
]);
56
});
packages/provider-acp/src/server/sessionConfig.ts
+1
@@ -102,6 +102,7 @@ export function acpProviderOptionDescriptors(input: {
102
...(currentValue && choices.some((choice) => choice.id === currentValue)
103
? { currentValue }
104
: {}),
105
+ ...(option.category === "thought_level" ? { role: "reasoning" as const } : {}),
106
});
107
if (descriptors.length === MAX_OPTION_DESCRIPTORS) return descriptors;
108
}
packages/provider-grok/src/server/status.ts
+7
@@ -126,6 +126,8 @@ function isRecord(value: unknown): value is Record<string, unknown> {
126
return typeof value === "object" && value !== null && !Array.isArray(value);
127
}
128
129
+const GROK_EFFORT_RANK = ["none", "minimal", "low", "medium", "high", "xhigh", "max"];
130
+
131
function grokReasoningOptionsFromModel(model: EffectAcpSchema.ModelInfo): {
132
readonly options: ReadonlyArray<{
133
value: string;
@@ -183,6 +185,11 @@ function grokReasoningOptionsFromModel(model: EffectAcpSchema.ModelInfo): {
185
const selectedDefault =
186
advertisedDefaults.find((option) => option.value === currentValue)?.value ??
187
advertisedDefaults[0]?.value;
188
+ // Grok advertises its strongest level first; pickers and effort bars read lowest to highest.
189
+ const rank = (option: { value: string }) => GROK_EFFORT_RANK.indexOf(option.value);
190
+ if (options.every((option) => rank(option) >= 0)) {
191
+ options.sort((left, right) => rank(left) - rank(right));
192
+ }
193
return {
194
options: options.map(({ value, label, description }) => ({
195
value,