AAP-95973 XLAB Leaderboard achievement alert and refresh on new sync #3739
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3739"
general
weight: 0.35
kcagran
Summary
AAP-95973 Adds a "new achievements" alert to the Automation Dashboard → Leaderboards tab and makes the leaderboard data refresh automatically after each analytics sync.
New achievement alert
localStorage(awx-automation-leaderboards-acknowledged-achievements:<userId>). User and org achievements are stored asuser:<id>/org:<id>.storageevent).isLiveRegion), so screen readers announce it.Leaderboard refresh on sync
[url, lastSyncedAt], so the report is refetched as soon ascollection_status(already polled every 10 s) reports a newlast_sync.keepPreviousDatakeeps the current report on screen while the new one loads, so the page does not flash back to the loading state.collection_statusalready handles a failed poll; SWR keeps retrying in the background.useAutomationDashboardCollectionStatusnow also returnsisRequestLoading(thecollection_statusrequest only, without waiting for the user's role). The report request waits only for that, not for/me/.Files
common/useNewAchievementsAlert.ts,utils/persistedAchievementState.ts(+ tests)AutomationLeaderboards.tsx,views/useAutomationLeaderboardsView.ts,common/useAutomationDashboardCollectionStatus.tsx(+ tests)frontend/awx/main/useAwxNavigation.test.tsx: mock updated with the newisRequestLoadingfield.Type of Change
Risk Analysis - REQUIRED
Changes are limited to the Automation Dashboard Leaderboards tab. The only shared piece,
useAutomationDashboardCollectionStatus, gains one additive return field; its existing fields and behavior are unchanged.Dependencies
None.
Testing
Ephemeral E2E Tests
Once PR is ready and preliminary checks pass, trigger tests by posting a comment
/run-playwrighton this PR.Unit Tests
useNewAchievementsAlert.test.tscovers: first visit, user and org achievements, dismiss, a new achievement after dismiss, lost and re-earned, no change while loading or after an error, unknown user, per-user isolation, user switch, storage only written on change, and dismiss in another tab.persistedAchievementState.test.tscovers: read/write round trip, per-user keys, malformed payloads, and storage errors.useAutomationLeaderboardsView.test.tsxcovers: refetch on a newlast_sync, no refetch on the samelast_sync, the timestamp matching the shown report, a failed refetch keeping the report, and not waiting for the user role.AutomationLeaderboards.test.tsxcovers: alert shown and dismissed, live region, and no alert in the empty state.Manual Testing
Setup: Log in as a user who has at least one earned achievement (user or organization) and open Analytics → Automation Dashboard → Leaderboards.
1. First visit: Clear the
awx-automation-leaderboards-acknowledged-achievements:<userId>key in DevTools → Application → Local Storage and reload. The success alert "Congratulations! You or your organization earned new achievements." is shown above the sync timestamp.2. Dismiss: Close the alert with the ✕ button. Reload the page and switch tabs (Dashboard ↔ Leaderboards); the alert stays hidden. The localStorage key now lists the earned achievements (e.g.
["user:centurion","org:topTier"]).3. New achievement: Earn a new achievement (or remove one key from the stored list in localStorage and wait for the next sync). The alert appears again.
4. Lost and re-earned achievement: When an achievement disappears from the report, it is removed from the stored list on the next response. When it is earned again, the alert appears again.
5. Multiple browser tabs: Open Leaderboards in two tabs while the alert is shown. Dismiss it in one; it also disappears in the other.
6. Refresh on sync: Keep the Leaderboards tab open until the next analytics sync. Within ~10 s of the new sync the "Updated:" timestamp and the leaderboard data both refresh. In the Network tab, a
dashboard_reports/leaderboard/request follows thecollection_statusresponse with the newlast_sync. No loading spinner is shown during the refresh.7. No achievements: Log in as a user with no earned achievements; no alert is shown.
8. Accessibility: With a screen reader, the alert is announced when it appears, and the close button is reachable by keyboard.
Screenshots
<!-- Add a screenshot of the Leaderboards tab with the alert shown. -->
<img width="1959" height="763" alt="image" src="https://github.com/user-attachments/assets/e36be082-9938-42b5-ac29-73b47c06b59a" />