Skip to content

Long words in assistant chat responses now wrap properly #5707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ryanjwilson9
Copy link

@ryanjwilson9 ryanjwilson9 commented May 16, 2025

Description

Previously, very long unbroken words in assistant responses would overflow their container or get cut off, especially on smaller screens.
This was due to markdown-rendered content (via StyledMarkdown) not propagating word-break and overflow-wrap to deeply nested elements

This change:
Only added a global * { word-break: break-word; overflow-wrap: break-word; } rule inside StyledMarkdown
-> gui/src/components/StyledMarkdownPreview/index.tsx
An explicit white-space: pre-wrap rule for p, span, and div
These changes ensure all markdown-rendered assistant responses wrap gracefully, even with unusually long tokens.

Checklist

  • I've read the contributing guide
  • The relevant docs, if any, have been updated or created
  • The relevant tests, if any, have been updated or created

Screenshots

## Tests

None


Summary by mrge

Long unbroken words in assistant chat responses now wrap correctly, preventing overflow and cut-off on all screen sizes.

  • Bug Fixes
    • Added global word-break and overflow-wrap rules to StyledMarkdown.
    • Set white-space: pre-wrap for p, span, and div elements.

@ryanjwilson9 ryanjwilson9 requested a review from a team as a code owner May 16, 2025 18:19
@ryanjwilson9 ryanjwilson9 requested review from RomneyDa and removed request for a team May 16, 2025 18:19
Copy link

netlify bot commented May 16, 2025

Deploy Preview for continuedev canceled.

Name Link
🔨 Latest commit 8b605dd
🔍 Latest deploy log https://app.netlify.com/projects/continuedev/deploys/6827b71426d65400083751c7

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label May 16, 2025
Copy link

github-actions bot commented May 16, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@ryanjwilson9
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request May 16, 2025
Copy link
Collaborator

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

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

Nice fix to implement the expected word wrap behavior for long non-"breakable" words in chat

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 16, 2025
@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs May 16, 2025
@RomneyDa
Copy link
Collaborator

@ryanjwilson9 just to confirm, this doesn't cause code to wrap?

@ryanjwilson9
Copy link
Author

@ryanjwilson9 just to confirm, this doesn't cause code to wrap?

@RomneyDa currently it does wrap code. But I also wrote something up to not wrap code.

Not sure what you prefer.
Initial fix (wrap everything):
* { word-break: break-word; overflow-wrap: break-word; } p, span, div { white-space: pre-wrap; }

Wrap text, not code:

@RomneyDa
Copy link
Collaborator

RomneyDa commented May 19, 2025

The expected behavior should be

  • use this fix for anything that's not a codeblock
  • Apply this fix to codeblocks only when the codeWrap ui setting is turned on (see StyledMarkdownPreview)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants