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
Stop the Assistant transcript re-mounting on every stream event
rcourtman7f3a0e3dd99b
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex fee531439a..9528193c1d 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -2289,6 +2289,20 @@ constructed at service start, so anything that must stay fresh per turncarries no PII and is therefore safe on cloud-routed turns regardless of theoperational-context sharing opt-in.+The streaming transcript list reconciles messages by `id` rather than rendering+the raw message array by reference. `useChat` rebuilds its message array+immutably on every stream event (each content chunk, workflow-status change, and+tool update spreads a brand-new message object), so a reference-keyed `<For>`+would tear down and recreate the whole `MessageItem` on every event — the+visible flashing, rows popping in and out, and transcript jumping up and down+during a turn. `ChatMessages` (`frontend-modern/src/components/AI/Chat/ChatMessages.tsx`)+reconciles the incoming array into a keyed `solid-js/store` mirror so each+message keeps a stable identity across updates; `MessageItem` already reads every+field through accessors, so only the genuinely changed text/rows update in place.+This keeps the live transcript stable the way OpenCode's timeline is. (Residual+in-place churn remains in the per-message stream-event/tool-row list, which is a+separate, narrower follow-up.)+Assistant slash-command availability is part of the command runtime contract,not only visual polish. The OpenCode reference at fetched `origin/dev` commit`c495635` filters prompt slash commands through the registered command catalogdiff --git a/frontend-modern/src/components/AI/Chat/ChatMessages.tsx b/frontend-modern/src/components/AI/Chat/ChatMessages.tsxindex a18f79e007..90a78d7808 100644--- a/frontend-modern/src/components/AI/Chat/ChatMessages.tsx+++ b/frontend-modern/src/components/AI/Chat/ChatMessages.tsx@@ -1,4 +1,5 @@import { Component, Show, For, createEffect, createMemo, createSignal } from 'solid-js';+import { createStore, reconcile } from 'solid-js/store';import ArrowDownIcon from 'lucide-solid/icons/arrow-down';import { MessageItem } from './MessageItem';import type { ChatSession } from '@/api/aiChat';@@ -52,6 +53,23 @@ export const ChatMessages: Component<ChatMessagesProps> = (props) => {let containerRef: HTMLDivElement | undefined;const [isPinnedToBottom, setIsPinnedToBottom] = createSignal(true);+ // useChat hands us a fresh, immutably-rebuilt message array on every stream+ // event (each content chunk, workflow-status change, tool update spreads a new+ // message object). Rendering that array directly through <For>, which keys by+ // object reference, tears down and recreates the whole MessageItem on every+ // event — the visible flashing / rows popping in and out and the transcript+ // jumping up and down during a turn.+ //+ // Reconcile the incoming array into a keyed store mirror so each message keeps+ // a stable identity across updates (matched by id). MessageItem already reads+ // every field through `() => props.message.x` accessors, so once it stops+ // re-mounting, only the genuinely changed text/rows update in place. This keeps+ // the streaming transcript stable the way OpenCode's timeline is.+ const [mirroredMessages, setMirroredMessages] = createStore<ChatMessage[]>([]);+ createEffect(() => {+ setMirroredMessages(reconcile(props.messages, { key: 'id', merge: false }));+ });+const isContainerNearBottom = () => {if (!containerRef) return true;const { scrollTop, scrollHeight, clientHeight } = containerRef;@@ -254,7 +272,7 @@ export const ChatMessages: Component<ChatMessagesProps> = (props) => {</Show>{/* Messages */}- <For each={props.messages}>+ <For each={mirroredMessages}>{(message) => {const queuedMeta = createMemo(() => queuedFollowUpMetaByMessageId().get(message.id));return (diff --git a/frontend-modern/src/components/AI/Chat/__tests__/ChatMessages.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/ChatMessages.test.tsxindex 64a5d84975..1f77ace0ba 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/ChatMessages.test.tsx+++ b/frontend-modern/src/components/AI/Chat/__tests__/ChatMessages.test.tsx@@ -708,4 +708,36 @@ describe('ChatMessages', () => {expect(scrollContainer).toHaveAttribute('data-testid', 'assistant-message-list');});});++ describe('streaming stability', () => {+ // useChat hands ChatMessages a freshly-rebuilt array on every stream event,+ // with a brand-new message object (same id) each time. The list must+ // reconcile by id so a streaming message keeps its DOM node instead of being+ // torn down and recreated on every tick — that re-mount churn is the visible+ // flashing / rows popping in and out this guards against.+ it('keeps a streaming message mounted in place across rebuilt arrays', () => {+ const [msgs, setMsgs] = createSignal<ChatMessage[]>([+ makeMessage({ id: 'm1', role: 'assistant', content: 'Hel', isStreaming: true }),+ ]);+ render(() => <ChatMessages messages={msgs()} {...makeHandlers()} />);++ const nodeBefore = screen.getByTestId('message-item-m1');+ expect(nodeBefore).toHaveTextContent('Hel');+ const instancesForM1 = () =>+ capturedMessageItemProps.filter((p) => p.message.id === 'm1').length;+ expect(instancesForM1()).toBe(1);++ // Next stream tick: a brand-new message object, same id, more content.+ setMsgs([+ makeMessage({ id: 'm1', role: 'assistant', content: 'Hello world', isStreaming: true }),+ ]);++ const nodeAfter = screen.getByTestId('message-item-m1');+ // Same DOM element instance: reconciled in place, not recreated.+ expect(nodeAfter).toBe(nodeBefore);+ expect(nodeAfter).toHaveTextContent('Hello world');+ // MessageItem was instantiated exactly once for this id across both renders.+ expect(instancesForM1()).toBe(1);+ });+ });});