Repository navigation
✨ feat(dashboard): Contributors sidebar pill reads online/total - #15652
Conversation
The Contributors nav item showed a bare registered count. It now shows online/total (e.g. 3/12) through the same setSidebarPairBadge pill the Governor and Overview items use, with the tooltip "N online · M registered (heartbeat within 15m)". Online is the stage tracker's presence predicate (ContributeWSHub .Presence / liveConnectionsFor): a registered contributor whose relay heartbeat landed within governor.labels.stage.presence_window, so the pill and "waiting on @x (offline 13m)" never disagree. - /api/status.contributorPool gains online + presence_window - /api/contributors rows gain online; the list sorts online first with a tokenised green/grey presence dot (.contrib-status-dot) - Contributors header shows the same N online / M registered - docs/dashboard-sections.md documents the window Fixes #15651 Signed-off-by: Andrew Anderson <andy@clubanderson.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
@clubanderson this PR is held at Failing checks:
Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path. |
check-docs-citations.py --fix after ContributorPoolStatus grew online / presence_window (#15651). Signed-off-by: Andrew Anderson <andy@clubanderson.com>
There was a problem hiding this comment.
Read against v5 HEAD. The online predicate and the pill wiring are correct; one small ordering defect contradicts the "never persisted" promise on the new field.
Finding (low): Online can be written to the profile file via the token migration.
src/pkg/dashboard/contribute_admin.go:81 sets profiles[i].Online before policy.migrate(&profiles[i], …) at :83. migrate (contribute_token_policy.go:59-65) calls saveContributorProfileTokenCAS for any profile with a RegistrationToken and zero TokenIssuedAt, and that function marshals the whole struct to <user>.json (contribute_profiles.go:361). So the first list request after upgrade that finds a legacy profile online persists "online": true (omitempty keeps the false case out). The field is then served as-is by handleContributorGet (contribute_admin.go:101-114, jsonResponse(p) from disk) with no presence recomputation, so that single-contributor endpoint reports online forever after. The comment on ContributorProfile.Online (contribute_profiles.go:233-235) says it is "filled on the list response only, never persisted". Fix: assign Online after the migrate call — next to where Active is set at :86, which already follows that order for the same reason.
Verified correct
countOnlineContributors(api_contribute.go:124-141) applies the same predicate asliveConnectionsFor(contribute_fixqueue.go:227:!pong.IsZero() && now.Sub(pong) <= window), case-insensitive on the login, withwindowfrompresenceWindow()— so the pill and the tracker's "(offline Nm)" caption cannot disagree.LastHeartbeatstakesc.muper connection underh.mu.RLock, same discipline as the existing readers.setSidebarPairBadge(knowledge.js:214) is reused unchanged;data-zeroat0/0and hidden-until-status behaviour come for free.src/docs/api-reference/contribute.mdanddashboard-misc.mdcitations were regenerated with the shifted lines, anddashboard-sections.mddescribes the new summary text.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the diff against v5 and the presence predicate it mirrors. The numerator is correctly the tracker's predicate; one small ordering slip makes the new field leak to disk.
Verified
countOnlineContributors(api_contribute.go:127-145) matchesliveConnectionsFor(contribute_fixqueue.go:227) exactly:!pong.IsZero() && now.Sub(pong) <= window, case-insensitive login, samepresenceWindow()source (contribute_fixqueue.go:166-171).LastHeartbeats(contribute_fleet.go:26-45) takesh.mu.RLockthen eachc.muin the same orderliveConnectionsFordoes, so no new lock-order risk.BuildContributorPoolStatuskeepsActiveandByRoleas before;Online/PresenceWindoware additive, so existing readers of/api/contribute/statusare unaffected.
One finding — low
contribute_admin.go:81 sets profiles[i].Online before policy.migrate(&profiles[i], …) at :83. migrate (contribute_token_policy.go:59-65) persists the profile via saveContributorProfileTokenCAS, which json.MarshalIndent(p)s the whole struct (contribute_profiles.go:365). So for any legacy profile that still triggers token migration, "online": true is written into the profile file — contradicting the field's own comment at contribute_profiles.go:233-235 ("filled on the list response only, never persisted"). The existing transient fields (Active, CurrentTask, …) are deliberately assigned after migrate at :92-96 for this reason. Impact is cosmetic (the value is recomputed on every list and never read from disk), but the fix is a one-line move: assign Online in the block at :92 alongside Active. While there, computing countOnlineContributors(profiles[i:i+1], …) per profile rebuilds the lower-cased heartbeat map once per contributor; lowering it once outside the loop would be cheaper, though at today's registry sizes it does not matter.
go test is blocked on this host; the two new Go tests read correctly against the code.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
stage 080-awaiting-merge-admission: no activity for 30m0s: merge-train:queued-behind#15637:3/9:0/0:dashboard-misc.md,dashboard-copy-inventory.md,dashboard-sections.md,hive-merge.md,+15 |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Fixes #15651
Maintainer ask: "i want to know how many contributors are 'online/total'".
What changed
#contributors-sidebar-badgenow rendersonline/total(e.g.3/12) via the samesetSidebarPairBadgerecipe Governor (3/12) and Overview (54/31) use: hidden until/api/statusanswers,data-zeroat0/0. Tooltip:N online · M registered (heartbeat within 15m).countOnlineContributorsapplies the exact predicateContributeWSHub.Presence/liveConnectionsForuses for waiting on @x (offline 13m): a registered profile whose relay's freshest pong is withingovernor.labels.stage.presence_window(default 15m, inclusive edge). NewContributeWSHub.LastHeartbeats()is the registry-wide form of that lookup./api/status.contributorPoolgainsonlineandpresence_window;/api/contributorsrows gainonline(never persisted).N online / M registered(tokenised.contrib-status-badge,.is-online); card list sorts online first (contributorsOnlineFirst), with a.contrib-status-dot.online|offlinepresence dot replacing the inline-styled dot.docs/dashboard-sections.md→ Contributors documents the window; changelog fragmentchangelog.d/added-contributors-online-total-badge.md.Tests
TestCountOnlineContributors: zero contributors, no heartbeats, all offline, window edge (inclusive), case-insensitive login, mixed, zero-time heartbeat.TestBuildContributorPoolStatusOnline: through a live hub, fresh pong online, stale pong active-but-offline,presence_window: "15m".TestSidebarPairBadgeWiringextended with the Contributors badge id/wiring;TestContributorsOnlineBadgeHelpersruns the JS helpers under node.TestDashboardSectionHelpCoverage, style ratchet, full./pkg/dashboardsuite green locally.