Skip to content

✨ feat(dashboard): Contributors sidebar pill reads online/total - #15652

Merged
hivecommons-hive[bot] merged 2 commits into
v5from
feat/contributors-online-badge
Oct 30, 2026
Merged

hivecommons-hive[bot] merged 2 commits into
v5from
feat/contributors-online-badge

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Fixes #15651

Maintainer ask: "i want to know how many contributors are 'online/total'".

What changed

  • Sidebar: #contributors-sidebar-badge now renders online/total (e.g. 3/12) via the same setSidebarPairBadge recipe Governor (3/12) and Overview (54/31) use: hidden until /api/status answers, data-zero at 0/0. Tooltip: N online · M registered (heartbeat within 15m).
  • Online definition (shared with the tracker): countOnlineContributors applies the exact predicate ContributeWSHub.Presence / liveConnectionsFor uses for waiting on @x (offline 13m): a registered profile whose relay's freshest pong is within governor.labels.stage.presence_window (default 15m, inclusive edge). New ContributeWSHub.LastHeartbeats() is the registry-wide form of that lookup.
  • Payload: /api/status.contributorPool gains online and presence_window; /api/contributors rows gain online (never persisted).
  • Contributors page: header shows N online / M registered (tokenised .contrib-status-badge, .is-online); card list sorts online first (contributorsOnlineFirst), with a .contrib-status-dot.online|offline presence dot replacing the inline-styled dot.
  • Docs: docs/dashboard-sections.md → Contributors documents the window; changelog fragment changelog.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".
  • TestSidebarPairBadgeWiring extended with the Contributors badge id/wiring; TestContributorsOnlineBadgeHelpers runs the JS helpers under node.
  • TestDashboardSectionHelpCoverage, style ratchet, full ./pkg/dashboard suite green locally.

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>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 30, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 30, 2026
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#15633 🌱 refactor: split stage tracker UI tests same files src/pkg/dashboard/static/index.html
#15664 🐛 tracker: a PR waiting on its author never leads with Close as superseded same files src/pkg/dashboard/static/index.html
#15658 🐛 fix(tracker): PRs at CI / Review ride no merge train; overlap hint instead same files src/docs/api-reference/dashboard-misc.md
src/docs/dashboard-sections.md
src/pkg/dashboard/static/index.html
#15668 🐛 Lead 090 merge-gate action is Approve and let hive merge same files src/docs/dashboard-sections.md
src/pkg/dashboard/static/index.html
#15637 📖 community: list the Twitch live stream everywhere community links live same files src/pkg/dashboard/static-src/html/sidebar.html
src/pkg/dashboard/static/index.html
#15530 🐛 fix(dashboard): issue-row linked PR passes null when the lineage chip is empty same files src/pkg/dashboard/static/index.html
#15566 🌱 refactor: split stage tracker UI tests same files src/pkg/dashboard/static/index.html
#15526 🌱 dashboard: split stage_tracker.go into 4 files same files src/docs/dashboard-sections.md
#15669 ✨ Stream the tracker's sounds on the Activity Monitor Twitch stream same files src/pkg/dashboard/static/index.html
#15657 🐛 Tracker: chevron column follows the current state, never the highest stage reached same files src/docs/api-reference/dashboard-misc.md
src/docs/dashboard-sections.md
src/pkg/dashboard/static/index.html

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@clubanderson this PR is held at stage/071-needs-author and the hive will not merge it yet.

Failing checks:

  • relative links and anchors resolve

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>

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 as liveConnectionsFor (contribute_fixqueue.go:227: !pong.IsZero() && now.Sub(pong) <= window), case-insensitive on the login, with window from presenceWindow() — so the pill and the tracker's "(offline Nm)" caption cannot disagree. LastHeartbeats takes c.mu per connection under h.mu.RLock, same discipline as the existing readers.
  • setSidebarPairBadge (knowledge.js:214) is reused unchanged; data-zero at 0/0 and hidden-until-status behaviour come for free.
  • src/docs/api-reference/contribute.md and dashboard-misc.md citations were regenerated with the shifted lines, and dashboard-sections.md describes the new summary text.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) matches liveConnectionsFor (contribute_fixqueue.go:227) exactly: !pong.IsZero() && now.Sub(pong) <= window, case-insensitive login, same presenceWindow() source (contribute_fixqueue.go:166-171). LastHeartbeats (contribute_fleet.go:26-45) takes h.mu.RLock then each c.mu in the same order liveConnectionsFor does, so no new lock-order risk.
  • BuildContributorPoolStatus keeps Active and ByRole as before; Online/PresenceWindow are additive, so existing readers of /api/contribute/status are 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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

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

@hivecommons-hive
hivecommons-hive Bot merged commit 25cd580 into v5 Oct 30, 2026
76 of 77 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the feat/contributors-online-badge branch October 30, 2026 04:25
@hivecommons-hive

Copy link
Copy Markdown
Contributor
Evidence bundle `#15652c12fe13` sha256:40c3802081a0a0109ed33747a8698f3de1df3ae991efe10fc640b078bb3b9332 — download from the dashboard or `hivectl review evidence #15652`.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sidebar Contributors badge should read online/total like Governor and Overview

1 participant