Skip to content

fix(browse): revert BROWSE_CAP 1000 → 500 - #82

Merged
lance0 merged 1 commit into
masterfrom
fix/browse-cap-revert-to-500
Jun 25, 2026
Merged

lance0 merged 1 commit into
masterfrom
fix/browse-cap-revert-to-500

Conversation

@lance0

@lance0 lance0 commented Jun 25, 2026

Copy link
Copy Markdown
Owner

What

Reverts the Nav-rail browse cap from 1000 back to 500 (0.11.0 raised it 500 → 1000).

Why

The 0.11.0 bump's rationale was network-only: "1000 = NetBox's per-request MAX_PAGE_SIZE ceiling, so a cap-full browse is still one round trip." Correct, but one-sided — it ignored the render side:

  • The TUI event loop calls terminal.draw at the top of every iteration; the 180ms PreviewTick is always arriving → render fires ~5.5 Hz while idle.
  • render_home_list builds the full Vec<Row> via .map(...).collect() over the whole list up to the cap on every draw (not cached, not windowed).
  • At 1000 that's 2× the 500 cost, always-on, for rows no one reads — past a few hundred, the filter narrows, not the cap.

500 is still a single round trip (500 ≤ MAX_PAGE_SIZE 1000), so the network cost is identical. The cap encodes the principle durably — the filter is the escape hatch, not a bigger cap — so it doesn't drift back up.

Independent of the dirty-flag decision

The ROADMAP's TUI render dirty-flag fix would eliminate idle rebuilds for all list sizes — but it does not argue for keeping 1000. Every actual change (keypress, result arrival) still rebuilds the full list, and at 1000 that's 2× the 500 cost at those moments. So 500 is the right cap regardless; the dirty-flag is a separate, scheduled, additive win (ROADMAP: medium, battery/SSH not latency).

Change

One-line const: pub const BROWSE_CAP: usize = 1000 → 500, with an expanded rationale comment. Downstream auto-adapts:

  • The 1000+/500+ truncation cue reads the const (ui.rs if n >= BROWSE_CAP { format!("{}+", BROWSE_CAP) }) → badge now reads 500+.
  • cap_sized_browse_is_one_round_trip reads the const (let n = BROWSE_CAP) → now mocks limit=500, passes unchanged.

Verification

  • Gate: fmt --check, clippy --all-targets --all-features -- -D warnings, test --all-features (1107 pass), test --no-default-features (1012 pass) — all green, counts unchanged.
  • Targeted: cap_sized_browse_is_one_round_trip adapted and passed.
  • Live: search/browse paths return 200 against the 4.6.2 box.
  • The literal-1000 pagination tests call list_all(.., 1000) directly (testing the paging mechanism with an arbitrary max), not browse/BROWSE_CAP — untouched.

Docs

  • CHANGELOG.md [Unreleased] → ### Changed entry (revert + rationale + dirty-flag independence note).
  • ROADMAP.md perf-candidates section: 1000-row Vec<Row> → 500 rows post-revert, was 1000.
  • The 0.11.0 release line is left immutable (historical fact; the revert is documented in [Unreleased]).

Files

  • src/netbox/browse.rs — const 1000 → 500 + rationale comment.
  • CHANGELOG.md, ROADMAP.md — doc updates.

0.11.0 raised the Nav-rail browse cap 500 → 1000. The rationale was
network-only ("1000 = NetBox's per-request ceiling, so a cap-full browse is
still one round trip"), which was correct but one-sided — it ignored the
render side. The TUI's event loop calls terminal.draw at the top of every
iteration, and the 180ms PreviewTick is always arriving, so render fires
~5.5 Hz while idle; render_home_list builds the full Vec<Row> via
.map(...).collect() over the whole list up to the cap on every draw (not
cached, not windowed). 1000 doubled that idle rebuild cost for rows no one
reads: past a few hundred, the filter narrows, not the cap.

Revert to 500. It's still a single round trip (500 <= MAX_PAGE_SIZE 1000), so
the network cost is identical. The cap encodes the principle durably in code
— the filter is the escape hatch, not a bigger cap — so it doesn't drift back
up. The list-count badge reads 500+ when capped (the cue reads the const).

This does NOT depend on the render-dirty-flag decision: that flag eliminates
idle rebuilds for all list sizes, but every actual change (keypress, result
arrival) still rebuilds the full list, and at 1000 that's 2x the 500 cost at
those moments. So 500 is the right cap regardless; the dirty-flag is a
separate, scheduled, additive win (ROADMAP: medium, battery/SSH not latency).

Verified: gate green (1107 all-features / 1012 no-default-features, clippy -D
warnings, fmt); cap_sized_browse_is_one_round_trip adapted (reads BROWSE_CAP,
now mocks limit=500); live search/browse paths return 200. The 1000+/500+ cue
and the cap-coupled test both read the const, so the revert is a 1-line const
change with auto-adapting downstream.

CHANGELOG [Unreleased] + ROADMAP perf-candidates section updated (1000-row
-> 500 rows post-revert). The 0.11.0 release line is left immutable
(historical fact: 0.11.0 did raise it; the revert is documented in [Unreleased]).
@lance0
lance0 merged commit 64cc8dc into master Jun 25, 2026
4 checks passed
@lance0
lance0 deleted the fix/browse-cap-revert-to-500 branch June 25, 2026 00:31
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