Skip to content

Commit 74b1627

Browse files
authored
feat(ui): show agent runtime distinction in model picker rows (#120617)
* feat(ui): show agent runtime distinction in model picker rows * fix(ui): label known CLI runtime ids in model picker rows
1 parent 13e30a9 commit 74b1627

4 files changed

Lines changed: 75 additions & 8 deletions

File tree

‎ui/src/pages/chat/chat-view.test.ts‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5196,6 +5196,55 @@ describe("chat model controls", () => {
51965196
expect(modelOption?.closest("openclaw-tooltip")).toBeNull();
51975197
});
51985198

5199+
it("distinguishes model rows that use different agent runtimes", () => {
5200+
const { state } = createChatHeaderState({
5201+
model: "gpt-5.6",
5202+
modelProvider: "openai",
5203+
models: [
5204+
{
5205+
id: "gpt-5.6",
5206+
name: "GPT-5.6",
5207+
provider: "openai",
5208+
contextWindow: 1_000_000,
5209+
agentRuntime: { id: "openclaw", source: "model" },
5210+
},
5211+
{
5212+
id: "gpt-5.6-sol",
5213+
name: "GPT-5.6 Sol",
5214+
provider: "openai",
5215+
contextWindow: 1_000_000,
5216+
agentRuntime: { id: "codex", source: "model" },
5217+
},
5218+
{
5219+
id: "claude-opus-4-5",
5220+
name: "Claude Opus 4.5",
5221+
provider: "anthropic",
5222+
contextWindow: 200_000,
5223+
agentRuntime: { id: "claude-cli", source: "model" },
5224+
},
5225+
{
5226+
id: "gemini-3-pro",
5227+
name: "Gemini 3 Pro",
5228+
provider: "google",
5229+
contextWindow: 1_000_000,
5230+
agentRuntime: { id: "google-gemini-cli", source: "model" },
5231+
},
5232+
],
5233+
});
5234+
const container = renderModelControls(state);
5235+
const metaFor = (value: string) =>
5236+
container.querySelector(
5237+
`[data-chat-model-option="${value}"] .chat-controls__model-option-meta`,
5238+
)?.textContent;
5239+
5240+
expect(metaFor("openai/gpt-5.6")).toBe("1M · OpenClaw");
5241+
expect(metaFor("openai/gpt-5.6")).not.toContain("Codex");
5242+
expect(metaFor("openai/gpt-5.6-sol")).toBe("1M · Codex");
5243+
// Known CLI runtime ids map to their product labels, not capitalized ids.
5244+
expect(metaFor("anthropic/claude-opus-4-5")).toBe("200k · Claude CLI");
5245+
expect(metaFor("google/gemini-3-pro")).toBe("1M · Gemini CLI");
5246+
});
5247+
51995248
it("marks chat-only models in the active control and picker", () => {
52005249
const { state } = createChatHeaderState({
52015250
model: "qwen3-8b",

‎ui/src/pages/chat/components/chat-model-controls.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,10 @@ export function renderChatModelControls(props: ChatModelControlsProps) {
200200
const isDefault =
201201
defaultSelectable && option.value.trim().toLowerCase() === normalizedDefaultModel;
202202
const catalogEntry = resolveChatModelCatalogEntry(option.value, props.modelCatalog);
203+
const agentRuntimeId = catalogEntry?.agentRuntime?.id.trim();
203204
return {
204205
commitValue: isDefault ? "" : option.value,
206+
...(agentRuntimeId ? { agentRuntimeId } : {}),
205207
...(catalogEntry?.contextWindow ? { contextWindow: catalogEntry.contextWindow } : {}),
206208
...(typeof catalogEntry?.supportsTools === "boolean"
207209
? { supportsTools: catalogEntry.supportsTools }

‎ui/src/pages/chat/components/chat-model-picker.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export type ChatModelCatalogState = {
1717
};
1818

1919
export type ChatModelPickerOption = {
20+
agentRuntimeId?: string;
2021
commitValue: string;
2122
contextWindow?: number;
2223
isDefault: boolean;
@@ -26,6 +27,24 @@ export type ChatModelPickerOption = {
2627
value: string;
2728
};
2829

30+
// Known models.list runtime ids; mirrors src/status/agent-runtime-label.ts,
31+
// which cannot be imported here (it drags terminal sanitizers into the bundle).
32+
const AGENT_RUNTIME_LABELS: Readonly<Record<string, string>> = {
33+
"claude-cli": "Claude CLI",
34+
codex: "Codex",
35+
"codex-cli": "Codex",
36+
"google-gemini-cli": "Gemini CLI",
37+
openclaw: "OpenClaw",
38+
};
39+
40+
function formatAgentRuntimeLabel(id: string): string {
41+
const normalized = id.trim().toLowerCase();
42+
return (
43+
AGENT_RUNTIME_LABELS[normalized] ??
44+
`${normalized.charAt(0).toUpperCase()}${normalized.slice(1)}`
45+
);
46+
}
47+
2948
type ChatModelPickerParams = {
3049
defaultModelLabel: string;
3150
disabled: boolean;
@@ -471,6 +490,9 @@ export function renderChatModelPicker(params: ChatModelPickerParams) {
471490
entry.supportsTools === false
472491
? t("chat.modelControls.chatOnly")
473492
: "",
493+
entry.agentRuntimeId
494+
? formatAgentRuntimeLabel(entry.agentRuntimeId)
495+
: "",
474496
]
475497
.filter(Boolean)
476498
.join(" · ");

‎ui/src/test-helpers/control-ui-e2e.ts‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type { Locator, Page } from "playwright";
1010
import type { InlineConfig, Plugin, PreviewServer, ViteDevServer } from "vite";
1111
import { PROTOCOL_VERSION } from "../../../packages/gateway-protocol/src/version.js";
1212
import { CONTROL_UI_BOOTSTRAP_CONFIG_PATH } from "../../../src/gateway/control-ui-contract.js";
13+
import type { ModelCatalogEntry } from "../api/types.ts";
1314
import type { ControlUiBuildInfo } from "../build-info.ts";
1415

1516
export function controlUiSessionPath(sessionKey: string, basePath = ""): string {
@@ -245,14 +246,7 @@ export type ControlUiMockGatewayScenario = {
245246
sessionInfo?: Record<string, unknown> | null;
246247
/** Partition sessions.list fixtures by archived state after applying patches. */
247248
sessionArchiveFiltering?: boolean;
248-
models?: Array<{
249-
id: string;
250-
name: string;
251-
provider: string;
252-
available?: boolean;
253-
contextWindow?: number;
254-
supportsTools?: boolean;
255-
}>;
249+
models?: ModelCatalogEntry[];
256250
/** Operator scopes returned by the mocked connect handshake. */
257251
operatorScopes?: string[];
258252
sessionKey?: string;

0 commit comments

Comments
 (0)