Repository navigation
[0.0.27] fix(runtime,term-state): resize follow-ups from #2534 (#2543) - #2551
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 47 minutes. View limit details
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. Comment |
Xuepoo
left a comment
There was a problem hiding this comment.
Independent review — NEEDS-FIX
Reviewed head 2d11166e (base 101efbc4, 10 files, +352/−26) for 0.0.27 / #2543. No changes pushed, nothing merged.
Method: full diff read; targeted suites on the PR head; scoped
CARGO_TARGET_DIR=$BITTY_WORKSPACE/.targets/review-2551; nextest group/profile
listing; a local remap-disabled probe to prove the new runtime regressions are
not vacuous; throwaway term-state and pane probes for the cursor-detach and
pane-remap edges (both removed before finishing).
Verified behavior
- Height-only selection remap (primary).
resize_with_reportreports the
signed content shift only for height-only changes;reflow_content_to_chrome,
resize_primary_grid, the panel-rule path, andsync_pane_geometry_toall
remap before the existing clamp. A pushed endpoint drops fail-closed; a
retained endpoint shifts. The width path returns early, so the prior
reflow/DPI clamp behavior is unchanged.height_resize_keeps_held_selection_on_its_content
proves anchor/focus rows, copied text, andbuffer_row/matched_text
identity across shrink and grow;height_shrink_drops_selection_pushed_into_scrollback
proves the fail-closed drop. - Non-vacuity. Disabling
remap_selection_for_resizelocally makes both new
runtime tests fail (2 failed / 1 passed in theheight_filter; the pass is
the pre-existing two-pane test), so they genuinely gate the fix. The tree was
restored (git statusclean) and the suite re-ran green. - Pane path. A throwaway split-pane probe holding a non-buffer selection
across a divider shrink/grow preserved its text; the new
sync_pane_geometry_toremap works. No committed regression covers it (see
follow-up 2). - Cursor-detach behavior. Term-state probes confirm the implementation:
content-full shrink with the cursor above the pushed prefix shifts the cursor
(24→12, cursor 20→8); a shrink whose push reaches the cursor clamps it to row
0 (24→5 with cursor row 4); all content rows remain present exactly once in
order. The committed regression proves the clamped case and row survival. resize_scrollbacknextest group.cargo nextest show-config test-groups --groups live-ptylistsbitty-runtime::resize_scrollback(all 7 tests,
including the two new ones) under both the default and ci overrides;
cargo nextest run -p bitty-runtime --test resize_scrollback --profile ci
ran 7/7 green.- 1-column reflow + cap. The committed 500-line/64-line-cap test passes:
cap enforced, oldest-first pruning keeps the newest logical line, invariants
hold after 1→80, and no panic. A throwaway wide-glyph-tail variant also
passed (no orphan halves, text preserved). The committed fixture is ASCII,
so its wide assertions are vacuous (follow-up 1). - Scrollback module doc. It now matches height-only pushes with wrap flags,
the width-reflow drain/rebuild,clear_last_wrap,pop_back_line, and the
ED 3/FullResetclear; the stale "append-only / scroll-under only" claim
is gone. - Remote CI is green on this head (Quality gates 1/2, Windows, macOS ARM64,
MSRV, CodeQL, Linux X11/Wayland, Supply chain, compat matrices). CodeRabbit
was rate-limited with no review comments to disposition.
Gates run on 2d11166e
cargo fmt --all -- --check # exit 0
cargo clippy -p bitty-term-state -p bitty-runtime --all-targets --locked -- -D warnings # exit 0
cargo test -p bitty-term-state --locked # 225 lib + all suites, resize_reflow_2529 14 passed
cargo test -p bitty-runtime --lib --locked # 1237 passed
cargo test -p bitty-runtime --test resize_scrollback --test selection_scrollback \
--test scrollback_search_selection_persistence --test scrollback_search_ui_integration \
--test selection_clipboard --locked # 7 / 6 / 9 / 9 / 29 passed
cargo nextest run -p bitty-runtime --test resize_scrollback --profile ci --locked # 7 passed
Blocker — cursor-detach documentation states the wrong condition and the “only when” is not gated
crates/bitty-term-state/src/state.rs:703-712 says detach happens when
non-blank content exists below the cursor and the shrink exceeds the absorbable
bottom padding, and that callers needing attachment must leave
cursor_row + 1 rows. Both are false:
- Trigger counterexample. 10 content rows, cursor row 2, resize 24→8:
padding = 14, shrink = 16 (> padding), push = 2, cursor 2−2 = 0, still
attached. Content below the cursor and shrink > padding are necessary but not
sufficient. - Attachment-bound counterexample. 24 full rows, cursor row 2, resize 24→3
(cursor_row + 1rows left): push = 21, cursor clamps to 0. Leaving
cursor_row + 1rows is not sufficient.
The correct condition is push = max(0, used_rows − new_rows); the cursor is
detached iff push > cursor_row, i.e. new_rows < used_rows − cursor_row, and
attachment requires at least used_rows − cursor_row rows (from the cursor
through the last used row), not cursor_row + 1.
The committed regression only proves the clamped case. No test asserts the
opposite: an attached cursor must shift rather than clamp (for example fill 10
rows, cursor row 2, resize(80, 8) → scrollback 2, cursor row 0; or full 24
rows, cursor row 20, resize(80, 12) → scrollback 12, cursor row 8). Add that
regression and correct the doc; a sentence on the public State::resize would
make the edge discoverable too.
Non-blocking findings
- 1-column test/doc precision.
crates/bitty-term-state/tests/resize_reflow_2529.rs:463
uses an ASCII fixture, so thespacer/width <= 1assertions and
assert_no_orphan_widesnever exercise a wide pair, and the comment at
state.rs:3859/ the test doc say the retained suffix “reflows back
losslessly” although width-1 wide leads stay narrow. The behavior is fine
(a wide-tail probe passed); qualify the wording and add a wide glyph to the
cap fixture so the assertions are not vacuous. - Pane selection remap has no committed test.
crates/bitty-runtime/src/runtime/panes.rs:984
is a new caller; the throwaway probe passes, but a future regression would
not be caught. Add a split-pane variant of the primary selection test
(divider shrink/grow, non-buffer selection, same text). - Nextest filter collateral.
.config/nextest.toml:38,45matches by binary
name, soresize_scrollbackalso pulls the 13 in-memory
bitty-ui::resize_scrollbacktests into thelive-ptygroup (max 2 threads,
ci retries). If unintended, scope the runtime suite with
package(bitty-runtime) & binary(resize_scrollback). - Canonical docs still claim unconditional cursor attachment. The
bitty-terminal-docsspecifications/terminal-state-rfc.mdheight-only
bullet says the shrink “moves the cursor with its content”; add the
pushed-cursor detach exception (or track it as a docs follow-up). - Residual edge (pre-existing). A non-buffer selection on a scrolled
viewport is left untouched by the remap (is_viewport_scrolledreturns
early) and is only reclamped, so it can retarget; pointer selections are
buffer-anchored, so this is reachable through the direct APIs only. Worth a
follow-up, not a blocker for this PR.
|
Review fixes pushed at
Gates: |
4e5a8a7 to
fa7b090
Compare
|
Rebased onto latest |
Xuepoo
left a comment
There was a problem hiding this comment.
Independent review — NEEDS-FIX (delta recheck)
Rechecked head fa7b0900 against its parent 5d49773c (3 files, +145/−9).
The head was force-pushed from 4e5a8a77 onto fa57b5b7 during the recheck;
the delta patch is byte-identical (diff -q of the two patches is clean), so
the reviewed content is unchanged. The delta is documentation and tests only: a
-U0 diff of crates/bitty-term-state/src/state.rs contains only /// lines,
and the runtime delta is one test plus its import. No resize behavior changed.
Previous blocker — fixed
- The condition is now exact. Under
resize_height_only,
absorb = old_rows - used_rowsandpush = used_rows - new_rowson a shrink,
so detachment (push > cursor_row) is exactly
new_rows < used_rows - cursor_row. The old “any shrink beyond the
absorbable padding detaches” claim and the falsecursor_row + 1attachment
bound are gone. The new text correctly says attachment needs
used_rows - cursor_rowrows (the cursor row plus every used row below it).
Grow and absorb-only resizes make the predicate false, so they cannot detach. - The new regression gates the behavior.
shrink_that_keeps_cursor_row_attaches_cursor_to_shifted_contentuses 12
content rows with the cursor on row 4 and resizes 24→10: shrink = 14 >
padding = 12 (the old false trigger), push = 2, and it requires the cursor on
row 2 withbody-04still under it and every row present once in order. It
passes. Locally forcing an unconditional cursor clamp makes it fail
(left: 0, right: 2); restored and re-ran green. - No behavior change. The only source edit is doc text; all other delta
lines are test code.
Blocker — Windows -D warnings compile failure from the new test import
crates/bitty-runtime/tests/resize_scrollback.rs:9 now has:
use bitty_ui::{CellPos, Selection, ViewId};Selection is used only by the new #[cfg(unix)]
pane_height_resize_remaps_pane_owned_selection test. On Windows the test is
compiled out, so the import is unused and RUSTFLAGS=-D warnings fails:
error: unused import: `Selection`
--> crates\bitty-runtime\tests\resize_scrollback.rs:9:25
= note: `-D unused-imports` implied by `-D warnings`
error: could not compile `bitty-runtime` (test "resize_scrollback")
Evidence: the Windows check and test job on fa7b0900
(actions/runs/39918910489/job/120300126355, step “Check workspace compilation”)
failed for exactly this, and all later Windows steps were skipped. Fix by
gating the import:
use bitty_ui::{CellPos, ViewId};
#[cfg(unix)]
use bitty_ui::Selection;(or import Selection inside the #[cfg(unix)] test). Re-run the Windows job.
Verified non-vacuous additions
- Pane remap test.
pane_height_resize_remaps_pane_owned_selectioninstalls
a non-buffer selection on the bottom pane, drags the divider, and requires the
pane-owned selection to move to the shifted row and keeppane-39. It passes
on both heads. Locally disablingremap_selection_for_resizemakes it fail
with the selection retargeted to a blank row; restored, suite green. This is
the new pane code path, not a primary-grid proxy. - 1-column additions. The new assertions require
1×24after the 1-column
pass,80×24after widening, and an80*24snapshot; a no-op or truncating
resize fails them. The fixture is still ASCII, so the wide-pair assertions
remain unexercised; that is the pre-existing non-blocking nit, not a new
regression.
Gates run
cargo fmt --all -- --check # exit 0 (rebased head)
cargo test -p bitty-term-state --locked # 225 lib + suites; resize_reflow_2529 15 (source identical to 4e5a8a77)
cargo test -p bitty-runtime --test resize_scrollback --locked # 8 passed (incl. new pane test; rebased head)
# vacuity probes: cursor clamp -> new term-state test fails; remap disabled -> pane test fails
# both restored; targeted tests re-ran green
cargo clippy -p bitty-term-state -p bitty-runtime --all-targets --locked -- -D warnings # Linux exit 0
Remote CI restarted on the force-pushed head: Windows check and test failed
on the unused import above; the remaining jobs were still running at review
time. CodeRabbit is rate-limited with no comments to disposition.
Residual non-blocking notes
- The 1-column fixture remains ASCII, so
assert_no_orphan_widesand the
width/spacer assertions do not exercise a wide pair; a wide-tail variant
passes, so this is coverage-only. - The canonical
bitty-terminal-docsheight-only bullet still says the
cursor moves with its content unconditionally; record the detach exception. .config/nextest.tomlbinary(resize_scrollback)still pulls the 13
in-memorybitty-uitests intolive-pty; scope tobitty-runtimeif
unintended.- Non-buffer selections on scrolled viewports remain on the old clamp path
(direct APIs only; pointer selections are buffer-anchored).
|
Windows fix pushed at |
Priority: P2 | Area: render | Labels: fix, P2, area:render | Milestone: v0.0.27 | RFC: — | Task: CTX-1464
Summary
Implements the five follow-ups tracked in #2543 from the independent review of #2534:
State::resizenow reports the signed primary-content row shift (ResizeReport), and the runtime remaps a held non-buffer selection by that shift before clamping. Selections whose endpoints are pushed into scrollback are dropped fail-closed; width-changing reflows keep the existing clamp path (a reflow is not a constant shift). Buffer-anchored pointer selections remain on their combined-buffer anchors.clear_last_wrap,pop_back_line, and theED 3/FullResetclear instead of claiming append-only immutability.resize_scrollbackadded to the nextestlive-ptygroup in both the default and CI profiles (it spawns/bin/sh).resize_height_onlynow states the exact condition: the cursor detaches iffnew_rows < used_rows - cursor_row, and attachment needsused_rows - cursor_rowrows. Regressions cover both directions (detach clamps to row 0 with content preserved; attachment shifts the cursor with its row).max_linesdocumented and tested. The bounded-memory tradeoff sits next to the width-1 wide-pair limitation, and a 500-line fixture with a 64-line cap proves the cap is enforced without panic, orphan wide halves, or lost retained suffix.Verification
cargo test -p bitty-term-state --locked— all suites pass (14 inresize_reflow_2529, including the new cursor and 1-column-cap regressions).cargo test -p bitty-runtime --test resize_scrollback --locked— 8 passed, including the selection remap/drop and pane-owned remap regressions.cargo test -p bitty-runtime --test selection_scrollback --test scrollback_search_selection_persistence --test scrollback_search_ui_integration --test selection_clipboard --locked— all pass.cargo test -p bitty-runtime --lib— 1237 passed.cargo nextest show-config test-groups --groups live-pty—bitty-runtime::resize_scrollbackis in the group under both profiles.cargo nextest run -p bitty-runtime --test resize_scrollback --profile ci— 7 passed (before the pane regression landed; the direct suite now covers 8).cargo fmt --all -- --checkand both workspace clippy recipes (-D warnings, plusbitty-terminal --features dev-tools --all-targets) pass.Docs follow-up (separate repository PR)
bitty-terminal-docs/specifications/terminal-state-rfc.mdstill says height-only shrink "moves the cursor with its content" unconditionally (Resize and reflow implementation evidence). It needs the same condition: detach iffnew_rows < used_rows - cursor_row; attachment needsused_rows - cursor_rowrows. Invariant 4 in the same file also still says lines enter scrollback only via scroll-under-region operations, which the height-only push path contradicts. Not edited here (Core-only scope).Scoped
CARGO_TARGET_DIR=$BITTY_WORKSPACE/.targets/ctx-2543; removed after the task.just ci-localwas not run for this scoped subagent pass; remote CI is the remaining gate.Closes #2543