fix(ui): reclaim pad by dead space instead of absolute height #135

Manually merged
jabber.developer merged 2 commits from fix/pad-dead-space-reclaim into master 2026-06-24 16:23:14 +00:00
Collaborator

Follow-up hardening to #133.

#133 raised PAD_THRESHOLD to 12000, but the reclaim redraw still keys off absolute pad height, so a single oversized message (huge paste, narrow terminal, crafted incoming) whose live render ≥ threshold re-enters win_redraw() from the print path on every message — the redraw storm again, and the message gets clipped.

This switches the trigger to dead space (getcury - buffer->lines). After a redraw the cursor equals buffer->lines, so dead space is 0 regardless of buffer size: the reclaim can never fire while scrolling, an oversized message no longer storms and renders in full. Dead space only accrues in a long append-only session that trimmed old entries — exactly when reclaiming is wanted.

1 file, +5/-4.

Testing (pending): scroll a >9000-line history to the top; receive/paste a ≥15000-line message; long append-only session (memory bound); narrow terminal (~40 cols).

Fixes #43

Follow-up hardening to #133. #133 raised PAD_THRESHOLD to 12000, but the reclaim redraw still keys off absolute pad height, so a single oversized message (huge paste, narrow terminal, crafted incoming) whose live render ≥ threshold re-enters win_redraw() from the print path on every message — the redraw storm again, and the message gets clipped. This switches the trigger to dead space (getcury - buffer->lines). After a redraw the cursor equals buffer->lines, so dead space is 0 regardless of buffer size: the reclaim can never fire while scrolling, an oversized message no longer storms and renders in full. Dead space only accrues in a long append-only session that trimmed old entries — exactly when reclaiming is wanted. 1 file, +5/-4. Testing (pending): scroll a >9000-line history to the top; receive/paste a ≥15000-line message; long append-only session (memory bound); narrow terminal (~40 cols). Fixes #43
jabber.developer2 added 1 commit 2026-06-09 11:38:28 +00:00
fix(ui): reclaim pad by dead space instead of absolute height
All checks were successful
CI Code / Check spelling (pull_request) Successful in 18s
CI Code / Check coding style (pull_request) Successful in 31s
CI Code / Linux (debian) (pull_request) Successful in 4m34s
CI Code / Linux (ubuntu) (pull_request) Successful in 4m46s
CI Code / Code Coverage (pull_request) Successful in 8m12s
CI Code / Linux (arch) (pull_request) Successful in 10m47s
3fd48a1f44
Variant A (PAD_THRESHOLD=12000) bounds the pad but still re-enters win_redraw() from the print path on every message once the *live* buffer renders >= the threshold — reachable with a single oversized message (huge paste, narrow terminal, crafted incoming), reintroducing the per-message redraw storm.

Trigger the reclaim redraw on dead space (getcury - buffer->lines) instead of absolute pad height. After a redraw the cursor equals buffer->lines, so dead space is 0 regardless of buffer size: the reclaim can never fire while scrolling, and an oversized message no longer storms (and is shown in full rather than clipped). Dead space only accrues in a long append-only session that trimmed old entries — exactly when reclaiming is wanted.
jabber.developer changed title from WIP: fix(ui): reclaim pad by dead space instead of absolute height to fix(ui): reclaim pad by dead space instead of absolute height 2026-06-12 13:51:06 +00:00
jabber.developer force-pushed fix/pad-dead-space-reclaim from 3fd48a1f44 to 5acd062c2d 2026-06-20 09:42:40 +00:00 Compare
jabber.developer2 changed title from fix(ui): reclaim pad by dead space instead of absolute height to WIP: fix(ui): reclaim pad by dead space instead of absolute height 2026-06-20 09:43:27 +00:00
jabber.developer changed title from WIP: fix(ui): reclaim pad by dead space instead of absolute height to fix(ui): reclaim pad by dead space instead of absolute height 2026-06-20 09:59:45 +00:00
jabber.developer2 force-pushed fix/pad-dead-space-reclaim from 5acd062c2d to e33874e6b5 2026-06-20 10:37:32 +00:00 Compare
jabber.developer2 added 1 commit 2026-06-23 11:20:24 +00:00
fix(ui): measure dead pad space from the cursor, not the requested lines
All checks were successful
CI Code / Check coding style (pull_request) Successful in 31s
CI Code / Check spelling (pull_request) Successful in 19s
CI Code / Code Coverage (pull_request) Successful in 3m24s
CI Code / Linux (debian) (pull_request) Successful in 4m42s
CI Code / Linux (ubuntu) (pull_request) Successful in 4m49s
CI Code / Linux (arch) (pull_request) Successful in 6m37s
36512d9dde
_win_print_internal now calls _win_ensure_pad_capacity() with getcury() plus the estimated message height, so deriving 'dead' from lines_needed counted that lookahead reservation as dead space. Compute it from getcury(win) directly so the reclaim keys off the real cursor-vs-buffer gap.
jabber.developer2 changed title from fix(ui): reclaim pad by dead space instead of absolute height to WIP: fix(ui): reclaim pad by dead space instead of absolute height 2026-06-23 11:25:44 +00:00
jabber.developer changed title from WIP: fix(ui): reclaim pad by dead space instead of absolute height to fix(ui): reclaim pad by dead space instead of absolute height 2026-06-24 12:22:31 +00:00
jabber.developer approved these changes 2026-06-24 12:25:46 +00:00
jabber.developer left a comment
Owner

LGTM

LGTM
@@ -44,3 +44,3 @@
static const int PAD_MIN_HEIGHT = 100;
static const int PAD_THRESHOLD = 12000; // above buffer cap (~9000): reclaims dead pad space, never fires while scrolling
static const int PAD_DEAD_SPACE_LIMIT = 2000; // reclaim once the pad holds this much dead space (cursor past live buffer); size-independent, so it never fires while scrolling

why it "it never fires while scrolling"?

why it "it never fires while scrolling"?
jabber.developer marked this conversation as resolved
jabber.developer manually merged commit ca92d29179 into master 2026-06-24 16:23:14 +00:00
Sign in to join this conversation.
No description provided.