Skip to content
TypeScript

fix(web,mobile): lineage and agent rows show which account a subagent runs on (#24833)

Vitaly Iegorov0343c83aa6d0
diff --git a/apps/mobile/src/components/ProviderIcon.tsx b/apps/mobile/src/components/ProviderIcon.tsx
index 1fe46085d9e..49ed0f53d24 100644
--- a/apps/mobile/src/components/ProviderIcon.tsx
+++ b/apps/mobile/src/components/ProviderIcon.tsx
@@ -10,6 +10,7 @@ import { useId, useState } from "react";
import { resolveOfficialAcpRegistryIconUrl } from "@t3tools/contracts";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
import { AppText as Text } from "./ui/AppText";
+import { cn } from "../lib/cn";
import { getProviderClient } from "@t3tools/client-runtime/provider-clients";
type ProviderIconProps = {
@@ -158,7 +159,7 @@ export function ProviderInstanceIcon(props: {
readonly displayName: string;
readonly accentColor?: string;
readonly showBadge?: boolean;
- readonly surfaceColor: string;
+ readonly surfaceColor?: string;
}) {
const accentColor = normalizeProviderAccentColor(props.accentColor);
return (
@@ -173,7 +174,7 @@ export function ProviderInstanceIcon(props: {
style={{ position: "absolute", right: -3, bottom: -3, width: 32, alignItems: "flex-end" }}
>
<View
- className={accentColor ? undefined : "bg-card"}
+ className={cn(!accentColor && "bg-card", !props.surfaceColor && "border-screen")}
style={{
height: 12,
minWidth: 12,
diff --git a/apps/mobile/src/features/threads/SubagentRow.tsx b/apps/mobile/src/features/threads/SubagentRow.tsx
index a888adb8273..ffca391f260 100644
--- a/apps/mobile/src/features/threads/SubagentRow.tsx
+++ b/apps/mobile/src/features/threads/SubagentRow.tsx
@@ -1,5 +1,9 @@
import { scopeProjectRef, scopeThreadRef } from "@t3tools/client-runtime/environment";
-import { resolveProviderInstanceDisplayName } from "@t3tools/client-runtime/state/provider-instance-display";
+import {
+ normalizeProviderAccentColor,
+ resolveProviderInstanceDisplayName,
+ shouldShowInstanceBadge,
+} from "@t3tools/client-runtime/state/provider-instance-display";
import { resolveSubagentMetadata } from "@t3tools/client-runtime/state/subagent-display";
import type { EnvironmentId, OrchestrationV2Subagent } from "@t3tools/contracts";
import type { ReactNode } from "react";
@@ -7,7 +11,7 @@ import { View } from "react-native";
import { AppText as Text } from "../../components/ui/AppText";
import { SymbolView } from "../../components/ui/AppSymbol";
-import { ProviderIcon } from "../../components/ProviderIcon";
+import { ProviderIcon, ProviderInstanceIcon } from "../../components/ProviderIcon";
import { cn } from "../../lib/cn";
import { useEnvironmentServerConfig, useProject, useThreadShell } from "../../state/entities";
import { subagentCardDetail } from "./subagent-card-presentation";
@@ -102,9 +106,24 @@ function SubagentMetadata(props: {
const { environmentId, subagent } = props;
// A task in a linked environment runs a provider instance of that environment.
const config = useEnvironmentServerConfig(subagent.remoteChild?.environmentId ?? environmentId);
- const provider = config?.providers.find(
+ const providers = (config?.providers ?? []).map((candidate) => {
+ const rawConfig = config?.settings.providerInstances[candidate.instanceId]?.config;
+ const instanceConfig =
+ rawConfig !== null && typeof rawConfig === "object"
+ ? (rawConfig as Readonly<Record<string, unknown>>)
+ : null;
+ const agentId = instanceConfig?.source === "local" ? undefined : instanceConfig?.agentId;
+ return {
+ ...candidate,
+ driverKind: candidate.driver,
+ accentColor: normalizeProviderAccentColor(candidate.accentColor),
+ acpRegistryAgentId: typeof agentId === "string" ? agentId.trim() || undefined : undefined,
+ };
+ });
+ const provider = providers.find(
(candidate) => candidate.instanceId === subagent.providerInstanceId,
);
+ const showBadge = provider !== undefined && shouldShowInstanceBadge(provider, providers);
const parent = useThreadShell(scopeThreadRef(environmentId, subagent.threadId))?.source;
const child = useThreadShell(
subagent.childThreadId === null ? null : scopeThreadRef(environmentId, subagent.childThreadId),
@@ -123,11 +142,22 @@ function SubagentMetadata(props: {
});
return (
<View className="min-w-0 flex-row items-center gap-1.5">
- <ProviderIcon
- provider={provider?.driver ?? subagent.driver}
- iconUrl={provider?.iconUrl}
- size={12}
- />
+ {showBadge ? (
+ <ProviderInstanceIcon
+ provider={provider.driver}
+ iconUrl={provider.iconUrl}
+ size={12}
+ displayName={resolveProviderInstanceDisplayName(provider)}
+ accentColor={provider.accentColor}
+ showBadge
+ />
+ ) : (
+ <ProviderIcon
+ provider={provider?.driver ?? subagent.driver}
+ iconUrl={provider?.iconUrl}
+ size={12}
+ />
+ )}
<Text className="min-w-0 shrink text-xs text-foreground-muted" numberOfLines={1}>
{provider ? `${resolveProviderInstanceDisplayName(provider)} · ` : ""}
{modelLabel}
diff --git a/apps/web/src/components/chat/ThreadLineageWorkflowRow.tsx b/apps/web/src/components/chat/ThreadLineageWorkflowRow.tsx
index ae13f519e02..9d31ec35761 100644
--- a/apps/web/src/components/chat/ThreadLineageWorkflowRow.tsx
+++ b/apps/web/src/components/chat/ThreadLineageWorkflowRow.tsx
@@ -10,6 +10,7 @@ import { AgentElapsed } from "./AgentElapsed";
import { SubagentTooltipContent } from "./SubagentTooltipContent";
import { ThreadHoverCardPopup } from "../ThreadHoverCard";
import { ThreadRelationshipIcon } from "./ThreadRelationshipIcon";
+import type { ProviderInstanceEntry } from "../../providerInstances";
import { cn } from "../../lib/utils";
import { ThreadDetailsControl } from "./ThreadDetailsControl";
import { CollapsibleSectionHeader, SectionHeaderStatus } from "../ui/collapsible-section-header";
@@ -52,6 +53,7 @@ function WorkflowMemberRow({
providerInstanceId,
provider,
providers,
+ providerEntries,
driver,
onOpen,
}: {
@@ -59,6 +61,7 @@ function WorkflowMemberRow({
providerInstanceId: ProviderInstanceId;
provider: ServerProvider | undefined;
providers: ReadonlyArray<ServerProvider> | undefined;
+ providerEntries: ReadonlyArray<ProviderInstanceEntry>;
driver: ProviderDriverKind | undefined;
onOpen: (threadId: string) => void;
}) {
@@ -78,7 +81,12 @@ function WorkflowMemberRow({
/>
}
>
- <ThreadRelationshipIcon driver={driver} provider={provider} status={member.status} />
+ <ThreadRelationshipIcon
+ driver={driver}
+ provider={provider}
+ providerEntries={providerEntries}
+ status={member.status}
+ />
<span className="min-w-0 flex-1 truncate">{member.title}</span>
<span className="sr-only">{member.status}</span>
{member.startedAt ? (
@@ -113,6 +121,7 @@ export function ThreadLineageWorkflowRow({
providerInstanceId,
provider,
providers,
+ providerEntries,
driver,
onOpenThread,
onStop,
@@ -124,6 +133,7 @@ export function ThreadLineageWorkflowRow({
readonly providerInstanceId: ProviderInstanceId;
readonly provider: ServerProvider | undefined;
readonly providers: ReadonlyArray<ServerProvider> | undefined;
+ readonly providerEntries: ReadonlyArray<ProviderInstanceEntry>;
readonly driver: ProviderDriverKind | undefined;
readonly onOpenThread: (threadId: string) => void;
readonly onStop?: (() => void) | undefined;
@@ -221,6 +231,7 @@ export function ThreadLineageWorkflowRow({
providerInstanceId={providerInstanceId}
provider={provider}
providers={providers}
+ providerEntries={providerEntries}
driver={driver}
onOpen={onOpenThread}
/>
@@ -237,6 +248,7 @@ export function ThreadLineageWorkflowRow({
providerInstanceId={providerInstanceId}
provider={provider}
providers={providers}
+ providerEntries={providerEntries}
driver={driver}
onOpen={onOpenThread}
/>
diff --git a/apps/web/src/components/chat/ThreadRelationshipIcon.tsx b/apps/web/src/components/chat/ThreadRelationshipIcon.tsx
index 6b6b3221593..c007ac03c2c 100644
--- a/apps/web/src/components/chat/ThreadRelationshipIcon.tsx
+++ b/apps/web/src/components/chat/ThreadRelationshipIcon.tsx
@@ -1,6 +1,7 @@
import type { ProviderDriverKind, ServerProvider } from "@t3tools/contracts";
import { BotIcon, type LucideIcon } from "lucide-react";
import { cn } from "../../lib/utils";
+import { shouldShowInstanceBadge, type ProviderInstanceEntry } from "../../providerInstances";
import { ProviderInstanceIcon } from "./ProviderInstanceIcon";
export function threadRelationshipStatusLabel(status: string | null): string {
@@ -45,22 +46,32 @@ export function threadRelationshipStatusLabel(status: string | null): string {
export function ThreadRelationshipIcon({
driver,
provider,
+ providerEntries = [],
status,
fallbackIcon: FallbackIcon = BotIcon,
}: {
driver?: ProviderDriverKind | undefined;
provider?: ServerProvider | undefined;
+ providerEntries?: ReadonlyArray<ProviderInstanceEntry>;
status: string | null;
fallbackIcon?: LucideIcon;
}) {
const iconClassName = "size-4 shrink-0 text-muted-foreground";
+ const entry = driver
+ ? providerEntries.find((candidate) => candidate.instanceId === provider?.instanceId)
+ : undefined;
+ const showInstanceBadge = entry !== undefined && shouldShowInstanceBadge(entry, providerEntries);
return (
<span className="relative inline-flex size-4 shrink-0 items-center justify-center">
{driver ? (
<ProviderInstanceIcon
driverKind={driver}
- displayName={provider?.displayName ?? driver}
- acpRegistryIconUrl={provider?.iconUrl}
+ displayName={entry?.displayName ?? provider?.displayName ?? driver}
+ accentColor={entry?.accentColor}
+ acpRegistryAgentId={entry?.acpRegistryAgentId}
+ acpRegistryIconUrl={entry?.acpRegistryIconUrl ?? provider?.iconUrl}
+ showBadge={showInstanceBadge}
+ size="compact"
iconClassName={iconClassName}
className="z-auto"
/>
@@ -69,7 +80,8 @@ export function ThreadRelationshipIcon({
)}
<span
className={cn(
- "absolute -bottom-1 -right-1 size-2 rounded-full border-2 border-card",
+ "absolute size-2 rounded-full border-2 border-card",
+ showInstanceBadge ? "-left-1 -top-1" : "-bottom-1 -right-1",
status === "running" ||
status === "in_progress" ||
status === "pending" ||
diff --git a/apps/web/src/components/chat/ThreadRelationshipsControl.tsx b/apps/web/src/components/chat/ThreadRelationshipsControl.tsx
index 0a9d20cd71e..a3eaf6e787b 100644
--- a/apps/web/src/components/chat/ThreadRelationshipsControl.tsx
+++ b/apps/web/src/components/chat/ThreadRelationshipsControl.tsx
@@ -66,6 +66,11 @@ import {
useThreadRelationshipShells,
} from "../../state/entities";
import { useEnvironment, useEnvironmentProviders } from "../../state/environments";
+import { serverEnvironment } from "../../state/server";
+import {
+ applyProviderInstanceSettings,
+ deriveProviderInstanceEntries,
+} from "../../providerInstances";
import { threadEnvironment } from "../../state/threads";
import { orchestrationEnvironment } from "../../state/orchestration";
import { useAtomCommand } from "../../state/use-atom-command";
@@ -357,6 +362,7 @@ export function ThreadRelationshipsPanel(props: {
const ref = scopeThreadRef(props.environmentId, props.threadId);
const projection = useThreadProjection(ref)?.projection ?? null;
const providersByEnvironment = useEnvironmentProviders();
+ const settings = useAtomValue(serverEnvironment.settingsValueAtom(props.environmentId));
const relationshipShells = useThreadRelationshipShells(ref);
const allProjects = useProjects();
const archived = useArchivedThreadSnapshots([props.environmentId]);
@@ -394,6 +400,14 @@ export function ThreadRelationshipsPanel(props: {
const [stoppingId, setStoppingId] = useState<string | null>(null);
// Derive graphs after hooks to preserve their compiler cache.
const providers = providersByEnvironment.get(props.environmentId);
+ const derivedProviderEntries = deriveProviderInstanceEntries(providers ?? []);
+ const providerEntries = settings
+ ? applyProviderInstanceSettings(
+ derivedProviderEntries,
+ settings,
+ currentThread?.projectId ?? null,
+ )
+ : derivedProviderEntries;
const projects = allProjects.filter((project) => project.environmentId === props.environmentId);
const parentNativeStatus = parentProjection
? deriveProviderSubagentStatus(parentProjection)?.status
@@ -673,6 +687,7 @@ export function ThreadRelationshipsPanel(props: {
<ThreadRelationshipIcon
driver={isSubagent && !isParent ? providerDriver : undefined}
provider={provider}
+ providerEntries={providerEntries}
fallbackIcon={RelationshipIcon}
status={rowStatus}
/>
@@ -729,6 +744,7 @@ export function ThreadRelationshipsPanel(props: {
providerInstanceId={agent.providerInstanceId}
provider={provider}
providers={providers}
+ providerEntries={providerEntries}
driver={providerDriver}
onOpenThread={(memberThreadId) => openThread(memberThreadId as ThreadId)}
onStop={canStopWorkflow ? () => void stopWorkflow(agent.id) : undefined}