feat(tui): incremental rendering for expand/collapse and scroll#1424
Merged
SorraTheOrc merged 2 commits intomainfrom Apr 7, 2026
Merged
Conversation
Agent-Logs-Url: https://github.com/TheWizardsCode/ContextHub/sessions/22d5cb68-d777-405b-94b9-e79616f11e1b Co-authored-by: SorraTheOrc <250240+SorraTheOrc@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Prototype incremental rendering to reduce TUI latency
feat(tui): incremental rendering for expand/collapse and scroll
Apr 7, 2026
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.
The TUI rebuilds the entire visible-node tree on every expand/collapse and scroll event, causing measurable lag and occasional full event-loop lockups.
Core: visible-node cache (
src/tui/state.ts)cachedVisibleNodes: VisibleNode[] | nulltoTuiStaterebuildTreeState()invalidates the cache;buildVisibleNodes()populates it after a full traversalincrementalExpand(state, nodeIdx)— splices only the newly-visible subtree into the cache (O(subtree) instead of O(total))incrementalCollapse(state, nodeIdx)— removes the descendant block from the cache by index scan, no traversal neededbuildVisibleNodes()when the cache is staleController wiring (
src/tui/controller.ts)buildVisible()changed tostate.cachedVisibleNodes ?? buildVisibleNodes(state)— scroll and navigation are now O(1) lookupsKEY_TOGGLE_EXPAND,KEY_NAV_RIGHT,KEY_NAV_LEFThandlers use the incremental functions instead of mutatingstate.expandeddirectly and triggering a full rebuildupdateListSelection(scroll/navigate handler) now emitsscrollperf events intoperfMetricswhen--perfis enabledTests (
tests/tui/incremental-rendering.test.ts)incrementalExpand/incrementalCollapsecovering: no-children guard, already-expanded guard, stale-cache fallback, multi-level nesting, depth-based descendant removalWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/graphql/usr/bin/gh gh issue create --repo TheWizardsCode/ContextHub --title Sample --body-file -(http block)/usr/bin/gh gh issue create --repo TheWizardsCode/ContextHub --title Sample --body-file - les s s i/mo�� commit rktree-xia8cN/wt-q i/mock-bin/bash po/.worklog/tmp-bash -q nfig/composer/vecommit git(http block)If you need me to access, download, or install something from one of these locations, you can either: