Fix Truncater counting OSC hyperlink payloads as printable width - #626
Open
trippyogi wants to merge 3 commits into
Open
Fix Truncater counting OSC hyperlink payloads as printable width#626trippyogi wants to merge 3 commits into
trippyogi wants to merge 3 commits into
Conversation
Truncater only skipped CSI after ESC, so OSC hyperlink payloads counted as printable width and spinner titles truncated early. Mirror ANSI.strip_codes OSC handling (BEL / ST terminators).
When truncation removes a hyperlink's closing sequence, emit OSC 8 end before the ellipsis so later output is not left clickable. Require a real ST backslash after ESC, and keep BEL/ST OSC handling with focused regression coverage.
Non-OSC8 terminators were clearing hyperlink state via osc8_open? returning false. Return nil for non-OSC8 so Truncater still closes dangling links when truncating after sequences like OSC 9.
trippyogi
marked this pull request as ready for review
August 13, 2026 19:45
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.
Summary
Fixes #614
CLI::UI::Truncateronly skipped CSI sequences (ESC [), so OSC hyperlink payloads (ESC ]…) were counted toward printable width and spinner titles truncated early even whenANSI.printing_widthwas correct.This change teaches Truncater to consume OSC sequences (BEL and ST /
ESC \), close an open OSC 8 hyperlink before emitting the truncation marker when a cut removes the original close, and keep OSC 8 open-state across unrelated OSC sequences (e.g. OSC 9) so a later truncate still closes the link.Overlap with #624
#624 also covers this class of terminal-width/OSC issues as part of a much broader layout/parser change set, currently aimed at the pending 3.0 work rather than a minimal mainline fix. This PR is intentionally scoped to
#614on currentmainso maintainers can take the narrow fix independently if desired.Test plan
TRUNCATEDbundle exec rake(full suite + RuboCop) — blocked locally on Windows (sorbet-statichas nox64-mingw-ucrtplatform); please rely on CI