Skip to content

Commit 32fe647

Browse files
vitalyiegorovclaude
andcommitted
fix(clients): handoff badges tell ACP agents apart
The badge rule skips different ACP registry agents because their glyphs already differ, but the handoff endpoints read only server snapshots, which carry no agent ID. Both clients now take it from the instance settings, as ChatView does, so two different ACP agents no longer get a redundant account badge. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 2533c9f commit 32fe647

3 files changed

Lines changed: 32 additions & 10 deletions

File tree

‎apps/mobile/src/features/threads/thread-handoff-row.tsx‎

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from "@t3tools/client-runtime/state/provider-instance-display";
99
import type {
1010
EnvironmentId,
11+
ProviderInstanceConfig,
1112
OrchestrationV2ProjectedTurnItem,
1213
ProviderInstanceId,
1314
ServerProvider,
@@ -53,7 +54,11 @@ export function ThreadHandoffRow(props: {
5354
const config = useAtomValue(serverEnvironment.configValueAtom(props.environmentId));
5455
if (item.type !== "handoff" || endpoints === null) return null;
5556
const color = item.status === "failed" ? "#e11d48" : props.iconColor;
56-
const endpointProps = { providers: config?.providers ?? [], surfaceColor: props.surfaceColor };
57+
const endpointProps = {
58+
providers: config?.providers ?? [],
59+
providerInstances: config?.settings.providerInstances,
60+
surfaceColor: props.surfaceColor,
61+
};
5762
return (
5863
<ThreadContextDivider
5964
label="Context handoff"
@@ -85,6 +90,7 @@ function HandoffEndpoint(props: {
8590
instanceId: ProviderInstanceId;
8691
model?: string | undefined;
8792
providers: ReadonlyArray<ServerProvider>;
93+
providerInstances: Readonly<Record<string, ProviderInstanceConfig>> | undefined;
8894
surfaceColor: string;
8995
}) {
9096
const provider = props.providers.find((candidate) => candidate.instanceId === props.instanceId);
@@ -96,12 +102,21 @@ function HandoffEndpoint(props: {
96102
(provider ? resolveProviderInstanceDisplayName(provider) : props.instanceId);
97103
const accentColor = normalizeProviderAccentColor(provider?.accentColor);
98104
// Same account badge as the thread rows: a handoff between two accounts of
99-
// one provider would otherwise show the same glyph on both sides.
105+
// one provider would otherwise show the same glyph on both sides. Settings
106+
// carry each ACP instance's agent, which tells its glyph apart.
107+
const badgeEntry = (candidate: ServerProvider) => {
108+
const config = props.providerInstances?.[candidate.instanceId]?.config;
109+
const agentId = typeof config === "object" && config ? Reflect.get(config, "agentId") : null;
110+
return {
111+
driverKind: candidate.driver,
112+
...(typeof agentId === "string" ? { acpRegistryAgentId: agentId.trim() } : {}),
113+
};
114+
};
100115
const showBadge =
101116
provider !== undefined &&
102117
shouldShowInstanceBadge(
103-
{ driverKind: provider.driver, accentColor },
104-
props.providers.map((candidate) => ({ driverKind: candidate.driver })),
118+
{ ...badgeEntry(provider), accentColor },
119+
props.providers.map(badgeEntry),
105120
);
106121
return (
107122
<Pressable

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ import {
3838

3939
import { Tooltip, TooltipTrigger, TooltipPopup } from "../ui/tooltip";
4040
import {
41+
applyProviderInstanceSettings,
4142
deriveProviderInstanceEntries,
42-
getProviderInstanceEntry,
4343
shouldShowInstanceBadge,
4444
} from "../../providerInstances";
45+
import { useEnvironmentSettings } from "../../hooks/useSettings";
4546
import { formatShortTimestamp } from "../../timestampFormat";
4647
import { getTriggerDisplayModelName } from "./providerIconUtils";
4748
import { ProviderInstanceIcon, providerTextColorClassName } from "./ProviderInstanceIcon";
@@ -141,6 +142,7 @@ export function V2LifecycleRow(props: {
141142
</span>
142143
) : null}
143144
<HandoffEndpoint
145+
environmentId={props.environmentId}
144146
providers={props.providerStatuses}
145147
instanceId={endpoint.instanceId}
146148
model={endpoint.model}
@@ -151,6 +153,7 @@ export function V2LifecycleRow(props: {
151153
<ArrowRightIcon aria-hidden="true" className="size-3 shrink-0" />
152154
) : null}
153155
<HandoffEndpoint
156+
environmentId={props.environmentId}
154157
providers={props.providerStatuses}
155158
instanceId={item.toProviderInstanceId}
156159
model={to.model}
@@ -560,16 +563,20 @@ function SubagentTimelineTooltip(
560563
}
561564

562565
function HandoffEndpoint(props: {
566+
readonly environmentId: EnvironmentId;
563567
readonly providers: ReadonlyArray<ServerProvider>;
564568
readonly instanceId: ProviderInstanceId;
565569
readonly model?: string | undefined;
566570
}) {
567-
const entry = getProviderInstanceEntry(props.providers, props.instanceId);
571+
// Settings carry each ACP instance's agent, which tells its glyph apart.
572+
const entries = applyProviderInstanceSettings(
573+
deriveProviderInstanceEntries(props.providers),
574+
useEnvironmentSettings(props.environmentId),
575+
);
576+
const entry = entries.find((candidate) => candidate.instanceId === props.instanceId);
568577
// Same account badge as the sidebar: a handoff between two accounts of one
569578
// provider would otherwise show the same glyph on both sides.
570-
const showBadge =
571-
entry !== undefined &&
572-
shouldShowInstanceBadge(entry, deriveProviderInstanceEntries(props.providers));
579+
const showBadge = entry !== undefined && shouldShowInstanceBadge(entry, entries);
573580
const model = props.model?.trim();
574581
const providerModel =
575582
model === undefined || model.length === 0

‎apps/web/src/providerInstances.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ export function sortProviderInstanceEntries(
261261
* Look up a single instance entry by exact `instanceId`. Missing snapshots
262262
* are not inferred from driver kind in UI routing code.
263263
*/
264-
export function getProviderInstanceEntry(
264+
function getProviderInstanceEntry(
265265
providers: ReadonlyArray<ServerProvider>,
266266
instanceId: ProviderInstanceId,
267267
): ProviderInstanceEntry | undefined {

0 commit comments

Comments
 (0)