Repository navigation
perf(nav-panel): optimize workspace session hierarchy indexing and partitioning - #3800
Open
Raing5Days wants to merge 1 commit into
Open
Raing5Days wants to merge 1 commit into
Raing5Days wants to merge 1 commit into
Conversation
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.
## Summary
Optimize sidebar multi-workspace session hierarchy indexing and partitioning in$O(N \times M)$ linear scans, intermediate array copies, and redundant relationship normalization for normal sessions.
getWorkspaceSessionHierarchy(sessionNavHierarchy.ts), eliminatingworkspaceIds.some(...)search with a pre-indexedworkspaceIdSet(sessionOwningWorkspaceIdonly once per session candidate instead of per workspace ID..filter()andnew Set(scoped.map(...))passes by collecting candidate sessions andknownIdsin a single forward loop.resolveParentSessionId: fast-paths the vast majority of ordinary top-level normal sessions (wheresessionKind === 'normal'without parent pointers) directly toundefined, avoiding fullresolveSessionRelationshipandnormalizeSessionRelationshipheap object allocations.Type and Areas
Performance / refactoring. Web UI sidebar navigation (
src/web-ui/src/app/components/NavPanel/sections/sessions/sessionNavHierarchy.ts). No wire protocol, persisted schema, or UI contract changes.Motivation / Impact
In workspaces with extensive history (e.g. hundreds of sessions spanning multiple project roots):
Array.from(sessions).filter(...)and re-scannedworkspaceIdslinearly.With single-pass set lookup and relationship fast-pathing:
3.72 msto0.68 ms(an ~80% latency reduction, well within the 1.0 ms budget).3.72 msto1.46 ms(budget ≤ 2.5 ms).Verification
node scripts/run-vitest.mjs run --maxWorkers=50% "src/app/components/NavPanel/sections/sessions/sessionNavHierarchy.test.ts"— 4 passed (100%), covering 659-record multi-workspace hierarchy counts.node scripts/check-repo-hygiene.mjs— passed.node --test scripts/check-repo-hygiene.test.mjs— 3 passed (100%).node scripts/verify-release-version-sync.mjs— passed.node scripts/format-changed-rust.mjs— passed.git diff --check— clean.Checklist