Repository navigation
fix(native-chat): keep item chips whole in agent message rows - #51563
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
"Started <worker> for <items>" rows clipped item chips flat when the names span ran out of room, leaving half a pill, a lone status icon or a sliver of the next chip. The item chips now sit in their own one-line, clipped, wrapping span, so a chip that cannot fit at its readable 6rem floor wraps out of view whole instead of being cut. The span becomes a scroll box while focused, so Tab still reaches every hidden chip. Rows narrower than 400px let the chips wrap under the name, with the icon and chevron kept centered on the first line. A four-item fixture row covers the worst case. Long localized "for" words, a host badge or a +N sender can still clip a chip at row widths of about 400-450px, so this is a partial fix. Refs stablyai#51205 Co-authored-by: Neil <[email protected]>
e54c521 to
3339e4f
Compare
ELI5
In a chat, the one-line "Started for " rows used to slice item chips in half when the row ran out of room. You'd see half a pill, a lone status icon, or a thin sliver of the next chip. Now each chip is either shown whole, at a readable size with "…" inside its rounded pill, or not shown on that line at all.
What Changed
Before: the names span (sender name, "for", then the item chips) caps its width and clips sideways with
overflow-x-clip. Once the chips' minimum widths add up to more than that cap, the clip cuts straight through a chip. In the fixture, the first chip is cut after its icon at 300px, the second chip is cut after its icon at 400px, and a sliver of the second chip shows at 480px.After:
NATIVE_CHAT_READABLE_MIN). A chip that can't fit at that floor drops off the line whole. It is never sliced.Mechanism:
NativeChatAgentMessageCard.tsx: the chips now sit in their owndata-agent-start-itemsspan. That span wraps (flex-wrap) but is only one line tall and clipped (max-h-5 overflow-clip), so a chip that doesn't fit wraps onto the hidden second line as a whole.focus-within:overflow-hiddenturns the span into a scroll box while it has focus, so a focused hidden chip scrolls into view. Chip focus rings are drawn inset so the clip doesn't cut them.NativeChatAgentMessageRow.tsx: under@max-[400px]/agent-row, and only when the row has item chips (:has([data-agent-start-items])), the names span may wrap and the row aligns to the top. The icon span and the end span getmin-h-lh items-center, which keeps them centered on the first line. In normal one-line rows this changes nothing.Why
Cutting a chip in half is the bug in #51205. With one line, a fixed name floor and a varying number of chips, CSS has two clean outcomes for a chip that doesn't fit: shrink it below a readable size, or move it out of view whole. Shrinking later chips to an icon-and-ellipsis stub was tried during review and dropped, because it reads worse than leaving the chip out. Everything here is CSS (no JS measuring, no ResizeObserver), so the row can't jitter and there's no per-update cost.
This is a partial fix. With longer localized "for" words (fr "pour", es/pt "para", ru, ja, ko, zh), a host badge or a
+Nsender, a chip can still be clipped in rows about 400-450px wide. That needs the floors and width cap redesigned, which is a follow-up. A "+N more" count for hidden chips is also out of scope. It needs JS to measure which chips wrapped.Linked Issue
Refs #51205
Visual Proof
Fixture
NativeChatAgentMessagePreviewRow, dark theme. Main is on the left, this PR on the right. The PR side has one more Started row, the new four-item fixture row.Narrow (300px). On main, the first chip is cut right after its icon. With this PR the chip moves under the name and shows whole:
Panel (400px). On main, the second chip is cut after its icon. With this PR it drops out whole:
Medium (480px). On main, a sliver of the second chip shows. With this PR it is gone:
Testing
Reproduced on main with the component fixture (
pnpm fixtures:shot native-chat/messages/rows/NativeChatAgentMessagePreviewRow --theme both, headless Chromium): 300px cuts the first chip and 400px cuts the second.Width sweep: a script swept frame widths 260-900px in 1px steps on macOS (local and the m4air test Mac) and measured each chip's visible fraction through its clipping ancestors.
+N, the only remaining cuts are in the known 464-570px frame band described under Why.Localized "for" words (pour, para, için, 対象:, für, для, 대상, 处理, 負責): für and için have no cut widths. The rest are cut only in the 464-50x frame band, which is the partial case above.
Keyboard: at 300, 466 and 560px, Tab reaches all four chips in the four-item row. Each focused chip is 100% visible, and scroll resets to 0 when focus leaves the row by Tab or by clicking outside.
Alignment: across 3372 row samples, the offsets between icon or chevron and the kind text match main (+0.38px).
Static checks:
oxlint,oxfmt --check, the anti-slop and native-plugin oxlint configs,ast-grep scanandcheck-changed-code-qualityall pass on the 3 changed files. vitestNativeChatBotItemNoteRow.test.tsx(ItemChip) passes.Platforms: tested on macOS only. The change is plain CSS with no platform-specific code.
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
No unit tests: the change is layout-only CSS, so the fixture row covers it instead.
Performance
Code paths: only class strings change, in the renderer. There is no JS, store, selector, memo, observer, IPC or main-process change.
cn()call per item-chip card render becomes a template literal.Layout cost, measured with 212 agent rows mounted, 164 of them with items:
Risk
Level: Low
:has()andcalc-size(), which this row and the renderer already use.Original fix by @season179. Maintainer review follow-ups are squashed into this single commit, with Season Saw as author.
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)