Skip to content

Commit 0f770e4

Browse files
vitalyiegorovclaude
andcommitted
fix(mobile): the model sheet and subagent bar show the account badge too
One resolveProviderBadge decides the badge for model options and the subagent bar, and one ProviderAccountIcon draws it. The model sheet's provider header and the subagent bar now use them, as triaged on #15910. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 047a7cf commit 0f770e4

7 files changed

Lines changed: 102 additions & 56 deletions

File tree

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

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { providerInstanceInitials } from "@t3tools/client-runtime/state/provider
55
import { useState } from "react";
66
import { resolveOfficialAcpRegistryIconUrl } from "@t3tools/contracts";
77
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
8-
import type { ModelOption } from "../lib/modelOptions";
8+
import type { ProviderBadge } from "../lib/modelOptions";
99
import { AppText as Text } from "./AppText";
1010

1111
type ProviderIconProps = {
@@ -212,31 +212,25 @@ export function ProviderInstanceIcon(props: {
212212
);
213213
}
214214

215-
/** A model option's provider glyph, with its account badge when the option carries one. */
216-
export function ModelOptionProviderIcon(props: {
217-
readonly option:
218-
| Pick<ModelOption, "providerDriver" | "providerIconUrl" | "providerBadge">
219-
| null
220-
| undefined;
215+
/** A provider glyph that carries the account badge when its instance needs one. */
216+
export function ProviderAccountIcon(props: {
217+
readonly provider: string | null | undefined;
218+
readonly iconUrl?: string | null | undefined;
219+
readonly badge: ProviderBadge | undefined;
221220
readonly size: number;
222221
readonly surfaceColor: string;
223222
}) {
224-
const badge = props.option?.providerBadge;
225-
return badge ? (
223+
return props.badge ? (
226224
<ProviderInstanceIcon
227-
provider={props.option?.providerDriver}
228-
iconUrl={props.option?.providerIconUrl}
225+
provider={props.provider}
226+
iconUrl={props.iconUrl}
229227
size={props.size}
230-
displayName={badge.displayName}
231-
{...(badge.accentColor ? { accentColor: badge.accentColor } : {})}
228+
displayName={props.badge.displayName}
229+
{...(props.badge.accentColor ? { accentColor: props.badge.accentColor } : {})}
232230
showBadge
233231
surfaceColor={props.surfaceColor}
234232
/>
235233
) : (
236-
<ProviderIcon
237-
provider={props.option?.providerDriver}
238-
iconUrl={props.option?.providerIconUrl}
239-
size={props.size}
240-
/>
234+
<ProviderIcon provider={props.provider} iconUrl={props.iconUrl} size={props.size} />
241235
);
242236
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import {
6262
} from "../../state/composer-attachment-uploads";
6363
import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePreviewModal";
6464
import { VideoPreviewModal, type VideoPreviewSource } from "../../components/VideoPreviewModal";
65-
import { ModelOptionProviderIcon } from "../../components/ProviderIcon";
65+
import { ProviderAccountIcon } from "../../components/ProviderIcon";
6666
import { SymbolView } from "../../components/AppSymbol";
6767
import { AppText as Text } from "../../components/AppText";
6868
import { hasProviderUsageLimits, isUsageLimitsCommand } from "@t3tools/shared/usageLimits";
@@ -1749,8 +1749,10 @@ export function NewTaskDraftScreen(props: {
17491749
disabled={isComposerInteractionLocked}
17501750
emphasized
17511751
renderIcon={(size) => (
1752-
<ModelOptionProviderIcon
1753-
option={flow.selectedModelOption}
1752+
<ProviderAccountIcon
1753+
provider={flow.selectedModelOption?.providerDriver}
1754+
iconUrl={flow.selectedModelOption?.providerIconUrl}
1755+
badge={flow.selectedModelOption?.providerBadge}
17541756
size={size}
17551757
surfaceColor={composerSurfaceColor}
17561758
/>

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import { useEffect, useState } from "react";
77
import { View } from "react-native";
88

99
import { AppText as Text } from "../../components/AppText";
10-
import { ProviderIcon } from "../../components/ProviderIcon";
10+
import { ProviderAccountIcon } from "../../components/ProviderIcon";
11+
import type { ProviderBadge } from "../../lib/modelOptions";
1112
import { RequestActionButton } from "./RequestActionButton";
1213

1314
/**
@@ -16,8 +17,12 @@ import { RequestActionButton } from "./RequestActionButton";
1617
* model is working, for how long, and leads back to the parent.
1718
*/
1819
export function ProviderSubagentBar(props: {
19-
/** Driver and catalog icon of the provider running the subagent. */
20-
readonly provider: { readonly driver: string; readonly iconUrl?: string | undefined } | null;
20+
/** Driver, catalog icon and account badge of the provider running the subagent. */
21+
readonly provider: {
22+
readonly driver: string;
23+
readonly iconUrl?: string | undefined;
24+
readonly badge?: ProviderBadge | undefined;
25+
} | null;
2126
readonly modelLabel: string;
2227
/** Reasoning effort as the composer names it, when the subagent has one. */
2328
readonly effortLabel: string | null;
@@ -46,10 +51,13 @@ export function ProviderSubagentBar(props: {
4651
>
4752
<View className="min-w-0 flex-row items-center gap-1.5">
4853
{props.provider ? (
49-
<ProviderIcon
50-
iconUrl={props.provider.iconUrl}
54+
<ProviderAccountIcon
5155
provider={props.provider.driver}
56+
iconUrl={props.provider.iconUrl}
57+
badge={props.provider.badge}
5258
size={16}
59+
// Theme colours aren't readable here, so the ring stays transparent.
60+
surfaceColor="transparent"
5361
/>
5462
) : null}
5563
<Text numberOfLines={1} className="min-w-0 shrink font-t3-bold text-sm text-foreground">

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ import {
8080
ComposerInlineControl,
8181
ComposerToolbarRow,
8282
} from "../../components/ComposerToolbar";
83-
import { ModelOptionProviderIcon } from "../../components/ProviderIcon";
83+
import { ProviderAccountIcon } from "../../components/ProviderIcon";
8484
import {
8585
composerStripAttachments,
8686
type DraftComposerAttachment,
@@ -1125,8 +1125,10 @@ export const ThreadComposer = memo(function ThreadComposer(props: ThreadComposer
11251125
accessibilityLabel="Model and reasoning settings"
11261126
emphasized
11271127
renderIcon={(size) => (
1128-
<ModelOptionProviderIcon
1129-
option={currentModelOption}
1128+
<ProviderAccountIcon
1129+
provider={currentModelOption?.providerDriver}
1130+
iconUrl={currentModelOption?.providerIconUrl}
1131+
badge={currentModelOption?.providerBadge}
11301132
size={size}
11311133
surfaceColor={composerSurfaceColor}
11321134
/>

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ import type { StatusTone } from "../../components/StatusPill";
8888
import type { DraftComposerAttachment } from "../../lib/composerImages";
8989
import { RenderErrorBoundary, RenderFailureView } from "../../components/RenderErrorBoundary";
9090
import { CHAT_CONTENT_MAX_WIDTH, type LayoutVariant } from "../../lib/layout";
91+
import { resolveProviderBadge } from "../../lib/modelOptions";
9192
import { editPendingThreadMessage } from "../../state/edit-pending-thread-message";
9293
import { deviceEnvironment } from "../../state/device";
9394
import { useEnvironmentQuery } from "../../state/query";
@@ -1299,7 +1300,17 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
12991300
}}
13001301
>
13011302
<ProviderSubagentBar
1302-
provider={providerSubagentProvider ?? null}
1303+
provider={
1304+
providerSubagentProvider
1305+
? {
1306+
...providerSubagentProvider,
1307+
badge: resolveProviderBadge(
1308+
props.serverConfig,
1309+
providerSubagentProvider,
1310+
),
1311+
}
1312+
: null
1313+
}
13031314
modelLabel={
13041315
providerSubagentCatalogModel?.name ??
13051316
formatModelSlugName(props.selectedThread.modelSelection.model)

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
4848
import { AndroidAnchoredMenu } from "../../components/AndroidAnchoredMenu";
4949
import { MaterialButton } from "../../components/MaterialButton";
5050
import { MaterialIconButton } from "../../components/MaterialIconButton";
51-
import { ProviderIcon } from "../../components/ProviderIcon";
51+
import { ProviderAccountIcon } from "../../components/ProviderIcon";
5252
import { ThemedSwitch } from "../../components/ThemedSwitch";
5353
import { cn } from "../../lib/cn";
54-
import type { ModelOption, ProviderGroup } from "../../lib/modelOptions";
54+
import type { ModelOption, ProviderBadge, ProviderGroup } from "../../lib/modelOptions";
5555
import { applyProviderOptionSelection } from "../../lib/providerOptions";
5656
import { resolveProviderOptionDescriptors } from "../../lib/providerOptions";
5757
import { useUniwindTheme } from "../../lib/useUniwindTheme";
@@ -130,15 +130,23 @@ const FAVORITES_PROVIDER_FILTER = "@favorites";
130130
function ProviderHeader(props: {
131131
readonly driver: string | undefined;
132132
readonly iconUrl: string | undefined;
133+
readonly badge: ProviderBadge | undefined;
133134
readonly label: string;
134135
readonly collapsible: boolean;
135136
readonly collapsed: boolean;
136137
readonly modelCount: number;
137138
readonly onToggle: () => void;
138139
}) {
140+
const sheetColor = useUniwindTheme()["--color-sheet-solid"];
139141
const content = (
140142
<>
141-
<ProviderIcon iconUrl={props.iconUrl} provider={props.driver} size={15} />
143+
<ProviderAccountIcon
144+
provider={props.driver}
145+
iconUrl={props.iconUrl}
146+
badge={props.badge}
147+
size={15}
148+
surfaceColor={sheetColor}
149+
/>
142150
<Text className="text-sm font-t3-medium text-foreground-muted">{props.label}</Text>
143151
{props.collapsible ? (
144152
<>
@@ -547,6 +555,7 @@ type ThreadSettingsProviderCatalog = {
547555
readonly key: string;
548556
readonly driver: string | undefined;
549557
readonly iconUrl: string | undefined;
558+
readonly badge: ProviderBadge | undefined;
550559
readonly label: string;
551560
readonly collapsible: boolean;
552561
readonly collapsed: boolean;
@@ -616,6 +625,7 @@ function ThreadSettingsProviderListHeader(props: {
616625
collapsed={props.provider.collapsed}
617626
driver={props.provider.driver}
618627
iconUrl={props.provider.iconUrl}
628+
badge={props.provider.badge}
619629
label={props.provider.label}
620630
modelCount={props.provider.modelCount}
621631
onToggle={onToggle}
@@ -678,6 +688,7 @@ function useThreadSettingsCatalogItems(
678688
key: group.providerKey,
679689
driver,
680690
iconUrl: group.models[0]?.providerIconUrl,
691+
badge: group.models[0]?.providerBadge,
681692
label: group.providerLabel,
682693
collapsible,
683694
collapsed,

‎apps/mobile/src/lib/modelOptions.ts‎

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,52 @@ export type ModelOption = {
2424
readonly providerDriver: string;
2525
readonly supportedRuntimeModes?: ReadonlyArray<RuntimeMode>;
2626
readonly providerIconUrl?: string | undefined;
27-
/** Set when the instance needs the account badge, by the rule the thread rows use. */
28-
readonly providerBadge?: { readonly displayName: string; readonly accentColor?: string };
27+
/** Set when the instance needs the account badge. */
28+
readonly providerBadge?: ProviderBadge;
2929
readonly isDefault: boolean;
3030
readonly isLegacy: boolean;
3131
readonly isUnavailable?: boolean;
3232
readonly capabilities: ModelCapabilities | null;
3333
readonly selection: ModelSelection;
3434
};
3535

36+
/** The account badge an instance's glyph carries. */
37+
export type ProviderBadge = { readonly displayName: string; readonly accentColor?: string };
38+
39+
type ServerProvider = T3ServerConfig["providers"][number];
40+
41+
/**
42+
* The badge an instance needs by the shared rule: an accent colour, or another
43+
* instance of the same provider. Settings carry each ACP instance's agent,
44+
* whose own glyph already tells it apart.
45+
*/
46+
export function resolveProviderBadge(
47+
config: T3ServerConfig | null | undefined,
48+
provider: ServerProvider,
49+
): ProviderBadge | undefined {
50+
const badgeEntry = (candidate: ServerProvider) => {
51+
const settings = config?.settings?.providerInstances[candidate.instanceId]?.config;
52+
const agentId =
53+
typeof settings === "object" && settings ? Reflect.get(settings, "agentId") : null;
54+
return {
55+
driverKind: candidate.driver,
56+
...(typeof agentId === "string" && agentId.trim()
57+
? { acpRegistryAgentId: agentId.trim() }
58+
: {}),
59+
};
60+
};
61+
const accentColor = normalizeProviderAccentColor(provider.accentColor);
62+
return shouldShowInstanceBadge(
63+
{ ...badgeEntry(provider), accentColor },
64+
(config?.providers ?? []).map(badgeEntry),
65+
)
66+
? {
67+
displayName: resolveProviderInstanceDisplayName(provider),
68+
...(accentColor ? { accentColor } : {}),
69+
}
70+
: undefined;
71+
}
72+
3673
export type ProviderGroup = {
3774
readonly providerKey: string;
3875
readonly providerLabel: string;
@@ -168,25 +205,6 @@ export function buildModelOptions(
168205
providerInstanceId?: ModelSelection["instanceId"],
169206
): ReadonlyArray<ModelOption> {
170207
const options = new Map<string, ModelOption>();
171-
// Settings carry each ACP instance's agent, whose own glyph already tells it apart.
172-
const badgeEntry = (provider: T3ServerConfig["providers"][number]) => {
173-
const settings = config?.settings?.providerInstances[provider.instanceId]?.config;
174-
const agentId = typeof settings === "object" && settings ? Reflect.get(settings, "agentId") : null;
175-
return {
176-
driverKind: provider.driver,
177-
...(typeof agentId === "string" && agentId.trim() ? { acpRegistryAgentId: agentId.trim() } : {}),
178-
};
179-
};
180-
const badgeEntries = (config?.providers ?? []).map(badgeEntry);
181-
const providerBadgeFor = (provider: T3ServerConfig["providers"][number]) => {
182-
const accentColor = normalizeProviderAccentColor(provider.accentColor);
183-
return shouldShowInstanceBadge({ ...badgeEntry(provider), accentColor }, badgeEntries)
184-
? {
185-
displayName: resolveProviderInstanceDisplayName(provider),
186-
...(accentColor ? { accentColor } : {}),
187-
}
188-
: undefined;
189-
};
190208

191209
for (const provider of config?.providers ?? []) {
192210
if (
@@ -200,7 +218,7 @@ export function buildModelOptions(
200218
}
201219

202220
const providerLabel = providerDisplayLabel(provider);
203-
const providerBadge = providerBadgeFor(provider);
221+
const providerBadge = resolveProviderBadge(config, provider);
204222
for (const model of provider.models) {
205223
const key = `${provider.instanceId}:${model.slug}`;
206224
options.set(key, {
@@ -258,7 +276,7 @@ export function buildModelOptions(
258276
displayName: provider?.displayName ?? instanceConfig?.displayName,
259277
instanceId: fallbackModelSelection.instanceId,
260278
});
261-
const providerBadge = provider ? providerBadgeFor(provider) : undefined;
279+
const providerBadge = provider ? resolveProviderBadge(config, provider) : undefined;
262280
options.set(key, {
263281
key,
264282
label: model?.name ?? fallbackModelSelection.model,

0 commit comments

Comments
 (0)