Skip to content

Commit 565514f

Browse files
fix: brand icons for text generators; clear review guide error without an agent
Text generators showed initials or a generic glyph in model pickers. They now show the service they reach (OpenAI, Anthropic, OpenRouter, Ollama, or a server glyph for other endpoints), and the instance badge appears only when two generators reach the same service. A review guide that inherits a text generator falls back to Codex or Claude. When neither was ready it failed with "No provider instance registered", which named nothing the user could fix; it now says a checkout-reading agent is needed and where to choose one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 2c47987 commit 565514f

10 files changed

Lines changed: 130 additions & 31 deletions

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

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -697,24 +697,31 @@ it.effect(
697697
}),
698698
}),
699699
} satisfies ProviderInstance;
700-
const service = yield* TextGeneration.make.pipe(
701-
Effect.provide(
702-
Layer.mergeAll(
703-
Layer.mock(ProviderInstanceRegistry.ProviderInstanceRegistry)({
704-
listInstances: Effect.succeed([instance]),
705-
getInstance: (id) => Effect.succeed(id === claude ? instance : undefined),
706-
}),
707-
ServerSettings.layerTest({}),
708-
Layer.mock(TextGenerators.TextGenerators)({
709-
runner: () => Effect.succeed(() => Effect.die("a text generator cannot investigate")),
710-
}),
711-
Layer.mock(SourceControlProviderRegistry.SourceControlProviderRegistry)({
712-
resolveLink: () => Effect.die("unused"),
713-
}),
700+
const serviceWith = (instances: ReadonlyArray<ProviderInstance>) =>
701+
TextGeneration.make.pipe(
702+
Effect.provide(
703+
Layer.mergeAll(
704+
Layer.mock(ProviderInstanceRegistry.ProviderInstanceRegistry)({
705+
listInstances: Effect.succeed(instances),
706+
getInstance: (id) =>
707+
Effect.succeed(instances.find((candidate) => candidate.instanceId === id)),
708+
}),
709+
ServerSettings.layerTest({}),
710+
Layer.mock(TextGenerators.TextGenerators)({
711+
runner: (id) =>
712+
Effect.succeed(
713+
id === "openrouter"
714+
? () => Effect.die("a text generator cannot investigate")
715+
: undefined,
716+
),
717+
}),
718+
Layer.mock(SourceControlProviderRegistry.SourceControlProviderRegistry)({
719+
resolveLink: () => Effect.die("unused"),
720+
}),
721+
),
714722
),
715-
),
716-
);
717-
yield* service.generateReviewGuide({
723+
);
724+
const input = {
718725
cwd: "/tmp",
719726
number: 1,
720727
title: "Change",
@@ -723,7 +730,12 @@ it.effect(
723730
baseCommit: "abc",
724731
settledReview: "",
725732
modelSelection: { instanceId: ProviderInstanceId.make("openrouter"), model: "some/model" },
726-
});
733+
};
734+
yield* (yield* serviceWith([instance])).generateReviewGuide(input);
727735
expect(calls.map((selection) => selection.instanceId)).toEqual([claude]);
736+
737+
// With no agent ready, it says what is missing instead of looking up a provider by that id.
738+
const failure = yield* Effect.flip((yield* serviceWith([])).generateReviewGuide(input));
739+
expect(failure.detail).toMatch(/^Review guides need an agent that can read the checkout/);
728740
}),
729741
);

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export const make = Effect.gen(function* () {
8888
) {
8989
const textGenerator = yield* textGenerators.runner(selection.instanceId);
9090
// A review guide reaches a text generator only through a fallback; it needs an agent instead.
91+
const textGeneratorId = selection.instanceId;
9192
const textGeneratorCannotRun =
9293
textGenerator !== undefined && operation === "generateReviewGuide";
9394
if (textGenerator !== undefined && !textGeneratorCannotRun) {
@@ -141,6 +142,13 @@ export const make = Effect.gen(function* () {
141142
{ includeConfiguredInstances: true },
142143
) ?? selection;
143144
}
145+
if (textGeneratorCannotRun && selection.instanceId === textGeneratorId) {
146+
return yield* new TextGenerationError({
147+
operation,
148+
detail:
149+
"Review guides need an agent that can read the checkout, such as Codex or Claude, and none is ready. Choose one as the review guide model in Settings → Source control.",
150+
});
151+
}
144152
return yield* resolveInstance(registry, operation, selection.instanceId).pipe(
145153
Effect.flatMap((service) => invoke(service, selection)),
146154
);

‎apps/web/src/components/Icons.tsx‎

Lines changed: 19 additions & 0 deletions
Large diffs are not rendered by default.

‎apps/web/src/components/chat/ProviderInstanceIcon.tsx‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SparklesIcon } from "lucide-react";
1+
import { ServerIcon } from "lucide-react";
22
import { type CSSProperties, memo } from "react";
33

44
import {
@@ -8,7 +8,15 @@ import {
88
} from "@t3tools/client-runtime/state/provider-instance-display";
99

1010
import { ProviderDriverKind } from "@t3tools/contracts";
11-
import { AntigravityIcon, ClaudeAI, Icon, OpenAI } from "../Icons";
11+
import {
12+
AnthropicIcon,
13+
AntigravityIcon,
14+
ClaudeAI,
15+
Icon,
16+
OllamaIcon,
17+
OpenAI,
18+
OpenRouterIcon,
19+
} from "../Icons";
1220

1321
import { cn } from "~/lib/utils";
1422
import { providerClients } from "../settings/providerDriverMeta";
@@ -23,16 +31,22 @@ const PROVIDER_ICON_BY_PROVIDER: Partial<Record<ProviderDriverKind, Icon>> = {
2331
[ProviderDriverKind.make("codex")]: OpenAI,
2432
[ProviderDriverKind.make("claudeAgent")]: ClaudeAI,
2533
[ProviderDriverKind.make("antigravity")]: AntigravityIcon,
26-
// Text generator kinds: the compatible kind also serves OpenRouter and local servers, so no brand.
27-
[ProviderDriverKind.make("anthropic")]: ClaudeAI,
28-
[ProviderDriverKind.make("openaiCompatible")]: SparklesIcon,
34+
// Text generators, by the service they reach (see textGeneratorBrand).
35+
[ProviderDriverKind.make("openai")]: OpenAI,
36+
[ProviderDriverKind.make("anthropic")]: AnthropicIcon,
37+
[ProviderDriverKind.make("openrouter")]: OpenRouterIcon,
38+
[ProviderDriverKind.make("ollama")]: OllamaIcon,
39+
[ProviderDriverKind.make("openaiCompatible")]: ServerIcon,
2940
};
3041

3142
const PROVIDER_TEXT_COLOR_BY_PROVIDER: Partial<Record<ProviderDriverKind, string>> = {
3243
[ProviderDriverKind.make("codex")]: "text-black dark:text-white",
3344
[ProviderDriverKind.make("claudeAgent")]: "text-[#d97757]",
3445
[ProviderDriverKind.make("antigravity")]: "text-[#5b87bf]",
35-
[ProviderDriverKind.make("anthropic")]: "text-[#d97757]",
46+
[ProviderDriverKind.make("openai")]: "text-black dark:text-white",
47+
[ProviderDriverKind.make("anthropic")]: "text-black dark:text-white",
48+
[ProviderDriverKind.make("openrouter")]: "text-black dark:text-white",
49+
[ProviderDriverKind.make("ollama")]: "text-black dark:text-white",
3650
};
3751

3852
export function providerTextColor(driverKind: ProviderDriverKind): {

‎apps/web/src/components/settings/SourceControlWritingSettings.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ export function SourceControlWritingSettingsSection() {
327327
serverScoped
328328
settingKeys={["reviewGuideModelSelection"]}
329329
{...searchableSetting("review-guide-model")}
330-
description="Model that reads a pull request to write its review guide. It reads the change itself over many steps, so a stronger model helps. Off uses the source control writer model."
330+
description="Agent that reads a pull request over many steps to write its review guide; a stronger model helps. Off uses the source control writer model, or Codex or Claude when that is a text generator."
331331
control={
332332
!hasServerTargets ? (
333333
<span className="text-sm text-muted-foreground">

‎apps/web/src/components/settings/TextGeneratorsSettings.tsx‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ import {
1717
refreshTextGeneratorModels,
1818
TEXT_GENERATOR_PRESETS,
1919
type TextGeneratorPreset,
20+
textGeneratorBrand,
2021
textGeneratorDisplayName,
2122
} from "../../textGenerators";
23+
import { ProviderInstanceIcon } from "../chat/ProviderInstanceIcon";
2224
import {
2325
AlertDialog,
2426
AlertDialogClose,
@@ -100,7 +102,17 @@ export function TextGeneratorsSettings({
100102
return (
101103
<SettingsRow
102104
key={id}
103-
title={name}
105+
title={
106+
<span className="inline-flex items-center gap-2">
107+
<ProviderInstanceIcon
108+
driverKind={textGeneratorBrand(config)}
109+
displayName={name}
110+
badgeContent="none"
111+
size="compact"
112+
/>
113+
{name}
114+
</span>
115+
}
104116
description={
105117
<span className="break-all">
106118
{KIND_LABELS[config.kind]}

‎apps/web/src/components/settings/useScopedModelAvailability.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66

77
import { mergeEnvironmentSettings } from "../../hooks/useSettings";
88
import { getCustomModelOptionsByInstance } from "../../modelSelection";
9+
import { textGeneratorBrand } from "../../textGenerators";
910
import {
1011
applyProviderInstanceSettings,
1112
deriveProviderInstanceEntries,
@@ -32,7 +33,7 @@ export function useScopedModelDisabledReason(
3233
const generator = textGeneratorForSelection(candidate.settings, instanceId);
3334
if (isTextGenerator || generator !== undefined) {
3435
// Only the shown environment's model list is loaded; elsewhere the generator must match.
35-
if (!generator?.enabled || generator.kind !== sourceEntry?.driverKind) {
36+
if (!generator?.enabled || textGeneratorBrand(generator) !== sourceEntry?.driverKind) {
3637
return unavailable;
3738
}
3839
continue;

‎apps/web/src/textGenerators.test.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ProviderDriverKind, ProviderInstanceId } from "@t3tools/contracts";
22
import { describe, expect, it } from "vite-plus/test";
33

4-
import { nextTextGeneratorId } from "./textGenerators";
4+
import { nextTextGeneratorId, textGeneratorBrand } from "./textGenerators";
55

66
describe("nextTextGeneratorId", () => {
77
it("skips ids that would make a selection name another target", () => {
@@ -26,3 +26,15 @@ describe("nextTextGeneratorId", () => {
2626
expect(nextTextGeneratorId("openrouter", settings, providers)).toBe("openrouter");
2727
});
2828
});
29+
30+
describe("textGeneratorBrand", () => {
31+
it.each([
32+
["anthropic", "https://proxy.example/v1", "anthropic"],
33+
["openaiCompatible", "https://openrouter.ai/api/v1", "openrouter"],
34+
["openaiCompatible", "https://api.openai.com/v1", "openai"],
35+
["openaiCompatible", "http://localhost:11434/v1", "ollama"],
36+
["openaiCompatible", "http://localhost:1234/v1", "openaiCompatible"],
37+
] as const)("%s at %s shows the %s icon", (kind, baseUrl, brand) => {
38+
expect(textGeneratorBrand({ kind, baseUrl })).toBe(brand);
39+
});
40+
});

‎apps/web/src/textGenerators.ts‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,25 @@ export function textGeneratorDisplayName(config: TextGeneratorConfig): string {
6565
}
6666
}
6767

68+
/**
69+
* The service a text generator reaches, which picks its picker icon. It stands in for the driver
70+
* kind in picker entries only, so generators of one service share an icon and get instance badges.
71+
*/
72+
export function textGeneratorBrand(config: Pick<TextGeneratorConfig, "kind" | "baseUrl">) {
73+
if (config.kind === "anthropic") return ProviderDriverKind.make("anthropic");
74+
let url: URL | null = null;
75+
try {
76+
url = new URL(config.baseUrl);
77+
} catch {}
78+
const host = url?.hostname ?? "";
79+
if (host === "openrouter.ai" || host.endsWith(".openrouter.ai")) {
80+
return ProviderDriverKind.make("openrouter");
81+
}
82+
if (host === "api.openai.com") return ProviderDriverKind.make("openai");
83+
if (url?.port === "11434" || host.includes("ollama")) return ProviderDriverKind.make("ollama");
84+
return ProviderDriverKind.make("openaiCompatible");
85+
}
86+
6887
/**
6988
* A new text generator id. Selections name a text generator by the same id as a provider
7089
* instance, so it must not match a configured instance, a driver's default instance, or
@@ -157,7 +176,7 @@ function textGeneratorSnapshot(
157176
const failure = Option.getOrUndefined(AsyncResult.error(result));
158177
return {
159178
instanceId: id,
160-
driver: ProviderDriverKind.make(config.kind),
179+
driver: textGeneratorBrand(config),
161180
displayName: textGeneratorDisplayName(config),
162181
supportsTextGeneration: true,
163182
enabled: config.enabled,

‎docs/user/text-generation.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ task needs, such as the staged diff for a commit message.
2828

2929
## Limits
3030

31-
- Review guides need an agent that can read the checkout, so they always use a coding agent.
32-
Pick one in **Settings → Source control → Review guide model**.
31+
- Review guides need an agent that can read the checkout, so they always use a coding agent. When
32+
the source control writer model is a text generator, review guides use Codex or Claude instead,
33+
and fail with a message if neither is ready. Pick one in **Settings → Source control → Review
34+
guide model** to choose which.
3335
- A [managed policy](./managed-policy.md) that limits providers also turns off text generators.
3436
- Turning a text generator off, or removing it, sends its tasks back to the environment's text
3537
generation model.

0 commit comments

Comments
 (0)