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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Clarify Assistant interruption state
rcourtman890b1d35ec03
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 78e7886cc8..29a4cf85db 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -78,6 +78,12 @@ runtime cost control, and shared AI transport surfaces.surface the result as actionable retry/settings status plus same-modelconfigured-provider alternatives without converting it intoassistant-authored output or disabling model-owned chat by default.+ Operator interruption is likewise chat-runtime state: Stop and replacement+ sends must abort the active stream, clear pending tool/approval/question+ affordances, preserve any partial model text, return focus to the composer,+ and render a neutral transcript marker rather than persisting synthetic+ assistant answer text or surfacing the interruption as a retryable provider+ failure.4. Add or change Patrol, alert-analysis, or remediation transport through `internal/api/ai_handlers.go`, `internal/api/ai_intelligence_handlers.go`, and `frontend-modern/src/api/patrol.ts`Provider preflight diagnostics returned from `internal/api/ai_handlers.go`must reuse the Patrol runtime failure classifier in `internal/ai/` anddiff --git a/frontend-modern/src/components/AI/Chat/MessageItem.tsx b/frontend-modern/src/components/AI/Chat/MessageItem.tsxindex d9d918f147..a2c182d388 100644--- a/frontend-modern/src/components/AI/Chat/MessageItem.tsx+++ b/frontend-modern/src/components/AI/Chat/MessageItem.tsx@@ -73,6 +73,16 @@ export const MessageItem: Component<MessageItemProps> = (props) => {!props.message.content.trim() &&!hasStreamEvents() &&!props.message.error;+ const interruptionLabel = createMemo(() => {+ switch (props.message.interruption) {+ case 'replaced':+ return 'Stopped when you sent the next message';+ case 'stopped':+ return 'Stopped';+ default:+ return '';+ }+ });// Copy-to-clipboard for a completed assistant answer.const [copied, setCopied] = createSignal(false);@@ -218,6 +228,15 @@ export const MessageItem: Component<MessageItemProps> = (props) => {/></Show>+ <Show when={interruptionLabel()}>+ <div+ class="mt-2 inline-flex items-center gap-1.5 rounded-md border border-border-subtle bg-surface-alt px-2 py-1 text-[11px] font-medium text-muted"+ role="status"+ >+ <span>{interruptionLabel()}</span>+ </div>+ </Show>+{/* Error block - distinct, recoverable */}<Show when={props.message.error}><divdiff --git a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsxindex 25acff5ff9..92f8cf6978 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx@@ -920,6 +920,16 @@ describe('AIChat', () => {expect(mockChat.stop).toHaveBeenCalledTimes(1);});+ it('returns focus to the composer after stopping a response', async () => {+ mockChat.isLoading.mockReturnValue(true);+ renderChat();+ const textarea = screen.getByPlaceholderText('Ask about your infrastructure...');++ fireEvent.click(screen.getByTitle('Stop'));++ await waitFor(() => expect(document.activeElement).toBe(textarea));+ });+it('submits via form submit button click', () => {renderChat();const textarea = screen.getByPlaceholderText('Ask about your infrastructure...');@@ -928,6 +938,16 @@ describe('AIChat', () => {fireEvent.click(submitBtn);expect(mockChat.sendMessage).toHaveBeenCalledWith('test query', undefined, undefined);});++ it('returns focus to the composer after submit button click', async () => {+ renderChat();+ const textarea = screen.getByPlaceholderText('Ask about your infrastructure...');+ fireEvent.input(textarea, { target: { value: 'test query' } });++ fireEvent.click(screen.getByTitle('Send'));++ await waitFor(() => expect(document.activeElement).toBe(textarea));+ });});// ── Control level ────────────────────────────────────────────────────diff --git a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsxindex 40051592a4..b72407ab47 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx+++ b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx@@ -175,6 +175,62 @@ describe('MessageItem', () => {});});+ describe('interruption marker', () => {+ it('renders a neutral stopped marker without treating it as answer content', () => {+ render(() => (+ <MessageItem+ message={makeMessage({+ role: 'assistant',+ content: '',+ interruption: 'stopped',+ isStreaming: false,+ })}+ {...makeHandlers()}+ />+ ));++ const marker = screen.getByRole('status');+ expect(marker).toHaveTextContent('Stopped');+ expect(screen.queryByRole('alert')).not.toBeInTheDocument();+ expect(screen.queryByRole('button', { name: /copy message/i })).not.toBeInTheDocument();+ });++ it('renders a replacement marker when a new user message interrupts the old turn', () => {+ render(() => (+ <MessageItem+ message={makeMessage({+ role: 'assistant',+ content: '',+ interruption: 'replaced',+ isStreaming: false,+ })}+ {...makeHandlers()}+ />+ ));++ expect(screen.getByRole('status')).toHaveTextContent(+ 'Stopped when you sent the next message',+ );+ });++ it('keeps partial content visible before the stopped marker', () => {+ render(() => (+ <MessageItem+ message={makeMessage({+ role: 'assistant',+ content: 'Partial answer',+ interruption: 'stopped',+ isStreaming: false,+ })}+ {...makeHandlers()}+ />+ ));++ expect(screen.getByText('Partial answer')).toBeInTheDocument();+ expect(screen.getByRole('status')).toHaveTextContent('Stopped');+ });+ });+describe('copy button', () => {it('copies the message content when clicked', () => {const writeText = vi.fn().mockResolvedValue(undefined);diff --git a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.tsindex b353974c1b..2b7e69d8b3 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts+++ b/frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts@@ -401,6 +401,8 @@ describe('useChat', () => {const msgs = chat.messages();const firstAssistant = msgs.find((m) => m.role === 'assistant');expect(firstAssistant?.isStreaming).toBe(false);+ expect(firstAssistant?.interruption).toBe('replaced');+ expect(firstAssistant?.content).toBe('');dispose();});@@ -485,7 +487,8 @@ describe('useChat', () => {expect(chat.isLoading()).toBe(false);const assistant = chat.messages().find((message) => message.role === 'assistant');expect(assistant).toMatchObject({- content: '(Stopped)',+ content: '',+ interruption: 'stopped',isStreaming: false,});dispose();@@ -1111,7 +1114,8 @@ describe('useChat', () => {expect(chat.isLoading()).toBe(false);const assistant = chat.messages().find((m) => m.role === 'assistant');expect(assistant?.isStreaming).toBe(false);- expect(assistant?.content).toBe('(Stopped)');+ expect(assistant?.content).toBe('');+ expect(assistant?.interruption).toBe('stopped');dispose();});@@ -1134,6 +1138,7 @@ describe('useChat', () => {const assistant = chat.messages().find((m) => m.role === 'assistant');expect(assistant?.content).toBe('partial response');+ expect(assistant?.interruption).toBe('stopped');dispose();});});diff --git a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts b/frontend-modern/src/components/AI/Chat/hooks/useChat.tsindex 3898bad3c9..4ba7844702 100644--- a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts+++ b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts@@ -21,6 +21,7 @@ import type {} from '../types';const generateId = () => Math.random().toString(36).substring(2, 9);+type AssistantInterruption = NonNullable<ChatMessage['interruption']>;export interface UseChatOptions {sessionId?: string;@@ -75,7 +76,7 @@ export function useChat(options: UseChatOptions = {}) {return promise;};- const cancelActiveRequest = (markStopped: boolean): Promise<void> | null => {+ const cancelActiveRequest = (interruption?: AssistantInterruption): Promise<void> | null => {const hasActiveRequest = isLoading() || abortControllerRef !== null;if (!hasActiveRequest) return null;@@ -92,8 +93,11 @@ export function useChat(options: UseChatOptions = {}) {? {...msg,isStreaming: false,- content: markStopped ? msg.content || '(Stopped)' : msg.content,+ interruption,pendingTools: [],+ pendingApprovals: [],+ pendingQuestions: [],+ workflowStatus: undefined,}: msg,),@@ -105,12 +109,12 @@ export function useChat(options: UseChatOptions = {}) {// Cleanup on unmountonCleanup(() => {- void cancelActiveRequest(false);+ void cancelActiveRequest();});// Stop/cancel current requestconst stop = () => {- void cancelActiveRequest(true);+ void cancelActiveRequest('stopped');};// Helper to add stream event for chronological display@@ -565,7 +569,7 @@ export function useChat(options: UseChatOptions = {}) {// run after it registers.if (isLoading()) {logger.debug('[useChat] Aborting current stream to send new message');- backendAbortBeforeNextSend = cancelActiveRequest(false);+ backendAbortBeforeNextSend = cancelActiveRequest('replaced');}// Echo the user's message before any network work. Cold sessions can spend@@ -667,14 +671,14 @@ export function useChat(options: UseChatOptions = {}) {// Clear messages and reset session (for starting fresh)const clearMessages = () => {- void cancelActiveRequest(false);+ void cancelActiveRequest();setMessages([]);setSessionId(''); // Clear session so next message creates a new one};// Load session messagesconst loadSession = async (id: string): Promise<boolean> => {- void cancelActiveRequest(false);+ void cancelActiveRequest();try {const msgs = await AIChatAPI.getMessages(id);setMessages(@@ -698,7 +702,7 @@ export function useChat(options: UseChatOptions = {}) {// Start a blank conversation. The durable backend session is created by the// next chat stream so the UI does not create empty server-side sessions.const newSession = async (): Promise<boolean> => {- void cancelActiveRequest(false);+ void cancelActiveRequest();setSessionId('');setMessages([]);return true;diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsxindex b8579831d3..52dac282d4 100644--- a/frontend-modern/src/components/AI/Chat/index.tsx+++ b/frontend-modern/src/components/AI/Chat/index.tsx@@ -1212,6 +1212,7 @@ export const AIChat: Component<AIChatProps> = (props) => {setInput('');setAccumulatedMentions([]);setMentionActive(false);+ focusComposer();};// Handle input change with @ mention detection@@ -2006,7 +2007,10 @@ export const AIChat: Component<AIChatProps> = (props) => {<Show when={chat.isLoading()}><buttontype="button"- onClick={chat.stop}+ onClick={() => {+ chat.stop();+ focusComposer();+ }}class="flex h-9 w-9 items-center justify-center rounded-md border border-border bg-surface text-base-content shadow-sm transition-colors hover:bg-surface-hover"title="Stop"aria-label="Stop response"diff --git a/frontend-modern/src/components/AI/Chat/types.ts b/frontend-modern/src/components/AI/Chat/types.tsindex 5192dc8fdb..4e3451bd16 100644--- a/frontend-modern/src/components/AI/Chat/types.ts+++ b/frontend-modern/src/components/AI/Chat/types.ts@@ -113,6 +113,7 @@ export interface ChatMessage {id: string;role: 'user' | 'assistant';content: string;+ interruption?: 'stopped' | 'replaced';// Clean, user-facing error for a failed turn. Rendered as a distinct error// block (not as answer content) so partial streamed content is preserved and// the failure is unmistakable and recoverable.