@devries-cameron20 / t3code Mirror · read-only / commits / 82ce7456de
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 09:45 UTC

fix(server): fx and Muse refreshes drop models they no longer list (#37457)

Sharad Patel committed Nov 16, 2026 at 11:41 UTC 82ce7456de2d132e638f373921e203240ec57272
4 files changed +91 -68
apps/server/src/provider/ProviderRegistry.test.ts
+43 -46
@@ -1375,48 +1375,15 @@ it.layer(
1375 );
1376 });
1377
1378 - it("drops Grok models a completed probe no longer advertises", () => {
1378 + it.each([
1379 + ["grok", "warning"],
1380 + ["cursor", "error"],
1381 + ["muse", "error"],
1382 + ["fx", "warning"],
1383 + ] as const)("drops %s models a completed listing no longer returns", (driver, failedStatus) => {
1384 const previousProvider = {
1380 - instanceId: ProviderInstanceId.make("grok"),
1381 - driver: ProviderDriverKind.make("grok"),
1382 - status: "ready",
1383 - enabled: true,
1384 - installed: true,
1385 - auth: { status: "authenticated" },
1386 - checkedAt: "2026-09-30T00:00:00.000Z",
1387 - version: "1.0.44",
1388 - models: [
1389 - { slug: "grok-4.7", name: "Grok 4.7", isCustom: false, capabilities: null },
1390 - { slug: "codexhub-removed", name: "Removed", isCustom: false, capabilities: null },
1391 - ],
1392 - slashCommands: [],
1393 - skills: [],
1394 - } as const satisfies ServerProvider;
1395 - const refreshedProvider = {
1396 - ...previousProvider,
1397 - checkedAt: "2026-09-30T00:01:00.000Z",
1398 - models: [previousProvider.models[0]],
1399 - } satisfies ServerProvider;
1400 - const acpFailedProvider = {
1401 - ...refreshedProvider,
1402 - status: "warning",
1403 - message: "Grok CLI is installed but ACP initialize failed.",
1404 - } satisfies ServerProvider;
1405 -
1406 - assert.deepStrictEqual(
1407 - ProviderRegistry.mergeProviderSnapshot(previousProvider, refreshedProvider).models,
1408 - [previousProvider.models[0]],
1409 - );
1410 - assert.deepStrictEqual(
1411 - ProviderRegistry.mergeProviderSnapshot(previousProvider, acpFailedProvider).models,
1412 - [...previousProvider.models],
1413 - );
1414 - });
1415 -
1416 - it("drops Cursor models a completed catalog read no longer returns", () => {
1417 - const previousProvider = {
1418 - instanceId: ProviderInstanceId.make("cursor"),
1419 - driver: ProviderDriverKind.make("cursor"),
1385 + instanceId: ProviderInstanceId.make(driver),
1386 + driver: ProviderDriverKind.make(driver),
1387 status: "ready",
1388 enabled: true,
1389 installed: true,
@@ -1424,8 +1391,8 @@ it.layer(
1391 checkedAt: "2026-10-30T00:00:00.000Z",
1392 version: "1.0.0",
1393 models: [
1427 - { slug: "composer-2", name: "Composer 2", isCustom: false, capabilities: null },
1428 - { slug: "retired-model-x", name: "Retired", isCustom: false, capabilities: null },
1394 + { slug: "current-model", name: "Current", isCustom: false, capabilities: null },
1395 + { slug: "retired-model", name: "Retired", isCustom: false, capabilities: null },
1396 ],
1397 slashCommands: [],
1398 skills: [],
@@ -1437,9 +1404,7 @@ it.layer(
1404 } satisfies ServerProvider;
1405 const failedProvider = {
1406 ...refreshedProvider,
1440 - status: "error",
1441 - auth: { status: "unknown" },
1442 - message: "Cursor SDK model discovery timed out.",
1407 + status: failedStatus,
1408 } satisfies ServerProvider;
1409
1410 assert.deepStrictEqual(
@@ -1452,6 +1417,38 @@ it.layer(
1417 );
1418 });
1419
1420 + it.each(["kiro", "claudeAgent"] as const)(
1421 + "keeps %s models a ready probe can omit",
1422 + (driver) => {
1423 + const previousProvider = {
1424 + instanceId: ProviderInstanceId.make(driver),
1425 + driver: ProviderDriverKind.make(driver),
1426 + status: "ready",
1427 + enabled: true,
1428 + installed: true,
1429 + auth: { status: "authenticated" },
1430 + checkedAt: "2026-10-30T00:00:00.000Z",
1431 + version: "1.0.0",
1432 + models: [
1433 + { slug: "built-in-model", name: "Built-in", isCustom: false, capabilities: null },
1434 + { slug: "listed-model", name: "Listed", isCustom: false, capabilities: null },
1435 + ],
1436 + slashCommands: [],
1437 + skills: [],
1438 + } as const satisfies ServerProvider;
1439 + const partialProvider = {
1440 + ...previousProvider,
1441 + checkedAt: "2026-10-30T00:01:00.000Z",
1442 + models: [previousProvider.models[0]],
1443 + } satisfies ServerProvider;
1444 +
1445 + assert.deepStrictEqual(
1446 + ProviderRegistry.mergeProviderSnapshot(previousProvider, partialProvider).models,
1447 + [...previousProvider.models],
1448 + );
1449 + },
1450 + );
1451 +
1452 it("retains stale OpenCode models when a refresh fails or lists none", () => {
1453 const previousProvider = {
1454 instanceId: ProviderInstanceId.make("opencode"),
apps/server/src/provider/ProviderRegistry.ts
+14 -8
@@ -210,20 +210,26 @@ const shouldRetainMissingProviderModels = (provider: ServerProvider): boolean =>
210 );
211 }
212
213 - if (
214 - provider.driver === ProviderDriverKind.make("grok") ||
215 - provider.driver === ProviderDriverKind.make("cursor")
216 - ) {
217 - // Grok and Cursor report ready only after they discover a model list; the pending,
218 - // failed, empty-inventory, and logged-out probes are warning/error.
219 - return !(provider.installed && provider.status === "ready");
213 + if (provider.driver === ProviderDriverKind.make("kiro")) {
214 + // Kiro is ready once `whoami` confirms the account, even when `--list-models` failed and
215 + // the snapshot fell back to the built-in list.
216 + return true;
217 + }
218 +
219 + if (provider.driver === ProviderDriverKind.make("claudeAgent")) {
220 + // Claude Code keeps one gateway model cache per Claude home, for one base URL at a time, so a
221 + // ready probe can omit this instance's gateway models after another instance or a terminal
222 + // `claude` on a different gateway rewrote that cache.
223 + return true;
224 }
225
226 const isAntigravity = provider.driver === ProviderDriverKind.make("antigravity");
227 const isCodex = provider.driver === ProviderDriverKind.make("codex");
228 const isOpenCode = provider.driver === ProviderDriverKind.make("opencode");
229 if (!isAntigravity && !isCodex && !isOpenCode) {
226 - return true;
230 + // Any other driver must report ready only after a completed model listing, or opt out above:
231 + // a ready list is authoritative, and warning/error probes keep the old models.
232 + return !(provider.installed && provider.status === "ready");
233 }
234
235 if (
packages/provider-fx/src/server/status.test.ts
+32 -10
@@ -38,21 +38,27 @@ function processHandle(stdout: string, code: number, answered: Effect.Effect<voi
38 });
39 }
40
41 +// `fx models --json` from fx 0.0.13, ids trimmed.
42 +const FX_MODELS_JSON = JSON.stringify({
43 + kind: "models",
44 + count: 2,
45 + shown_count: 2,
46 + more_count: 0,
47 + private_models_hidden: false,
48 + ids: ["anthropic/claude-sonnet-5.5", "anthropic/claude-opus-5.5"],
49 +});
50 +
51 /** Answers `fx` invocations by their arguments and records which ran. */
42 -const check = (statusJson: string, versionDelay: Duration.Input = 0) =>
52 +const check = (
53 + statusJson: string,
54 + versionDelay: Duration.Input = 0,
55 + modelsJson: string = FX_MODELS_JSON,
56 +) =>
57 Effect.gen(function* () {
58 const outputs: Record<string, string> = {
59 "--version": "fx 0.0.13\n",
60 "status --json": statusJson,
47 - // `fx models --json` from fx 0.0.13, ids trimmed.
48 - "models --json": JSON.stringify({
49 - kind: "models",
50 - count: 2,
51 - shown_count: 2,
52 - more_count: 0,
53 - private_models_hidden: false,
54 - ids: ["anthropic/claude-sonnet-5.5", "anthropic/claude-opus-5.5"],
55 - }),
61 + "models --json": modelsJson,
62 };
63 const invoked: Array<string> = [];
64 const spawner = ChildProcessSpawner.make((command) => {
@@ -150,4 +156,20 @@ describe("checkFxProviderStatus", () => {
156 assert.equal(unknown.draft.auth.status, "unknown");
157 }),
158 );
159 +
160 + // A ready snapshot drops models it does not list, so only a real listing may report ready.
161 + it.effect("treats `fx models` output without ids as a failed listing", () =>
162 + Effect.gen(function* () {
163 + const signedIn = JSON.stringify({ kind: "status", auth: "fx login" });
164 + const reshaped = yield* check(signedIn, 0, JSON.stringify({ kind: "models", models: [] }));
165 + assert.equal(reshaped.draft.status, "warning");
166 + assert.deepEqual(
167 + reshaped.draft.models.map((model) => model.slug),
168 + ["default"],
169 + );
170 +
171 + const empty = yield* check(signedIn, 0, JSON.stringify({ kind: "models", ids: [] }));
172 + assert.equal(empty.draft.status, "ready");
173 + }),
174 + );
175 });
packages/provider-fx/src/server/status.ts
+2 -4
@@ -131,9 +131,7 @@ const FxStatus = Schema.fromJsonString(
131 }),
132 );
133 const decodeFxStatus = Schema.decodeUnknownOption(FxStatus);
134 -const FxModels = Schema.fromJsonString(
135 - Schema.Struct({ ids: Schema.optional(Schema.Array(Schema.String)) }),
136 -);
134 +const FxModels = Schema.fromJsonString(Schema.Struct({ ids: Schema.Array(Schema.String) }));
135 const decodeFxModels = Schema.decodeUnknownOption(FxModels);
136
137 const VERSION_PROBE_TIMEOUT_MS = 10_000;
@@ -203,7 +201,7 @@ export const checkFxProviderStatus = Effect.fn("checkFxProviderStatus")(function
201 );
202 const status = Option.flatMap(yield* read(["status", "--json"]), decodeFxStatus);
203 const listed = Option.flatMap(yield* read(["models", "--json"]), decodeFxModels).pipe(
206 - Option.map((models) => models.ids?.flatMap((id) => nonEmptyTrimmed(id) ?? []) ?? []),
204 + Option.map((models) => models.ids.flatMap((id) => nonEmptyTrimmed(id) ?? [])),
205 );
206 const auth = fxAuth(Option.getOrUndefined(status)?.auth);
207 const defaultModel = nonEmptyTrimmed(Option.getOrUndefined(status)?.model);