Wrap logs correctly at terminal width#361
Draft
jw2 wants to merge 1 commit into
Draft
Conversation
c53da31 to
afc1c4f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
In
lstk logs --follow, log lines wrapped narrower than the terminal.HardWrapcounts characters, but styled prefixes (e.g.styles.Secondary.Render("container | ")) embed invisible ANSI escape sequences. Those bytes were counted as visible width, so wrapping fired before the visible content reached the terminal edge.What changes
renderLogLinenow takes anavailableWidthand acontinuationIndent. It wraps the message on visible width, indents continuation lines to align under the message (past the prefix), and preserves the meta/message styling split (" : "boundary) across wrap points.app.goLogLineEvent handler measures the visible prefix width vialipgloss.Widthand passes the remaining width torenderLogLine. Pre-wrapped lines are flagged (styledLine.preWrapped) soView()emits them verbatim instead of re-wrapping.logrender_test.gofor plain wrap, visible-prefix width, meta/message styling across wraps, continuation indent, and zero-width passthrough; a golden-file test (TestAppLogLineEventWrapsAtTerminalWidth) for the end-to-end event path.Note on the test changes
withTrueColorProfilemutates lipgloss's package-global color profile. The tests using it were markedt.Parallel(), which is a race: a sibling's cleanup restoring the default profile mid-run strips the colors another test is asserting on, producing intermittent failures. Those tests are now serial, matching the convention already used by the inline profile-mutating tests inapp_test.go.Testing
make test— all green (internal/uiverified stable across 20 consecutive runs).🤖 Generated with Claude Code