[trees] Focus/Nav + Visible tree projection feature + performance optimizations#490
Conversation
Add createVisibleTreeProjection API with benchmark/profile scripts, public types, static-store integration, test coverage, and tree controller/view integration. Includes major performance optimizations: - Rewrite createVisibleTreeProjection: single-pass with Int32Array parent/child tracking, lazy visibleIndexByPath Map - Add DFS-based full-tree getVisibleSlice (avoids parent-walk for sibling finding) - Inline file-node materialization in DFS (~70% of rows skip directory checks) - Inline path cache + segment lookup in hot loop - Cache DirectoryChildIndex in DFS stack frame (avoid per-child Map.get) - Collapse benchmark uses preparePresortedInput to skip re-sorting - Eager name-id map building in presorted builder finish - Iterative recomputeCountsRecursive (explicit stack, -64% sub-timing) Experiments: #1–#12, #15, #20, #21 toggle_wall_ms: 877ms → 143ms (-84%) collapse_wall_ms: 4757ms → 1510ms (-68%)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 91ed9f234d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // lastRowAtDepth[d+1] stores the projection-row index of the most recent row | ||
| // at depth d. Index 0 is the virtual root. Offset by +1 so depth 0 maps to | ||
| // lastRowAtDepth[1] and the virtual root is at lastRowAtDepth[0] = -1. | ||
| const lastRowAtDepth = new Int32Array(64); |
There was a problem hiding this comment.
Handle arbitrary row depths in projection builder
The fixed Int32Array(64) depth table silently breaks projection metadata for trees deeper than 63 levels. Once row.depth >= 64, lastRowAtDepth[depth] returns undefined, so countSlot becomes NaN, posInSet becomes NaN, and parent linkage/set sizes are corrupted (e.g., parentPath falls back to null). In this commit that bad metadata now drives keyboard parent navigation and ARIA set math, so deeply nested repos will get incorrect focus behavior and invalid tree semantics.
Useful? React with 👍 / 👎.
Add phase 3 work, focus, navigation, etc.
Fix perf in collapse situations.
Meaningfully improve a11y around virtualizer for focus states i think.
Add createVisibleTreeProjection API with benchmark/profile scripts, public types, static-store integration, test coverage, and tree controller/view integration.
Includes major performance optimizations:
Experiments: #1–#12, #15, #20, #21
toggle_wall_ms: 877ms → 143ms (-84%)
collapse_wall_ms: 4757ms → 1510ms (-68%)