Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Normalize Assistant model route labels

rcourtman30f22ee761ac
diff --git a/docs/release-control/v6/internal/status.json b/docs/release-control/v6/internal/status.json
index 49b355c37e..4ab4bb391a 100644
--- a/docs/release-control/v6/internal/status.json
+++ b/docs/release-control/v6/internal/status.json
@@ -6767,11 +6767,11 @@
{
"id": "codex-lane-followup-architecture-post-rc-canonicalization",
"agent_id": "codex",
- "summary": "Fast-path deterministic Assistant inventory counts",
+ "summary": "Normalize Assistant model route labels",
"target_id": "v6-product-lane-expansion",
"claimed_at": "2026-06-05T21:57:48Z",
- "heartbeat_at": "2026-06-06T00:22:42Z",
- "expires_at": "2026-06-06T02:22:42Z",
+ "heartbeat_at": "2026-06-06T00:49:27Z",
+ "expires_at": "2026-06-06T02:49:27Z",
"work_item": {
"kind": "lane-followup",
"id": "architecture-post-rc-canonicalization"
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 7cb9304f41..2d66aa3c3f 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -366,7 +366,11 @@ runtime cost control, and shared AI transport surfaces.
route. Assistant transcript rows must carry and render the effective model
route that produced each live or restored response so route recovery and
mixed-provider sessions remain auditable. Direct provider models must not
- gain a gateway label.
+ gain a gateway label. Gateway route strings must still render as readable
+ provider/model labels before catalog hydration; this mirrors OpenCode's
+ source pattern of retaining structured `providerID`/`modelID` metadata and
+ presenting catalog names with ID fallbacks rather than leaking raw route
+ storage IDs into primary chat chrome.
7. Keep AI chat presentation helpers aligned through `frontend-modern/src/components/AI/Chat/` and the shared `frontend-modern/src/utils/textPresentation.ts`
8. Keep assistant drawer context, session, and org-switch reset state aligned through the shared `frontend-modern/src/stores/aiChat.ts` boundary instead of letting `frontend-modern/src/App.tsx`, `frontend-modern/src/AppLayout.tsx`, or feature callers fork their own assistant shell state
That shared drawer ownership also covers passive resource reads while the
diff --git a/frontend-modern/src/components/AI/Chat/ModelSelector.tsx b/frontend-modern/src/components/AI/Chat/ModelSelector.tsx
index 9722a011e8..971cea825b 100644
--- a/frontend-modern/src/components/AI/Chat/ModelSelector.tsx
+++ b/frontend-modern/src/components/AI/Chat/ModelSelector.tsx
@@ -141,7 +141,7 @@ export const ModelSelector: Component<ModelSelectorProps> = (props) => {
}
const match = props.models.find((model) => model.id === selected);
if (match) return formatAIModelRouteLabel(match);
- return selected;
+ return formatAIModelRouteLabel(selected);
});
// Click outside handler
@@ -292,7 +292,7 @@ export const ModelSelector: Component<ModelSelectorProps> = (props) => {
>
<div class="font-medium text-base-content">Chat override</div>
<div class="text-[11px] text-muted">
- {props.chatOverrideLabel || props.chatOverrideModel}
+ {props.chatOverrideLabel || formatAIModelRouteLabel(props.chatOverrideModel!)}
</div>
</button>
</Show>
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/ModelSelector.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/ModelSelector.test.tsx
index 47f4d25b26..d7608c548d 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/ModelSelector.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/ModelSelector.test.tsx
@@ -94,16 +94,16 @@ describe('ModelSelector', () => {
expect(screen.getByText('default')).toBeInTheDocument();
});
- it('shows raw model ID when selectedModel is not in the models list', () => {
+ it('formats gateway route IDs when selectedModel is not in the models list', () => {
render(() => (
<ModelSelector
models={SAMPLE_MODELS}
- selectedModel="custom:my-model"
+ selectedModel="openrouter:qwen/qwen3.7-plus"
onModelSelect={vi.fn()}
/>
));
- expect(screen.getByText('custom:my-model')).toBeInTheDocument();
+ expect(screen.getByText('Qwen: Qwen3.7 Plus via OpenRouter')).toBeInTheDocument();
});
it('shows the loading spinner when isLoading is true', () => {
@@ -216,21 +216,20 @@ describe('ModelSelector', () => {
expect(screen.getByText('GPT-4o (override)')).toBeInTheDocument();
});
- it('uses chatOverrideModel as label when chatOverrideLabel is not provided', () => {
+ it('formats chatOverrideModel when chatOverrideLabel is not provided', () => {
render(() => (
<ModelSelector
models={SAMPLE_MODELS}
selectedModel=""
- chatOverrideModel="openai:gpt-4o"
+ chatOverrideModel="openrouter:qwen/qwen3.7-plus"
onModelSelect={vi.fn()}
/>
));
fireEvent.click(screen.getByTitle('Select model for this chat'));
- // The override section label should contain the model ID
const overrideButton = screen.getByText('Chat override').closest('button')!;
- expect(overrideButton.textContent).toContain('openai:gpt-4o');
+ expect(overrideButton.textContent).toContain('Qwen: Qwen3.7 Plus via OpenRouter');
});
it('does not show chat override option when chatOverrideModel is not provided', () => {
diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsx
index bd2d798405..be793a4d2e 100644
--- a/frontend-modern/src/components/AI/Chat/index.tsx
+++ b/frontend-modern/src/components/AI/Chat/index.tsx
@@ -740,14 +740,14 @@ export const AIChat: Component<AIChatProps> = (props) => {
const fallback = defaultModel().trim();
if (!fallback) return '';
const match = aiRuntimeModels().find((model) => model.id === fallback);
- return match ? formatAIModelRouteLabel(match) : fallback;
+ return match ? formatAIModelRouteLabel(match) : formatAIModelRouteLabel(fallback);
});
const chatOverrideLabel = createMemo(() => {
const override = chatOverrideModel().trim();
if (!override) return '';
const match = aiRuntimeModels().find((model) => model.id === override);
- return match ? formatAIModelRouteLabel(match) : override;
+ return match ? formatAIModelRouteLabel(match) : formatAIModelRouteLabel(override);
});
const selectedChatModel = createMemo(() => {
diff --git a/frontend-modern/src/utils/__tests__/aiProviderPresentation.test.ts b/frontend-modern/src/utils/__tests__/aiProviderPresentation.test.ts
index db75235af8..c383f5d797 100644
--- a/frontend-modern/src/utils/__tests__/aiProviderPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/aiProviderPresentation.test.ts
@@ -52,6 +52,22 @@ describe('aiProviderPresentation', () => {
).toBe('DeepSeek R1 via OpenRouter');
});
+ it('formats OpenRouter route IDs when model catalog names are not hydrated', () => {
+ expect(formatAIModelRouteLabel('openrouter:qwen/qwen3.7-plus')).toBe(
+ 'Qwen: Qwen3.7 Plus via OpenRouter',
+ );
+ expect(
+ formatAIModelRouteLabel({
+ id: 'openrouter:anthropic/claude-sonnet-4.5',
+ name: 'anthropic/claude-sonnet-4.5',
+ provider: 'openrouter',
+ }),
+ ).toBe('Anthropic: Claude Sonnet 4.5 via OpenRouter');
+ expect(formatAIModelRouteLabel('openrouter:~anthropic/claude-sonnet-latest')).toBe(
+ 'Anthropic: Claude Sonnet Latest via OpenRouter',
+ );
+ });
+
it('labels Pulse-owned local runtime routes without provider wording', () => {
expect(formatAIModelRouteLabel('pulse:local-inventory')).toBe('Pulse inventory');
});
diff --git a/frontend-modern/src/utils/aiProviderPresentation.ts b/frontend-modern/src/utils/aiProviderPresentation.ts
index 569fc098a0..52b77f9b18 100644
--- a/frontend-modern/src/utils/aiProviderPresentation.ts
+++ b/frontend-modern/src/utils/aiProviderPresentation.ts
@@ -55,22 +55,77 @@ const GATEWAY_MODEL_PROVIDERS = new Set<string>(['openrouter']);
const LOCAL_MODEL_ROUTE_LABELS: Record<string, string> = {
'pulse:local-inventory': 'Pulse inventory',
};
+const UPSTREAM_PROVIDER_DISPLAY_NAMES: Record<string, string> = {
+ anthropic: 'Anthropic',
+ 'arcee-ai': 'Arcee AI',
+ 'bytedance-seed': 'ByteDance Seed',
+ cohere: 'Cohere',
+ deepseek: 'DeepSeek',
+ google: 'Google',
+ 'ibm-granite': 'IBM',
+ inclusionai: 'inclusionAI',
+ kwaipilot: 'Kwaipilot',
+ meta: 'Meta',
+ 'meta-llama': 'Meta Llama',
+ minimax: 'MiniMax',
+ mistral: 'Mistral',
+ mistralai: 'Mistral',
+ moonshotai: 'MoonshotAI',
+ nvidia: 'NVIDIA',
+ openai: 'OpenAI',
+ openrouter: 'OpenRouter',
+ perceptron: 'Perceptron',
+ poolside: 'Poolside',
+ qwen: 'Qwen',
+ rekaai: 'Reka',
+ stepfun: 'StepFun',
+ tencent: 'Tencent',
+ xiaomi: 'Xiaomi',
+ xai: 'xAI',
+ 'x-ai': 'xAI',
+ 'z-ai': 'Z.ai',
+};
+const MODEL_TOKEN_DISPLAY_NAMES: Record<string, string> = {
+ api: 'API',
+ deepseek: 'DeepSeek',
+ flash: 'Flash',
+ gemini: 'Gemini',
+ gpt: 'GPT',
+ haiku: 'Haiku',
+ instruct: 'Instruct',
+ llama: 'Llama',
+ mini: 'Mini',
+ opus: 'Opus',
+ plus: 'Plus',
+ pro: 'Pro',
+ qwen: 'Qwen',
+ r: 'R',
+ sonnet: 'Sonnet',
+ turbo: 'Turbo',
+ v: 'V',
+};
const modelIdForLabel = (model: AIModelRouteLabelInput): string =>
typeof model === 'string' ? model.trim() : model.id.trim();
+const explicitModelNameForLabel = (model: AIModelRouteLabelInput): string => {
+ if (typeof model === 'string') return '';
+ const name = model.name?.trim();
+ if (!name) return '';
+ const id = modelIdForLabel(model);
+ const routePayload = id.split(':').pop()?.trim();
+ if (name === id || (routePayload && name === routePayload)) return '';
+ return name;
+};
+
const baseModelLabel = (model: AIModelRouteLabelInput): string => {
const id = modelIdForLabel(model);
const localLabel = LOCAL_MODEL_ROUTE_LABELS[id];
if (localLabel) {
return localLabel;
}
- if (typeof model !== 'string') {
- const name = model.name?.trim();
- if (name) {
- return name;
- }
- }
+ const name = explicitModelNameForLabel(model);
+ if (name) return name;
return id.split(':').pop() || id;
};
@@ -85,9 +140,59 @@ const transportProviderForLabel = (model: AIModelRouteLabelInput): string => {
return id ? getProviderFromModelId(id) : '';
};
+const titleizeRouteNamespace = (namespace: string): string => {
+ const normalized = namespace.trim().toLowerCase().replace(/^~+/, '');
+ if (!normalized) return '';
+ const known = UPSTREAM_PROVIDER_DISPLAY_NAMES[normalized];
+ if (known) return known;
+ return normalized
+ .split(/[-_\s]+/)
+ .filter(Boolean)
+ .map((token) => token.charAt(0).toUpperCase() + token.slice(1))
+ .join(' ');
+};
+
+const titleizeModelToken = (token: string): string => {
+ const normalized = token.trim().toLowerCase();
+ if (!normalized) return '';
+ const known = MODEL_TOKEN_DISPLAY_NAMES[normalized];
+ if (known) return known;
+ const alphaNumeric = normalized.match(/^([a-z]+)([0-9].*)$/);
+ if (alphaNumeric) {
+ const prefix = MODEL_TOKEN_DISPLAY_NAMES[alphaNumeric[1]] || titleizeModelToken(alphaNumeric[1]);
+ return `${prefix}${alphaNumeric[2]}`;
+ }
+ if (/^[rv][0-9]/.test(normalized)) {
+ return normalized.charAt(0).toUpperCase() + normalized.slice(1);
+ }
+ return normalized.charAt(0).toUpperCase() + normalized.slice(1);
+};
+
+const titleizeModelRouteId = (modelId: string): string =>
+ modelId
+ .split(/[-_\s]+/)
+ .filter(Boolean)
+ .map(titleizeModelToken)
+ .join(' ');
+
+const gatewayFallbackLabel = (model: AIModelRouteLabelInput): string => {
+ if (explicitModelNameForLabel(model)) return '';
+ const id = modelIdForLabel(model);
+ const payload = id.includes(':') ? id.split(':').slice(1).join(':') : id;
+ const slashIndex = payload.indexOf('/');
+ if (slashIndex <= 0 || slashIndex === payload.length - 1) return '';
+ const upstreamProvider = titleizeRouteNamespace(payload.slice(0, slashIndex));
+ const modelLabel = titleizeModelRouteId(payload.slice(slashIndex + 1));
+ if (!upstreamProvider || !modelLabel) return '';
+ return `${upstreamProvider}: ${modelLabel}`;
+};
+
export const formatAIModelRouteLabel = (model: AIModelRouteLabelInput): string => {
- const label = baseModelLabel(model);
const provider = transportProviderForLabel(model);
+ const label =
+ provider && GATEWAY_MODEL_PROVIDERS.has(provider)
+ ? gatewayFallbackLabel(model) || baseModelLabel(model)
+ : baseModelLabel(model);
if (!provider || !GATEWAY_MODEL_PROVIDERS.has(provider)) {
return label;
}