[Dashboard] Share one /users/role lookup across components and plugins #11549
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.42) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 349 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.350
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #11549"
general
weight: 0.35
devin-ai-integration[bot]
Summary
Every dashboard component and plugin bundle fetched
GET /users/roleon its own — sidebar, config page, users page, workspaces, recipe hub, the jobs log download, and each plugin bundle — so a single page load sent the same request 6–9 times (up to 11 on a slow machine).This adds one shared lookup:
client.js: new session-cached, promise-dedupedgetUserRole()(plusinvalidateCurrentUserRole());getCurrentUserInfo()now derives from it, and every internal caller routes through it (sidebar, config save-check, users, workspaces, recipe hub, jobs log download).SkyDashboardPluginAPI.getContext().getUserRole()/invalidateUserRole(), so a plugin joins the page's single request instead of adding its own round trip (previously each bundle fetched independently —dashboardCacheis keyed by function source, so a per-plugin fetch could never be shared).Failure semantics: a transport failure or 5xx resolves the anonymous
'local'sentinel without caching it (the next caller retries); a 401/403 caches the sentinel like a success, so an unauthenticated session does not re-ask on every component mount.invalidateCurrentUserRole()drops both caches and is called after the users page changes a role (the viewer's own account may be the target).Test plan
Unit tests — full dashboard jest suite passes (47 suites, 527 tests), including 5 new
getUserRoletests covering concurrent-caller dedupe, invalidation, and the three failure modes:Before/after measurement —
GET /users/rolerequests per full page load, counted in the browser (Playwright request listener aroundpage.goto, waiting for the page to settle) on a local API server with plugin frontend bundles loaded, signed in as a non-admin user:| Page | Before | After |
|---|---|---|
| /dashboard/clusters | 10 | 1 |
| /dashboard/jobs | 10 | 1 |
| /dashboard/settings/config | 6 | 1 |
| /dashboard/settings/audit-log | 7 | 1 |
Functional checks in the browser after the change: non-admin correctly gated on the audit log and config pages, admin sees the config editor, jobs "Mine | All" toggle scopes correctly, users/service-account tables render, no new console errors.
🤖 Generated with Claude Code
<!-- devin-review-badge-begin -->
---
<a href="https://app.devin.ai/review/skypilot-org/skypilot/pull/11549" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->