mirror of
https://github.com/vernu/textbee.git
synced 2026-07-30 17:07:46 -04:00
The effect depended on the whole session object. SessionProvider returns a new object on every refetch, and React compares deps by reference, so an identical session still ran the cleanup and the body again: the widget was destroyed and its script re-injected even though nothing about the user had changed, closing any chat the user had open. It now depends on the individual strings the effect actually reads, which compare by value, so it only re-initialises when the metadata genuinely changes. Two related leaks fixed at the same time: - cleanup called destroy() but left the script tag in the document, so every re-run added another one for the life of the page. It is now removed. - a script whose src is already cached can finish loading after cleanup ran, and initialising then left a widget behind that nothing would destroy. That late load is now ignored. Tests cover all four behaviours and fail against the previous version. Also gives the API guide page focus before the clipboard test: writeText rejects on an unfocused document, which is where a page sits while other workers run, and granting clipboard permissions does not cover it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>