Skip to content

Wrap todo descriptions at word boundaries in sidebar#1643

Merged
rumpl merged 1 commit intodocker:mainfrom
rumpl:todos-wrap
Feb 9, 2026
Merged

Wrap todo descriptions at word boundaries in sidebar#1643
rumpl merged 1 commit intodocker:mainfrom
rumpl:todos-wrap

Conversation

@rumpl
Copy link
Member

@rumpl rumpl commented Feb 8, 2026

Replace truncation with word-aware wrapping so that todo items in the sidebar display their full description regardless of sidebar width.

Long descriptions wrap onto subsequent lines, indented to align with the text after the icon prefix, and line breaks prefer word boundaries over splitting mid-word.

Changes

  • pkg/tui/components/toolcommon/truncate.go — New WrapLinesWords function that wraps at word boundaries, falling back to rune-level splitting for words exceeding the available width.
  • pkg/tui/components/tool/todotool/sidebar.go — Use WrapLinesWords instead of TruncateText so todo descriptions wrap fully with proper indentation on continuation lines.
  • pkg/tui/components/toolcommon/common_test.go — Tests for WrapLinesWords covering normal wrapping, long words, multi-line input, edge cases, and unicode/CJK.
Screenshot 2026-02-08 at 23 08 14

@rumpl rumpl requested a review from a team as a code owner February 8, 2026 22:09
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Review Summary

Found 1 issue in the changed code that should be addressed:

High Severity

  • Negative maxDescWidth when terminal width is very small: The calculation on line 64 can produce negative values when c.width < prefixWidth, causing word wrapping to be completely bypassed.

The word wrapping logic itself looks good for normal cases, but needs defensive handling for edge cases where the component width becomes smaller than the icon prefix width.

Replace truncation with word-aware wrapping so that todo items in the
sidebar display their full description regardless of sidebar width.
Long descriptions wrap onto subsequent lines, indented to align with
the text after the icon prefix, and line breaks prefer word boundaries
over splitting mid-word.

Assisted-By: cagent
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
Copy link
Contributor

@krissetto krissetto left a comment

Choose a reason for hiding this comment

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

maybe we could also add some minimal visual separation between the todos 🤔 will give it a look

@rumpl
Copy link
Member Author

rumpl commented Feb 9, 2026

Adding separation will make it even more vertical, idk

@krissetto
Copy link
Contributor

true, but maybe even todos should have a title and content if they are that long though, these in the example are more like full blown tasks than simple todos.. but anyway stuff for separate PRs

@rumpl rumpl merged commit 48d3846 into docker:main Feb 9, 2026
7 of 8 checks passed
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.

2 participants