mirror of
https://github.com/mudler/LocalAI
synced 2026-05-24 09:28:23 +00:00
useOperations() was calling setOperations() with a fresh array on every
1s poll, even when the payload was identical. In React 19 the DOM diff
no longer short-circuits dangerouslySetInnerHTML on equal __html, so the
forced Chat re-render re-assigned innerHTML on every assistant message
once per second — wiping any text the user had selected.
Skip the state update when the serialised operations payload is
unchanged, and switch loading/error to functional setters so they also
short-circuit at the source.
Also fixes the chat copy button on plain HTTP: navigator.clipboard is
undefined in non-secure contexts (a common LXC+Docker deployment), but
the previous code called it unconditionally and showed a success toast
regardless. Routed Chat, AgentChat and CanvasPanel through a new
copyToClipboard() helper that uses navigator.clipboard when available
and falls back to a hidden-textarea + execCommand('copy') trick that
browsers still honour outside secure contexts. The fallback preserves
the user's existing selection.
Regression coverage in e2e/chat-polling-selection.spec.js: a
MutationObserver counts mutations on the assistant content node across
3s of polling (must be 0); the copy test stubs out navigator.clipboard
and asserts that execCommand('copy') is invoked.
Assisted-by: claude-opus-4-7-1m
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
|
||
|---|---|---|
| .. | ||
| useAgentChat.js | ||
| useAudioPeaks.js | ||
| useAutocomplete.js | ||
| useChat.js | ||
| useCodeMirror.js | ||
| useConfigMetadata.js | ||
| useDebounce.js | ||
| useDistributedMode.js | ||
| useGalleryEnrichment.js | ||
| useMCPClient.js | ||
| useMediaCapture.js | ||
| useMediaHistory.js | ||
| useModels.js | ||
| useObjectUrl.js | ||
| useOperations.js | ||
| useResources.js | ||
| useUserMap.js | ||
| useVramEstimate.js | ||