Skip to content

Commit 0fed5a7

Browse files
medric-zclaude
andcommitted
fix(server): thread titles no longer fail when the text generation provider can't run
Codex is the default text generation provider and is enabled by default. When its CLI is missing, or installed but signed out, its probe fails, but it stayed selected, so every thread title, branch name, and commit message request failed. A selected provider whose probe failed for either reason now takes the existing fallback, like an exhausted one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 60aec28 commit 0fed5a7

2 files changed

Lines changed: 30 additions & 12 deletions

File tree

‎apps/server/src/textGeneration/CodexTextGeneration.test.ts‎

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,15 @@ it.layer(layerCodexTextGenerationTest)("CodexTextGeneration", (it) => {
444444
);
445445
});
446446

447-
it.effect.each([false, true])("text generation preflight: exhausted=%s", (exhausted) =>
447+
const PREFLIGHT_PRIMARY_STATES = [
448+
"ready",
449+
"pending",
450+
"exhausted",
451+
"not installed",
452+
"signed out",
453+
] as const;
454+
455+
it.effect.each(PREFLIGHT_PRIMARY_STATES)("text generation preflight: %s", (primaryState) =>
448456
Effect.gen(function* () {
449457
const primary = ProviderInstanceId.make("codex");
450458
const fallback = ProviderInstanceId.make("claude_work");
@@ -468,7 +476,16 @@ it.effect.each([false, true])("text generation preflight: exhausted=%s", (exhaus
468476
models: [],
469477
slashCommands: [],
470478
skills: [],
471-
...(exhausted && instanceId === primary
479+
...(primaryState === "pending" && instanceId === primary
480+
? { installed: false, status: "warning", auth: { status: "unknown" } }
481+
: {}),
482+
...(primaryState === "not installed" && instanceId === primary
483+
? { installed: false, status: "error", auth: { status: "unknown" } }
484+
: {}),
485+
...(primaryState === "signed out" && instanceId === primary
486+
? { status: "error", auth: { status: "unauthenticated" } }
487+
: {}),
488+
...(primaryState === "exhausted" && instanceId === primary
472489
? {
473490
usageLimits: {
474491
checkedAt: "1970-01-01T00:00:00Z",
@@ -526,13 +543,13 @@ it.effect.each([false, true])("text generation preflight: exhausted=%s", (exhaus
526543
}),
527544
).toEqual({ title: "Generated title" });
528545
expect(calls).toEqual([
529-
exhausted
530-
? {
546+
primaryState === "ready" || primaryState === "pending"
547+
? selection
548+
: {
531549
instanceId: fallback,
532550
model:
533551
DEFAULT_TEXT_GENERATION_MODEL_BY_PROVIDER[ProviderDriverKind.make("claudeAgent")],
534-
}
535-
: selection,
552+
},
536553
]);
537554
}),
538555
);

‎apps/server/src/textGeneration/TextGeneration.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,13 @@ export const make = Effect.gen(function* () {
8686
),
8787
);
8888
const now = DateTime.toEpochMillis(yield* DateTime.now);
89-
const limited = exhaustedUsageWindow(
90-
snapshots.find((provider) => provider.instanceId === selection.instanceId),
91-
now,
92-
selection.model,
93-
);
94-
if (limited) {
89+
const selected = snapshots.find((provider) => provider.instanceId === selection.instanceId);
90+
// Only a failed probe counts: a pending one is also not installed yet.
91+
const unusable =
92+
selected?.enabled === true &&
93+
selected.status === "error" &&
94+
(!selected.installed || selected.auth.status === "unauthenticated");
95+
if (unusable || exhaustedUsageWindow(selected, now, selection.model)) {
9596
const settings = yield* serverSettings.getSettings.pipe(
9697
Effect.mapError(
9798
(cause) =>

0 commit comments

Comments
 (0)