Skip to content

Commit 6933eb0

Browse files
fix(providers): keep cached models and prompt links while checking
The pending Codex snapshot moved from warning to checking, so the registry stopped retaining cached models during the initial probe and prompt links could not resolve a provider until it finished. Treat checking like the old pending warning in both places, and trim tests to the regressions they guard. AI-assisted; verified with the tests and tools listed above.
1 parent 7d1be16 commit 6933eb0

5 files changed

Lines changed: 15 additions & 41 deletions

File tree

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ import { deepMerge } from "@t3tools/shared/Struct";
4444
import { createModelCapabilities } from "@t3tools/shared/model";
4545
import { applyServerSettingsPatch } from "@t3tools/shared/serverSettings";
4646

47-
import {
48-
checkCodexProviderStatus,
49-
makePendingCodexProvider,
50-
type CodexAppServerProviderSnapshot,
51-
} from "./CodexProvider.ts";
47+
import { checkCodexProviderStatus, type CodexAppServerProviderSnapshot } from "./CodexProvider.ts";
5248
import { BUNDLED_CLAUDE_MODEL_CATALOG } from "./ClaudeModelCatalog.ts";
5349
import { checkClaudeProviderStatus } from "./ClaudeProvider.ts";
5450
import * as BackgroundPolicy from "../background/BackgroundPolicy.ts";
@@ -364,14 +360,6 @@ it.layer(
364360
describe("checkCodexProviderStatus", () => {
365361
it.effect("uses the app-server account and model list for provider status", () =>
366362
Effect.gen(function* () {
367-
const pending = yield* makePendingCodexProvider(defaultCodexSettings);
368-
assert.strictEqual(pending.status, "checking");
369-
assert.strictEqual(pending.auth.status, "unknown");
370-
const disabled = yield* makePendingCodexProvider({
371-
...defaultCodexSettings,
372-
enabled: false,
373-
});
374-
assert.strictEqual(disabled.status, "disabled");
375363
const status = yield* checkCodexProviderStatus(defaultCodexSettings, () =>
376364
Effect.succeed(
377365
makeCodexProbeSnapshot({
@@ -1201,7 +1189,7 @@ it.layer(
12011189
} satisfies ServerProvider;
12021190
const pendingProvider = {
12031191
...cachedProvider,
1204-
status: "warning",
1192+
status: "checking",
12051193
installed: false,
12061194
auth: { status: "unknown" },
12071195
models: [customModel],

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ const shouldRetainMissingProviderModels = (provider: ServerProvider): boolean =>
218218
const isPendingAntigravityAuthentication =
219219
isAntigravity && provider.status === "warning" && provider.auth.status === "unknown";
220220
const isPendingInitialProbe =
221-
provider.enabled && !provider.installed && provider.status === "warning";
221+
provider.enabled &&
222+
!provider.installed &&
223+
(provider.status === "checking" || provider.status === "warning");
222224
const isIncompleteInstalledProbe =
223225
provider.installed &&
224226
(provider.status === "error" || (isCodex && provider.status === "warning"));

‎apps/web/src/components/chat/ProviderStatusBanner.test.ts‎

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,8 @@ describe("provider status banners", () => {
3838
message: "Codex provider status has not been checked in this session yet.",
3939
};
4040
expect(shouldShowProviderStatusBanner(checking, null)).toBe(false);
41-
expect(
42-
shouldShowProviderStatusBanner({ ...checking, message: "Checking installation." }, null),
43-
).toBe(false);
44-
expect(
45-
shouldShowProviderStatusBanner(
46-
{ ...checking, installed: true, status: "ready", auth: { status: "authenticated" } },
47-
null,
48-
),
49-
).toBe(false);
50-
for (const failure of [
51-
{ status: "error", installed: false, message: "Could not start Codex CLI." },
52-
{ status: "error", installed: true, message: "Codex provider probe failed." },
53-
{ status: "error", installed: true, message: "Timed out while checking Codex." },
54-
{
55-
status: "warning",
56-
installed: true,
57-
message: "Codex did not return its model catalog in time.",
58-
},
59-
{ status: "warning", installed: false, message: checking.message },
60-
{ status: "error", auth: { status: "unauthenticated" }, message: "Run codex login." },
61-
] as const) {
62-
expect(shouldShowProviderStatusBanner({ ...checking, ...failure }, null)).toBe(true);
63-
}
64-
expect(shouldShowProviderStatusBanner({ ...checking, status: "disabled" }, null)).toBe(false);
41+
expect(shouldShowProviderStatusBanner({ ...checking, status: "warning" }, null)).toBe(true);
42+
expect(shouldShowProviderStatusBanner({ ...checking, status: "error" }, null)).toBe(true);
6543
expect(
6644
shouldShowProviderStatusBanner(
6745
{

‎packages/client-runtime/src/promptLinks.test.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ describe("resolvePromptLinkModelSelection", () => {
129129
const provider = (
130130
instanceId: string,
131131
driver: string,
132-
status: "ready" | "warning" | "error" | "disabled" = "ready",
132+
status: "checking" | "ready" | "warning" | "error" | "disabled" = "ready",
133133
) => ({
134134
instanceId: ProviderInstanceId.make(instanceId),
135135
driver: ProviderDriverKind.make(driver),
@@ -168,5 +168,11 @@ describe("resolvePromptLinkModelSelection", () => {
168168
expect(
169169
resolvePromptLinkModelSelection(providers, { provider: "cursor", model: null }),
170170
).toBeNull();
171+
expect(
172+
resolvePromptLinkModelSelection([provider("codex", "codex", "checking")], {
173+
provider: "codex",
174+
model: "small",
175+
}),
176+
).toEqual({ selection: { instanceId: "codex", model: "small" }, exact: true });
171177
});
172178
});

‎packages/client-runtime/src/promptLinks.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export function resolvePromptLinkModelSelection(
111111
);
112112
const instance =
113113
usable.find((provider) => provider.status === "ready") ??
114-
usable.find((provider) => provider.status === "warning");
114+
usable.find((provider) => provider.status === "warning" || provider.status === "checking");
115115
if (instance === undefined) return null;
116116
const requested =
117117
request.model === null

0 commit comments

Comments
 (0)