Repository navigation
fix(native-chat): wrap long URLs in item comment bubbles instead of widening the chat - #47998
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
…idening the chat
An item comment's text was a whitespace-pre-wrap div with the default
overflow-wrap, so a long unbroken token (URL, path) set its min-content
width: the text ran past the bubble and the transcript scrolled sideways.
Add overflow-wrap:anywhere, as markdown links and other native chat rows
already use.
Wrapping makes Chromium reshape a kerned run with no break opportunity at
every wrap point, quadratic in its length ('q' x 30000: ~970 ms per
layout vs 1.1 ms on main). Reuse the unkerned-run helper user prompts and
queued messages use (stablyai#36031), memoized per text; that comment now lays
out in ~1.5 ms.
Fixes stablyai#47995
Co-authored-by: Taekhun Nam <[email protected]>
54dbc19 to
a5dcd5a
Compare
ELI5
When you reply on a bot item, the reply shows up in the bot chat as your message bubble with the item's name on top. If the reply had a very long link with no spaces, the chat kept the whole link on one line, so it ran past the bubble and the chat got a sideways scrollbar. Now the link wraps onto several lines inside the bubble, the way it already does in a normal message, and even a huge unbroken reply stays fast to draw.
What Changed
CommentRowinNativeChatBotItemNoteRow.tsx) never broke inside a long token. A long URL ran past the bubble's right edge and the transcript scrolled sideways (848px of horizontal overflow at a 420px pane, 928px at 320px).whitespace-pre-wrapwith the defaultoverflow-wrap: normal, so an unbroken token set its min-content width, which passed up through the transcript's flex ancestors. It now has[overflow-wrap:anywhere], the same utility markdown links,NativeChatEventRowbodies and background task summaries (fix(native-chat): wrap long background task summaries instead of widening the chat #47359) use.nativeChatTextHasUnkernedRun/NATIVE_CHAT_UNKERNED_CSS), memoized per text, the same way user prompts and queued messages already do. Only text that contains such a run getsfont-kerning: none.Why
This fixes the element that causes the overflow and nothing else.
break-wordswould not work, becauseoverflow-wrap: break-worddoes not lower min-content.overflow-x: hiddenon the scroller would hide the scrollbar but clip the text, and addingmin-w-0up the ancestor chain would touch many components to fix one leaf. Reusing the existing unkerned-run helper keeps the wrap from turning a pathological comment into a long layout stall.Linked Issue
Fixes #47995
Visual Proof
Headless component fixture (
pnpm fixtures:shot) rendering owner item comments: short, sentence, URL with text, long item title + URL, multi-line with indent. The top bar reports the transcript scroller's horizontal overflow.320px, dark
420px, light
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Reproduced on
origin/mainwith a scratch fixture (not committed) and compared with this branch: long URL comment overflowX 928px / 848px (320px / 420px pane) on main, 0px on this branch.'q' x 6000and'q' x 30000comments also 0px.All 14 existing
NativeChatBotItemNoteRowfixture shots (7 fixtures, dark and light) are byte-identical (cmp) before and after.No unit test: the change is one class plus one inline style on a text div, and the test guidance says not to assert CSS. The fixture measurements are the evidence.
oxlint,
oxfmt --check, anti-slop, code-quality native plugins, ast-grep, and the changed-code quality gate: clean.macOS, headless fixture renderer. Renderer CSS only; platform, SSH and remote setups are not involved.
Performance
Renderer transcript row layout only; no new I/O, IPC, polling or subprocesses. Headless fixture, one owner comment at 420px, median of 9 forced layouts (remount / resize):
'q' x 6000'q' x 30000Main's resize is ~0 because unwrapped text overflows instead of reflowing; it pays with a horizontal scrollbar. The helper is a linear scan memoized per comment text: 0.6 us typical, 0.12 ms for 30 KB.
Risk
Level: Low
Only the item comment text in bot chats changes. The riskiest part is text that previously overflowed now wrapping, which makes those rows taller; the transcript measures real row heights, so virtualization is unaffected. Comments with a long unbroken run render without kerning (barely visible, same as user prompts). Back out with a plain revert.
Review
Agent skill upstream boundary
Notes
Original fix by @tech-hoon in #47998 (the
overflow-wrapchange); a maintainer added the unkerned-run perf fix on top. Authorship is kept viaCo-authored-by.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)