@devries-cameron20 / t3code-1 / commits / bab2613d27
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web,mobile): disabled provider instances no longer badge their siblings (#14545)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Tristan Knight committed Oct 19, 2026 at 19:07 UTC bab2613d27fc7cce5f6e5873f79a9db1940867ca
11 files changed +182 -44
apps/mobile/src/features/threads/thread-provider-instance.test.ts
+60 -1
@@ -7,6 +7,9 @@ import {
7 type ServerConfig,
8 } from "@t3tools/contracts";
9 import { describe, expect, it } from "vite-plus/test";
10 +import { Atom, AtomRegistry } from "effect/reactivity";
11 +
12 +import { createThreadListEnvironmentsAtom } from "../../state/thread-list-environments";
13
14 import {
15 createThreadRowProviderInstanceResolver,
@@ -21,7 +24,11 @@ function makeConfig(
24 readonly accentColor?: string;
25 }>,
26 ): ServerConfig {
24 - return { providers } as unknown as ServerConfig;
27 + return {
28 + providers: providers.map((provider) => ({ enabled: true, ...provider })),
29 + environment: { capabilities: {}, platform: { machine: "laptop" } },
30 + settings: {},
31 + } as unknown as ServerConfig;
32 }
33
34 function makeThread(environmentId: EnvironmentId, instanceId: string): EnvironmentThreadShell {
@@ -147,6 +154,58 @@ describe("resolveThreadProviderInstance", () => {
154 });
155
156 describe("createThreadRowProviderInstanceResolver", () => {
157 + it("updates thread badges through the environment projection when a sibling is disabled and re-enabled", () => {
158 + const environmentId = EnvironmentId.make("environment-a");
159 + const personal = makeThread(environmentId, "codex");
160 + const work = makeThread(environmentId, "codex_work");
161 + const config = makeConfig([
162 + { instanceId: "codex", driver: "codex" },
163 + { instanceId: "codex_work", driver: "codex" },
164 + ]);
165 + const configs = Atom.make<ReadonlyMap<EnvironmentId, ServerConfig>>(
166 + new Map([[environmentId, config]]),
167 + );
168 + const environments = createThreadListEnvironmentsAtom(configs);
169 + const registry = AtomRegistry.make();
170 + registry.mount(environments);
171 + try {
172 + const before = createThreadRowProviderInstanceResolver(
173 + registry.get(environments).providersByEnvironmentId,
174 + );
175 + expect(before(personal)?.showBadge).toBe(true);
176 + expect(before(work)?.showBadge).toBe(true);
177 +
178 + registry.set(
179 + configs,
180 + new Map([
181 + [
182 + environmentId,
183 + {
184 + ...config,
185 + providers: config.providers.map((provider) =>
186 + provider.instanceId === "codex_work" ? { ...provider, enabled: false } : provider,
187 + ),
188 + },
189 + ],
190 + ]),
191 + );
192 + const disabled = createThreadRowProviderInstanceResolver(
193 + registry.get(environments).providersByEnvironmentId,
194 + );
195 + expect(disabled(personal)?.showBadge).toBe(false);
196 + expect(disabled(work)?.showBadge).toBe(true);
197 +
198 + registry.set(configs, new Map([[environmentId, config]]));
199 + const restored = createThreadRowProviderInstanceResolver(
200 + registry.get(environments).providersByEnvironmentId,
201 + );
202 + expect(restored(personal)?.showBadge).toBe(true);
203 + expect(restored(work)?.showBadge).toBe(true);
204 + } finally {
205 + registry.dispose();
206 + }
207 + });
208 +
209 const environmentId = EnvironmentId.make("environment-a");
210 const serverConfigs = new Map<EnvironmentId, ServerConfig>([
211 [
apps/mobile/src/features/threads/thread-provider-instance.ts
+2 -2
@@ -37,8 +37,8 @@ export function resolveThreadProviderInstance(
37 return {
38 ...entry,
39 showBadge: shouldShowInstanceBadge(
40 - entry,
41 - providers.map((provider) => ({ driverKind: provider.driver })),
40 + { ...entry, enabled: snapshot.enabled },
41 + providers.map((provider) => ({ driverKind: provider.driver, enabled: provider.enabled })),
42 ),
43 };
44 }
apps/mobile/src/state/thread-list-environments.ts
+4 -2
@@ -9,7 +9,7 @@ import { Atom } from "effect/reactivity";
9
10 export type ThreadListProvider = Pick<
11 ServerProvider,
12 - "instanceId" | "driver" | "displayName" | "accentColor" | "iconUrl"
12 + "instanceId" | "driver" | "enabled" | "displayName" | "accentColor" | "iconUrl"
13 >;
14
15 const capabilityKeys = [
@@ -25,9 +25,10 @@ const capabilityKeys = [
25 function selectEnvironment(config: ServerConfig) {
26 return {
27 providers: config.providers.map(
28 - ({ instanceId, driver, displayName, accentColor, iconUrl }) => ({
28 + ({ instanceId, driver, enabled, displayName, accentColor, iconUrl }) => ({
29 instanceId,
30 driver,
31 + enabled,
32 displayName,
33 accentColor,
34 iconUrl,
@@ -51,6 +52,7 @@ function sameProviders(
52 return (
53 provider.instanceId === other.instanceId &&
54 provider.driver === other.driver &&
55 + provider.enabled === other.enabled &&
56 provider.displayName === other.displayName &&
57 provider.accentColor === other.accentColor &&
58 provider.iconUrl === other.iconUrl
apps/server/src/provider/Drivers/CodexDriver.test.ts
+15
@@ -97,6 +97,21 @@ const noSpawn = ChildProcessSpawner.make(() =>
97 const encodeCredentials = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));
98
99 it.layer(layerTest)("CodexDriver", (it) => {
100 + it.effect("reports a disabled managed account as disabled", () =>
101 + Effect.gen(function* () {
102 + const instance = yield* CodexDriver.create({
103 + instanceId: ProviderInstanceId.make("disabled-managed-account"),
104 + displayName: "Disabled account",
105 + enabled: false,
106 + environment: [],
107 + config: { ...CodexDriver.defaultConfig(), setupMode: "managed" },
108 + }).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn));
109 +
110 + expect((yield* instance.snapshot.getSnapshot).enabled).toBe(false);
111 + expect((yield* instance.snapshot.refresh).enabled).toBe(false);
112 + }).pipe(Effect.scoped),
113 + );
114 +
115 it.effect("disconnect refreshes a restored managed account while its auth flow is idle", () =>
116 Effect.gen(function* () {
117 const instanceId = ProviderInstanceId.make("restored-managed-account");
apps/server/src/provider/Drivers/CodexManagedProvider.ts
+1 -1
@@ -55,7 +55,7 @@ export const makeManagedCodexProvider = Effect.fn("makeManagedCodexProvider")(fu
55 homePath: runtime.homeLayout.sharedHomePath,
56 shadowHomePath: runtime.homeLayout.mode === "authOverlay" ? runtime.homePath : null,
57 };
58 - const pending = makePendingCodexProvider({ ...config, customModels: [] }).pipe(
58 + const pending = makePendingCodexProvider({ ...config, enabled, customModels: [] }).pipe(
59 Effect.map((draft) =>
60 stamp({
61 ...draft,
apps/web/src/components/Sidebar.tsx
+2
@@ -299,6 +299,7 @@ type SidebarProviderEntry = Pick<
299 ProviderInstanceEntry,
300 | "instanceId"
301 | "driverKind"
302 + | "enabled"
303 | "displayName"
304 | "accentColor"
305 | "acpRegistryAgentId"
@@ -316,6 +317,7 @@ function sameSidebarProviderEntries(
317 if (
318 other === undefined ||
319 other.driverKind !== entry.driverKind ||
320 + other.enabled !== entry.enabled ||
321 other.displayName !== entry.displayName ||
322 other.accentColor !== entry.accentColor ||
323 other.acpRegistryAgentId !== entry.acpRegistryAgentId ||
apps/web/src/components/chat/ThreadRelationshipsControl.agents.browser.test.tsx
+4
@@ -295,12 +295,14 @@ it("opens the correct chat for every workflow phase and unphased member", async
295 {
296 instanceId: "claude-personal",
297 driver: "claudeAgent",
298 + enabled: true,
299 displayName: "Personal account",
300 models: [],
301 },
302 {
303 instanceId: "claude-work",
304 driver: "claudeAgent",
305 + enabled: true,
306 displayName: "Work account",
307 models: [{ slug: "claude-sonnet-4-6", name: "Sonnet" }],
308 },
@@ -969,6 +971,7 @@ it("shows readable models and only differing workspace details in agent tooltips
971 {
972 instanceId: "codex",
973 driver: "codex",
974 + enabled: true,
975 displayName: "Work account",
976 models: [
977 {
@@ -981,6 +984,7 @@ it("shows readable models and only differing workspace details in agent tooltips
984 {
985 instanceId: "codex_personal",
986 driver: "codex",
987 + enabled: true,
988 displayName: "Personal account",
989 models: [],
990 },
apps/web/src/providerInstances.test.ts
+34 -1
@@ -1,4 +1,9 @@
1 -import { ProviderDriverKind, ProviderInstanceId, type ServerProvider } from "@t3tools/contracts";
1 +import {
2 + ProjectId,
3 + ProviderDriverKind,
4 + ProviderInstanceId,
5 + type ServerProvider,
6 +} from "@t3tools/contracts";
7 import { describe, expect, it } from "vite-plus/test";
8 import {
9 applyProviderInstanceSettings,
@@ -10,6 +15,7 @@ import {
15 resolveDefaultProviderModelSelection,
16 resolveProviderCatalogAvailability,
17 resolveSelectableProviderInstance,
18 + shouldShowInstanceBadge,
19 } from "./providerInstances";
20
21 function provider(input: {
@@ -337,6 +343,33 @@ describe("deriveProviderEntriesByEnvironment", () => {
343 expect(byEnvironment.get("remote")?.get("claude")?.accentColor).toBe("#445566");
344 });
345
346 + it("keeps an instance a project turns on as a sibling for the instance badge", () => {
347 + const codex = ProviderDriverKind.make("codex");
348 + const byEnvironment = deriveProviderEntriesByEnvironment([
349 + [
350 + "local",
351 + [
352 + provider({ provider: codex, instanceId: "codex" }),
353 + provider({ provider: codex, instanceId: "codex_work" }),
354 + ],
355 + {
356 + providerInstances: {
357 + [ProviderInstanceId.make("codex_work")]: { driver: codex, enabled: false },
358 + },
359 + projectSettingsOverrides: {
360 + [ProjectId.make("project-work")]: {
361 + providerInstances: { [ProviderInstanceId.make("codex_work")]: { enabled: true } },
362 + },
363 + },
364 + },
365 + ],
366 + ]);
367 + const entries = byEnvironment.get("local");
368 + const personal = entries?.get("codex");
369 +
370 + expect(personal && shouldShowInstanceBadge(personal, entries?.values() ?? [])).toBe(true);
371 + });
372 +
373 it("never falls back to another environment's instances", () => {
374 const byEnvironment = deriveProviderEntriesByEnvironment([
375 ["local", [provider({ provider: ProviderDriverKind.make("codex"), instanceId: "codex" })]],
apps/web/src/providerInstances.ts
+36 -28
@@ -121,9 +121,10 @@ export function deriveProviderEntriesByEnvironment(
121 const byEnvironment = new Map<string, ReadonlyMap<string, ProviderInstanceEntry>>();
122 for (const [environmentId, providers, settings] of providersByEnvironment) {
123 const derived = deriveProviderInstanceEntries(providers);
124 - // One map per environment serves every project with a thread there, so
125 - // there is no single project to scope `enabled` to; it stays machine-wide.
126 - const entries = settings ? applyProviderInstanceSettings(derived, settings, null) : derived;
124 + // The snapshot includes instances enabled by any project; machine settings alone do not.
125 + const entries = settings
126 + ? derived.map((entry) => applyProviderInstanceBranding(entry, settings))
127 + : derived;
128 byEnvironment.set(
129 environmentId,
130 new Map(entries.map((entry) => [entry.instanceId as string, entry] as const)),
@@ -145,35 +146,42 @@ export function applyProviderInstanceSettings(
146 projectId: ProjectId | null,
147 ): ReadonlyArray<ProviderInstanceEntry> {
148 return entries.map((entry) => {
148 - const explicitInstance = Object.hasOwn(settings.providerInstances, entry.instanceId)
149 - ? settings.providerInstances[entry.instanceId]
150 - : undefined;
149 const enabled = resolveProjectProviderInstanceEnabled(settings, projectId, entry.instanceId);
152 - if (entry.driverKind !== "acpRegistry" || explicitInstance === undefined) {
153 - return enabled === entry.enabled ? entry : { ...entry, enabled };
154 - }
155 - const config =
156 - explicitInstance.config !== null && typeof explicitInstance.config === "object"
157 - ? (explicitInstance.config as Readonly<Record<string, unknown>>)
158 - : null;
159 - if (config?.source === "local") {
160 - return { ...entry, enabled, acpRegistryAgentId: undefined, acpRegistryIconUrl: undefined };
161 - }
162 - const agentId = config?.agentId;
163 - const iconUrl = config?.registryIconUrl;
164 - return {
165 - ...entry,
166 - enabled,
167 - ...(typeof agentId === "string" && agentId.trim()
168 - ? { acpRegistryAgentId: agentId.trim() }
169 - : {}),
170 - ...(typeof iconUrl === "string" && iconUrl.trim()
171 - ? { acpRegistryIconUrl: iconUrl.trim() }
172 - : {}),
173 - };
150 + return applyProviderInstanceBranding(
151 + enabled === entry.enabled ? entry : { ...entry, enabled },
152 + settings,
153 + );
154 });
155 }
156
157 +function applyProviderInstanceBranding(
158 + entry: ProviderInstanceEntry,
159 + settings: Pick<ServerSettings, "providerInstances">,
160 +): ProviderInstanceEntry {
161 + const explicitInstance = Object.hasOwn(settings.providerInstances, entry.instanceId)
162 + ? settings.providerInstances[entry.instanceId]
163 + : undefined;
164 + if (entry.driverKind !== "acpRegistry" || explicitInstance === undefined) return entry;
165 + const config =
166 + explicitInstance.config !== null && typeof explicitInstance.config === "object"
167 + ? (explicitInstance.config as Readonly<Record<string, unknown>>)
168 + : null;
169 + if (config?.source === "local") {
170 + return { ...entry, acpRegistryAgentId: undefined, acpRegistryIconUrl: undefined };
171 + }
172 + const agentId = config?.agentId;
173 + const iconUrl = config?.registryIconUrl;
174 + return {
175 + ...entry,
176 + ...(typeof agentId === "string" && agentId.trim()
177 + ? { acpRegistryAgentId: agentId.trim() }
178 + : {}),
179 + ...(typeof iconUrl === "string" && iconUrl.trim()
180 + ? { acpRegistryIconUrl: iconUrl.trim() }
181 + : {}),
182 + };
183 +}
184 +
185 export function sortProviderInstanceEntries(
186 entries: ReadonlyArray<ProviderInstanceEntry>,
187 ): ReadonlyArray<ProviderInstanceEntry> {
packages/client-runtime/src/state/providerInstanceDisplay.test.ts
+20 -9
@@ -91,14 +91,14 @@ describe("normalizeProviderAccentColor", () => {
91
92 describe("shouldShowInstanceBadge", () => {
93 it("hides badges for distinct ACP agents sharing the registry driver", () => {
94 - const mistral = { driverKind: acpRegistry, acpRegistryAgentId: "mistral-vibe" };
95 - const devin = { driverKind: acpRegistry, acpRegistryAgentId: "devin" };
94 + const mistral = { driverKind: acpRegistry, acpRegistryAgentId: "mistral-vibe", enabled: true };
95 + const devin = { driverKind: acpRegistry, acpRegistryAgentId: "devin", enabled: true };
96 expect(shouldShowInstanceBadge(mistral, [mistral, devin])).toBe(false);
97 expect(shouldShowInstanceBadge(devin, [mistral, devin])).toBe(false);
98 });
99
100 it("shows badges for multiple instances of the same ACP agent", () => {
101 - const first = { driverKind: acpRegistry, acpRegistryAgentId: "mistral-vibe" };
101 + const first = { driverKind: acpRegistry, acpRegistryAgentId: "mistral-vibe", enabled: true };
102 const second = { ...first };
103 expect(shouldShowInstanceBadge(first, [first, second])).toBe(true);
104 });
@@ -108,29 +108,40 @@ describe("shouldShowInstanceBadge", () => {
108 driverKind: acpRegistry,
109 acpRegistryAgentId: "mistral-vibe",
110 accentColor: "#ff8800",
111 + enabled: true,
112 };
113 expect(shouldShowInstanceBadge(entry, [entry])).toBe(true);
114 });
115
116 it("distinguishes registry instances whose agent identity is unavailable", () => {
116 - const entry = { driverKind: acpRegistry };
117 + const entry = { driverKind: acpRegistry, enabled: true };
118 expect(shouldShowInstanceBadge(entry, [entry, { ...entry }])).toBe(true);
119 });
120
121 it("shows the badge when the entry has an accent color", () => {
121 - const entry = { driverKind: codex, accentColor: "#ff8800" };
122 + const entry = { driverKind: codex, accentColor: "#ff8800", enabled: true };
123 expect(shouldShowInstanceBadge(entry, [entry])).toBe(true);
124 });
125
126 it("shows the badge when two entries share a driver, even without an accent", () => {
126 - const first = { driverKind: codex, accentColor: undefined };
127 - const second = { driverKind: codex, accentColor: undefined };
127 + const first = { driverKind: codex, accentColor: undefined, enabled: true };
128 + const second = { driverKind: codex, accentColor: undefined, enabled: true };
129 expect(shouldShowInstanceBadge(first, [first, second])).toBe(true);
130 });
131
132 + it("ignores disabled siblings for enabled instances while distinguishing historical owners", () => {
133 + const enabled = { driverKind: codex, enabled: true };
134 + const disabled = { driverKind: codex, enabled: false };
135 +
136 + expect(shouldShowInstanceBadge(enabled, [enabled, disabled])).toBe(false);
137 + expect(shouldShowInstanceBadge(disabled, [enabled, disabled])).toBe(true);
138 + expect(shouldShowInstanceBadge(disabled, [disabled, { ...disabled }])).toBe(true);
139 + expect(shouldShowInstanceBadge(disabled, [disabled])).toBe(false);
140 + });
141 +
142 it("hides the badge for a single instance of a driver with no accent", () => {
132 - const entry = { driverKind: codex, accentColor: undefined };
133 - const other = { driverKind: claude, accentColor: undefined };
143 + const entry = { driverKind: codex, accentColor: undefined, enabled: true };
144 + const other = { driverKind: claude, accentColor: undefined, enabled: true };
145 expect(shouldShowInstanceBadge(entry, [entry, other])).toBe(false);
146 });
147 });
packages/client-runtime/src/state/providerInstanceDisplay.ts
+4
@@ -47,16 +47,20 @@ export function shouldShowInstanceBadge(
47 readonly driverKind: ProviderDriverKind;
48 readonly accentColor?: string | undefined;
49 readonly acpRegistryAgentId?: string | undefined;
50 + readonly enabled: boolean;
51 },
52 entries: Iterable<{
53 readonly driverKind: ProviderDriverKind;
54 readonly acpRegistryAgentId?: string | undefined;
55 + readonly enabled: boolean;
56 }>,
57 ): boolean {
58 if (entry.accentColor) return true;
59 let sharedProviderCount = 0;
60 for (const candidate of entries) {
61 if (candidate.driverKind !== entry.driverKind) continue;
62 + // Historical threads still need to distinguish accounts that are all disabled.
63 + if (entry.enabled && !candidate.enabled) continue;
64 if (
65 entry.driverKind === "acpRegistry" &&
66 candidate.acpRegistryAgentId !== entry.acpRegistryAgentId