fix(control-panel): deduplicate the access-scope computation behind one shared helper#8453
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8453 +/- ##
==========================================
+ Coverage 79.69% 89.62% +9.92%
==========================================
Files 791 98 -693
Lines 79319 22785 -56534
Branches 23954 3903 -20051
==========================================
- Hits 63216 20420 -42796
+ Misses 13298 2187 -11111
+ Partials 2805 178 -2627
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-24 14:47:42 UTC
Review summary Nits — 4 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
Summary
buildControlPanelAccessScopeandbuildControlPanelRoleSummaryeach carried a byte-identical copy of the same access-scope computation — including the #953 suspension fix, which had to be applied twice. That's the exact structural precondition for the "fixed in one place, missed in its identical sibling" bug class, on logiccanLoginAccessRepo/canWatchReporely on for private-repo access decisions.Both now call one private
resolveAccountRepoScope(args), and the#953comment lives on that single computation instead of being duplicated.Behaviour-preserving, and one subtlety made it non-mechanical: the two
maintainerReposlines were not identical —buildControlPanelAccessScopefinishes withuniqueRepoNames, whilebuildControlPanelRoleSummaryusesuniqueRepos, which additionally appliessanitizeRoleText. So the helper returnsmaintainerRepoNamespre-deduplication and each caller applies its own finisher; deduplicating inside the helper would have silently changed one builder's output. That reasoning is recorded in the helper's doc comment so it isn't "simplified" away later.accountInstallationIds/suspendedAccountInstallationIdsstay internal to the helper — neither caller uses them beyond derivingownedInstalledRepos, so they're deliberately not in the returned shape.Nothing else changed:
canLoginAccessRepo,canWatchRepo,loadControlPanelAccessScope,loadControlPanelRoleSummary,buildStaticControlPanelRoleSummary,buildRoleCards, and the exportedRoleSummaryInputs/ControlPanelAccessScope/ControlPanelRoleSummarytypes are all untouched.Closes #8373
Test plan
test/unit/control-panel-roles.test.ts,test/unit/agent-orchestrator.test.ts,test/unit/policy-sanitizer.test.ts. Since this is a pure refactor, the existing suite passing untouched (including its [Bug]: suspending the App does not revoke control-panel access to your own repos #953 suspended-installation cases) is the correctness evidence; no new assertions were invented to describe unchanged behavioursrc/services/control-panel-roles.ts: every line and branch in this diff (lines 74-131) is covered — the file's remaining uncovered lines are its DB-loading functions (loadControlPanelAccessScope,canLoginAccessRepo), which this change does not touchnpm run typecheckclean