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.

Show Assistant response model routes

rcourtman5462cefa19cc
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 18f80d7788..9897af8a80 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -180,7 +180,10 @@ runtime cost control, and shared AI transport surfaces.
`openrouter:deepseek/...` must render with an explicit `via OpenRouter`
label in the shared picker, System AI settings status, and inherited default
descriptions unless the server-supplied model name already carries that
- route. Direct provider models must not gain a gateway label.
+ 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.
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/ChatMessages.tsx b/frontend-modern/src/components/AI/Chat/ChatMessages.tsx
index 5bae36d0f2..86cee2d409 100644
--- a/frontend-modern/src/components/AI/Chat/ChatMessages.tsx
+++ b/frontend-modern/src/components/AI/Chat/ChatMessages.tsx
@@ -21,6 +21,7 @@ interface ChatMessagesProps {
onSkipQuestion: (messageId: string, questionId: string) => void;
onRetry?: (messageId: string) => void;
onChangeModel?: () => void;
+ getModelRouteLabel?: (modelId: string) => string;
getModelRouteAlternative?: (message: ChatMessage) => ModelRouteRecoveryOption | null;
onUseModelRoute?: (modelId: string, messageId?: string) => void;
// Dashboard props
@@ -155,6 +156,7 @@ export const ChatMessages: Component<ChatMessagesProps> = (props) => {
onSkipQuestion={(questionId) => props.onSkipQuestion(message.id, questionId)}
onRetry={props.onRetry}
onChangeModel={props.onChangeModel}
+ getModelRouteLabel={props.getModelRouteLabel}
modelRouteAlternative={props.getModelRouteAlternative?.(message)}
onUseModelRoute={props.onUseModelRoute}
/>
diff --git a/frontend-modern/src/components/AI/Chat/MessageItem.tsx b/frontend-modern/src/components/AI/Chat/MessageItem.tsx
index 86c266f88e..6a934a37da 100644
--- a/frontend-modern/src/components/AI/Chat/MessageItem.tsx
+++ b/frontend-modern/src/components/AI/Chat/MessageItem.tsx
@@ -23,6 +23,7 @@ import {
AI_CHAT_ASSISTANT_MESSAGE_LABEL,
AI_CHAT_CONTEXT_USED_LABEL,
} from '@/utils/aiChatPresentation';
+import { formatAIModelRouteLabel } from '@/utils/aiProviderPresentation';
import { formatIdentifierLabel } from '@/utils/textPresentation';
interface MessageItemProps {
@@ -36,6 +37,7 @@ interface MessageItemProps {
onSkipQuestion: (questionId: string) => void;
onRetry?: (messageId: string) => void;
onChangeModel?: () => void;
+ getModelRouteLabel?: (modelId: string) => string;
modelRouteAlternative?: ModelRouteRecoveryOption | null;
onUseModelRoute?: (modelId: string, messageId?: string) => void;
}
@@ -90,6 +92,11 @@ export const MessageItem: Component<MessageItemProps> = (props) => {
});
const visibleMessageContent = () =>
stripAssistantOutputArtifacts(props.message.content || '').text;
+ const messageModelLabel = () => {
+ const model = props.message.model?.trim();
+ if (!model) return '';
+ return props.getModelRouteLabel?.(model) || formatAIModelRouteLabel(model);
+ };
// Check if currently streaming content (no tools pending, still streaming)
const isStreamingText = () =>
@@ -161,8 +168,13 @@ export const MessageItem: Component<MessageItemProps> = (props) => {
<span class="text-xs font-semibold text-base-content">
{AI_CHAT_ASSISTANT_MESSAGE_LABEL}
</span>
- <Show when={props.message.model && !props.message.isStreaming}>
- <span class="text-[10px] text-muted font-mono">{props.message.model}</span>
+ <Show when={messageModelLabel() && !props.message.isStreaming}>
+ <span
+ class="truncate rounded border border-border-subtle bg-surface-alt px-1.5 py-0.5 text-[10px] font-medium text-muted"
+ title={props.message.model}
+ >
+ {messageModelLabel()}
+ </span>
</Show>
<Show when={canCopy()}>
<button
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
index e0a2347cba..5501dd0787 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
@@ -20,6 +20,7 @@ const {
const mockChatMessagesProps: Array<{
messages: ChatMessage[];
onChangeModel?: () => void;
+ getModelRouteLabel?: (modelId: string) => string;
getModelRouteAlternative?: (message: ChatMessage) => ModelRouteRecoveryOption | null;
onUseModelRoute?: (modelId: string, messageId?: string) => void;
}> = [];
@@ -193,6 +194,7 @@ vi.mock('../ChatMessages', () => ({
messages: ChatMessage[];
emptyState?: { title: string; subtitle?: string };
onChangeModel?: () => void;
+ getModelRouteLabel?: (modelId: string) => string;
getModelRouteAlternative?: (message: ChatMessage) => ModelRouteRecoveryOption | null;
onUseModelRoute?: (modelId: string, messageId?: string) => void;
}) => {
@@ -437,6 +439,31 @@ describe('AIChat', () => {
});
});
+ it('passes catalog-grade model route labels to transcript rows', async () => {
+ mockAIAPI.getModels.mockResolvedValue({
+ models: [
+ {
+ id: 'openrouter:deepseek/deepseek-v4-pro',
+ name: 'DeepSeek: DeepSeek V4 Pro',
+ provider: 'openrouter',
+ notable: true,
+ },
+ ],
+ });
+
+ renderChat();
+
+ await waitFor(() => {
+ expect(mockAIAPI.getModels).toHaveBeenCalled();
+ });
+ await waitFor(() => {
+ const props = mockChatMessagesProps[mockChatMessagesProps.length - 1];
+ expect(props?.getModelRouteLabel?.('openrouter:deepseek/deepseek-v4-pro')).toBe(
+ 'DeepSeek: DeepSeek V4 Pro via OpenRouter',
+ );
+ });
+ });
+
it('switches a failed turn to an equivalent configured-provider route and retries it', async () => {
mockChat.model.mockReturnValue('deepseek:deepseek-v4-pro');
mockChat.messages.mockReturnValue([
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/ChatMessages.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/ChatMessages.test.tsx
index a3e469b449..780628ca87 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/ChatMessages.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/ChatMessages.test.tsx
@@ -19,6 +19,7 @@ let capturedMessageItemProps: Array<{
) => void;
onSkipQuestion: (questionId: string) => void;
onChangeModel?: () => void;
+ getModelRouteLabel?: (modelId: string) => string;
modelRouteAlternative?: ModelRouteRecoveryOption | null;
onUseModelRoute?: (modelId: string, messageId?: string) => void;
}> = [];
@@ -34,6 +35,7 @@ vi.mock('../MessageItem', () => ({
) => void;
onSkipQuestion: (questionId: string) => void;
onChangeModel?: () => void;
+ getModelRouteLabel?: (modelId: string) => string;
modelRouteAlternative?: ModelRouteRecoveryOption | null;
onUseModelRoute?: (modelId: string, messageId?: string) => void;
}) => {
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
index f87789723e..392bf60c75 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
@@ -321,6 +321,26 @@ describe('MessageItem', () => {
expect(screen.getByText('Pulse Assistant')).toBeInTheDocument();
});
+ it('renders completed assistant model routes with provider labels', () => {
+ render(() => (
+ <MessageItem
+ message={makeMessage({
+ role: 'assistant',
+ content: 'Done.',
+ model: 'openrouter:deepseek/deepseek-v4-pro',
+ })}
+ getModelRouteLabel={(modelId) =>
+ modelId === 'openrouter:deepseek/deepseek-v4-pro'
+ ? 'DeepSeek: DeepSeek V4 Pro via OpenRouter'
+ : modelId
+ }
+ {...makeHandlers()}
+ />
+ ));
+
+ expect(screen.getByText('DeepSeek: DeepSeek V4 Pro via OpenRouter')).toBeInTheDocument();
+ });
+
it('does not use right-alignment for assistant messages', () => {
const { container } = render(() => (
<MessageItem message={makeMessage({ role: 'assistant' })} {...makeHandlers()} />
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
index 722fee0aba..f793175334 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
+++ b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts
@@ -193,6 +193,23 @@ describe('useChat', () => {
dispose();
});
+ it('uses the configured default model route for the request and assistant turn', async () => {
+ mockChat.mockResolvedValue(undefined);
+
+ const { value: chat, dispose } = withRoot(() =>
+ useChat({ defaultModel: () => 'deepseek:deepseek-v4-pro' }),
+ );
+ await chat.sendMessage('hello');
+
+ expect(mockChat).toHaveBeenCalledOnce();
+ expect(mockChat.mock.calls[0][2]).toBe('deepseek:deepseek-v4-pro');
+ expect(chat.messages()[1]).toMatchObject({
+ role: 'assistant',
+ model: 'deepseek:deepseek-v4-pro',
+ });
+ dispose();
+ });
+
it('reuses existing session', async () => {
mockChat.mockResolvedValue(undefined);
diff --git a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
index 45db40c336..e79fd25c47 100644
--- a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
+++ b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts
@@ -34,6 +34,7 @@ type AssistantInterruption = NonNullable<ChatMessage['interruption']>;
export interface UseChatOptions {
sessionId?: string;
model?: string;
+ defaultModel?: () => string;
onConversationChanged?: () => void | Promise<void>;
}
@@ -63,6 +64,12 @@ export function useChat(options: UseChatOptions = {}) {
const [model, setModel] = createSignal(options.model || '');
const [queuedFollowUps, setQueuedFollowUps] = createSignal<QueuedFollowUp[]>([]);
+ const effectiveModelRoute = () => {
+ const selected = model().trim();
+ if (selected) return selected;
+ return options.defaultModel?.().trim() || '';
+ };
+
const notifyConversationChanged = async () => {
if (!options.onConversationChanged) return;
try {
@@ -836,11 +843,13 @@ export function useChat(options: UseChatOptions = {}) {
};
const assistantId = generateId();
+ const requestModel = effectiveModelRoute();
const streamingMessage: ChatMessage = {
id: assistantId,
role: 'assistant',
content: '',
timestamp: new Date(),
+ model: requestModel || undefined,
isStreaming: true,
pendingTools: [],
toolCalls: [],
@@ -872,7 +881,7 @@ export function useChat(options: UseChatOptions = {}) {
await AIChatAPI.chat(
trimmedPrompt,
currentSessionId || undefined,
- model() || undefined,
+ requestModel || undefined,
(event: StreamEvent) => {
processEvent(assistantId, requestId, event);
},
diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsx
index 8cf6181906..9fc6831bef 100644
--- a/frontend-modern/src/components/AI/Chat/index.tsx
+++ b/frontend-modern/src/components/AI/Chat/index.tsx
@@ -668,6 +668,7 @@ export const AIChat: Component<AIChatProps> = (props) => {
// Chat hook
const chat = useChat({
model: initialModelSelections[DEFAULT_SESSION_KEY] || '',
+ defaultModel: () => defaultModel().trim(),
onConversationChanged: refreshSessions,
});
@@ -728,6 +729,13 @@ export const AIChat: Component<AIChatProps> = (props) => {
return match?.provider?.trim() || getProviderFromModelId(model);
});
+ const formatChatMessageModelRoute = (modelId: string) => {
+ const normalized = modelId.trim();
+ if (!normalized) return '';
+ const match = aiRuntimeModels().find((candidate) => candidate.id === normalized);
+ return match ? formatAIModelRouteLabel(match) : formatAIModelRouteLabel(normalized);
+ };
+
const providerForModelRoute = (modelId: string) => {
const normalized = modelId.trim();
if (!normalized) return '';
@@ -2169,6 +2177,7 @@ export const AIChat: Component<AIChatProps> = (props) => {
onSkipQuestion={handleSkipQuestion}
onRetry={(messageId) => chat.retryMessage(messageId)}
onChangeModel={openModelSelectorFromError}
+ getModelRouteLabel={formatChatMessageModelRoute}
getModelRouteAlternative={getFailedTurnModelRouteAlternative}
onUseModelRoute={switchToModelRoute}
recentSessions={sessions()