LocalAI/core/http/react-ui
LocalAI [bot] 11d5bd0cc3
fix(react-ui/chat): stop wiping selection on every /api/operations poll (#9904) (#9917)
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>
2026-05-21 12:17:51 +02:00
..
e2e fix(react-ui/chat): stop wiping selection on every /api/operations poll (#9904) (#9917) 2026-05-21 12:17:51 +02:00
public/locales fix(react-ui/chat): stop wiping selection on every /api/operations poll (#9904) (#9917) 2026-05-21 12:17:51 +02:00
scripts feat(react-ui): add multilingual (i18n) support (#9642) 2026-05-02 22:42:08 +02:00
src fix(react-ui/chat): stop wiping selection on every /api/operations poll (#9904) (#9917) 2026-05-21 12:17:51 +02:00
bun.lock chore: Security hardening (#9719) 2026-05-08 16:25:45 +02:00
eslint.config.js feat(ui): move to React for frontend (#8772) 2026-03-05 21:47:12 +01:00
i18next-parser.config.js feat(react-ui): add multilingual (i18n) support (#9642) 2026-05-02 22:42:08 +02:00
index.html chore: Security hardening (#9719) 2026-05-08 16:25:45 +02:00
package-lock.json chore(deps): bump the npm_and_yarn group across 1 directory with 3 updates (#9728) 2026-05-12 09:54:38 +02:00
package.json chore: Security hardening (#9719) 2026-05-08 16:25:45 +02:00
playwright.config.js feat(ui, gallery): Show model backends and add searchable model/backend selector (#9060) 2026-03-18 21:14:41 +01:00
vite.config.js fix(ui): fix /app redirect 2026-03-05 21:43:46 +00:00