Skip to content

Commit 82cbf83

Browse files
vitalyiegorovclaude
andcommitted
fix(web,mobile): subagent cards show which account each subagent runs on
Closes #24896 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 5b35402 commit 82cbf83

3 files changed

Lines changed: 64 additions & 12 deletions

File tree

‎apps/mobile/src/components/ProviderIcon.tsx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { useId, useState } from "react";
1010
import { resolveOfficialAcpRegistryIconUrl } from "@t3tools/contracts";
1111
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
1212
import { AppText as Text } from "./ui/AppText";
13+
import { cn } from "../lib/cn";
1314
import { getProviderClient } from "../lib/providerClients";
1415

1516
type ProviderIconProps = {
@@ -158,7 +159,7 @@ export function ProviderInstanceIcon(props: {
158159
readonly displayName: string;
159160
readonly accentColor?: string;
160161
readonly showBadge?: boolean;
161-
readonly surfaceColor: string;
162+
readonly surfaceColor?: string;
162163
}) {
163164
const accentColor = normalizeProviderAccentColor(props.accentColor);
164165
return (
@@ -173,14 +174,14 @@ export function ProviderInstanceIcon(props: {
173174
style={{ position: "absolute", right: -3, bottom: -3, width: 32, alignItems: "flex-end" }}
174175
>
175176
<View
176-
className={accentColor ? undefined : "bg-card"}
177+
className={cn(!accentColor && "bg-card", !props.surfaceColor && "border-screen")}
177178
style={{
178179
height: 12,
179180
minWidth: 12,
180181
paddingHorizontal: 2,
181182
borderRadius: 999,
182183
borderWidth: 1,
183-
borderColor: props.surfaceColor,
184+
...(props.surfaceColor ? { borderColor: props.surfaceColor } : {}),
184185
backgroundColor: accentColor,
185186
alignItems: "center",
186187
justifyContent: "center",

‎apps/mobile/src/features/threads/thread-subagent-group.tsx‎

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
import { useAtomValue } from "@effect/atom-react";
22
import { StackActions, useIsFocused, useNavigation } from "@react-navigation/native";
33
import { scopeThreadRef } from "@t3tools/client-runtime/environment";
4+
import {
5+
resolveProviderInstanceDisplayName,
6+
shouldShowInstanceBadge,
7+
} from "@t3tools/client-runtime/state/provider-instance-display";
48
import { summarizeSubagentStatuses } from "@t3tools/client-runtime/state/subagent-display";
59
import { isActiveSubagentStatus } from "@t3tools/client-runtime/state/subagentRuntime";
610
import type {
711
EnvironmentId,
812
OrchestrationV2Subagent,
913
OrchestrationV2TurnItem,
14+
ServerProvider,
1015
} from "@t3tools/contracts";
1116
import { useEffect, useState } from "react";
1217
import { AppState, Pressable, View, type ColorValue } from "react-native";
1318

1419
import { AppText as Text } from "../../components/ui/AppText";
1520
import { SymbolView } from "../../components/ui/AppSymbol";
16-
import { ProviderIcon } from "../../components/ProviderIcon";
21+
import { ProviderIcon, ProviderInstanceIcon } from "../../components/ProviderIcon";
1722
import { cn } from "../../lib/cn";
1823
import type { ThreadFeedActivity } from "../../lib/threadActivity";
1924
import { serverEnvironment } from "../../state/server";
@@ -49,14 +54,34 @@ function SubagentElapsed({ agents }: { readonly agents: ReadonlyArray<AgentTimin
4954

5055
function SubagentAvatar(props: {
5156
readonly item: SubagentItem;
52-
readonly iconUrl?: string | null | undefined;
57+
readonly providers: ReadonlyArray<ServerProvider>;
5358
}) {
59+
const provider = props.providers.find(
60+
(candidate) => candidate.instanceId === props.item.providerInstanceId,
61+
);
62+
const showBadge =
63+
provider !== undefined &&
64+
shouldShowInstanceBadge(
65+
{ ...provider, driverKind: provider.driver },
66+
props.providers.map((candidate) => ({ ...candidate, driverKind: candidate.driver })),
67+
);
5468
return (
5569
<View
5670
accessible={false}
5771
className="h-7 w-7 shrink-0 items-center justify-center rounded-full border border-border bg-card"
5872
>
59-
<ProviderIcon provider={props.item.driver} iconUrl={props.iconUrl} size={15} />
73+
{showBadge ? (
74+
<ProviderInstanceIcon
75+
provider={provider.driver}
76+
iconUrl={provider.iconUrl}
77+
size={15}
78+
displayName={resolveProviderInstanceDisplayName(provider)}
79+
accentColor={provider.accentColor}
80+
showBadge
81+
/>
82+
) : (
83+
<ProviderIcon provider={props.item.driver} iconUrl={provider?.iconUrl} size={15} />
84+
)}
6085
</View>
6186
);
6287
}
@@ -95,8 +120,6 @@ export function ThreadSubagentGroup(props: {
95120
const label = `${agents.length} subagents`;
96121
const summary = summarizeSubagentStatuses(agents.map((agent) => agent.status));
97122
const expanded = props.expandedRows[props.anchorKey] ?? false;
98-
const iconUrl = (item: SubagentItem) =>
99-
config?.providers.find((provider) => provider.instanceId === item.providerInstanceId)?.iconUrl;
100123
return (
101124
<WorkLogBlock>
102125
{grouped ? (
@@ -110,7 +133,7 @@ export function ThreadSubagentGroup(props: {
110133
<View className="flex-row items-center">
111134
{agents.slice(0, 3).map((agent, index) => (
112135
<View key={agent.item.id} style={{ marginLeft: index === 0 ? 0 : -7 }}>
113-
<SubagentAvatar item={agent.item} iconUrl={iconUrl(agent.item)} />
136+
<SubagentAvatar item={agent.item} providers={config?.providers ?? []} />
114137
</View>
115138
))}
116139
{agents.length > 3 ? (

‎apps/web/src/components/chat/V2LifecycleRow.tsx‎

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,16 @@ function SubagentAvatar({
259259
driver,
260260
displayName,
261261
iconUrl,
262+
accentColor,
263+
showBadge,
262264
status,
263265
className,
264266
}: {
265267
driver?: ProviderDriverKind | undefined;
266268
displayName?: string | undefined;
267269
iconUrl?: string | undefined;
270+
accentColor?: string | undefined;
271+
showBadge: boolean;
268272
status?: OrchestrationV2TurnItem["status"] | undefined;
269273
className?: string;
270274
}) {
@@ -280,7 +284,10 @@ function SubagentAvatar({
280284
<ProviderInstanceIcon
281285
driverKind={driver}
282286
displayName={displayName ?? driver}
287+
accentColor={accentColor}
283288
acpRegistryIconUrl={iconUrl}
289+
showBadge={showBadge}
290+
size="compact"
284291
className="z-auto"
285292
iconClassName="size-3.5"
286293
/>
@@ -290,7 +297,8 @@ function SubagentAvatar({
290297
{status ? (
291298
<span
292299
className={cn(
293-
"absolute -right-px -bottom-px size-2 rounded-full ring-2 ring-background",
300+
"absolute size-2 rounded-full ring-2 ring-background",
301+
showBadge ? "-left-px -top-px" : "-right-px -bottom-px",
294302
subagentStatusVisual(status).dotClass,
295303
)}
296304
/>
@@ -311,17 +319,37 @@ export function EnvironmentSubagentAvatar({
311319
status?: OrchestrationV2TurnItem["status"] | undefined;
312320
}) {
313321
const providersAtom = serverEnvironment.providersValueAtom(environmentId);
322+
const entries = (providers: ReadonlyArray<ServerProvider> | null | undefined) =>
323+
deriveProviderInstanceEntries(providers ?? []);
314324
const displayName = useAtomValue(
315325
providersAtom,
316326
(providers) =>
317-
providers?.find((provider) => provider.instanceId === providerInstanceId)?.displayName,
327+
entries(providers).find((entry) => entry.instanceId === providerInstanceId)?.displayName,
318328
);
329+
const accentColor = useAtomValue(
330+
providersAtom,
331+
(providers) =>
332+
entries(providers).find((entry) => entry.instanceId === providerInstanceId)?.accentColor,
333+
);
334+
const showBadge = useAtomValue(providersAtom, (providers) => {
335+
const all = entries(providers);
336+
const entry = all.find((candidate) => candidate.instanceId === providerInstanceId);
337+
return entry !== undefined && shouldShowInstanceBadge(entry, all);
338+
});
319339
const iconUrl = useAtomValue(
320340
providersAtom,
321341
(providers) =>
322342
providers?.find((provider) => provider.instanceId === providerInstanceId)?.iconUrl,
323343
);
324-
return <SubagentAvatar {...props} displayName={displayName} iconUrl={iconUrl} />;
344+
return (
345+
<SubagentAvatar
346+
{...props}
347+
displayName={displayName}
348+
iconUrl={iconUrl}
349+
accentColor={accentColor}
350+
showBadge={showBadge}
351+
/>
352+
);
325353
}
326354

327355
const NOTIFICATION_OUTCOME_STATUS: Record<

0 commit comments

Comments
 (0)