Skip to content

terminal: keep a 133;P primary prompt on its own line and drop wrap padding - #247

Merged
lawrencecchen merged 4 commits into
mainfrom
fix/prompt-start-wrap
Sep 30, 2026
Merged

lawrencecchen merged 4 commits into
mainfrom
fix/prompt-start-wrap

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented Sep 30, 2026 •

Copy link
Copy Markdown

Summary

Follow-up to #245. Cloud terminals (cmux-tui, bash with ble.sh) still left prompt fragments after an aggressive resize.

  • 133;P primary prompt. With ble.sh active, Ghostty's bash integration marks the prompt with 133;P;k=i instead of 133;A, because ble.sh cannot track A's fresh-line. ble.sh pads a partial line past the right edge like zsh PROMPT_SP, so the prompt still starts at column 0 of a soft-wrapped row. An explicit primary prompt start (k=i or no kind) now breaks that wrap the same as 133;A. Continuation (k=c, k=s) and right (k=r) prompts keep their wrap.
  • Padding. When the wrap is broken, the trailing run of unstyled plain spaces on the row above is cleared. That padding only forced the new row. Kept as text, it reflows into extra blank rows of the partial line whenever the terminal narrows. A shell redraw computed for the old width can then land in those rows and print the prompt into the partial line again. The zsh % mark is styled, so the trim stops there.

Testing

On a Blacksmith testbox (Linux, Zig 0.16.0):

  • Terminal: OSC133P after a padded partial line keeps the prompt on its own line across resize: red at f1906ae (expected 1, found 0, the prompt joined the padded row), green at c318e78. The padding assertion (narrowing to 5 columns keeps the cursor on row 1) is new in that test.
  • Terminal: OSC133P continuation prompt keeps a soft wrap passes.
  • zig build test-lib-vt: one failure, kitty temporary file medium preserves bool ABI, which also fails at the earlier pin on Linux.
  • End to end in cmux-tui with the Cloud VM's exact shell setup (/bin/bash, /etc/cmux/bashrc, prompt.bash, ble.sh nightly), a partial line, and 81 width changes at 4 ms intervals through an attached client: main was clean in 0 of 6 runs; this change plus cmux-tui shell injection was clean in 6 of 6.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Keeps 133;P primary prompts on their own line in Cloud terminals (cmux-tui, bash with ble.sh) so resize no longer leaves prompt fragments behind. An explicit primary prompt start (k=i) now breaks a soft wrap the same as 133;A, and the wrap-padding spaces are cleared so they don't reflow into extra rows when the terminal narrows.

  • Continuation (k=c, k=s) and right (k=r) prompts keep their existing wrap behavior.
  • Padding removal only applies to trailing runs of unstyled plain spaces, so styled marks like zsh's % are preserved.
  • Adds tests for primary prompt line-breaking across resize and continuation wrap preservation.

Written for commit c318e78. Summary will update on new commits.

Review in cubic

lawrencecchen and others added 4 commits September 30, 2026 02:02
… its own line

ble.sh pads a partial line past the right edge like zsh PROMPT_SP, and
Ghostty's bash integration marks its prompt with 133;P instead of 133;A.
Reflow still joins that prompt onto the padded row.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Extend the 133;A rule to an explicit primary prompt start. Ghostty's bash
integration emits 133;P;k=i when ble.sh is active, and ble.sh pads a
partial line into a soft-wrapped row before it, so Cloud terminals kept
leaving prompt fragments behind on resize. Continuation and right
prompts keep their wrap.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
When a primary prompt breaks the soft wrap into its row, the unstyled
spaces that ran into that wrap were padding (zsh PROMPT_SP, ble.sh), not
content. Kept, they reflow into extra blank rows of the partial line
whenever the terminal narrows, and a shell redraw computed for the old
width can land in them and print the prompt into that line again.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 30, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 64cb087e-c74e-4436-b1ae-865a52f991ad

📥 Commits

Reviewing files that changed from the base of the PR and between e30b480 and c318e78.

📒 Files selected for processing (2)
  • src/terminal/Screen.zig
  • src/terminal/Terminal.zig

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lawrencecchen
lawrencecchen merged commit 64cd5eb into main Sep 30, 2026
155 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.

1 participant