Skip to content

Commit 6b84d2c

Browse files
medric-zclaude
andauthored
fix(server): thread titles no longer fail when the text generation provider can't run (pingdotgg#29607)
Co-authored-by: medric-z <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent e5193ac commit 6b84d2c

2 files changed

Lines changed: 37 additions & 12 deletions

File tree

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

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,16 @@ it.layer(layerCodexTextGenerationTest)("CodexTextGeneration", (it) => {
519519
);
520520
});
521521

522-
it.effect.each([false, true])("text generation preflight: exhausted=%s", (exhausted) =>
522+
const PREFLIGHT_PRIMARY_STATES = [
523+
"ready",
524+
"pending",
525+
"exhausted",
526+
"not installed",
527+
"signed out",
528+
"signed out, fallback failed",
529+
] as const;
530+
531+
it.effect.each(PREFLIGHT_PRIMARY_STATES)("text generation preflight: %s", (primaryState) =>
523532
Effect.gen(function* () {
524533
const primary = ProviderInstanceId.make("codex");
525534
const fallback = ProviderInstanceId.make("claude_work");
@@ -543,7 +552,19 @@ it.effect.each([false, true])("text generation preflight: exhausted=%s", (exhaus
543552
models: [],
544553
slashCommands: [],
545554
skills: [],
546-
...(exhausted && instanceId === primary
555+
...(primaryState === "pending" && instanceId === primary
556+
? { installed: false, status: "warning", auth: { status: "unknown" } }
557+
: {}),
558+
...(primaryState === "not installed" && instanceId === primary
559+
? { installed: false, status: "error", auth: { status: "unknown" } }
560+
: {}),
561+
...(primaryState.startsWith("signed out") && instanceId === primary
562+
? { status: "error", auth: { status: "unauthenticated" } }
563+
: {}),
564+
...(primaryState === "signed out, fallback failed" && instanceId === fallback
565+
? { status: "error", auth: { status: "unknown" } }
566+
: {}),
567+
...(primaryState === "exhausted" && instanceId === primary
547568
? {
548569
usageLimits: {
549570
checkedAt: "1970-01-01T00:00:00Z",
@@ -602,13 +623,15 @@ it.effect.each([false, true])("text generation preflight: exhausted=%s", (exhaus
602623
}),
603624
).toEqual({ title: "Generated title" });
604625
expect(calls).toEqual([
605-
exhausted
606-
? {
626+
primaryState === "ready" ||
627+
primaryState === "pending" ||
628+
primaryState === "signed out, fallback failed"
629+
? selection
630+
: {
607631
instanceId: fallback,
608632
model:
609633
DEFAULT_TEXT_GENERATION_MODEL_BY_PROVIDER[ProviderDriverKind.make("claudeAgent")],
610-
}
611-
: selection,
634+
},
612635
]);
613636
}),
614637
);

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,13 @@ export const make = Effect.gen(function* () {
8989
),
9090
);
9191
const now = DateTime.toEpochMillis(yield* DateTime.now);
92-
const limited = exhaustedUsageWindow(
93-
snapshots.find((provider) => provider.instanceId === selection.instanceId),
94-
now,
95-
selection.model,
96-
);
97-
if (limited) {
92+
const selected = snapshots.find((provider) => provider.instanceId === selection.instanceId);
93+
// Only a failed probe counts: a pending one is also not installed yet.
94+
const unusable =
95+
selected?.enabled === true &&
96+
selected.status === "error" &&
97+
(!selected.installed || selected.auth.status === "unauthenticated");
98+
if (unusable || exhaustedUsageWindow(selected, now, selection.model)) {
9899
const settings = yield* serverSettings.getSettings.pipe(
99100
Effect.mapError(
100101
(cause) =>
@@ -116,6 +117,7 @@ export const make = Effect.gen(function* () {
116117
resolveProjectProviderInstanceEnabled(settings, null, instanceId) &&
117118
provider.installed &&
118119
provider.auth.status !== "unauthenticated" &&
120+
provider.status !== "error" &&
119121
isProviderAvailable(provider) &&
120122
isProviderTextGenerationCapable(provider) &&
121123
(operation !== "generateReviewGuide" || INVESTIGATING_DRIVERS.has(driver)) &&

0 commit comments

Comments
 (0)