Skip to content

Commit 156d1ce

Browse files
t3dotggclaude
andcommitted
fix(models): a new model also rechecks the latest CLI versions
T3 caches each provider's latest CLI version for an hour. A new model usually ships with the CLI release that supports it, so the update prompt stayed hidden for up to an hour after the model showed up. When the model picker finds a changed manifest, the cache is now cleared before providers are probed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 143ab48 commit 156d1ce

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎apps/server/src/provider/ProviderRegistry.test.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,9 +1574,9 @@ it.layer(
15741574
["codex_second-package", "1.0.0"],
15751575
]),
15761576
);
1577-
const readCachedVersion = (key: string) =>
1577+
const readCachedVersion = (key: string, latest = "2.0.0") =>
15781578
ProviderLatestVersions.ProviderLatestVersions.use((latestVersions) =>
1579-
latestVersions.cached(key, Effect.succeed("2.0.0")),
1579+
latestVersions.cached(key, Effect.succeed(latest)),
15801580
);
15811581

15821582
yield* Effect.gen(function* () {
@@ -1615,13 +1615,16 @@ it.layer(
16151615
const probesBefore = yield* Ref.get(second.probes);
16161616
yield* registry.refreshModelCatalog;
16171617
assert.strictEqual(yield* Ref.get(second.probes), probesBefore);
1618+
assert.strictEqual(yield* readCachedVersion("codex_second-package", "3.0.0"), "2.0.0");
16181619
yield* Ref.set(onDemandManifest, {
16191620
...ModelManifest.BUNDLED_MODEL_MANIFEST,
16201621
updatedAt: "2999-01-01T00:00:00Z",
16211622
});
16221623
yield* registry.refreshModelCatalog;
16231624
yield* registry.refreshModelCatalog;
16241625
assert.strictEqual(yield* Ref.get(second.probes), probesBefore + 1);
1626+
// A changed manifest also rechecks latest CLI versions.
1627+
assert.strictEqual(yield* readCachedVersion("codex_second-package", "3.0.0"), "3.0.0");
16251628
}).pipe(
16261629
Effect.provide(
16271630
ProviderRegistry.layer.pipe(

‎apps/server/src/provider/ProviderRegistry.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export class ProviderRegistry extends Context.Service<
9494

9595
/**
9696
* For an opened model picker: refetch a model manifest older than a few
97-
* minutes, and probe providers only when it has models they have not seen.
97+
* minutes. When it changed, recheck latest CLI versions and probe providers.
9898
*/
9999
readonly refreshModelCatalog: Effect.Effect<void>;
100100

@@ -1080,6 +1080,8 @@ export const layer = Layer.effect(
10801080
const refreshModelCatalog = Effect.fn("ProviderRegistry.refreshModelCatalog")(function* () {
10811081
const { updatedAt } = yield* manifestService.refreshOnDemand;
10821082
if ((yield* Ref.getAndSet(probedManifestUpdatedAt, updatedAt)) === updatedAt) return;
1083+
// A new model usually ships with the CLI release that supports it.
1084+
yield* latestVersions.invalidateAll;
10831085
yield* refreshAll().pipe(Effect.catchCause(recoverRefreshFailure));
10841086
});
10851087

‎apps/server/src/provider/providerMaintenanceRunner.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ function layerFailingLatestLookupAfterFirst() {
272272
return yield* lookup;
273273
}),
274274
invalidate: () => Effect.void,
275+
invalidateAll: Effect.void,
275276
});
276277
}
277278

‎packages/provider-core/src/server/ProviderLatestVersions.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class ProviderLatestVersions extends Context.Service<
2626
options?: { readonly fresh?: boolean },
2727
) => Effect.Effect<string | null, E, R>;
2828
readonly invalidate: (key: string) => Effect.Effect<void>;
29+
readonly invalidateAll: Effect.Effect<void>;
2930
}
3031
>()("@t3tools/provider-core/server/ProviderLatestVersions") {}
3132

@@ -84,6 +85,7 @@ export const make = Effect.fn("ProviderLatestVersions.make")(function* (
8485
return next;
8586
});
8687
}),
88+
invalidateAll: Ref.set(entries, new Map()),
8789
});
8890
});
8991

0 commit comments

Comments
 (0)