Repository navigation
perf(tui): render-signature redraw gate + concurrent VLAN detail - #86
Merged
Merged
Conversation
Render gate: the 180ms preview tick still drives debounce, status expiry, and
the loading spinner, but the event loop now skips `terminal.draw` when a
conservative render signature is unchanged — so idle ticks no longer rebuild
the Results table (the per-tick `Vec<Row>` clone + `format!`). The signature
(`App::render_digest`) hashes everything the renderer can put on screen plus
the terminal size; over-inclusion is deliberate (an extra redraw is harmless,
while omitting a visible field would freeze stale pixels). Masked input fields
hash their rendered bullets, never the raw token. `record_drawn` runs post-draw
so the stored signature matches an actually-clamped frame, and `ui::render`'s
only mutations are viewports + idempotent clamps, so it settles in one frame and
never oscillates. The two hashed collections (`nav_counts`, prefix-tree
collapsed set) are sorted first for a stable digest. 8 tests over `TestBackend`
cover the tick paths: idle-skip, spinner-while-loading-then-settle,
status-TTL-countdown, debounce-emits-no-redraw, async-result, keypress, resize,
and initial draw.
VLAN detail fan-out: `vlan_prefixes` and the VLAN group's scope are independent,
so fetch them with `try_join!` across all three paths (the shared
`vlan_view_by_ref`, TUI `load_detail` by-id, and `load_detail_by_ref` by-ref) —
saving a round trip when a VLAN has both, with the same view shape. The MCP vlan
test now mocks the `vlan-groups/{id}/` follow-up and asserts
`group_scope`/`group_scope_type`, so the concurrency can't silently drop the
enrichment.
status_ttl counts a transient status down but is never rendered, so hashing it forced a full redraw on every tick of the ~1.8s status window with no visible change. Drop it from render_digest — the expiry redraw still fires, since clearing the TTL empties self.status, which is hashed. This tightens the gate to its stated contract: redraw only when on-screen pixels can change. Flip render_gate_transient_status_draws_until_it_clears so intermediate ticks assert no redraw (and that the status stays visible on the last drawn frame), while the expiry tick still asserts one redraw to clear. If a future UI shows a TTL-derived value (countdown/fade), hash that derived visible value instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two independent perf wins from the ROADMAP perf-candidates list, verified together.
1. TUI render-signature redraw gate
The event loop drew on every iteration — and the always-on 180ms
PreviewTick(~5.5 Hz) meant a fullrender_home_listrebuild (Vec<Row>clone +format!) even when nothing visible changed. The loop now skipsterminal.drawwhen a conservative render signature is unchanged.App::render_digest((w,h))hashes everything the renderer can put on screen plus the terminal size. Over-inclusion is deliberate: an extra redraw is harmless, while omitting a visible field would freeze stale pixels. The two hashed collections (nav_counts, prefix-tree collapsed set) are sorted first for a stable digest.RenderGateinapp.rsstores the last drawn signature;draw_if_dirtyis generic overB: Backendso tests drive it withTestBackend.record_drawnruns post-draw, so the stored signature matches an actually-clamped frame.ui::rendermutates only viewports + idempotent clamps (x.min(bound)), so it settles in one frame and never oscillates.rendered_text()), never the raw token;cursor_pos()is hashed so arrow-key moves still redraw. Config/Filter modals feed the digest through their ownhash_render_state.status_ttlis not hashed. It counts a transient status down but is never rendered, so hashing it would redraw every tick of the ~1.8s status window with no visible change. The expiry redraw still fires — clearing the TTL emptiesself.status, which is hashed. (If a future UI shows a TTL-derived value — countdown/fade — hash that derived visible value instead.)The tick still drives debounce, status expiry, and the spinner — those paths still redraw. 8
TestBackendtests cover: idle-skip, spinner-while-loading-then-settle, transient-status (intermediate ticks don't redraw, status stays visible, expiry redraws once to clear), debounce-emits-command-no-redraw, async-result, keypress, resize, initial draw.2. VLAN detail fan-out
vlan_prefixesand the VLAN group's scope are independent, so they now run undertokio::try_join!across all three paths (sharedvlan_view_by_ref, TUIload_detailby-id,load_detail_by_refby-ref) — one fewer round trip when a VLAN has both, same view shape. Mirrors the prefix-detail fix. The MCP vlan test now mocks thevlan-groups/{id}/follow-up and assertsgroup_scope/group_scope_type, pinning that the concurrency doesn't drop the enrichment.Verification
fmtclean;clippy --all-targetsclean on--all-featuresand--no-default-features; 1134 all-features / 1039 no-default tests pass, 0 failed.VlanView::build(...)is unchanged → VLAN output is byte-identical; the gate only changes when the existing render runs, not what it produces.