Skip to content

Commit 29bfc86

Browse files
vitalyiegorovclaude
andcommitted
fix(web): subagent avatars count accounts a project turns on
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 35e0de9 commit 29bfc86

3 files changed

Lines changed: 38 additions & 5 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
import { Tooltip, TooltipTrigger, TooltipPopup } from "../ui/tooltip";
4545
import {
4646
applyProviderInstanceSettings,
47+
brandProviderInstanceEntries,
4748
deriveProviderInstanceEntries,
4849
shouldShowInstanceBadge,
4950
type ProviderInstanceEntry,
@@ -322,7 +323,7 @@ export function EnvironmentSubagentAvatar({
322323
const settings = useAtomValue(serverEnvironment.settingsValueAtom(environmentId));
323324
const entries = (providers: ReadonlyArray<ServerProvider> | null | undefined) => {
324325
const derived = deriveProviderInstanceEntries(providers ?? []);
325-
return settings ? applyProviderInstanceSettings(derived, settings, null) : derived;
326+
return settings ? brandProviderInstanceEntries(derived, settings) : derived;
326327
};
327328
const displayName = useAtomValue(
328329
providersAtom,

‎apps/web/src/providerInstances.test.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
import { describe, expect, it } from "vite-plus/test";
99
import {
1010
applyProviderInstanceSettings,
11+
brandProviderInstanceEntries,
1112
deriveProviderEntriesByEnvironment,
1213
deriveProviderInstanceEntries,
1314
getDefaultProviderInstanceModel,
@@ -295,6 +296,32 @@ describe("deriveProviderEntriesByEnvironment", () => {
295296
});
296297
});
297298

299+
describe("brandProviderInstanceEntries", () => {
300+
it("keeps an instance a project turns on as a sibling for the instance badge", () => {
301+
const codex = ProviderDriverKind.make("codex");
302+
const settings = {
303+
providerInstances: {
304+
[ProviderInstanceId.make("codex_work")]: { driver: codex, enabled: false },
305+
},
306+
projectSettingsOverrides: {
307+
[ProjectId.make("project-work")]: {
308+
providerInstances: { [ProviderInstanceId.make("codex_work")]: { enabled: true } },
309+
},
310+
},
311+
};
312+
const entries = brandProviderInstanceEntries(
313+
deriveProviderInstanceEntries([
314+
provider({ provider: codex, instanceId: "codex" }),
315+
provider({ provider: codex, instanceId: "codex_work" }),
316+
]),
317+
settings,
318+
);
319+
const personal = entries.find((entry) => entry.instanceId === "codex");
320+
321+
expect(personal && shouldShowInstanceBadge(personal, entries)).toBe(true);
322+
});
323+
});
324+
298325
describe("resolveSelectableProviderInstance", () => {
299326
it("falls back to the first enabled and available instance", () => {
300327
const disabled = ProviderInstanceId.make("codex");

‎apps/web/src/providerInstances.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,7 @@ export function deriveProviderEntriesByEnvironment(
105105
const byEnvironment = new Map<string, ReadonlyMap<string, ProviderInstanceEntry>>();
106106
for (const [environmentId, providers, settings] of providersByEnvironment) {
107107
const derived = deriveProviderInstanceEntries(providers);
108-
// The snapshot includes instances enabled by any project; machine settings alone do not.
109-
const entries = settings
110-
? derived.map((entry) => applyProviderInstanceBranding(entry, settings))
111-
: derived;
108+
const entries = settings ? brandProviderInstanceEntries(derived, settings) : derived;
112109
byEnvironment.set(
113110
environmentId,
114111
new Map(entries.map((entry) => [entry.instanceId as string, entry] as const)),
@@ -117,6 +114,14 @@ export function deriveProviderEntriesByEnvironment(
117114
return byEnvironment;
118115
}
119116

117+
// The snapshot includes instances enabled by any project; machine settings alone do not.
118+
export function brandProviderInstanceEntries(
119+
entries: ReadonlyArray<ProviderInstanceEntry>,
120+
settings: Pick<ServerSettings, "providerInstances">,
121+
): ReadonlyArray<ProviderInstanceEntry> {
122+
return entries.map((entry) => applyProviderInstanceBranding(entry, settings));
123+
}
124+
120125
/** projectId applies project overrides; explicit null uses machine settings. */
121126
export function applyProviderInstanceSettings(
122127
entries: ReadonlyArray<ProviderInstanceEntry>,

0 commit comments

Comments
 (0)