Skip to content

fix(terminal): break soft wraps after erase above clears a row - #4828

Merged
devswha merged 3 commits into
devswha:mainfrom
iyuzhang:fix/terminal-erase-above-wrap
Nov 26, 2026
Merged

devswha merged 3 commits into
devswha:mainfrom
iyuzhang:fix/terminal-erase-above-wrap

Conversation

@iyuzhang

Copy link
Copy Markdown
Contributor

Change

Break the soft wrap into the next row when ED 1 or DECSED 1 clears the cursor row. Partial erases and selective erases that leave protected text keep the wrap.

Fixes #4782.

Validation

  • Rebuilt libghostty-vt with Zig 0.17.1. The regression tests check selection and copied text against the rebuilt WASM.
  • Workflow syntax, generated files, typecheck, build and the full unit suite passed. The check fast report was invalidated when the changes were committed mid-run. The tested file contents match the commit, and the focused tests also passed after committing.
  • bun run check run --build -- bun scripts/terminal-copy-off-regression.ts passed with Chromium, herdr 0.9.3 and the Rust PTY host. The full integration and browser suites were skipped.

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: devswha/ovis
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 7e779af
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5a0d238e-3531-4466-9152-87deec50cc3d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Fixed terminal selection and copying so clearing the cursor’s entire row with an erase-above command no longer joins the following row to it.
    • Corrected soft-wrap handling after erase and line-feed operations. Rows now retain their wrap when content remains, and the following row is separated when the erase clears the cursor’s entire row.

The erase-ends-wrap.patch updates erase-above handling when it clears the cursor’s entire row. Tests check the following row’s wrap state and selection text, including cases with wide characters and remaining text to the right of the cursor.

Changes: Erase-above wrap handling

Layer / File(s) Summary
Erase-above wrap reset
scripts/ghostty-vt/erase-ends-wrap.patch, scripts/ghostty-vt/build.sh
The patch resets wrap state when erase-above reaches the end of a wrapped cursor row and the protection and remaining-text conditions are met. Build comments and the expected output hash are updated.
Wrapping and selection regression checks
src/lib/terminalReflow.test.ts, changelog.d/terminal-erase-above-wrap.md, THIRD_PARTY_NOTICES.md
Tests check following-row text, wrap state, wrapped range, and selection text for ED 1 and DECSED 1 cases. The changelog and third-party notice describe the related behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

  • devswha/ovis#4681: Moves triple-click selection and copy reads onto libghostty ScreenRows, whose behavior depends on the wrap state changed here.

Suggested reviewers: devswha

Merge Risk: Minimal · previous review 096e9 · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: soft wraps are broken after an erase-above command clears a row. The changeset adds Screen.cursorResetWrapContinuation, updates the erase-ends-wrap patch, changelog, a…
Description check Passed The description follows the template. It has a Change section that describes the problem and resulting behavior, and it links the issue #4782. It also has a Validation section that lists the commands …
Linked Issues check Passed [#4782] Coding requirements, as stated in the issue, are: (1) extend scripts/ghostty-vt/erase-ends-wrap.patch so ED 1 and unprotected DECSED 1 end the soft wrap when they clear the cursor row; (2) reb…
Out of Scope Changes check Passed All reviewed changes support the linked objective. scripts/ghostty-vt/erase-ends-wrap.patch and its Terminal.zig index metadata implement the wrap reset. src/lib/terminalReflow.test.ts covers the new …
Full details: Title check

Explanation

The title names the main change: soft wraps are broken after an erase-above command clears a row. The changeset adds Screen.cursorResetWrapContinuation, updates the erase-ends-wrap patch, changelog, and regression tests for ED 1 and DECSED 1. The title is specific and matches the linked issue #4782.

Full details: Description check

Explanation

The description follows the template. It has a Change section that describes the problem and resulting behavior, and it links the issue #4782. It also has a Validation section that lists the commands run and their results. It does not state which checks were skipped beyond the full integration and browser suites, and it says the check fast report was invalidated. These gaps are minor. The description is mostly complete.

Full details: Linked Issues check

Explanation

[#4782] Coding requirements, as stated in the issue, are: (1) extend scripts/ghostty-vt/erase-ends-wrap.patch so ED 1 and unprotected DECSED 1 end the soft wrap when they clear the cursor row; (2) rebuild shared/ghostty/ghostty-vt.wasm; (3) restore two assertions in src/lib/terminalReflow.test.ts.

Requirement (1): The patch summary shows a new Screen.cursorResetWrapContinuation helper. It is called from erase-display-above when the erase reaches the cursor row's end and no protected text remains. This matches the whole-row ED 1 and unprotected DECSED 1 case. Partial erases and protected-text cases keep the wrap, as the PR description states.

Requirement (3): terminalReflow.test.ts has expanded ED 1 and unprotected DECSED tests. They check that the following row is unwrapped, check its text and wrapped range, and check selection text. A test also confirms that ED 1 keeps the wrap when text remains right of the cursor.

Requirement (2): shared/ghostty/ghostty-vt.wasm is excluded from review by the rule !**/*.wasm. The WASM contents were not inspected. The result rests on the patch and test changes, which were reviewed, and on the PR description stating the rebuild and passing regression checks.

Full details: Out of Scope Changes check

Explanation

All reviewed changes support the linked objective. scripts/ghostty-vt/erase-ends-wrap.patch and its Terminal.zig index metadata implement the wrap reset. src/lib/terminalReflow.test.ts covers the new behavior. scripts/ghostty-vt/build.sh updates the patch description and the expected build SHA-256, which follows from the patch change. THIRD_PARTY_NOTICES.md updates the patch description to match. changelog.d/terminal-erase-above-wrap.md records the fix. Tests for wide-character final-column erasure extend the same ED 1 behavior. No unrelated change was found in the reviewed summary.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: devswha/ovis
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 7d1d71a
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d26466b6-aed8-4995-b989-def0958cc315
Commits

Reviewing files that changed from the base of the PR and between 7d1d71a and 096e9b2.

Files ignored due to path filters: 1

  • shared/ghostty/ghostty-vt.wasm is excluded by !**/*.wasm
Files selected for processing: 5

  • THIRD_PARTY_NOTICES.md
  • changelog.d/terminal-erase-above-wrap.md
  • scripts/ghostty-vt/build.sh
  • scripts/ghostty-vt/erase-ends-wrap.patch
  • src/lib/terminalReflow.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

…s a row whose wrap already ended

An earlier ED 1 can reset the cleared row's own wrap flag while the row
below still continues it; the whole-row erase now ends that continuation
too. Rebuilt ghostty-vt.wasm with Zig 0.17.1.
@devswha

devswha commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Thanks @iyuzhang, this is a clean fix with a reproducible WASM: an independent Zig 0.17.1 rebuild of your head was byte-identical to the shipped ghostty-vt.wasm, and three of the new tests fail on main's WASM.

Reviews (an omo gate review and a Codex review) both reproduced one remaining case, which I fixed on your branch in 205f07d:

  • An earlier erase above can reset the cleared row's own wrap flag while the next row keeps wrap_continuation (e.g. abcdefgh\x1b[2;1H\x1b[1J\x1b[1;1HXY\x1b[1;5H\x1b[1J in 5 columns). The whole-row ED 1 / DECSED 1 now also ends the next row's continuation, so the next row no longer selects or copies as part of the erased one. The patch, the rebuilt WASM (sha256 ef5b5329…, recorded in build.sh) and a test for both ED 1 and DECSED 1 are in that commit.

I also merged main into the branch (no force push). bun run check fast passed.

@devswha
devswha merged commit b378257 into devswha:main Nov 26, 2026
23 checks passed
@devswha

devswha commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Merged through pr-merge at head 39f971265. Seen before the merge was asked for: required checks green, no unresolved thread, no conflict, no hold, main not red, no release in progress. CodeRabbit said it did not review (a limit or a skip) since this head.

main moved but untouched: merged without update. Its new commits up to f97aa8006 change no file of this pull request, none imported by one, nothing that decides which checks run, and no core path.

Outside contributor's fix/test PR, merged under the owner's standing rule for external fix PRs that change no feature, UI, setting or HTTP/WS contract. Reviews: one omo gate review and one Codex adversarial review (gpt-6.2-sol-fast, xhigh, team proxy) of the contributor's head; both reproduced one MEDIUM (a row whose wrap an earlier erase had ended kept the next row's continuation), fixed by the maintainer in 205f07d with a rebuilt WASM (Zig 0.17.1). The gate review rebuilt the contributor's WASM byte-identically. CodeRabbit did not review the latest head. Reproduced on main: 3 new tests fail on main's WASM.

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.

terminal: an ED 1 that clears a whole row keeps the soft wrap into it

2 participants