Skip to content

Commit 0b1ef3a

Browse files
committed
fix(mobile): resolve workflow child provider traits
1 parent 3fe1d51 commit 0b1ef3a

3 files changed

Lines changed: 99 additions & 9 deletions

File tree

‎apps/mobile/src/features/threads/SubagentRow.tsx‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,14 @@ function SubagentMetadata(props: {
114114
parentProject,
115115
childProject,
116116
});
117-
const traits = resolveSubagentTraits({ subagent, provider, childThread: child });
117+
const traits = resolveSubagentTraits({
118+
subagent,
119+
provider,
120+
childThread: child,
121+
childProvider: config?.providers.find(
122+
(candidate) => candidate.instanceId === child?.providerInstanceId,
123+
),
124+
});
118125
return (
119126
<View className="min-w-0 flex-row items-center gap-1.5">
120127
<ProviderIcon

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

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe("subagent traits", () => {
8383
resolveSubagentTraits({
8484
subagent: { ...subagent, modelSelection: undefined },
8585
provider,
86-
childThread: { modelSelection: selection },
86+
childThread: { providerInstanceId: instanceId, modelSelection: selection },
8787
}),
8888
).toBe("High · Fast");
8989
});
@@ -93,7 +93,7 @@ describe("subagent traits", () => {
9393
resolveSubagentTraits({
9494
subagent: { ...subagent, origin: "provider_native", modelSelection: undefined },
9595
provider,
96-
childThread: { modelSelection: selection },
96+
childThread: { providerInstanceId: instanceId, modelSelection: selection },
9797
}),
9898
).toBe("");
9999
});
@@ -120,6 +120,7 @@ describe("subagent traits", () => {
120120
subagent,
121121
provider,
122122
childThread: {
123+
providerInstanceId: instanceId,
123124
modelSelection: { ...selection, options: [{ id: "reasoningEffort", value: "low" }] },
124125
},
125126
}),
@@ -178,4 +179,73 @@ describe("subagent traits", () => {
178179
}),
179180
).toBe(label);
180181
});
182+
183+
it("uses a validated app-owned child's provider for cross-provider workflow traits", () => {
184+
const childInstanceId = ProviderInstanceId.make("claude");
185+
const childSelection: ModelSelection = {
186+
instanceId: childInstanceId,
187+
model: "claude-test",
188+
options: [
189+
{ id: "effort", value: "max" },
190+
{ id: "fastMode", value: true },
191+
],
192+
};
193+
const childProvider = {
194+
instanceId: childInstanceId,
195+
driver: ProviderDriverKind.make("claudeAgent"),
196+
models: [
197+
{
198+
slug: "claude-test",
199+
name: "Claude Test",
200+
isCustom: false,
201+
capabilities: {
202+
optionDescriptors: [
203+
{
204+
id: "effort",
205+
label: "Effort",
206+
type: "select" as const,
207+
options: [{ id: "max", label: "Max" }],
208+
},
209+
{ id: "fastMode", label: "Fast", type: "boolean" as const },
210+
],
211+
},
212+
},
213+
],
214+
};
215+
const input = {
216+
subagent: { ...subagent, model: "Claude Test", modelSelection: undefined },
217+
provider,
218+
childProvider,
219+
childThread: { providerInstanceId: childInstanceId, modelSelection: childSelection },
220+
};
221+
expect(resolveSubagentTraits(input)).toBe("Max · Fast");
222+
expect(resolveSubagentTraits({ ...input, subagent })).toBe("High · Fast");
223+
expect(
224+
resolveSubagentTraits({
225+
...input,
226+
subagent: { ...input.subagent, origin: "provider_native" },
227+
}),
228+
).toBe("");
229+
expect(resolveSubagentTraits({ ...input, childThread: undefined })).toBe("");
230+
expect(resolveSubagentTraits({ ...input, childProvider: undefined })).toBe("");
231+
expect(
232+
resolveSubagentTraits({
233+
...input,
234+
childThread: { ...input.childThread, providerInstanceId: instanceId },
235+
}),
236+
).toBe("");
237+
expect(
238+
resolveSubagentTraits({ ...input, childProvider: { ...childProvider, instanceId } }),
239+
).toBe("");
240+
expect(
241+
resolveSubagentTraits({ ...input, subagent: { ...input.subagent, model: "another-model" } }),
242+
).toBe("");
243+
expect(
244+
resolveSubagentTraits({
245+
subagent: { ...subagent, modelSelection: undefined },
246+
provider,
247+
childThread: { providerInstanceId: childInstanceId, modelSelection: selection },
248+
}),
249+
).toBe("");
250+
});
181251
});

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,25 @@ export function resolveSubagentTraits(input: {
2020
"model" | "providerInstanceId" | "origin" | "modelSelection"
2121
>;
2222
readonly provider?: Pick<ServerProvider, "driver" | "models"> | undefined;
23-
readonly childThread?: Pick<OrchestrationV2ThreadShell, "modelSelection"> | undefined;
23+
readonly childProvider?: Pick<ServerProvider, "instanceId" | "driver" | "models"> | undefined;
24+
readonly childThread?:
25+
| Pick<OrchestrationV2ThreadShell, "providerInstanceId" | "modelSelection">
26+
| undefined;
2427
}): string {
25-
const { subagent, provider } = input;
26-
const selection =
27-
subagent.modelSelection ??
28-
(subagent.origin === "app_owned" ? input.childThread?.modelSelection : undefined);
28+
const { subagent, childThread } = input;
29+
const childSelection =
30+
subagent.origin === "app_owned" &&
31+
subagent.modelSelection === undefined &&
32+
childThread !== undefined &&
33+
childThread.providerInstanceId === childThread.modelSelection.instanceId
34+
? childThread.modelSelection
35+
: undefined;
36+
const childProvider =
37+
childSelection && childSelection.instanceId === input.childProvider?.instanceId
38+
? input.childProvider
39+
: undefined;
40+
const provider = childProvider ?? input.provider;
41+
const selection = subagent.modelSelection ?? childSelection;
2942
const modelSlug = provider
3043
? resolveSelectableModel(provider.driver, subagent.model, provider.models)
3144
: subagent.model?.trim();
@@ -36,7 +49,7 @@ export function resolveSubagentTraits(input: {
3649
!selection ||
3750
modelSlug == null ||
3851
selectedModel !== modelSlug ||
39-
selection.instanceId !== subagent.providerInstanceId
52+
selection.instanceId !== (childProvider?.instanceId ?? subagent.providerInstanceId)
4053
)
4154
return "";
4255

0 commit comments

Comments
 (0)