Fix chat view hanging on messages with overlapping marks (#2280)#2309
Open
caddydove wants to merge 2 commits into
Open
Fix chat view hanging on messages with overlapping marks (#2280)#2309caddydove wants to merge 2 commits into
caddydove wants to merge 2 commits into
Conversation
Replace require('linux-distro') with dynamic import() to resolve
TypeError: execa is not a function on Linux. linux-distro v4 is a
CJS module that internally requires execa, but execa v6+ is ESM-only.
require() cannot load ESM modules from CJS context, crashing the app
at the login screen. Dynamic import() handles CJS→ESM interop and
resolves the module correctly.
Fixes anyproto#2236
… checkRanges checkRanges merges adjacent/overlapping marks of the same type and param. However, the comparison (prev.param == mark.param) failed when one mark had param: undefined and the other had param: '' — they were treated as different and left unmerged. This caused the chat view to hang when rendering messages with such marks (e.g. from MCP agents). Fix: normalize the comparison with (prev.param || '') == (mark.param || '') so undefined and empty string are treated equivalently, ensuring touching/overlapping same-type marks are always merged. Fixes anyproto#2280
Contributor
Author
|
Hi @requilence, this PR fixes #2280 — chat view hanging on messages with overlapping marks. The fix normalizes the param comparison in checkRanges so undefined and empty string are treated as equivalent, ensuring same-type marks always merge. Would appreciate a review when you have time. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #2280 — the chat view hangs when a message contains marks with touching/overlapping ranges (e.g. generated by MCP agents).
Root Cause
checkRangesinmark.tsmerges adjacent marks of the same type and param to produce clean HTML. The merge condition used strict equality (prev.param == mark.param), which failed when one mark hadparam: undefined(omitted) and the other hadparam: ''(empty string). These marks were left unmerged, creating two separate tags wrapping adjacent ranges — which caused the chat view to hang during rendering.Fix
Changed the param comparison in the merge condition to:
This normalizes both
undefinedand''to empty string, ensuring touching/overlapping same-type marks always merge correctly regardless of how the param was stored.Test
Added a test case that verifies two adjacent italic marks (one with
param: undefined, one withparam: '') are merged into a single mark.Verification
mark.test.tstests pass