mirror of
https://github.com/nesquena/hermes-webui.git
synced 2026-07-20 14:40:35 +00:00
ef33ad44f2
A message whose text contained a lone UTF-16 surrogate (e.g. a truncated emoji from a partial paste/stream) made encodeURIComponent throw URIError inside _messageViewportAnchorKeyForMessage, crashing the viewport-anchor computation and breaking scroll-anchor restore for the whole transcript. New _safeEncodeURIComponent catches the URIError and rebuilds the string via a UTF-16 code-unit walk that keeps valid high+low surrogate PAIRS intact (emoji survive) and drops only LONE surrogates. Uses no regex lookbehind/lookahead so it parses on every browser engine (older WebViews / Safari <16.4 lack lookbehind and would brick ui.js at parse time). Contributor stage; gate-pass. Co-authored-by: rumotoshino <rumotoshino@users.noreply.github.com>