Skip to content

Commit 3fe1d51

Browse files
committed
fix(mobile): validate saved agent traits
1 parent fda4a65 commit 3fe1d51

2 files changed

Lines changed: 44 additions & 9 deletions

File tree

‎apps/mobile/src/features/threads/threadAgentsPresentation.test.ts‎

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ const provider = {
2626
isCustom: false,
2727
capabilities: {
2828
optionDescriptors: [
29+
{
30+
id: "reasoningEffort",
31+
label: "Effort",
32+
type: "select" as const,
33+
options: [{ id: "high", label: "High" }],
34+
},
2935
{
3036
id: "serviceTier",
3137
label: "Speed",
@@ -44,8 +50,32 @@ const provider = {
4450
};
4551

4652
describe("subagent traits", () => {
53+
it("does not match two models that are absent from the catalog", () => {
54+
expect(
55+
resolveSubagentTraits({
56+
subagent: {
57+
...subagent,
58+
model: "missing-agent-model",
59+
modelSelection: { ...selection, model: "missing-selection-model" },
60+
},
61+
provider,
62+
}),
63+
).toBe("");
64+
});
65+
66+
it("hides an obsolete saved effort value", () => {
67+
expect(
68+
resolveSubagentTraits({
69+
subagent: {
70+
...subagent,
71+
modelSelection: { ...selection, options: [{ id: "reasoningEffort", value: "removed" }] },
72+
},
73+
provider,
74+
}),
75+
).toBe("");
76+
});
4777
it("shows the agent's saved effort and speed, including model display names", () => {
48-
expect(resolveSubagentTraits({ subagent, provider })).toBe("high · Fast");
78+
expect(resolveSubagentTraits({ subagent, provider })).toBe("High · Fast");
4979
});
5080

5181
it("uses an app-owned child's selection when the agent has no saved selection", () => {
@@ -55,7 +85,7 @@ describe("subagent traits", () => {
5585
provider,
5686
childThread: { modelSelection: selection },
5787
}),
58-
).toBe("high · Fast");
88+
).toBe("High · Fast");
5989
});
6090

6191
it("does not use a provider-managed child's selection", () => {
@@ -93,7 +123,7 @@ describe("subagent traits", () => {
93123
modelSelection: { ...selection, options: [{ id: "reasoningEffort", value: "low" }] },
94124
},
95125
}),
96-
).toBe("high · Fast");
126+
).toBe("High · Fast");
97127
});
98128

99129
it("shows Claude effort and boolean fast mode", () => {
@@ -117,14 +147,20 @@ describe("subagent traits", () => {
117147
...provider.models[0]!,
118148
capabilities: {
119149
optionDescriptors: [
150+
{
151+
id: "effort",
152+
label: "Effort",
153+
type: "select",
154+
options: [{ id: "max", label: "Max" }],
155+
},
120156
{ id: "fastMode", label: "Fast", type: "boolean", currentValue: false },
121157
],
122158
},
123159
},
124160
],
125161
},
126162
}),
127-
).toBe("max · Fast");
163+
).toBe("Max · Fast");
128164
});
129165

130166
it.each([

‎apps/mobile/src/features/threads/threadAgentsPresentation.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import {
33
subagentDetailPreview,
44
} from "@t3tools/client-runtime/state/subagent-display";
55
import { isActiveSubagentStatus } from "@t3tools/client-runtime/state/subagentRuntime";
6-
import { REASONING_EFFORT_OPTION_IDS } from "@t3tools/client-runtime/state/thread-execution";
6+
import { formatModelSelectionEffort } from "@t3tools/client-runtime/state/thread-execution";
77
import { buildTraitsTriggerDisplay } from "@t3tools/client-runtime/model-traits";
88
import type {
99
OrchestrationV2Subagent,
1010
OrchestrationV2ThreadShell,
1111
ServerProvider,
1212
} from "@t3tools/contracts";
13-
import { getModelSelectionStringOptionValue, resolveSelectableModel } from "@t3tools/shared/model";
13+
import { resolveSelectableModel } from "@t3tools/shared/model";
1414

1515
const PROMPT_TITLE_LIMIT = 80;
1616

@@ -34,14 +34,13 @@ export function resolveSubagentTraits(input: {
3434
: selection?.model.trim();
3535
if (
3636
!selection ||
37+
modelSlug == null ||
3738
selectedModel !== modelSlug ||
3839
selection.instanceId !== subagent.providerInstanceId
3940
)
4041
return "";
4142

42-
const effort = REASONING_EFFORT_OPTION_IDS.map((id) =>
43-
getModelSelectionStringOptionValue(selection, id),
44-
).find(Boolean);
43+
const effort = formatModelSelectionEffort({ ...selection, model: modelSlug }, provider?.models);
4544
const descriptors =
4645
provider?.models.find((model) => model.slug === modelSlug)?.capabilities?.optionDescriptors ??
4746
[];

0 commit comments

Comments
 (0)