Skip to content

fix(term-state): prevent inline TUI status-bar staircasing and border duplication during panel resize drag #3103

Closed

Description

@Xuepoo

Priority: P1 | Area: area:runtime | Labels: fix,P1,area:runtime,area:panel | Milestone: v0.1.0 | RFC: OQ-007 | Task: CTX-1783

Summary

When dragging a split-panel divider (update_border_drag) with inline primary-screen TUIs running in both panes (such as agy rendering via DECSET 2026 synchronized updates, CUU, ED 0, and trailing CR):

  1. Inline widget rows soft-wrap into multiple physical rows on width shrink:
    • State::resize_with_report rewraps active inline widget rows (──── horizontal borders, > prompt, and full-width status bar) into 2+ physical rows when new_cols < old_cols, while the inline TUI's SIGWINCH redraw (\x1b[<n>A\x1b[J) steps up by its logical widget height (1 row per widget line), stranding duplicate ──────── borders and truncated status-bar fragments above the widget on every width-shrink step.
  2. In-flight DECSET 2026 synchronized frames formatted for the previous width auto-wrap on a narrowed grid:
    • During continuous mouse border drags, a ?2026h ... ?2026l synchronized frame rendered by the TUI for width W_1 can arrive after the grid has already narrowed to W_2 < W_1. Auto-wrapping the overflow onto a new row scrolls the primary screen up and leaves the trailing \r parked on the continuation row while the TUI's internal cursor remains at (x = 0, y = 0).
  3. Cursor offset mapping on soft-wrapped continuation rows maps ccol == 0 (after \r) to seg_start % new_cols != 0:
    • Subsequent width resizes map unit_offset = seg_start to a non-zero column (e.g. col = 3 after "edi"), so the next \x1b[J (emitted without a redundant \r because the TUI believes its cursor is already at column 0) erases only from col = 3 onward and prints "esc to cancel..." at col = 3, producing "ediesc to cancel..." and "AI: Out of creesc to cancel" staircasing across the pane.

Fix

  1. Track the active inline TUI viewport top row (inline_top_row) on the primary screen across DECSET 2026 synchronized updates, upward cursor motions, carriage-return in-place redraws, and ED 0 erases (invalidated on unsynchronized linefeeds and full clears/resets), and resize active inline widget rows 1-to-1 in place (truncate_or_pad_one_logical) while continuing to reflow committed history lines and scrollback above inline_top_row losslessly.
  2. Clip horizontal overflow at the right margin during active primary-screen synchronized TUI frames (?2026h) instead of soft-wrapping and scrolling the viewport, and unwind any pre-existing soft-wrapped continuation chain at column 0 on ED 0 (\x1b[J).
  3. Preserve column 0 when mapping the cursor across width resizes on inline/carriage-returned rows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1area:panelarea:runtimefix

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions