feat(terminal): collapse wrapped user prompt rows - #449
Open
RonenMars wants to merge 2 commits into
Open
Conversation
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
Claude Code's CLI wraps long submitted prompts to its own terminal column width before echoing them back over the PTY, embedding real newline bytes at wrap points.
VirtualTerminalcorrectly turns each into a separate row, but tb-mobile's phone-width terminal view then showed one prompt sentence as several choppy rows.This adds a pure helper,
collapseWrappedUserLines, that detects a run of PTY rows reconstructing oneuserMessageTextsentry (the ground-truth text the streamer already sends) and collapses them into a single row — no punctuation heuristics, exact-match only.lib/collapseWrappedUserLines.ts: new pure helper, identity passthrough whenuserMessageTextsis empty/undefined, 20-row lookahead cap.components/terminal/TerminalOutput.tsx: wires the helper in via oneuseMemo, replacinglineswithcollapsedLinesin the FlashList data,keys, and thequestionBlockwindow.isUserLinecouldn't highlight a wrapped multi-row prompt before, since no single raw row matcheduserMessageTextsexactly — after collapsing it does, so highlighting now works for wrapped prompts too.Test plan
npx jest --ci --runInBand __tests__/unit/lib/collapseWrappedUserLines.test.ts— 7/7 passing (no-match passthrough, single-row no-op, multi-row collapse, empty set passthrough, lookahead-bound-exceeded, non-prompt content never engaged)npx jest --ci --runInBand --testPathPattern "TerminalOutput"— full suite passing, including new collapsing case, run twice in isolation per repo conventionnpx eslintclean on all touched files