Skip to content

feat(terminal): collapse wrapped user prompt rows - #449

Open
RonenMars wants to merge 2 commits into
mainfrom
feat/collapse-wrapped-prompt-lines
Open

feat(terminal): collapse wrapped user prompt rows#449
RonenMars wants to merge 2 commits into
mainfrom
feat/collapse-wrapped-prompt-lines

Conversation

@RonenMars

Copy link
Copy Markdown
Owner

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.
VirtualTerminal correctly 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 one userMessageTexts entry (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 when userMessageTexts is empty/undefined, 20-row lookahead cap.
  • components/terminal/TerminalOutput.tsx: wires the helper in via one useMemo, replacing lines with collapsedLines in the FlashList data, keys, and the questionBlock window.
  • Fixes a related latent bug: isUserLine couldn't highlight a wrapped multi-row prompt before, since no single raw row matched userMessageTexts exactly — 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 convention
  • npx eslint clean on all touched files

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.

1 participant