Skip to content

fix(core): ChatToolCalls truncates its target inside a ChatMessage - #12424

Merged
josephfarina merged 2 commits into
mainfrom
josephfarina/rl-37-toolcall-truncate
Nov 18, 2026
Merged

josephfarina merged 2 commits into
mainfrom
josephfarina/rl-37-toolcall-truncate

Conversation

@josephfarina

Copy link
Copy Markdown
Contributor

User impact

A single ChatToolCalls row inside a ChatMessage runs past the message column on a phone when its target is long (for example a file path). At 375 px the path is cut by the screen edge with no ellipsis and no way to scroll; at 390 px it runs into the column's padding. The ai-chat template shows it on its running "edit" call.

Problem and solution fit

  • Why does the row overflow? The message's children column aligns its children to the start, so the ChatToolCalls root is sized to fit its content. Its row's min-content width is the full, unwrapped target, so the root grows past the column.
  • Why does that hurt? The target label already truncates (min-width: 0, text-overflow: ellipsis), but it only shrinks when its row is narrower than its content. A root that grows to the content never gives it that chance, so the text is clipped by the viewport, not ellipsized.
  • Why does it matter? Readers lose the end of the path and the page can shift sideways on touch screens.

Capping the root at max-width: 100% lets the row shrink to the column, so the existing truncation takes over. No other style changes.

Expected behavior and authority

component:ChatToolCalls, Representative states, "Narrow / RTL context": rows truncate without horizontal overflow.

Smallest restoration

One declaration on the root: maxWidth: '100%'. The Narrow story now also renders the same call inside a ChatMessage and keeps its existing play assertion (no horizontal overflow at 320 CSS px).

Evidence

  • Reproduction before the change: ai-chat template at 375 px and 390 px, light and dark, in a Vite app and in a single-file export: the target is not ellipsized and ends past the message column (at 375 px it is cut by the screen edge).
  • Result after the change: the target ends at the column edge with an ellipsis at 375 px and 390 px, light and dark, in both.
  • Representative unchanged path: at 1280 px the target fits and renders in full, as before.
  • Regression test or other mutation-sensitive proof: the Narrow story's play function, with the new ChatMessage case, fails without the fix (container scrollWidth 520 vs clientWidth 320) and passes with it (320 vs 320), light and dark.

Scope

Components: ChatToolCalls

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • CI=1 vitest run --project ui packages/core/src/Chat (ChatToolCalls, ChatMessage and the rest of Chat pass), packages/core/src/theme/themingTargets.test.ts.
  • Real Chromium: ai-chat at 375, 390 and 1280 px, light and dark, Vite app and exported file, before and after; the Narrow story composition before and after.

@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 18, 2026 1:15am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 17, 2026
@astracat-bot

astracat-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 18, 2026, 1:27 AM UTC

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · aa24be3

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
ChatToolCalls 33.8 kB (+15 B) · 8.5 kB CSS (0) — ✓ · ✓ · —
ChatComposer 85.8 kB (0) · 12.9 kB CSS (0) — ✓ · ✓ · —
ChatComposerDrawer 18.2 kB (0) · 4.7 kB CSS (0) — ✓ · ✓ · —
14 more components
Component Size LoC Visual · A11y · RTL
ChatComposerInput 83.5 kB (0) · 12.1 kB CSS (0) — ✓ · ✓ · —
ChatComposerTokenElement 83.5 kB (0) · 12.1 kB CSS (0) — ✓ · ✓ · —
ChatDictationButton 66.8 kB (0) · 10.9 kB CSS (0) — ✓ · ✓ · —
ChatLayout 89.8 kB (0) · 11.4 kB CSS (0) — ✓ · ✓ · —
ChatLayoutScrollButton 66.8 kB (0) · 11.0 kB CSS (0) — ✓ · ✓ · —
ChatMessage 17.2 kB (0) · 3.7 kB CSS (0) — ✓ · ✓ · ✓
ChatMessageBubble 7.6 kB (0) · 3.7 kB CSS (0) — ✓ · ✓ · ✓
ChatMessageList 29.5 kB (0) · 7.1 kB CSS (0) — ✓ · ✓ · —
ChatMessageMetadata 20.5 kB (0) · 4.1 kB CSS (0) — ✓ · ✓ · —
ChatSendButton 66.6 kB (0) · 10.8 kB CSS (0) — ✓ · ✓ · —
ChatSystemMessage 7.1 kB (0) · 3.8 kB CSS (0) — ✓ · ✓ · —
ChatTokenizedText 7.6 kB (0) · 4.0 kB CSS (0) — ✓ · ✓ · —
chat — — — · ✓ · —
Chat — — ✓ · ✓ · —

Package size: @astryxdesign/core 7.65 MB packed (+125 B); no new dependencies.

Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this head yet because the pull request is a draft; it runs once the pull request is marked ready for review.

The root max-width: 100% cap restores the ChatToolCalls contract that rows truncate without horizontal overflow: the extended Narrow story fails without the fix (a 520 px scroll width in a 320 px container) and passes with it, and in the ai-chat template the running edit call's target now ends at the message column with an ellipsis at 375 and 390 px. One optional suggestion: shorten the new comment on the root and drop "to the start", since user and system messages align their children to the end and the centre (see the inline comment).

Claims and files checked

Review mode: full; reason: no-earlier-review

  • Changeset: inside a ChatMessage, a long target now truncates with an ellipsis on a narrow screen instead of running past the message column. Verified: the Narrow story fails on the base packages and passes on this head; the template target is flush and ellipsized at 375 and 390 px.
  • Description: a single row inside a message overflows the column on a phone, and the ai-chat template's running edit call shows it. Verified: page.tsx:771-788; on the base the target ends 70 px past the column at 375 px and 55 px past it at 390 px.
  • Description: at 375 px the target is cut by the screen edge; at 390 px it runs into the padding. Verified at 375 px (it ends 22 px past the viewport); at 390 px it ended 7 px past the viewport with this environment's fallback font, so the exact placement depends on the font.
  • Description: the message's children column aligns children to the start, so the root takes the row's min-content width, which is the whole target. Verified: ChatMessage.tsx:160-168, ChatToolCalls.tsx:257-267; on the base the in-message root is 504 px wide in a 288 px column.
  • Description: the target label already truncates (min-width: 0, text-overflow: ellipsis). Verified: ChatToolCalls.tsx:257-267.
  • Description: readers lose the end of the path and the page can shift sideways. Verified in part: on the base the target is not ellipsized and the overflow widens the message list's scrollable content; touch scrolling was not exercised.
  • Description: one declaration on the root and no other style changes. Verified: ChatToolCalls.tsx:110-113 is the only source change.
  • Description: the governing claim is the ChatToolCalls record's narrow-context state, rows truncate without horizontal overflow. Verified in the current component record.
  • Description: the Narrow story also renders the call inside a ChatMessage and keeps its no-overflow assertion at 320 CSS px. Verified: ChatToolCalls.stories.tsx:137-171.
  • Description: the play function fails without the fix (520 vs 320) and passes with it (320 vs 320), light and dark. Verified in Chromium against the base packages with this head's story, and against this head.
  • Description: at 1280 px the target fits and renders in full, as before. Verified: the before and after template frames are pixel-identical.
  • Description: the Chat unit tests and the theming-targets test pass. Verified: 27 files, 959 tests passed.
  • Description: one defect, no new public API, default or interaction model. Verified: the API report lists no added, changed or removed rows.
  • File .changeset/chat-tool-calls-message-truncate.md: clear.
  • File apps/storybook/stories/ChatToolCalls.stories.tsx: clear.
  • File packages/core/src/Chat/ChatToolCalls.tsx: one optional comment-style suggestion.

Automated review (maintainer link)

Comment on lines +110 to +112
// A message column aligns its children to the start, so the root sizes
// to its content and a long target never shrinks. The cap lets each row
// shrink to the column, so its target truncates.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: this comment packs three topics into its first sentence, and "aligns its children to the start" is true only for assistant messages; user messages align their children to the end and system messages to the centre, and the cap matters for all three. A shorter version that keeps only the reason:

// A parent that does not stretch this root sizes it to its content.
// The cap keeps the root in the parent, so a long target truncates.

@josephfarina
josephfarina marked this pull request as ready for review November 17, 2026 21:52

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI is still running on this head.

The root max-width: 100% cap restores the ChatToolCalls contract that rows truncate without horizontal overflow: the extended Narrow story fails without the fix (a 520 px scroll width in a 320 px container) and passes with it, and in the ai-chat template the running edit call's target now ends at the message column with an ellipsis at 375 and 390 px. The new changeset credit line follows the documented changeset format. The earlier optional suggestion to shorten the comment on the root still stands (see the open inline comment).

Claims and files checked

Review mode: incremental; reason: none

  • changed rules (0): none
  • Changeset: inside a ChatMessage, a long target now truncates with an ellipsis on a narrow screen instead of running past the message column. Verified: the Narrow story fails on the base packages and passes on this head; the template target is flush with the column and ellipsized at 375 and 390 px.
  • Description: a single row inside a message overflows the column on a phone, and the ai-chat template's running edit call shows it. Verified: page.tsx:771-788; on the base the target ends 70 px past the column at 375 px and 55 px past it at 390 px.
  • Description: at 375 px the target is cut by the screen edge with no ellipsis and no way to scroll; at 390 px it runs into the padding. Verified at 375 px (it ends 22 px past the screen, and the message list hides horizontal overflow, ChatLayout.tsx:139-140); at 390 px it ended 7 px past the screen with this environment's fallback font, so the exact placement depends on the font.
  • Description: the message's children column aligns its children to the start, so the root takes the row's min-content width, the whole target. Verified: ChatMessage.tsx:160-168, ChatToolCalls.tsx:257-267; on the base the in-message root is 504 px wide in a 288 px column.
  • Description: the target label already truncates (min-width: 0, text-overflow: ellipsis). Verified: ChatToolCalls.tsx:257-267.
  • Description: readers lose the end of the path and the page can shift sideways. Verified in part: on the base the list's content is 38 px wider than the list at 375 px, and scrolling the target into view shifts the list sideways by that much; touch scrolling was not exercised.
  • Description: one declaration on the root and no other style changes. Verified: ChatToolCalls.tsx:110-113 is the only package source change.
  • Description: the governing claim is the ChatToolCalls record's narrow-context state, rows truncate without horizontal overflow. Verified in the current component record.
  • Description: the Narrow story also renders the call inside a ChatMessage and keeps its no-overflow assertion at 320 CSS px. Verified: ChatToolCalls.stories.tsx:137-171.
  • Description: the play function fails without the fix (520 vs 320) and passes with it (320 vs 320), light and dark. Verified in Chromium against the base packages with this head's story, and against this head.
  • Description: at 1280 px the target fits and renders in full, as before. Verified: the before and after template frames are pixel-identical.
  • Description: the Chat unit tests and the theming-targets test pass. Verified: 27 files, 959 tests passed.
  • Description: one defect, with no new public API, default or interaction model. Verified: the API comparison lists no added, changed or removed rows.
  • Description: the public text carries no internal context. Verified for the added lines, title, description and commit messages.
  • File .changeset/chat-tool-calls-message-truncate.md: clear.
  • File apps/storybook/stories/ChatToolCalls.stories.tsx: clear.
  • File packages/core/src/Chat/ChatToolCalls.tsx: one optional comment-style suggestion, carried.

Automated review (maintainer link)

@josephfarina
josephfarina merged commit 23638a7 into main Nov 18, 2026
90 checks passed
@github-actions
github-actions Bot deleted the josephfarina/rl-37-toolcall-truncate branch November 18, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — aa24be3e Deployed Nov 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant