Skip to content

Commit 02b4e4f

Browse files
committed
fix(mobile): omit unselected reasoning variants
1 parent 47f23ed commit 02b4e4f

2 files changed

Lines changed: 72 additions & 7 deletions

File tree

‎apps/mobile/src/lib/providerOptions.test.ts‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,65 @@ describe("composer model option summary", () => {
9797
expect(summary()).toEqual({ reasoningLabel: "Medium", speedLabel: undefined });
9898
});
9999

100+
const openCodeCapabilities: ModelCapabilities = {
101+
optionDescriptors: [
102+
{
103+
id: "variant",
104+
label: "Reasoning",
105+
type: "select",
106+
options: [
107+
{ id: "low", label: "Low" },
108+
{ id: "medium", label: "Medium", isDefault: true },
109+
{ id: "high", label: "High" },
110+
],
111+
currentValue: "medium",
112+
},
113+
],
114+
};
115+
116+
it("omits an unselected OpenCode variant even when the catalog has a default", () => {
117+
const reported: ModelSelection = {
118+
...selection,
119+
options: [{ id: "variant", value: "high" }],
120+
};
121+
for (const report of [
122+
undefined,
123+
{ ...reported, model: "other-model" },
124+
{ ...reported, instanceId: ProviderInstanceId.make("other-provider") },
125+
]) {
126+
expect(summary(openCodeCapabilities, selection, report, "opencode")).toEqual({
127+
reasoningLabel: undefined,
128+
speedLabel: undefined,
129+
});
130+
}
131+
});
132+
133+
it("preserves explicit and matching reported OpenCode variant labels", () => {
134+
const reported: ModelSelection = {
135+
...selection,
136+
options: [{ id: "variant", value: "low" }],
137+
};
138+
expect(summary(openCodeCapabilities, selection, reported, "opencode").reasoningLabel).toBe(
139+
"Low",
140+
);
141+
expect(
142+
summary(
143+
openCodeCapabilities,
144+
{ ...selection, options: [{ id: "variant", value: "high" }] },
145+
reported,
146+
"opencode",
147+
).reasoningLabel,
148+
).toBe("High");
149+
expect(
150+
summary(
151+
openCodeCapabilities,
152+
selection,
153+
{ ...selection, options: [{ id: "variant", value: "default" }] },
154+
"opencode",
155+
).reasoningLabel,
156+
).toBe("Default");
157+
});
158+
100159
it("shows a selected reasoning label and Codex fast tier", () => {
101160
expect(
102161
summary(CODEX_CAPABILITIES, {

‎apps/mobile/src/lib/providerOptions.ts‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,19 @@ export function composerModelOptionSummary(input: {
3131
input.selection,
3232
input.reportedSelection,
3333
);
34-
const reasoningLabel = reasoning
35-
? getProviderOptionCurrentLabel(reasoning, input.selection, input.reportedSelection)
36-
: typeof thinkingValue === "boolean"
37-
? thinkingValue
38-
? "Thinking"
39-
: "No thinking"
40-
: undefined;
34+
const reasoningValue = getProviderOptionCurrentValue(
35+
reasoning,
36+
input.selection,
37+
input.reportedSelection,
38+
);
39+
const reasoningLabel =
40+
reasoning && reasoningValue !== undefined
41+
? getProviderOptionCurrentLabel(reasoning, input.selection, input.reportedSelection)
42+
: typeof thinkingValue === "boolean"
43+
? thinkingValue
44+
? "Thinking"
45+
: "No thinking"
46+
: undefined;
4147
const speed = input.descriptors.find(
4248
(descriptor) =>
4349
(descriptor.id === "fastMode" && descriptor.type === "boolean") ||

0 commit comments

Comments
 (0)