Skip to content

Commit a753b9f

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 c83dee5 commit a753b9f

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}
@@ -556,16 +559,20 @@ function SubagentTimelineTooltip(
556559
}
557560

558561
function HandoffEndpoint(props: {
562+
readonly environmentId: EnvironmentId;
559563
readonly providers: ReadonlyArray<ServerProvider>;
560564
readonly instanceId: ProviderInstanceId;
561565
readonly model?: string | undefined;
562566
}) {
563-
const entry = getProviderInstanceEntry(props.providers, props.instanceId);
567+
// Settings carry each ACP instance's agent, which tells its glyph apart.
568+
const entries = applyProviderInstanceSettings(
569+
deriveProviderInstanceEntries(props.providers),
570+
useEnvironmentSettings(props.environmentId),
571+
);
572+
const entry = entries.find((candidate) => candidate.instanceId === props.instanceId);
564573
// Same account badge as the sidebar: a handoff between two accounts of one
565574
// provider would otherwise show the same glyph on both sides.
566-
const showBadge =
567-
entry !== undefined &&
568-
shouldShowInstanceBadge(entry, deriveProviderInstanceEntries(props.providers));
575+
const showBadge = entry !== undefined && shouldShowInstanceBadge(entry, entries);
569576
const model = props.model?.trim();
570577
const providerModel =
571578
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)