You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Chat: memoise item views so a streamed text delta re-renders only the last item #924
A long chat stays responsive while an answer streams: each text delta re-renders only the item it changes, not every earlier item with its Markdown.
Context
On develop the frontend uses no React.memo at all. ChatPanel.tsx (:676–684) copies the whole items array on every chat-text-delta, and items.map (:1476) renders every ChatItemView, including react-markdown for each assistant message. After the chat panel series (#832–#847) the item views live in src/components/chat/ and the transcript reducer keeps the object identity of unchanged items.
Memoising was not safe before: DocumentCard reads the document-action registry with listDocumentActions() during render, and extension contributions registered later only appeared because the whole chat re-rendered. The reactive registry (#884) removes that dependency.
Requirements
ChatItemView (and AssistantMessageView/DocumentCard if they are rendered separately) is wrapped in React.memo; the props passed from the panel are stable for unchanged items (callbacks via useCallback or a stable dispatch, no inline objects).
DocumentCard reads document actions through the reactive registry (useSyncExternalStore subscription), so a document action registered or removed after the card was rendered still appears or disappears.
No visible behaviour change.
Acceptance Criteria
Test with the React Profiler (or a render counter in a test-only wrapper): a chat with 200 items receives 10 text deltas; only the last item re-renders per delta.
Test: a document action registered after a document card is shown appears on that card without any other state change; removing it makes it disappear.
Existing ChatPanel*.test.tsx and src/components/chat/* tests pass; their count does not decrease.
npm run lint, npx vitest run, npm run build and npm run test:e2e pass.
Technical Notes
Frontend only; no filter, risk, redaction or credential logic. The confirmation card of a proposed action must re-render when its decision or risk assessment changes (covered by existing tests).
Activity
21 remaining items