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>
|
||
|---|---|---|
| .. | ||
| audio-transform.spec.js | ||
| backend-logs.spec.js | ||
| chat-errors.spec.js | ||
| chat-polling-selection.spec.js | ||
| import-form-ux-batch-a.spec.js | ||
| import-form-ux-batch-b.spec.js | ||
| import-form-ux-batch-d.spec.js | ||
| import-form-ux-batch-e.spec.js | ||
| import-form-ux-batch-f.spec.js | ||
| manage-logs-link.spec.js | ||
| media-history.spec.js | ||
| model-config.spec.js | ||
| models-gallery.spec.js | ||
| navigation.spec.js | ||
| nodes-per-node-backend-actions.spec.js | ||
| settings-backend-logging.spec.js | ||
| traces-errors.spec.js | ||
| traces.spec.js | ||