Repository navigation
perf(renderer): reuse folder connection inference across store writes - #34800
Conversation
…read check Drop the zustand store wrapper and duplicate 1,000-repo case, and use a neutral fixture path.
The invalidation and tri-state test guards observable behavior; the getter read counter only pinned the cache implementation.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 1 minute. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
[Low impact] The optimization is limited to renderer folder-workspace ownership lookups. This appears safe to merge, with a non-blocking gap in tests for the performance benefit. Findings
SummaryReuses folder connection answers across reads with the same folder, project-group, and repository arrays.
Reviews (1) · Last reviewed commit: "test(renderer): drop folder connection r..." · Reviewed by Greptile |
| it('invalidates folder connection inference for each catalog slice and preserves tri-state answers', () => { | ||
| const key = folderWorkspaceKey('folder-workspace-1') | ||
| const state: ConnectionContextState = { | ||
| folderWorkspaces: [makeFolderWorkspace()], | ||
| projectGroups: [makeProjectGroup()], | ||
| repos: [makeRepo({ id: 'repo-1', projectGroupId: 'group-1', connectionId: 'ssh-1' })], | ||
| worktreesByRepo: {} | ||
| } | ||
| expect(getConnectionIdFromState(state, key)).toBe('ssh-1') |
There was a problem hiding this comment.
The added test would still pass if getFolderWorkspaceConnectionId called resolveFolderWorkspaceHost every time. It checks answers and changed catalogs, but not whether repeated folder lookups skip repository scans.
Add a test that counts repository reads across repeated calls and unrelated store writes, then confirms that changing a catalog triggers fresh work. This would protect the performance benefit this PR introduces.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
ELI5
Folder tab bars repeatedly search the same repositories to identify their connection. Reuse that answer until the ownership catalogs change.
What Changed
Retained folder-workspace tab strips resolve their SSH ownership on every store publication, including unrelated terminal title and editor writes. For folders with inherited ownership this repeatedly walks the folder catalog, project-group subtree, and repository list on the renderer thread. Cache the existing resolver's answer by the three immutable catalog arrays so these reads reuse their result until ownership inputs change.
Evidence
The regression test subscribes to a vanilla store and calls the production
getConnectionIdFromStateroute for two folder workspaces across 50 unrelated publications. Property getters count actual repository classifications inside host inference; the test does not replace the resolver.Both count assertions fail on the base implementation with exactly the before counts. This proves removal of repeated renderer work; it does not claim a measured end-to-end frame-time improvement.
Correctness and resource lifetime
null/ missing-or-ambiguousundefinedresults, including paired hosts' nested SSH targets.Validation
08c807b72ce, pinned base66e2d398278, disk-backedTMPDIR, background launch and two workers: 20/21 checks passed; exited 1 after 3139.7s. The unit task failed after 3126.1s with repeatedEACCES: permission denied, posix_spawnerrors for the pinned test runtime executable./tmpinode exhaustion and missing temporary modules. No source, assertion, timeout or pass-cache stamp was changed to bypass either result.Visual Proof
N/A — the rendered controls and interactions are unchanged; evidence counts eliminated computation at production selectors.
Review
Reviewed for cache invalidation, ownership, retention and meaningful-update controls. No transport or platform-specific API change. Only Linux was executed locally; cross-platform ownership cases use fixtures.
Agent skill upstream boundary
Checklist