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, 20:45 UTC
fix(mobile): bring model controls in line with web (#21406)
maria committed
Oct 21, 2026 at 00:04 UTC
f16251f164f80caebd051394cfefdbb6c855d4f4
13 files changed
+640
-219
apps/mobile/src/components/ComposerModelControl.tsx
new
+85
@@ -0,0 +1,85 @@
1
+import type { ModelSelection, ProviderDriverKind } from "@t3tools/contracts";
2
+import {
3
+ buildTraitsTriggerDisplay,
4
+ getPromptControlledTraits,
5
+} from "@t3tools/client-runtime/model-traits";
6
+import type { ModelOption } from "../lib/modelOptions";
7
+import { resolveProviderOptionDescriptors } from "../lib/providerOptions";
8
+import { AppText as Text } from "./ui/AppText";
9
+import { ComposerInlineControl } from "./ComposerToolbar";
10
+import { ProviderIcon, ProviderInstanceIcon } from "./ProviderIcon";
11
+
12
+export function ComposerModelControl(props: {
13
+ readonly modelOption: ModelOption | null;
14
+ readonly selection: ModelSelection | null;
15
+ readonly provider: ProviderDriverKind | undefined;
16
+ readonly reportedSelection?: ModelSelection | null | undefined;
17
+ readonly prompt: string;
18
+ readonly surfaceColor: string;
19
+ readonly disabled?: boolean;
20
+ readonly iconOnly?: boolean;
21
+ readonly showSummary?: boolean;
22
+ readonly onPress: () => void;
23
+}) {
24
+ const descriptors = resolveProviderOptionDescriptors({
25
+ capabilities: props.modelOption?.capabilities,
26
+ selections: props.selection?.options,
27
+ });
28
+ const promptTraits = getPromptControlledTraits(descriptors, props.prompt);
29
+ const summary = props.provider
30
+ ? buildTraitsTriggerDisplay({
31
+ provider: props.provider,
32
+ descriptors,
33
+ primarySelectDescriptorId: promptTraits.primarySelectDescriptor?.id ?? null,
34
+ ultrathinkPromptControlled: promptTraits.ultrathinkPromptControlled,
35
+ modelSelection: props.selection,
36
+ reportedModelSelection: props.reportedSelection,
37
+ }).label
38
+ : "";
39
+ const badge = props.modelOption?.providerBadge;
40
+ const label = props.modelOption?.label ?? props.selection?.model ?? "Choose model";
41
+ return (
42
+ <ComposerInlineControl
43
+ accessibilityLabel={[
44
+ "Model and reasoning settings",
45
+ label,
46
+ badge?.showBadge ? badge.displayName : null,
47
+ summary,
48
+ ]
49
+ .filter(Boolean)
50
+ .join(", ")}
51
+ disabled={props.disabled}
52
+ emphasized
53
+ renderIcon={(size) =>
54
+ badge?.showBadge ? (
55
+ <ProviderInstanceIcon
56
+ iconUrl={props.modelOption?.providerIconUrl}
57
+ provider={props.modelOption?.providerDriver}
58
+ displayName={badge.displayName}
59
+ accentColor={badge.accentColor}
60
+ showBadge
61
+ surfaceColor={props.surfaceColor}
62
+ size={size}
63
+ />
64
+ ) : (
65
+ <ProviderIcon
66
+ iconUrl={props.modelOption?.providerIconUrl}
67
+ provider={props.modelOption?.providerDriver}
68
+ size={size}
69
+ />
70
+ )
71
+ }
72
+ label={label}
73
+ iconOnly={props.iconOnly}
74
+ suffix={
75
+ props.showSummary !== false && summary ? (
76
+ <Text className="text-xs text-foreground-muted" numberOfLines={1}>
77
+ {summary}
78
+ </Text>
79
+ ) : undefined
80
+ }
81
+ maxWidth="100%"
82
+ onPress={props.onPress}
83
+ />
84
+ );
85
+}
apps/mobile/src/components/ComposerToolbar.tsx
+4
@@ -36,6 +36,7 @@ export function ComposerInlineControl(props: {
36
readonly icon?: ComponentProps<typeof SymbolView>["name"];
37
readonly renderIcon?: (size: number) => ReactNode;
38
readonly label: string;
39
+ readonly suffix?: ReactNode;
40
/** Show only the icon and chevron; the label still names the control for accessibility. */
41
readonly iconOnly?: boolean;
42
readonly maxWidth?: ViewStyle["maxWidth"];
@@ -105,6 +106,9 @@ export function ComposerInlineControl(props: {
106
</Text>
107
</Animated.View>
108
)}
109
+ {!props.iconOnly && props.suffix ? (
110
+ <View className="min-w-0 shrink">{props.suffix}</View>
111
+ ) : null}
112
{props.showChevron === false ? null : (
113
<SymbolView
114
name={props.chevronDirection === "right" ? "chevron.right" : "chevron.down"}
apps/mobile/src/features/settings/ScheduledTaskPickerScreens.tsx
+6
@@ -53,6 +53,12 @@ export function ScheduledTaskModelPickerRouteScreen() {
53
projectId={projectId}
54
providerGroups={providerGroups}
55
selectedModel={selectedModel}
56
+ prompt={editor.draft.prompt}
57
+ onPromptChange={(prompt) =>
58
+ setEditor((current) =>
59
+ current ? { ...current, draft: { ...current.draft, prompt } } : current,
60
+ )
61
+ }
62
onSelectModel={(option) =>
63
setEditor((current) =>
64
current
apps/mobile/src/features/threads/NewTaskDraftScreen.tsx
+7
-13
@@ -67,7 +67,7 @@ import {
67
} from "../../state/composer-attachment-uploads";
68
import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePreviewModal";
69
import { VideoPreviewModal, type VideoPreviewSource } from "../../components/VideoPreviewModal";
70
-import { ProviderIcon } from "../../components/ProviderIcon";
70
+import { ComposerModelControl } from "../../components/ComposerModelControl";
71
import { SymbolView } from "../../components/ui/AppSymbol";
72
import { AppText as Text } from "../../components/ui/AppText";
73
import { hasProviderUsageLimits, isUsageLimitsCommand } from "@t3tools/shared/usageLimits";
@@ -1726,19 +1726,13 @@ export function NewTaskDraftScreen(props: {
1726
/>
1727
<View className="min-w-0 flex-1 flex-row items-center justify-end gap-2">
1728
<View className="min-w-0 shrink">
1729
- <ComposerInlineControl
1730
- accessibilityLabel="Model and reasoning settings"
1729
+ <ComposerModelControl
1730
+ modelOption={flow.selectedModelOption}
1731
+ selection={flow.selectedModel}
1732
+ provider={flow.selectedProviderStatus?.driver}
1733
+ prompt={flow.prompt}
1734
+ surfaceColor={theme["--color-composer-panel"]}
1735
disabled={isComposerInteractionLocked}
1732
- emphasized
1733
- renderIcon={(size) => (
1734
- <ProviderIcon
1735
- iconUrl={flow.selectedModelOption?.providerIconUrl}
1736
- provider={flow.selectedModelOption?.providerDriver}
1737
- size={size}
1738
- />
1739
- )}
1740
- label={flow.selectedModelOption?.label ?? "Choose model"}
1741
- maxWidth="100%"
1736
onPress={settingsSheetPresentation.open}
1737
/>
1738
</View>
apps/mobile/src/features/threads/ThreadComposer.tsx
+14
-20
@@ -74,12 +74,8 @@ import { VideoPreviewModal, type VideoPreviewSource } from "../../components/Vid
74
import { GlassSurface } from "../../components/ui/GlassSurface";
75
import { ComposerEditor, type ComposerEditorHandle } from "../../components/ComposerEditor";
76
import { fileRoutePathSegments } from "../files/filePath";
77
-import {
78
- ComposerActionButton,
79
- ComposerInlineControl,
80
- ComposerToolbarRow,
81
-} from "../../components/ComposerToolbar";
82
-import { ProviderIcon } from "../../components/ProviderIcon";
77
+import { ComposerActionButton, ComposerToolbarRow } from "../../components/ComposerToolbar";
78
+import { ComposerModelControl } from "../../components/ComposerModelControl";
79
import {
80
composerStripAttachments,
81
type DraftComposerFileAttachment,
@@ -657,6 +653,8 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
653
...(lockedProviderInstanceId ? { lockedProviderInstanceId } : {}),
654
providerGroups: threadProviderGroups,
655
selectedModel: currentModelSelection,
656
+ prompt: draftMessage,
657
+ onPromptChange: (text) => setComposerDraftText(composerDraftKey, text),
658
reportedModelSelection: props.reportedModelSelection,
659
onSelectModel: (option) =>
660
props.onUpdateModelSelection(withRememberedModelOptions(option.selection)),
@@ -761,22 +759,18 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
759
) : null;
760
761
// The row and the card's toolbar share this picker. It shrinks to the provider
764
- // icon once the draft has text, so the draft keeps the width.
762
+ // icon in the row once the draft has text, so the draft keeps the width.
763
const modelControl = (
764
<View className="min-w-0 shrink">
767
- <ComposerInlineControl
768
- accessibilityLabel="Model and reasoning settings"
769
- emphasized
770
- renderIcon={(size) => (
771
- <ProviderIcon
772
- iconUrl={currentModelOption?.providerIconUrl}
773
- provider={currentModelOption?.providerDriver}
774
- size={size}
775
- />
776
- )}
777
- label={currentModelOption?.label ?? currentModelSelection.model}
778
- iconOnly={draftMessage.length > 0}
779
- maxWidth="100%"
765
+ <ComposerModelControl
766
+ modelOption={currentModelOption}
767
+ selection={currentModelSelection}
768
+ provider={selectedProviderStatus?.driver}
769
+ reportedSelection={props.reportedModelSelection}
770
+ prompt={draftMessage}
771
+ surfaceColor={composerPanel}
772
+ iconOnly={!usesCard && draftMessage.length > 0}
773
+ showSummary={usesCard}
774
onPress={openSettings}
775
/>
776
</View>
apps/mobile/src/features/threads/ThreadSettingsSheet.tsx
+73
-12
@@ -1,3 +1,7 @@
1
+import {
2
+ getPromptControlledTraits,
3
+ getTraitSelectChange,
4
+} from "@t3tools/client-runtime/model-traits";
5
import { SheetHeader } from "../../components/ui/SheetHeader";
6
import { Toolbar } from "../../components/ui/Toolbar";
7
import * as Dialog from "../../components/ui/Dialog";
@@ -247,6 +251,8 @@ type ThreadSettingsSessionProps = {
251
readonly lockedProviderInstanceId?: ProviderInstanceId;
252
readonly providerGroups: ReadonlyArray<ProviderGroup>;
253
readonly selectedModel: ModelSelection | null;
254
+ readonly prompt: string;
255
+ readonly onPromptChange: (prompt: string) => void;
256
readonly reportedModelSelection?: ModelSelection | null;
257
readonly onSelectModel: (option: ModelOption) => void;
258
readonly restoreSelection?: (selection: ModelSelection) => ModelSelection;
@@ -311,6 +317,7 @@ type ThreadSettingsSessionValue = {
317
readonly runtimeModeChoices: ReturnType<typeof runtimeModeChoicesForSupportedModes>;
318
readonly onUpdateRuntimeMode: (mode: RuntimeMode) => void;
319
readonly displayedDescriptors: ReadonlyArray<ProviderOptionDescriptor>;
320
+ readonly promptTraits: ReturnType<typeof getPromptControlledTraits>;
321
readonly displayedModelSelection: ModelSelection | null;
322
readonly reportedModelSelection: ModelSelection | null;
323
readonly providerExpansionOverrides: ReadonlySet<string>;
@@ -491,6 +498,8 @@ function ThreadSettingsSessionProvider(
498
() => new Set(),
499
);
500
const [pendingModel, setPendingModel] = useState<ModelOption | null>(null);
501
+ const [pendingPrompt, setPendingPrompt] = useState<string | null>(null);
502
+ const displayedPrompt = pendingModel ? (pendingPrompt ?? props.prompt) : props.prompt;
503
504
const isApplied = (option: ModelOption) =>
505
option.selection.instanceId === props.selectedModel?.instanceId &&
@@ -506,6 +515,7 @@ function ThreadSettingsSessionProvider(
515
})
516
: []
517
: props.optionDescriptors;
518
+ const promptTraits = getPromptControlledTraits(displayedDescriptors, displayedPrompt);
519
const displayedModel =
520
pendingModel ??
521
props.providerGroups.flatMap((group) => group.models).find((option) => isApplied(option)) ??
@@ -532,12 +542,39 @@ function ThreadSettingsSessionProvider(
542
}
543
void Haptics.selectionAsync();
544
props.onSelectModel(pendingModel);
545
+ if (pendingPrompt !== null && pendingPrompt !== props.prompt) {
546
+ props.onPromptChange(pendingPrompt);
547
+ }
548
}
549
return true;
550
};
551
552
const applyOptionChange = (id: string, value: string | boolean) => {
540
- const next = applyProviderOptionSelection(displayedDescriptors, { id, value });
553
+ const descriptor = displayedDescriptors.find((entry) => entry.id === id);
554
+ const change =
555
+ descriptor?.type === "select" && typeof value === "string"
556
+ ? getTraitSelectChange(
557
+ { ...promptTraits, descriptors: displayedDescriptors },
558
+ descriptor,
559
+ displayedPrompt,
560
+ value,
561
+ )
562
+ : null;
563
+ if (descriptor?.type === "select") {
564
+ if (!change) return;
565
+ if (change.prompt !== displayedPrompt) {
566
+ if (pendingModel) {
567
+ setPendingPrompt(change.prompt);
568
+ } else {
569
+ props.onPromptChange(change.prompt);
570
+ }
571
+ }
572
+ if (!("modelOptions" in change)) return;
573
+ }
574
+ const next =
575
+ change && "modelOptions" in change
576
+ ? (change.modelOptions ?? [])
577
+ : applyProviderOptionSelection(displayedDescriptors, { id, value });
578
if (!next) {
579
return;
580
}
@@ -564,6 +601,9 @@ function ThreadSettingsSessionProvider(
601
602
const pressModel = (option: ModelOption) => {
603
void Haptics.selectionAsync();
604
+ if (isApplied(option) || option.key !== pendingModel?.key) {
605
+ setPendingPrompt(null);
606
+ }
607
setPendingModel((current) =>
608
pendingModelAfterPress({
609
current,
@@ -586,6 +626,7 @@ function ThreadSettingsSessionProvider(
626
runtimeModeChoices,
627
onUpdateRuntimeMode: props.onUpdateRuntimeMode,
628
displayedDescriptors,
629
+ promptTraits,
630
displayedModelSelection: pendingModel?.selection ?? props.selectedModel,
631
reportedModelSelection: pendingModel ? null : (props.reportedModelSelection ?? null),
632
favoriteKeys,
@@ -832,11 +873,16 @@ function ThreadSettingsOptionsItem(props: {
873
>
874
<DisclosureRow
875
label={descriptor.label}
835
- value={getProviderOptionCurrentLabel(
836
- descriptor,
837
- session.displayedModelSelection,
838
- session.reportedModelSelection,
839
- )}
876
+ value={
877
+ session.promptTraits.ultrathinkPromptControlled &&
878
+ descriptor.id === session.promptTraits.primarySelectDescriptor?.id
879
+ ? "Ultrathink"
880
+ : getProviderOptionCurrentLabel(
881
+ descriptor,
882
+ session.displayedModelSelection,
883
+ session.reportedModelSelection,
884
+ )
885
+ }
886
onPress={() => props.onOpenSubmenu({ kind: "descriptor", id: descriptor.id })}
887
/>
888
</Animated.View>
@@ -1076,16 +1122,29 @@ function ThreadSettingsChoiceContent(props: {
1122
rows: selectableChoices(activeDescriptor).map((choice) => ({
1123
id: choice.id,
1124
label: choice.label,
1079
- description: undefined,
1125
+ description: choice.description,
1126
selected:
1127
choice.id ===
1082
- getProviderOptionCurrentValue(
1083
- activeDescriptor,
1084
- session.displayedModelSelection,
1085
- session.reportedModelSelection,
1086
- ),
1128
+ (session.promptTraits.ultrathinkPromptControlled &&
1129
+ activeDescriptor.id === session.promptTraits.primarySelectDescriptor?.id
1130
+ ? "ultrathink"
1131
+ : getProviderOptionCurrentValue(
1132
+ activeDescriptor,
1133
+ session.displayedModelSelection,
1134
+ session.reportedModelSelection,
1135
+ )),
1136
onPress: () => {
1137
void Haptics.selectionAsync();
1138
+ if (
1139
+ session.promptTraits.ultrathinkInBodyText &&
1140
+ activeDescriptor.id === session.promptTraits.primarySelectDescriptor?.id
1141
+ ) {
1142
+ Dialog.alert(
1143
+ "Reasoning controlled by prompt",
1144
+ 'Your prompt contains "ultrathink" in the text. Remove it to change this option.',
1145
+ );
1146
+ return;
1147
+ }
1148
session.applyOptionChange(activeDescriptor.id, choice.id);
1149
props.onSelected();
1150
},
@@ -1482,6 +1541,8 @@ export function NewTaskThreadSettingsRouteScreen() {
1541
{...(flow.selectedModel ? { providerInstanceId: flow.selectedModel.instanceId } : {})}
1542
providerGroups={flow.providerGroups}
1543
selectedModel={flow.selectedModel}
1544
+ prompt={flow.prompt}
1545
+ onPromptChange={flow.setPrompt}
1546
onSelectModel={(option) => flow.setSelectedModelKey(option.key, option.selection.options)}
1547
restoreSelection={withRememberedModelOptions}
1548
optionDescriptors={optionDescriptors}
apps/mobile/src/features/threads/thread-settings-options.test.ts
+60
-1
@@ -1,3 +1,7 @@
1
+import {
2
+ getPromptControlledTraits,
3
+ getTraitSelectChange,
4
+} from "@t3tools/client-runtime/model-traits";
5
import type { ProviderOptionDescriptor } from "@t3tools/contracts";
6
import { describe, expect, it } from "vite-plus/test";
7
@@ -19,11 +23,13 @@ const effortDescriptor: Extract<ProviderOptionDescriptor, { type: "select" }> =
23
};
24
25
describe("selectableChoices", () => {
22
- it("hides prompt-injected and workflow-trigger choices, keeping declared order", () => {
26
+ it("includes prompt-injected and workflow choices in declared order", () => {
27
expect(selectableChoices(effortDescriptor).map((choice) => choice.id)).toEqual([
28
"low",
29
"medium",
30
"high",
31
+ "ultrathink",
32
+ "ultracode",
33
]);
34
});
35
});
@@ -33,3 +39,56 @@ describe("runtimeModeChoicesForSupportedModes", () => {
39
expect(runtimeModeChoicesForSupportedModes([])).toHaveLength(4);
40
});
41
});
42
+
43
+describe("prompt-controlled reasoning", () => {
44
+ it("adds Ultrathink to the prompt without persisting an injected option", () => {
45
+ const descriptors = [effortDescriptor];
46
+ const change = getTraitSelectChange(
47
+ { ...getPromptControlledTraits(descriptors, "solve it"), descriptors },
48
+ effortDescriptor,
49
+ "solve it",
50
+ "ultrathink",
51
+ );
52
+ expect(change).toEqual({ prompt: "Ultrathink:\nsolve it" });
53
+ expect(
54
+ getPromptControlledTraits(descriptors, change?.prompt ?? "").ultrathinkPromptControlled,
55
+ ).toBe(true);
56
+ expect(
57
+ getTraitSelectChange(
58
+ { ...getPromptControlledTraits(descriptors, ""), descriptors },
59
+ effortDescriptor,
60
+ "",
61
+ "ultrathink",
62
+ ),
63
+ ).toEqual({ prompt: "Ultrathink:\n" });
64
+ });
65
+
66
+ it("removes the prefix when choosing a regular effort and saves Ultracode as an option", () => {
67
+ const descriptors = [effortDescriptor];
68
+ const prompt = "Ultrathink:\nsolve it";
69
+ expect(
70
+ getTraitSelectChange(
71
+ { ...getPromptControlledTraits(descriptors, prompt), descriptors },
72
+ effortDescriptor,
73
+ prompt,
74
+ "ultracode",
75
+ ),
76
+ ).toEqual({ prompt: "solve it", modelOptions: [{ id: "effort", value: "ultracode" }] });
77
+ });
78
+
79
+ it("keeps body-controlled Ultrathink locked and preserves slash commands", () => {
80
+ const descriptors = [effortDescriptor];
81
+ const prompt = "please ultrathink about this";
82
+ const selected = { ...getPromptControlledTraits(descriptors, prompt), descriptors };
83
+ expect(selected.ultrathinkInBodyText).toBe(true);
84
+ expect(getTraitSelectChange(selected, effortDescriptor, prompt, "low")).toBeNull();
85
+ expect(
86
+ getTraitSelectChange(
87
+ { ...getPromptControlledTraits(descriptors, "/review"), descriptors },
88
+ effortDescriptor,
89
+ "/review",
90
+ "ultrathink",
91
+ ),
92
+ ).toEqual({ prompt: "/review" });
93
+ });
94
+});
apps/mobile/src/features/threads/thread-settings-options.ts
+2
-16
@@ -1,11 +1,4 @@
1
-import type { ProviderOptionDescriptor, RuntimeMode } from "@t3tools/contracts";
2
-
3
-/**
4
- * Prompt-injected values (ultrathink and friends) are filtered from the
5
- * descriptor metadata; ultracode is a real option but a workflow trigger, not a
6
- * reasoning level.
7
- */
8
-const HIDDEN_EFFORT_OPTION_IDS: ReadonlySet<string> = new Set(["ultracode"]);
1
+import type { RuntimeMode } from "@t3tools/contracts";
2
3
export const RUNTIME_MODE_CHOICES: ReadonlyArray<{
4
readonly mode: RuntimeMode;
@@ -51,11 +44,4 @@ export function compatibleRuntimeModeForChoices(
44
: (choices[0]?.mode ?? runtimeMode);
45
}
46
54
-export function selectableChoices(
55
- descriptor: Extract<ProviderOptionDescriptor, { type: "select" }>,
56
-) {
57
- const injected = new Set(descriptor.promptInjectedValues ?? []);
58
- return descriptor.options.filter(
59
- (option) => !injected.has(option.id) && !HIDDEN_EFFORT_OPTION_IDS.has(option.id),
60
- );
61
-}
47
+export { selectableProviderOptionChoices as selectableChoices } from "@t3tools/client-runtime/model-traits";
apps/mobile/src/lib/modelOptions.test.ts
+122
@@ -245,6 +245,127 @@ describe("mobile model options", () => {
245
);
246
});
247
248
+ it("keeps accounts in the continuation group and excludes other providers", () => {
249
+ const config = {
250
+ providers: [
251
+ { instanceId: "codex", driver: "codex", continuation: { groupKey: "shared" } },
252
+ { instanceId: "codex_work", driver: "codex", continuation: { groupKey: "shared" } },
253
+ { instanceId: "codex_other", driver: "codex", continuation: { groupKey: "other" } },
254
+ { instanceId: "claude", driver: "claudeAgent", continuation: { groupKey: "shared" } },
255
+ ].map((provider) => ({
256
+ ...provider,
257
+ enabled: true,
258
+ installed: true,
259
+ auth: { status: "authenticated" },
260
+ models: [{ slug: "test", name: "Test", capabilities: null }],
261
+ })),
262
+ } as unknown as ServerConfig;
263
+ expect(
264
+ buildModelOptions(config, null, ProviderInstanceId.make("codex"), null).map(
265
+ (option) => option.providerKey,
266
+ ),
267
+ ).toEqual(["codex", "codex_work"]);
268
+ });
269
+
270
+ it("matches the web driver fallback without moving unknown Antigravity history", () => {
271
+ const config = {
272
+ providers: [
273
+ { instanceId: "codex", driver: "codex" },
274
+ { instanceId: "codex_work", driver: "codex" },
275
+ { instanceId: "google", driver: "antigravity" },
276
+ { instanceId: "google_work", driver: "antigravity" },
277
+ ].map((provider) => ({
278
+ ...provider,
279
+ enabled: true,
280
+ installed: true,
281
+ auth: { status: "authenticated" },
282
+ models: [{ slug: "test", name: "Test", capabilities: null }],
283
+ })),
284
+ } as unknown as ServerConfig;
285
+ expect(
286
+ buildModelOptions(config, null, ProviderInstanceId.make("codex"), null).map(
287
+ (option) => option.providerKey,
288
+ ),
289
+ ).toEqual(["codex", "codex_work"]);
290
+ expect(
291
+ buildModelOptions(config, null, ProviderInstanceId.make("google"), null).map(
292
+ (option) => option.providerKey,
293
+ ),
294
+ ).toEqual(["google"]);
295
+ });
296
+
297
+ it("carries account badges into catalog and saved fallback models", () => {
298
+ const config = {
299
+ providers: [
300
+ { instanceId: "codex", driver: "codex", displayName: "Personal" },
301
+ { instanceId: "codex_work", driver: "codex", displayName: "Work", accentColor: "#123456" },
302
+ ].map((provider) => ({
303
+ ...provider,
304
+ enabled: true,
305
+ installed: true,
306
+ auth: { status: "authenticated" },
307
+ models: [{ slug: "test", name: "Test", capabilities: null }],
308
+ })),
309
+ } as unknown as ServerConfig;
310
+ const selection = { instanceId: ProviderInstanceId.make("codex_work"), model: "saved" };
311
+ const options = buildModelOptions(config, selection, undefined, null);
312
+ expect(options[0]?.providerBadge).toEqual({ displayName: "Personal", showBadge: true });
313
+ expect(options[1]?.providerBadge).toEqual({
314
+ displayName: "Work",
315
+ accentColor: "#123456",
316
+ showBadge: true,
317
+ });
318
+ expect(options[2]?.providerBadge).toEqual(options[1]?.providerBadge);
319
+ expect(
320
+ buildModelOptions(
321
+ { ...config, providers: config.providers.slice(0, 1) },
322
+ null,
323
+ undefined,
324
+ null,
325
+ )[0]?.providerBadge?.showBadge,
326
+ ).toBe(false);
327
+ });
328
+
329
+ it("only badges ACP accounts that share the same agent", () => {
330
+ const config = {
331
+ settings: {
332
+ ...DEFAULT_SERVER_SETTINGS,
333
+ providerInstances: {
334
+ acp_one: { driver: "acpRegistry", enabled: true, config: { agentId: "one" } },
335
+ acp_two: { driver: "acpRegistry", enabled: true, config: { agentId: "two" } },
336
+ },
337
+ },
338
+ providers: ["acp_one", "acp_two"].map((instanceId) => ({
339
+ instanceId,
340
+ driver: "acpRegistry",
341
+ enabled: true,
342
+ installed: true,
343
+ auth: { status: "authenticated" },
344
+ models: [{ slug: "test", name: "Test", capabilities: null }],
345
+ })),
346
+ } as unknown as ServerConfig;
347
+ expect(
348
+ buildModelOptions(config, null, undefined, null).map(
349
+ (option) => option.providerBadge?.showBadge,
350
+ ),
351
+ ).toEqual([false, false]);
352
+ const shared = {
353
+ ...config,
354
+ settings: {
355
+ ...config.settings,
356
+ providerInstances: {
357
+ ...config.settings.providerInstances,
358
+ acp_two: config.settings.providerInstances[ProviderInstanceId.make("acp_one")]!,
359
+ },
360
+ },
361
+ };
362
+ expect(
363
+ buildModelOptions(shared, null, undefined, null).map(
364
+ (option) => option.providerBadge?.showBadge,
365
+ ),
366
+ ).toEqual([true, true]);
367
+ });
368
+
369
it.each(["disabled", "unavailable", "missing"] as const)(
370
"retains the selected %s provider's fallback in a filtered catalog",
371
(state) => {
@@ -763,6 +884,7 @@ describe("synchronized mobile model visibility", () => {
884
},
885
providers: [provider, other].map((instanceId) => ({
886
instanceId,
887
+ continuation: { groupKey: instanceId },
888
driver: "codex",
889
enabled: true,
890
installed: true,
apps/mobile/src/lib/modelOptions.ts
+65
-1
@@ -1,3 +1,8 @@
1
+import {
2
+ normalizeProviderAccentColor,
3
+ resolveProviderInstanceDisplayName,
4
+ shouldShowInstanceBadge,
5
+} from "@t3tools/client-runtime/state/provider-instance-display";
6
import type { MenuAction } from "@react-native-menu/menu";
7
import type {
8
ModelCapabilities,
@@ -21,6 +26,11 @@ export type ModelOption = {
26
readonly providerDriver: string;
27
readonly supportedRuntimeModes?: ReadonlyArray<RuntimeMode>;
28
readonly providerIconUrl?: string | undefined;
29
+ readonly providerBadge?: {
30
+ readonly displayName: string;
31
+ readonly accentColor?: string;
32
+ readonly showBadge: boolean;
33
+ };
34
readonly isDefault: boolean;
35
readonly isLegacy: boolean;
36
readonly isUnavailable?: boolean;
@@ -235,10 +245,61 @@ export function buildModelOptions(
245
includeHidden = false,
246
): ReadonlyArray<ModelOption> {
247
const options = new Map<string, ModelOption>();
248
+ const lockedProvider = config?.providers.find(
249
+ (provider) => provider.instanceId === providerInstanceId,
250
+ );
251
+ const matchesLockedProvider = (provider: T3ServerConfig["providers"][number]) => {
252
+ if (providerInstanceId === undefined || provider.instanceId === providerInstanceId) return true;
253
+ if (!lockedProvider || provider.driver !== lockedProvider.driver) return false;
254
+ const groupKey = lockedProvider.continuation?.groupKey;
255
+ if (groupKey) return provider.continuation?.groupKey === groupKey;
256
+ return provider.driver !== "antigravity";
257
+ };
258
+ const registryAgentId = (instanceId: ModelSelection["instanceId"]) => {
259
+ const configValue = config?.settings?.providerInstances[instanceId]?.config;
260
+ if (configValue === null || typeof configValue !== "object") return undefined;
261
+ const agentId = "agentId" in configValue ? configValue.agentId : undefined;
262
+ return "source" in configValue && configValue.source === "local"
263
+ ? undefined
264
+ : typeof agentId === "string"
265
+ ? agentId.trim() || undefined
266
+ : undefined;
267
+ };
268
+ const badgeEntries = (config?.providers ?? []).map((provider) => ({
269
+ driverKind: provider.driver,
270
+ enabled: provider.enabled,
271
+ acpRegistryAgentId: registryAgentId(provider.instanceId),
272
+ }));
273
+ const providerBadgeFor = (instanceId: ModelSelection["instanceId"]) => {
274
+ const snapshot = config?.providers.find((provider) => provider.instanceId === instanceId);
275
+ const instance = config?.settings?.providerInstances[instanceId];
276
+ const driver = snapshot?.driver ?? instance?.driver;
277
+ if (!driver) return undefined;
278
+ const accentColor = normalizeProviderAccentColor(
279
+ snapshot?.accentColor ?? instance?.accentColor,
280
+ );
281
+ return {
282
+ displayName: resolveProviderInstanceDisplayName({
283
+ instanceId,
284
+ driver,
285
+ displayName: snapshot?.displayName ?? instance?.displayName,
286
+ }),
287
+ ...(accentColor ? { accentColor } : {}),
288
+ showBadge: shouldShowInstanceBadge(
289
+ {
290
+ driverKind: driver,
291
+ accentColor,
292
+ acpRegistryAgentId: registryAgentId(instanceId),
293
+ enabled: snapshot?.enabled ?? instance?.enabled ?? false,
294
+ },
295
+ badgeEntries,
296
+ ),
297
+ };
298
+ };
299
300
for (const provider of config?.providers ?? []) {
301
if (
241
- (providerInstanceId !== undefined && provider.instanceId !== providerInstanceId) ||
302
+ !matchesLockedProvider(provider) ||
303
!isProviderEnabledForProject(config, provider, projectId) ||
304
!provider.installed ||
305
provider.auth.status === "unauthenticated" ||
@@ -248,6 +309,7 @@ export function buildModelOptions(
309
}
310
311
const providerLabel = providerDisplayLabel(provider);
312
+ const providerBadge = providerBadgeFor(provider.instanceId);
313
const updateRequired = provider.updateRequiredModels?.length
314
? { driver: provider.driver, updateRequiredModels: provider.updateRequiredModels }
315
: undefined;
@@ -268,6 +330,7 @@ export function buildModelOptions(
330
providerKey: provider.instanceId,
331
providerLabel,
332
providerDriver: provider.driver,
333
+ providerBadge,
334
...(provider.supportedRuntimeModes === undefined
335
? {}
336
: { supportedRuntimeModes: provider.supportedRuntimeModes }),
@@ -332,6 +395,7 @@ export function buildModelOptions(
395
providerKey: fallbackModelSelection.instanceId,
396
providerLabel,
397
providerDriver,
398
+ providerBadge: providerBadgeFor(fallbackModelSelection.instanceId),
399
isDefault: false,
400
isLegacy: model?.isLegacy === true,
401
...(isModelSelectionUnavailable(config, fallbackModelSelection, projectId) ||
apps/web/src/components/chat/TraitsPicker.tsx
+17
-156
@@ -1,3 +1,14 @@
1
+import {
2
+ buildTraitsTriggerDisplay,
3
+ getDescriptorStringValue,
4
+ getPromptControlledTraits,
5
+ getTraitSelectChange,
6
+ replaceDescriptorCurrentValue,
7
+ selectableProviderOptionChoices,
8
+ REASONING_SELECT_DESCRIPTOR_IDS,
9
+ ULTRATHINK_PROMPT_PREFIX,
10
+} from "@t3tools/client-runtime/model-traits";
11
+export { buildTraitsTriggerDisplay } from "@t3tools/client-runtime/model-traits";
12
import {
13
type ModelSelection,
14
type ProviderDriverKind,
@@ -8,15 +19,11 @@ import {
19
type ServerProviderModel,
20
} from "@t3tools/contracts";
21
import {
11
- applyClaudePromptEffortPrefix,
22
buildProviderOptionSelectionsFromDescriptors,
23
getProviderOptionCurrentLabel,
14
- getProviderOptionCurrentValue,
24
getProviderOptionDescriptors,
16
- isClaudeUltrathinkPrompt,
25
normalizeModelSlug,
26
} from "@t3tools/shared/model";
19
-import { REASONING_EFFORT_OPTION_IDS } from "@t3tools/client-runtime/state/thread-execution";
27
import { memo } from "react";
28
import { BrainIcon } from "lucide-react";
29
import {
@@ -90,13 +97,6 @@ type TraitsPersistence =
97
onModelOptionsChange: (nextOptions: ProviderOptions | undefined) => void;
98
};
99
93
-const ULTRATHINK_PROMPT_PREFIX = "Ultrathink:\n";
94
-
95
-const REASONING_SELECT_DESCRIPTOR_IDS: ReadonlySet<string> = new Set([
96
- ...REASONING_EFFORT_OPTION_IDS,
97
- "thinking",
98
-]);
99
-
100
function DefaultBadge() {
101
return (
102
<Badge variant="outline" size="sm" className="min-w-0">
@@ -105,38 +105,6 @@ function DefaultBadge() {
105
);
106
}
107
108
-function replaceDescriptorCurrentValue(
109
- descriptors: ReadonlyArray<ProviderOptionDescriptor>,
110
- descriptorId: string,
111
- currentValue: string | boolean | undefined,
112
-): ReadonlyArray<ProviderOptionDescriptor> {
113
- return descriptors.map((descriptor) =>
114
- descriptor.id !== descriptorId
115
- ? descriptor
116
- : descriptor.type === "boolean"
117
- ? {
118
- ...descriptor,
119
- ...(typeof currentValue === "boolean" ? { currentValue } : {}),
120
- }
121
- : {
122
- ...descriptor,
123
- ...(typeof currentValue === "string" ? { currentValue } : {}),
124
- },
125
- );
126
-}
127
-
128
-function getDescriptorStringValue(
129
- descriptor: Extract<ProviderOptionDescriptor, { type: "select" }> | null,
130
- selection?: ModelSelection | null,
131
- reportedSelection?: ModelSelection | null,
132
-): string | null {
133
- if (!descriptor) {
134
- return null;
135
- }
136
- const value = getProviderOptionCurrentValue(descriptor, selection, reportedSelection);
137
- return typeof value === "string" ? value : null;
138
-}
139
-
108
function getSelectedTraits(
109
provider: ProviderDriverKind,
110
models: ReadonlyArray<ServerProviderModel>,
@@ -177,13 +145,11 @@ function getSelectedTraits(
145
const thinkingDescriptor =
146
booleanDescriptors.find((descriptor) => descriptor.id === "thinking") ?? null;
147
180
- const ultrathinkPromptControlled =
181
- allowPromptInjectedEffort &&
182
- (primarySelectDescriptor?.promptInjectedValues?.length ?? 0) > 0 &&
183
- isClaudeUltrathinkPrompt(prompt);
184
-
185
- const ultrathinkInBodyText =
186
- ultrathinkPromptControlled && isClaudeUltrathinkPrompt(prompt.replace(/^Ultrathink:\s*/i, ""));
148
+ const { ultrathinkPromptControlled, ultrathinkInBodyText } = getPromptControlledTraits(
149
+ descriptors,
150
+ prompt,
151
+ allowPromptInjectedEffort,
152
+ );
153
const effort =
154
(ultrathinkPromptControlled
155
? "ultrathink"
@@ -259,34 +225,6 @@ function getTraitsSectionVisibility(input: {
225
};
226
}
227
262
-function getTraitSelectChange(
263
- selected: ReturnType<typeof getSelectedTraits>,
264
- descriptor: Extract<ProviderOptionDescriptor, { type: "select" }>,
265
- prompt: string,
266
- value: string,
267
-) {
268
- if (!value) return null;
269
- if (descriptor.promptInjectedValues?.includes(value)) {
270
- return {
271
- prompt:
272
- prompt.trim().length === 0
273
- ? ULTRATHINK_PROMPT_PREFIX
274
- : applyClaudePromptEffortPrefix(prompt, "ultrathink"),
275
- };
276
- }
277
- const isPrimary = descriptor.id === selected.primarySelectDescriptor?.id;
278
- if (isPrimary && selected.ultrathinkInBodyText) return null;
279
- return {
280
- prompt:
281
- isPrimary && selected.ultrathinkPromptControlled
282
- ? prompt.replace(/^Ultrathink:\s*/i, "")
283
- : prompt,
284
- modelOptions: buildProviderOptionSelectionsFromDescriptors(
285
- replaceDescriptorCurrentValue(selected.descriptors, descriptor.id, value),
286
- ),
287
- };
288
-}
289
-
228
/**
229
* `modelOptions` must already carry the composer's implicit defaults (see
230
* `withImplicitFastModeDefault`) so the persisted selection matches what the
@@ -496,7 +434,7 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
434
value={selectedValue}
435
onValueChange={(value) => handleSelectChange(descriptor, value)}
436
>
499
- {descriptor.options.map((option) => (
437
+ {selectableProviderOptionChoices(descriptor).map((option) => (
438
<MenuRadioItem
439
key={option.id}
440
value={option.id}
@@ -558,83 +496,6 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
496
);
497
});
498
561
-export function buildTraitsTriggerDisplay(input: {
562
- provider: ProviderDriverKind;
563
- descriptors: ReadonlyArray<ProviderOptionDescriptor>;
564
- primarySelectDescriptorId: string | null;
565
- ultrathinkPromptControlled: boolean;
566
- modelSelection?: ModelSelection | null;
567
- reportedModelSelection?: ModelSelection | null | undefined;
568
-}): { label: string } {
569
- let fastModeFallbackLabel: string | null = null;
570
- let speedLabel: string | null = null;
571
- let reasoningLabelIndex = -1;
572
- const labels: Array<string> = [];
573
- for (const descriptor of input.descriptors) {
574
- if (descriptor.id === "fastMode" && descriptor.type === "boolean") {
575
- speedLabel = descriptor.currentValue === true ? "Fast" : null;
576
- fastModeFallbackLabel = speedLabel ?? "Normal";
577
- continue;
578
- }
579
- if (
580
- input.provider === "codex" &&
581
- descriptor.id === "serviceTier" &&
582
- descriptor.type === "select"
583
- ) {
584
- const currentValue = getProviderOptionCurrentValue(descriptor);
585
- const fastTier = descriptor.options.find(({ label }) => label === "Fast");
586
- const ultrafastTier = descriptor.options.find(({ label }) => label === "Ultrafast");
587
- if (
588
- ((fastTier || ultrafastTier) && currentValue === "default") ||
589
- (fastTier && currentValue === fastTier.id) ||
590
- (ultrafastTier && currentValue === ultrafastTier.id)
591
- ) {
592
- speedLabel =
593
- ultrafastTier && currentValue === ultrafastTier.id
594
- ? "Ultrafast"
595
- : fastTier && currentValue === fastTier.id
596
- ? "Fast"
597
- : null;
598
- fastModeFallbackLabel =
599
- descriptor.options.find(({ id }) => id === currentValue)?.label ?? "Normal";
600
- continue;
601
- }
602
- }
603
- const label =
604
- input.ultrathinkPromptControlled && descriptor.id === input.primarySelectDescriptorId
605
- ? "Ultrathink"
606
- : descriptor.type === "boolean"
607
- ? `${descriptor.label} ${descriptor.currentValue === true ? "On" : "Off"}`
608
- : getProviderOptionCurrentLabel(
609
- descriptor,
610
- input.modelSelection,
611
- input.reportedModelSelection,
612
- );
613
- if (typeof label === "string" && label.length > 0) {
614
- if (
615
- reasoningLabelIndex === -1 &&
616
- descriptor.type === "select" &&
617
- REASONING_SELECT_DESCRIPTOR_IDS.has(descriptor.id)
618
- ) {
619
- reasoningLabelIndex = labels.length;
620
- }
621
- labels.push(label);
622
- }
623
- }
624
-
625
- if (labels.length === 0 && fastModeFallbackLabel !== null) {
626
- return { label: fastModeFallbackLabel };
627
- }
628
- if (speedLabel) {
629
- if (reasoningLabelIndex >= 0) {
630
- labels[reasoningLabelIndex] = `${labels[reasoningLabelIndex]} ${speedLabel}`;
631
- } else {
632
- labels.push(speedLabel);
633
- }
634
- }
635
- return { label: labels.join(" · ") };
636
-}
637
-
499
export const TraitsPicker = memo(function TraitsPicker({
500
provider,
501
instanceId,
packages/client-runtime/package.json
+4
@@ -434,6 +434,10 @@
434
"./pull-request-query": {
435
"types": "./src/pullRequestQuery.ts",
436
"default": "./src/pullRequestQuery.ts"
437
+ },
438
+ "./model-traits": {
439
+ "types": "./src/modelTraits.ts",
440
+ "default": "./src/modelTraits.ts"
441
}
442
},
443
"scripts": {
packages/client-runtime/src/modelTraits.ts
new
+181
@@ -0,0 +1,181 @@
1
+import type {
2
+ ModelSelection,
3
+ ProviderDriverKind,
4
+ ProviderOptionDescriptor,
5
+} from "@t3tools/contracts";
6
+import {
7
+ applyClaudePromptEffortPrefix,
8
+ buildProviderOptionSelectionsFromDescriptors,
9
+ getProviderOptionCurrentLabel,
10
+ getProviderOptionCurrentValue,
11
+ isClaudeUltrathinkPrompt,
12
+} from "@t3tools/shared/model";
13
+import { REASONING_EFFORT_OPTION_IDS } from "./state/threadExecution.ts";
14
+
15
+export const ULTRATHINK_PROMPT_PREFIX = "Ultrathink:\n";
16
+
17
+export const REASONING_SELECT_DESCRIPTOR_IDS: ReadonlySet<string> = new Set([
18
+ ...REASONING_EFFORT_OPTION_IDS,
19
+ "thinking",
20
+]);
21
+
22
+export function replaceDescriptorCurrentValue(
23
+ descriptors: ReadonlyArray<ProviderOptionDescriptor>,
24
+ descriptorId: string,
25
+ currentValue: string | boolean | undefined,
26
+): ReadonlyArray<ProviderOptionDescriptor> {
27
+ return descriptors.map((descriptor) =>
28
+ descriptor.id !== descriptorId
29
+ ? descriptor
30
+ : descriptor.type === "boolean"
31
+ ? {
32
+ ...descriptor,
33
+ ...(typeof currentValue === "boolean" ? { currentValue } : {}),
34
+ }
35
+ : {
36
+ ...descriptor,
37
+ ...(typeof currentValue === "string" ? { currentValue } : {}),
38
+ },
39
+ );
40
+}
41
+
42
+export function getDescriptorStringValue(
43
+ descriptor: Extract<ProviderOptionDescriptor, { type: "select" }> | null,
44
+ selection?: ModelSelection | null,
45
+ reportedSelection?: ModelSelection | null,
46
+): string | null {
47
+ if (!descriptor) {
48
+ return null;
49
+ }
50
+ const value = getProviderOptionCurrentValue(descriptor, selection, reportedSelection);
51
+ return typeof value === "string" ? value : null;
52
+}
53
+
54
+export function selectableProviderOptionChoices(
55
+ descriptor: Extract<ProviderOptionDescriptor, { type: "select" }>,
56
+) {
57
+ return descriptor.options;
58
+}
59
+
60
+export function getPromptControlledTraits(
61
+ descriptors: ReadonlyArray<ProviderOptionDescriptor>,
62
+ prompt: string,
63
+ allowPromptInjectedEffort = true,
64
+) {
65
+ const primarySelectDescriptor =
66
+ descriptors.find((descriptor) => descriptor.type === "select") ?? null;
67
+ const ultrathinkPromptControlled =
68
+ allowPromptInjectedEffort &&
69
+ (primarySelectDescriptor?.promptInjectedValues?.length ?? 0) > 0 &&
70
+ isClaudeUltrathinkPrompt(prompt);
71
+ const ultrathinkInBodyText =
72
+ ultrathinkPromptControlled && isClaudeUltrathinkPrompt(prompt.replace(/^Ultrathink:\s*/i, ""));
73
+ return { primarySelectDescriptor, ultrathinkPromptControlled, ultrathinkInBodyText };
74
+}
75
+
76
+export function getTraitSelectChange(
77
+ selected: ReturnType<typeof getPromptControlledTraits> & {
78
+ descriptors: ReadonlyArray<ProviderOptionDescriptor>;
79
+ },
80
+ descriptor: Extract<ProviderOptionDescriptor, { type: "select" }>,
81
+ prompt: string,
82
+ value: string,
83
+) {
84
+ if (!value) return null;
85
+ if (descriptor.promptInjectedValues?.includes(value)) {
86
+ return {
87
+ prompt:
88
+ prompt.trim().length === 0
89
+ ? ULTRATHINK_PROMPT_PREFIX
90
+ : applyClaudePromptEffortPrefix(prompt, "ultrathink"),
91
+ };
92
+ }
93
+ const isPrimary = descriptor.id === selected.primarySelectDescriptor?.id;
94
+ if (isPrimary && selected.ultrathinkInBodyText) return null;
95
+ return {
96
+ prompt:
97
+ isPrimary && selected.ultrathinkPromptControlled
98
+ ? prompt.replace(/^Ultrathink:\s*/i, "")
99
+ : prompt,
100
+ modelOptions: buildProviderOptionSelectionsFromDescriptors(
101
+ replaceDescriptorCurrentValue(selected.descriptors, descriptor.id, value),
102
+ ),
103
+ };
104
+}
105
+
106
+export function buildTraitsTriggerDisplay(input: {
107
+ provider: ProviderDriverKind;
108
+ descriptors: ReadonlyArray<ProviderOptionDescriptor>;
109
+ primarySelectDescriptorId: string | null;
110
+ ultrathinkPromptControlled: boolean;
111
+ modelSelection?: ModelSelection | null;
112
+ reportedModelSelection?: ModelSelection | null | undefined;
113
+}): { label: string } {
114
+ let fastModeFallbackLabel: string | null = null;
115
+ let speedLabel: string | null = null;
116
+ let reasoningLabelIndex = -1;
117
+ const labels: Array<string> = [];
118
+ for (const descriptor of input.descriptors) {
119
+ if (descriptor.id === "fastMode" && descriptor.type === "boolean") {
120
+ speedLabel = descriptor.currentValue === true ? "Fast" : null;
121
+ fastModeFallbackLabel = speedLabel ?? "Normal";
122
+ continue;
123
+ }
124
+ if (
125
+ input.provider === "codex" &&
126
+ descriptor.id === "serviceTier" &&
127
+ descriptor.type === "select"
128
+ ) {
129
+ const currentValue = getProviderOptionCurrentValue(descriptor);
130
+ const fastTier = descriptor.options.find(({ label }) => label === "Fast");
131
+ const ultrafastTier = descriptor.options.find(({ label }) => label === "Ultrafast");
132
+ if (
133
+ ((fastTier || ultrafastTier) && currentValue === "default") ||
134
+ (fastTier && currentValue === fastTier.id) ||
135
+ (ultrafastTier && currentValue === ultrafastTier.id)
136
+ ) {
137
+ speedLabel =
138
+ ultrafastTier && currentValue === ultrafastTier.id
139
+ ? "Ultrafast"
140
+ : fastTier && currentValue === fastTier.id
141
+ ? "Fast"
142
+ : null;
143
+ fastModeFallbackLabel =
144
+ descriptor.options.find(({ id }) => id === currentValue)?.label ?? "Normal";
145
+ continue;
146
+ }
147
+ }
148
+ const label =
149
+ input.ultrathinkPromptControlled && descriptor.id === input.primarySelectDescriptorId
150
+ ? "Ultrathink"
151
+ : descriptor.type === "boolean"
152
+ ? `${descriptor.label} ${descriptor.currentValue === true ? "On" : "Off"}`
153
+ : getProviderOptionCurrentLabel(
154
+ descriptor,
155
+ input.modelSelection,
156
+ input.reportedModelSelection,
157
+ );
158
+ if (typeof label === "string" && label.length > 0) {
159
+ if (
160
+ reasoningLabelIndex === -1 &&
161
+ descriptor.type === "select" &&
162
+ REASONING_SELECT_DESCRIPTOR_IDS.has(descriptor.id)
163
+ ) {
164
+ reasoningLabelIndex = labels.length;
165
+ }
166
+ labels.push(label);
167
+ }
168
+ }
169
+
170
+ if (labels.length === 0 && fastModeFallbackLabel !== null) {
171
+ return { label: fastModeFallbackLabel };
172
+ }
173
+ if (speedLabel) {
174
+ if (reasoningLabelIndex >= 0) {
175
+ labels[reasoningLabelIndex] = `${labels[reasoningLabelIndex]} ${speedLabel}`;
176
+ } else {
177
+ labels.push(speedLabel);
178
+ }
179
+ }
180
+ return { label: labels.join(" · ") };
181
+}