Skip to content

fix: prevent sparse spacing in hyphenated words - #1102

Merged
adamdotdevin merged 4 commits into
anomalyco:devfrom
monotykamary:fix/hyphen-word-wrapping
Jul 19, 2025
Merged

adamdotdevin merged 4 commits into
anomalyco:devfrom
monotykamary:fix/hyphen-word-wrapping

Conversation

@monotykamary

@monotykamary monotykamary commented Jul 17, 2025 •

Copy link
Copy Markdown
Contributor

Summary

This PR fixes the sparse spacing issue that occurs when displaying hyphenated words like 'claude-code-action' in both Assistant and User messages in the TUI. Fixes #621.

Problem

Previously, hyphenated words would break at hyphens, creating sparse single-word lines that made the chat interface look broken and difficult to read.

Before:
image

Solution

After:
image

  • Assistant messages: Use non-breaking hyphens (U+2011) in markdown rendering to prevent word breaks at hyphens
  • User messages: Apply non-breaking hyphens before word wrapping and styling
  • Textarea component: Modified word boundary detection to treat hyphens as part of words
  • Width constraint: Maintained 86 character width limit with precise calculations

Changes Made

  1. packages/tui/internal/components/chat/message.go: Updated user message rendering to use non-breaking hyphens
  2. packages/tui/internal/components/textarea/textarea.go: Modified word boundary detection in textarea word wrapping
  3. packages/tui/internal/util/file.go: Enhanced markdown rendering with hyphen handling

Testing

  • Verified both Assistant and User messages display correctly
  • Confirmed 86 character width constraint is maintained
  • Tested with various hyphenated words and phrases
  • No visual regressions in existing functionality

This change significantly improves the readability of hyphenated content in the TUI without affecting any other functionality.

- Use non-breaking hyphens (U+2011) to prevent word breaks at hyphens
- Apply fix to both Assistant (markdown) and User (chat) messages
- Maintain 86 character width constraint
- Fix word boundary detection in textarea component

Fixes sparse single-word lines when displaying hyphenated words like 'claude-code-action'

@adamdotdevin adamdotdevin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just a few questions, i'd love to have this fixed, just need to understand the implementation a little better

Comment thread packages/tui/internal/util/file.go Resolved
Comment thread packages/tui/internal/util/file.go Resolved
@monotykamary
monotykamary force-pushed the fix/hyphen-word-wrapping branch from 8df9568 to ac501a1 Compare July 19, 2025 00:35
@monotykamary

monotykamary commented Jul 19, 2025 •

Copy link
Copy Markdown
Contributor Author

Now that you've pointed it out, I think there might be a more ergonomic way to do this 🤔
also now that we're going for a stretched look

- Extract hyphen preservation logic into reusable utility functions
- Replace magic numbers with dynamic style-based calculations
- Add GetMessageContainerFrame() and GetMarkdownContainerFrame() for DRY width calculations
- Simplify width calculations by removing outdated constraints
- Improve code maintainability with semantic function names and clear documentation

The hyphen handling now automatically adapts to style changes without manual updates.
@monotykamary

Copy link
Copy Markdown
Contributor Author
Before After
image image

@adamdotdevin
adamdotdevin merged commit 2b44dbd into anomalyco:dev Jul 19, 2025
thdxr added a commit that referenced this pull request Jul 19, 2025
bussard76 pushed a commit to bussard76/openwork that referenced this pull request May 12, 2026
* refine connect remote workspace modal

* simplify remote workspace modal

* align remote modal with create workspace
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
meSingh pushed a commit to meSingh/opencode that referenced this pull request Sep 6, 2026
meSingh pushed a commit to meSingh/opencode that referenced this pull request Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrapping is off in terminal

2 participants