Commit 53abaae
fix(ui): stop breaking words mid-word in chat messages (#2351)
### Summary
Chat message bodies are rendered with `break-all`, which lets a line
break
inside a word even when the whole word would have fit on the next line.
Ordinary prose comes out chopped — `ModelConfig` renders as `M /
odelConfig`,
`propagates` as `propaga / tes`.
`overflow-wrap: anywhere` keeps the behaviour `break-all` was added for
(long
tool-call ids and URLs still wrap instead of overflowing the column) but
only
breaks a word that genuinely cannot fit on a line of its own.
The difference is invisible in CJK text, where a line break is permitted
between almost any two characters — which is likely why it went
unnoticed.
### Before / after
Rendered from the `MessageWithUnbreakableTokens` story added in this PR,
at a
560px-wide column.
| | |
|---|---|
| **Before** (`break-all`) | `propaga` / `tes`, `componen` /
`ts/chat/...` |
| **After** (`overflow-wrap: anywhere`) | words intact; the URL breaks
after `github.com/kagent-`, the tool-call id still wraps |
<img width="560" height="340" alt="wb-before"
src="https://github.com/user-attachments/assets/890102ed-4a43-4734-98ff-b413a3d89a24"
/>
<img width="560" height="340" alt="wb-after"
src="https://github.com/user-attachments/assets/9125fbb8-dcf5-441b-bf3e-b13503d478b7"
/>
### Test plan
- [x] `npm run lint`
- [x] `npm run test` — 344 passed
- [x] `npm run test:vitest` — 34 files / 141 tests passed
- [x] New story `Chat/ChatMessage/MessageWithUnbreakableTokens` renders
prose
next to a long tool-call id and a long URL, so Chromatic catches a
regression here.
### Notes for reviewers
- Chromatic will report a visual diff on this story only. It is a new
story, so
there is no prior baseline to compare against.
- This does not address the separate problem where one over-wide element
in the
transcript widens the whole conversation column (see #2032). That is a
container-level issue and I will open it separately.
Signed-off-by: Golden Garlic <148346166+garlicKim21@users.noreply.github.com>
Co-authored-by: Peter Jausovec <peterj@users.noreply.github.com>1 parent a2eedd6 commit 53abaae
2 files changed
Lines changed: 31 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
210 | 234 | | |
211 | 235 | | |
212 | 236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
178 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
179 | 185 | | |
180 | 186 | | |
181 | 187 | | |
| |||
0 commit comments