diff --git a/changelog.d/added-contributor-pill-online-ids.md b/changelog.d/added-contributor-pill-online-ids.md new file mode 100644 index 0000000000..4cc69e3ad2 --- /dev/null +++ b/changelog.d/added-contributor-pill-online-ids.md @@ -0,0 +1 @@ +- Show online ClankeR contributor IDs vertically in the Contributors sidebar count pill's hover and keyboard-focus tooltip. diff --git a/dashboard/test/config-tooltip.test.js b/dashboard/test/config-tooltip.test.js index 891fea35d6..cdce459843 100644 --- a/dashboard/test/config-tooltip.test.js +++ b/dashboard/test/config-tooltip.test.js @@ -72,6 +72,12 @@ class FakeElement { while (n.parentNode) n = n.parentNode; return n.isRoot === true; } + get textContent() { return this._textContent || ''; } + set textContent(value) { + this._textContent = String(value); + for (const child of this.children) child.parentNode = null; + this.children = []; + } get classList() { const self = this; return { @@ -86,8 +92,8 @@ class FakeElement { return false; } closest(selector) { - const cls = selector.replace(/^\./, ''); - for (let n = this; n; n = n.parentNode) if (n.classList && n.classList.contains(cls)) return n; + const classes = selector.split(',').map(s => s.trim().replace(/^\./, '')); + for (let n = this; n; n = n.parentNode) if (n.classList && classes.some(cls => n.classList.contains(cls))) return n; return null; } querySelector(selector) { @@ -157,8 +163,15 @@ function harness() { 'let _configTooltipOpenTimer = 0;', 'let _configTooltipCloseTimer = 0;', ...HELPER_FUNCTIONS.map(extractFunction), + ...['esc', 'sidebarPairBadgeText', 'setSidebarPairBadge', 'contributorsOnlineTitle', 'contributorsOnlineTooltip', 'updateContributorBadge'].map(extractFunction), + extractConst('NAV_COUNT_CUE_MS'), + 'const _navCountDeltas = new Map();', + extractFunction('navCountDelta'), + 'let _cachedContributors = [];', + 'function refreshSectionCardShell() {} function setSectionSummary() {} function contributorsSectionSummary() {}', extractListeners(), ...HELPER_FUNCTIONS.map(n => `exports.${n} = ${n};`), + 'exports.updateContributorBadge = updateContributorBadge;', 'exports.openDelay = CONFIG_TOOLTIP_OPEN_DELAY_MS; exports.closeGrace = CONFIG_TOOLTIP_CLOSE_GRACE_MS;', ].join('\n'); vm.runInNewContext(source, context); @@ -316,6 +329,17 @@ test('clicking inside the popover does not hide it', () => { assert.equal(h.isOpen(), true); }); +test('scrolling a long online ID list keeps the tooltip open, page scrolling still dismisses it', () => { + const h = harness(); + const pill = makeTrigger(h.root, 'contributors'); + pill.className = 'contributor-online-trigger'; + h.fire('document', 'focusin', pill); + h.fire('window', 'scroll', h.portal()); + assert.equal(h.isOpen(), true); + h.fire('window', 'scroll', h.root); + assert.equal(h.isOpen(), false); +}); + test('Escape dismissal and modal-open hooks are wired to the shared helper', () => { const dismiss = extractFunction('hiveDismissTopOverlay'); assert.match(dismiss, /configTooltipIsOpen\(\)/); @@ -329,3 +353,50 @@ test('Escape dismissal and modal-open hooks are wired to the shared helper', () test('portal stylesheet hides the portal when the hidden attribute is set', () => { assert.match(indexHtml, /\.config-tooltip-portal\[hidden\] \{ display: none; \}/); }); + +test('Contributors tooltip targets the count pill and supports focus without changing navigation or pill styling', () => { + const badge = indexHtml.match(/]+>/)[0]; + assert.match(badge, /class="badge-count oc-nav-count contributor-online-trigger"/); + assert.match(badge, /tabindex="0" role="link"/); + assert.match(badge, /data-keydown-action="ocNavigate" data-arg0="contributors-section"/); + assert.match(indexHtml, /data-action="ocNavigate" data-arg0="contributors-section">๐Ÿ‘ฅ/); + assert.match(indexHtml, /\.contributor-online-ids li \{ display: block; \}/, 'one ID per line'); + + const h = harness(); + const pill = new FakeElement('span', 'badge-count oc-nav-count contributor-online-trigger'); + pill.id = 'contributors-sidebar-badge'; + h.root.appendChild(pill); + h.api.updateContributorBadge({ online: 2, registered: 4, presence_window: '15m', online_ids: ['clanker-a', 'clanker-b'] }); + assert.equal(pill.textContent, '2/4'); + assert.equal(pill.getAttribute('title'), null, 'no duplicate browser-native title'); + assert.match(pill.getAttribute('aria-label'), /2 online ยท 4 registered/); + h.fire('document', 'focusin', pill); + assert.equal(h.isOpen(), true); + assert.match(h.portal().innerHTML, /
  • clanker-a<\/li>
  • clanker-b<\/li>/); + + h.api.updateContributorBadge({ online: 1, registered: 4, online_ids: ['clanker-reconnected'] }); + assert.equal(pill.textContent, '1/4'); + assert.match(h.portal().innerHTML, /
  • clanker-reconnected<\/li>/); + assert.doesNotMatch(h.portal().innerHTML, /clanker-a|clanker-b/); + + h.api.updateContributorBadge({ online: 0, registered: 4, online_ids: [] }); + assert.equal(pill.textContent, '0/4'); + assert.match(h.portal().innerHTML, /No ClankeRs online/); + h.api.hideConfigTooltip(); + h.fire('document', 'mouseover', pill); + h.advance(h.api.openDelay); + assert.equal(h.isOpen(), true, 'same pill also opens on hover'); +}); + +test('Contributors tooltip escapes IDs and distinguishes unavailable IDs from no online ClankeRs', () => { + const context = {}; + vm.runInNewContext(['esc', 'contributorsOnlineTitle', 'contributorsOnlineTooltip'].map(extractFunction).join('\n'), context); + const html = context.contributorsOnlineTooltip({ online: 1, registered: 2, online_ids: ['&'] }); + assert.match(html, /
  • <img src=x onerror="bad">&<\/li>/); + assert.doesNotMatch(html, /.svg`). | `pkg/dashboard/social_cards.go:112` | | `GET` | `/api/cards/achievement/{login}/{asset}` | Public | OpenAPI alias for a cacheable attained-achievement SVG (`asset` is `.svg`). | `pkg/dashboard/social_cards.go:113` | | `GET` | `/api/cards/leaderboard/{asset}` | Public | OpenAPI alias for a cacheable leaderboard-summary SVG (`contributors.svg`, `teams.svg`, or `swarm.svg`). | `pkg/dashboard/social_cards.go:114` | @@ -58,10 +58,10 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f | `GET` | `/share/player/{login}` | Public | Share landing page with Open Graph/Twitter metadata for a contributor card and link to the public dossier. | `pkg/dashboard/social_cards.go:115` | | `GET` | `/share/achievement/{login}/{achievementID}` | Public | Share landing page with metadata for an unlocked achievement card and link to the public dossier. | `pkg/dashboard/social_cards.go:116` | | `GET` | `/share/leaderboard/{board}` | Public | Share landing page with metadata for a public leaderboard card and link to live standings. | `pkg/dashboard/social_cards.go:117` | -| `PUT` | `/api/contribute/help-links` | Owner/read-write | Contribute Help Links | `pkg/dashboard/api_contribute.go:217` | -| `GET` | `/api/contribute/operators/message` | Public path; caller identity resolved server-side (401 anonymous, 403 without a profile) | Returns only the signed-in contributor's unacknowledged operator messages; no username/body field can select another recipient ([#8461](https://github.com/hivecommons/hive/issues/8461)). | `pkg/dashboard/api_contribute.go:252` | -| `POST` | `/api/contribute/operators/message` | Owner/read-write | Sends a sanitized, length-capped one-to-one operator note to a contributor profile, persists it until acknowledgement, and pushes it to matching live relay sockets only ([#8461](https://github.com/hivecommons/hive/issues/8461)). | `pkg/dashboard/api_contribute.go:253` | -| `POST` | `/api/contribute/operators/message/ack` | Public path; caller identity resolved server-side | Acknowledges the signed-in contributor's own message, optionally recording a short sanitized reply for operators. | `pkg/dashboard/api_contribute.go:254` | +| `PUT` | `/api/contribute/help-links` | Owner/read-write | Contribute Help Links | `pkg/dashboard/api_contribute.go:226` | +| `GET` | `/api/contribute/operators/message` | Public path; caller identity resolved server-side (401 anonymous, 403 without a profile) | Returns only the signed-in contributor's unacknowledged operator messages; no username/body field can select another recipient ([#8461](https://github.com/hivecommons/hive/issues/8461)). | `pkg/dashboard/api_contribute.go:261` | +| `POST` | `/api/contribute/operators/message` | Owner/read-write | Sends a sanitized, length-capped one-to-one operator note to a contributor profile, persists it until acknowledgement, and pushes it to matching live relay sockets only ([#8461](https://github.com/hivecommons/hive/issues/8461)). | `pkg/dashboard/api_contribute.go:262` | +| `POST` | `/api/contribute/operators/message/ack` | Public path; caller identity resolved server-side | Acknowledges the signed-in contributor's own message, optionally recording a short sanitized reply for operators. | `pkg/dashboard/api_contribute.go:263` | ### Issue claims (hivecommons/hive#8380) diff --git a/src/docs/api-reference/dashboard-misc.md b/src/docs/api-reference/dashboard-misc.md index 59e1fe61a8..d5691c9556 100644 --- a/src/docs/api-reference/dashboard-misc.md +++ b/src/docs/api-reference/dashboard-misc.md @@ -47,21 +47,21 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f | `PUT` | `/api/hive-id` | Owner only | Hive IDSet | `pkg/dashboard/api.go:431` | | `POST` | `/api/chat` | Dashboard auth/session | Chat | `pkg/dashboard/api.go:460` | | `GET` | `/api/auth/token` | Public | Auth Token | `pkg/dashboard/api.go:494` | -| `GET` | `/api/v1/` | GitHub token | Contributor v1 API dispatcher | `pkg/dashboard/api_contribute.go:310` | -| `POST` | `/api/v1/` | GitHub token | Contributor v1 API dispatcher | `pkg/dashboard/api_contribute.go:311` | -| `GET` | `/api/docs` | Dashboard auth/session | APIDocs | `pkg/dashboard/api_contribute.go:312` | -| `GET` | `/leaderboard` | Public | Leaderboard Page | `pkg/dashboard/api_contribute.go:314` | -| `GET` | `/api/leaderboard` | Public | Leaderboard API | `pkg/dashboard/api_contribute.go:315` | -| `GET` | `/api/leaderboard/teams` | Public | Team Leaderboards | `pkg/dashboard/api_contribute.go:316` | -| `GET` | `/api/leaderboard/style` | Public | Leaderboard Style | `pkg/dashboard/api_contribute.go:317` | +| `GET` | `/api/v1/` | GitHub token | Contributor v1 API dispatcher | `pkg/dashboard/api_contribute.go:319` | +| `POST` | `/api/v1/` | GitHub token | Contributor v1 API dispatcher | `pkg/dashboard/api_contribute.go:320` | +| `GET` | `/api/docs` | Dashboard auth/session | APIDocs | `pkg/dashboard/api_contribute.go:321` | +| `GET` | `/leaderboard` | Public | Leaderboard Page | `pkg/dashboard/api_contribute.go:323` | +| `GET` | `/api/leaderboard` | Public | Leaderboard API | `pkg/dashboard/api_contribute.go:324` | +| `GET` | `/api/leaderboard/teams` | Public | Team Leaderboards | `pkg/dashboard/api_contribute.go:325` | +| `GET` | `/api/leaderboard/style` | Public | Leaderboard Style | `pkg/dashboard/api_contribute.go:326` | | `GET` | `/api/leaderboard/battle-log` | Public | Scrubbed public Battle Log activity feed for leaderboard widgets. | `pkg/dashboard/battle_log.go:108` | | `GET` | `/api/leaderboard/hive-of-week` | Public | Featured weekly project metadata, configured render URLs (empty when none), gource source URL, and embed snippets. | `pkg/dashboard/battle_log.go:109` | | `GET` | `/api/leaderboard/gource-log` | Public | Gource custom log source for a project/week, derived from public hive event data. | `pkg/dashboard/battle_log.go:110` | | `POST` | `/api/leaderboard/hive-of-week/archive` | Owner only | Archive the selected project's weekly gource source log into knowledge; stores source only, never rendered video. | `pkg/dashboard/battle_log.go:111` | -| `GET` | `/api/leaderboard/contributor/{username}` | Public | Contributor Profile | `pkg/dashboard/api_contribute.go:324` | -| `GET` | `/api/hives` | Dashboard auth/session | Hives List | `pkg/dashboard/api_contribute.go:335` | -| `POST` | `/api/hives/register` | Dashboard auth/session | Hives Register | `pkg/dashboard/api_contribute.go:336` | -| `POST` | `/api/hives/{id}/heartbeat` | Dashboard auth/session | Hives Heartbeat | `pkg/dashboard/api_contribute.go:337` | -| `DELETE` | `/api/hives/{id}` | Owner only | Hives Delete | `pkg/dashboard/api_contribute.go:338` | -| `POST` | `/api/hives/onboard` | Dashboard auth/session | Hives Onboard | `pkg/dashboard/api_contribute.go:339` | +| `GET` | `/api/leaderboard/contributor/{username}` | Public | Contributor Profile | `pkg/dashboard/api_contribute.go:333` | +| `GET` | `/api/hives` | Dashboard auth/session | Hives List | `pkg/dashboard/api_contribute.go:344` | +| `POST` | `/api/hives/register` | Dashboard auth/session | Hives Register | `pkg/dashboard/api_contribute.go:345` | +| `POST` | `/api/hives/{id}/heartbeat` | Dashboard auth/session | Hives Heartbeat | `pkg/dashboard/api_contribute.go:346` | +| `DELETE` | `/api/hives/{id}` | Owner only | Hives Delete | `pkg/dashboard/api_contribute.go:347` | +| `POST` | `/api/hives/onboard` | Dashboard auth/session | Hives Onboard | `pkg/dashboard/api_contribute.go:348` | | `GET` | `/sso` | Public | SSO | `pkg/dashboard/server.go:1663` | diff --git a/src/pkg/dashboard/api_contribute.go b/src/pkg/dashboard/api_contribute.go index 454b2bd011..436e6cf7f1 100644 --- a/src/pkg/dashboard/api_contribute.go +++ b/src/pkg/dashboard/api_contribute.go @@ -94,6 +94,8 @@ type ContributorPoolStatus struct { Active int `json:"active"` Online int `json:"online"` Registered int `json:"registered"` + // OnlineIDs contains the ClankeR contributor IDs counted by Online. + OnlineIDs []string `json:"online_ids"` // PresenceWindow is the window Online was judged against ("15m"). PresenceWindow string `json:"presence_window"` ByRole map[string]int `json:"by_role,omitempty"` @@ -105,21 +107,23 @@ type ContributorPoolStatus struct { func (s *Server) BuildContributorPoolStatus() *ContributorPoolStatus { profiles := listContributorProfiles() - active, online := 0, 0 + active := 0 + onlineIDs := []string{} var byRole map[string]int window := config.DefaultPresenceWindow if s.contributeHub != nil { active = s.contributeHub.ActiveCount() byRole = s.contributeHub.RoleBreakdown() window = s.contributeHub.presenceWindow() - online = countOnlineContributors(profiles, s.contributeHub.LastHeartbeats(), window, time.Now()) + onlineIDs = onlineContributorIDs(profiles, s.contributeHub.LastHeartbeats(), window, time.Now()) } abandoned, abandonedByLogin := contributorAbandonedCounts(profiles) return &ContributorPoolStatus{ Abandoned: abandoned, AbandonedByLogin: abandonedByLogin, Active: active, - Online: online, + Online: len(onlineIDs), + OnlineIDs: onlineIDs, Registered: len(profiles), PresenceWindow: stageTrackerShortDuration(window), ByRole: byRole, @@ -149,21 +153,26 @@ func contributorAbandonedCounts(profiles []ContributorProfile) (int, map[string] // a heartbeat landing exactly at the window edge still counts, as in // liveConnectionsFor. func countOnlineContributors(profiles []ContributorProfile, lastSeen map[string]time.Time, window time.Duration, now time.Time) int { + return len(onlineContributorIDs(profiles, lastSeen, window, now)) +} + +func onlineContributorIDs(profiles []ContributorProfile, lastSeen map[string]time.Time, window time.Duration, now time.Time) []string { + ids := []string{} if len(profiles) == 0 || len(lastSeen) == 0 { - return 0 + return ids } byUser := make(map[string]time.Time, len(lastSeen)) for user, t := range lastSeen { byUser[strings.ToLower(strings.TrimSpace(user))] = t } - n := 0 for _, p := range profiles { t, ok := byUser[strings.ToLower(strings.TrimSpace(p.GitHubUsername))] if ok && !t.IsZero() && now.Sub(t) <= window { - n++ + ids = append(ids, p.ContributorID) } } - return n + sort.Strings(ids) + return ids } func (s *Server) registerContributeRoutes() { diff --git a/src/pkg/dashboard/contributor_pool_online_test.go b/src/pkg/dashboard/contributor_pool_online_test.go index 9162bceaf5..1c15005902 100644 --- a/src/pkg/dashboard/contributor_pool_online_test.go +++ b/src/pkg/dashboard/contributor_pool_online_test.go @@ -1,6 +1,8 @@ package dashboard import ( + "encoding/json" + "reflect" "testing" "time" ) @@ -73,4 +75,48 @@ func TestBuildContributorPoolStatusOnline(t *testing.T) { if got.PresenceWindow != "15m" { t.Fatalf("presence_window = %q, want 15m", got.PresenceWindow) } + if !reflect.DeepEqual(got.OnlineIDs, []string{"id-fresh"}) { + t.Fatalf("online IDs = %v, want only id-fresh", got.OnlineIDs) + } + + // A second session for the same contributor does not add another row. + hub.connections["c3"] = &ContributorConnection{connID: "c3", profile: &ContributorProfile{ContributorID: "id-fresh", GitHubUsername: "fresh"}, lastPong: time.Now()} + assertPool := func(want []string) { + t.Helper() + pool := s.BuildContributorPoolStatus() + if !reflect.DeepEqual(pool.OnlineIDs, want) || pool.Online != len(want) || pool.Registered != 3 { + t.Fatalf("online IDs/count = %v/%d, registered %d; want %v/%d, registered 3", pool.OnlineIDs, pool.Online, pool.Registered, want, len(want)) + } + } + assertPool([]string{"id-fresh"}) + delete(hub.connections, "c1") + assertPool([]string{"id-fresh"}) + delete(hub.connections, "c3") + assertPool([]string{}) + hub.connections["c2"].lastPong = time.Now() + assertPool([]string{"id-stale"}) + + // The zero-state is an explicit array, not unavailable/null. + empty := (&Server{}).BuildContributorPoolStatus() + data, err := json.Marshal(empty) + if err != nil { + t.Fatal(err) + } + var payload map[string]json.RawMessage + if err := json.Unmarshal(data, &payload); err != nil || string(payload["online_ids"]) != "[]" { + t.Fatalf("empty pool must encode online_ids: [], got %s (%v)", data, err) + } +} + +func TestOnlineContributorIDs(t *testing.T) { + now := time.Now() + profiles := []ContributorProfile{ + {ContributorID: "clanker-z", GitHubUsername: "Zed"}, + {ContributorID: "clanker-a", GitHubUsername: "Amy"}, + {ContributorID: "clanker-offline", GitHubUsername: "Offline"}, + } + seen := map[string]time.Time{"zed": now, "amy": now.Add(-15 * time.Minute), "offline": now.Add(-16 * time.Minute), "unknown": now} + if got, want := onlineContributorIDs(profiles, seen, 15*time.Minute, now), []string{"clanker-a", "clanker-z"}; !reflect.DeepEqual(got, want) { + t.Fatalf("online IDs = %v, want %v (not GitHub usernames or unknown/offline relays)", got, want) + } } diff --git a/src/pkg/dashboard/modal_tooltip_regression_test.go b/src/pkg/dashboard/modal_tooltip_regression_test.go index a6018c1c3a..5bcb6070be 100644 --- a/src/pkg/dashboard/modal_tooltip_regression_test.go +++ b/src/pkg/dashboard/modal_tooltip_regression_test.go @@ -90,7 +90,7 @@ func TestHelpTooltipsUseBodyFixedPortal11269(t *testing.T) { "portal.id = 'config-tooltip-portal'", "document.body.appendChild(portal)", "const rect = info.getBoundingClientRect()", - "window.addEventListener('scroll', () => { if (configTooltipIsOpen()) hideConfigTooltip(); }, true)", + "window.addEventListener('scroll', (e) => { if (configTooltipIsOpen() && !configTooltipOwns(e.target)) hideConfigTooltip(); }, true)", "window.addEventListener('resize', () => { if (configTooltipIsOpen()) hideConfigTooltip(); })", } { if !strings.Contains(html, want) { diff --git a/src/pkg/dashboard/nav_count_delta.test.js b/src/pkg/dashboard/nav_count_delta.test.js index ce25ebee22..048dd92582 100644 --- a/src/pkg/dashboard/nav_count_delta.test.js +++ b/src/pkg/dashboard/nav_count_delta.test.js @@ -21,14 +21,17 @@ function load() { const el = { id, attrs, textContent: '', hidden: false, title: '', setAttribute(k, v) { attrs[k] = String(v); }, removeAttribute(k) { delete attrs[k]; }, - querySelector() { return null; }, + children: [], + querySelector(sel) { return this.children.find(c => sel === '.' + c.className.split(' ').pop()) || null; }, + appendChild(child) { this.children.push(child); return child; }, classList: { toggle() {} }, }; elements.set(id, el); return el; } IDS.concat(['activity-monitor-panel']).forEach(element); - const document = { hidden: false, getElementById: id => elements.get(id) || null }; + const document = { hidden: false, getElementById: id => elements.get(id) || null, + createElement: tag => ({ tag, className: '', hidden: false, innerHTML: '' }) }; const ctx = vm.createContext({ document, window: {}, console, Number, setTimeout(cb, ms) { const id = ++nextTimer; timers.set(id, { cb, at: now + ms }); return id; }, clearTimeout(id) { timers.delete(id); }, @@ -67,10 +70,13 @@ function load() { function stageTrackerWaitingToast() {} function stageTrackerActedAgo() { return ''; } function setIfChanged(el, text) { el.innerHTML = text; } + var _configTooltipTrigger = null; + function positionConfigTooltip() {} + function esc(s) { return String(s); } `, ctx); for (const [file, names] of [ ['knowledge', ['sidebarPairBadgeText', 'setSidebarPairBadge', 'setSidebarCountBadge', 'kbTotalFactsFromStats', 'kbFactsLabel', 'kbSidebarFactCount', 'fetchKnowledgeStats']], - ['contributors', ['contributorsOnlineTitle', 'updateContributorBadge']], + ['contributors', ['contributorsOnlineTitle', 'contributorsOnlineTooltip', 'updateContributorBadge']], ['tracker-waiting', ['stageTrackerWaitingOnYou', 'stageTrackerWaitingTitle', 'stageTrackerWaitKindWords', 'stageTrackerRenderWaiting']], ['tracker-words-stage', ['stageTrackerDefaultFilter']], ['tracker-filter-render', ['renderStageTracker']], diff --git a/src/pkg/dashboard/sidebar_pair_badge_test.go b/src/pkg/dashboard/sidebar_pair_badge_test.go index a577e7b9b3..1fd218d2c4 100644 --- a/src/pkg/dashboard/sidebar_pair_badge_test.go +++ b/src/pkg/dashboard/sidebar_pair_badge_test.go @@ -25,8 +25,9 @@ func TestSidebarPairBadgeWiring(t *testing.T) { `if (data && data.actionableNow) setSidebarPairBadge(document.getElementById('governor-sidebar-badge'), issueCount, prCount, 'actionable: ' + issueCount + ' issues / ' + prCount + ' PRs')`, // Contributors reads online/total off /api/status.contributorPool // with the tracker's presence window in the tooltip (#15651). - `Contributors`, - `if (sidebarBadge) setSidebarPairBadge(sidebarBadge, onlineCount, totalCount, tip);`, + `Contributors`, + `setSidebarPairBadge(sidebarBadge, onlineCount, totalCount);`, + `tooltip.innerHTML = contributorsOnlineTooltip(pool);`, `function contributorsOnlineTitle(online, total, window)`, ``, } { diff --git a/src/pkg/dashboard/static-src/css/config-dialog.css b/src/pkg/dashboard/static-src/css/config-dialog.css index b1cf90c7ad..66f42f13b8 100644 --- a/src/pkg/dashboard/static-src/css/config-dialog.css +++ b/src/pkg/dashboard/static-src/css/config-dialog.css @@ -456,6 +456,9 @@ /* The author `display: block` above outranks the UA `[hidden] { display: none }` rule, so without this the portal stayed on screen after `portal.hidden = true`. */ .config-tooltip-portal[hidden] { display: none; } + .contributor-online-tooltip { max-height: calc(100vh - var(--sp-8)); overflow-y: auto; pointer-events: auto; overflow-wrap: anywhere; } + .contributor-online-ids { display: block; list-style: none; margin: var(--sp-2) 0 0; padding: 0; } + .contributor-online-ids li { display: block; } .config-info:hover .config-tooltip, .config-info:focus-within .config-tooltip { display: none; } .section-help-mark { text-decoration: none; } .section-help-mark .section-help-tip-action { display: block; margin-top: var(--sp-2); color: var(--muted); } diff --git a/src/pkg/dashboard/static-src/html/sidebar.html b/src/pkg/dashboard/static-src/html/sidebar.html index bce56b237e..c823fd7cdb 100644 --- a/src/pkg/dashboard/static-src/html/sidebar.html +++ b/src/pkg/dashboard/static-src/html/sidebar.html @@ -34,7 +34,7 @@
    Intelligence
    @@ -105,4 +105,3 @@ block turns it on. Its id is registered in OVERLAY_SELECTOR so the existing installModalScrollLock() observer body-locks scroll for free. -->
    - diff --git a/src/pkg/dashboard/static-src/js/contributors.js b/src/pkg/dashboard/static-src/js/contributors.js index f08f576d9c..ebb4434688 100644 --- a/src/pkg/dashboard/static-src/js/contributors.js +++ b/src/pkg/dashboard/static-src/js/contributors.js @@ -514,8 +514,21 @@ const totalCount = pool.registered; const tip = contributorsOnlineTitle(onlineCount, totalCount, pool.presence_window); // Same two-part pill as Governor / Overview: "online/total". - if (sidebarBadge) setSidebarPairBadge(sidebarBadge, onlineCount, totalCount, tip); + if (sidebarBadge) setSidebarPairBadge(sidebarBadge, onlineCount, totalCount); navCountDelta(sidebarBadge, onlineCount, 'Contributors: ' + tip); + if (sidebarBadge) { + // Reuse the tooltip node across refreshes so the pill does not grow + // one hidden span per poll. + let tooltip = sidebarBadge.querySelector('.contributor-online-tooltip'); + if (!tooltip) { + tooltip = document.createElement('span'); + tooltip.className = 'config-tooltip contributor-online-tooltip'; + tooltip.hidden = true; + sidebarBadge.appendChild(tooltip); + } + tooltip.innerHTML = contributorsOnlineTooltip(pool); + if (_configTooltipTrigger === sidebarBadge) positionConfigTooltip(sidebarBadge); + } setSectionSummary('contributors-section', contributorsSectionSummary(_cachedContributors || [], pool)); if (statusBadge) { statusBadge.textContent = `${onlineCount} online / ${totalCount} registered`; @@ -524,7 +537,19 @@ } } - // contributorsOnlineTitle is the pill tooltip: "3 online ยท 12 registered + function contributorsOnlineTooltip(pool) { + const online = Number(pool.online) || 0; + const summary = esc(contributorsOnlineTitle(online, pool.registered, pool.presence_window)); + const ids = pool.online_ids; + if (!Array.isArray(ids) || ids.length !== online || ids.some(id => typeof id !== 'string' || !id)) { + return summary + '
    Online ClankeR IDs unavailable
    '; + } + if (!ids.length) return summary + '
    No ClankeRs online
    '; + return summary + '
    Online ClankeRs
      ' + + ids.map(id => '
    • ' + esc(id) + '
    • ').join('') + '
    '; + } + + // contributorsOnlineTitle is the presence summary: "3 online ยท 12 registered // (heartbeat within 15m)". The window is the hub's presence_window, the // same one the tracker's "(offline 13m)" caption is judged against. function contributorsOnlineTitle(online, total, window) { diff --git a/src/pkg/dashboard/static-src/js/tooltips-dialogs.js b/src/pkg/dashboard/static-src/js/tooltips-dialogs.js index d28aeb13d5..3fb78d20d1 100644 --- a/src/pkg/dashboard/static-src/js/tooltips-dialogs.js +++ b/src/pkg/dashboard/static-src/js/tooltips-dialogs.js @@ -132,7 +132,7 @@ } function configTooltipPointerOver(target) { - const info = target && target.closest ? target.closest('.config-info') : null; + const info = target && target.closest ? target.closest('.config-info, .contributor-online-trigger') : null; if (info) { scheduleConfigTooltipOpen(info); return; } if (configTooltipOwns(target)) { cancelConfigTooltipClose(); return; } // Pointer is over something else: a sibling, a modal overlay that now @@ -142,13 +142,13 @@ function configTooltipPointerOut(target, relatedTarget) { if (configTooltipOwns(relatedTarget)) return; - if (relatedTarget && relatedTarget.closest && relatedTarget.closest('.config-info')) return; - const info = target && target.closest ? target.closest('.config-info') : null; + if (relatedTarget && relatedTarget.closest && relatedTarget.closest('.config-info, .contributor-online-trigger')) return; + const info = target && target.closest ? target.closest('.config-info, .contributor-online-trigger') : null; if (info || configTooltipOwns(target)) scheduleConfigTooltipHide(); } function configTooltipFocusIn(target) { - const info = target && target.closest ? target.closest('.config-info') : null; + const info = target && target.closest ? target.closest('.config-info, .contributor-online-trigger') : null; if (info) { positionConfigTooltip(info); return; } if (configTooltipOwns(target)) { cancelConfigTooltipClose(); return; } if (configTooltipIsOpen()) hideConfigTooltip(); @@ -164,7 +164,7 @@ document.addEventListener('focusin', (e) => configTooltipFocusIn(e.target)); document.addEventListener('focusout', (e) => configTooltipFocusOut(e.target, e.relatedTarget)); document.addEventListener('click', (e) => { if (configTooltipIsOpen() && !configTooltipOwns(e.target)) hideConfigTooltip(); }); - window.addEventListener('scroll', () => { if (configTooltipIsOpen()) hideConfigTooltip(); }, true); + window.addEventListener('scroll', (e) => { if (configTooltipIsOpen() && !configTooltipOwns(e.target)) hideConfigTooltip(); }, true); window.addEventListener('resize', () => { if (configTooltipIsOpen()) hideConfigTooltip(); }); // โ”€โ”€ Event delegation for actions with user-controlled data โ”€โ”€ diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 51a950591b..9f59abe610 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -4459,6 +4459,9 @@ /* The author `display: block` above outranks the UA `[hidden] { display: none }` rule, so without this the portal stayed on screen after `portal.hidden = true`. */ .config-tooltip-portal[hidden] { display: none; } + .contributor-online-tooltip { max-height: calc(100vh - var(--sp-8)); overflow-y: auto; pointer-events: auto; overflow-wrap: anywhere; } + .contributor-online-ids { display: block; list-style: none; margin: var(--sp-2) 0 0; padding: 0; } + .contributor-online-ids li { display: block; } .config-info:hover .config-tooltip, .config-info:focus-within .config-tooltip { display: none; } .section-help-mark { text-decoration: none; } .section-help-mark .section-help-tip-action { display: block; margin-top: var(--sp-2); color: var(--muted); } @@ -7432,7 +7435,7 @@

    ๐Ÿ Getting Started
    Resources
    ๐Ÿ“ฆProjects0 - ๐Ÿ‘ฅContributors + ๐Ÿ‘ฅContributors

    Intelligence
    @@ -7503,7 +7506,6 @@

    ๐Ÿ Getting Started

    -
    @@ -42907,8 +42909,21 @@ const totalCount = pool.registered; const tip = contributorsOnlineTitle(onlineCount, totalCount, pool.presence_window); // Same two-part pill as Governor / Overview: "online/total". - if (sidebarBadge) setSidebarPairBadge(sidebarBadge, onlineCount, totalCount, tip); + if (sidebarBadge) setSidebarPairBadge(sidebarBadge, onlineCount, totalCount); navCountDelta(sidebarBadge, onlineCount, 'Contributors: ' + tip); + if (sidebarBadge) { + // Reuse the tooltip node across refreshes so the pill does not grow + // one hidden span per poll. + let tooltip = sidebarBadge.querySelector('.contributor-online-tooltip'); + if (!tooltip) { + tooltip = document.createElement('span'); + tooltip.className = 'config-tooltip contributor-online-tooltip'; + tooltip.hidden = true; + sidebarBadge.appendChild(tooltip); + } + tooltip.innerHTML = contributorsOnlineTooltip(pool); + if (_configTooltipTrigger === sidebarBadge) positionConfigTooltip(sidebarBadge); + } setSectionSummary('contributors-section', contributorsSectionSummary(_cachedContributors || [], pool)); if (statusBadge) { statusBadge.textContent = `${onlineCount} online / ${totalCount} registered`; @@ -42917,7 +42932,19 @@ } } - // contributorsOnlineTitle is the pill tooltip: "3 online ยท 12 registered + function contributorsOnlineTooltip(pool) { + const online = Number(pool.online) || 0; + const summary = esc(contributorsOnlineTitle(online, pool.registered, pool.presence_window)); + const ids = pool.online_ids; + if (!Array.isArray(ids) || ids.length !== online || ids.some(id => typeof id !== 'string' || !id)) { + return summary + '
    Online ClankeR IDs unavailable
    '; + } + if (!ids.length) return summary + '
    No ClankeRs online
    '; + return summary + '
    Online ClankeRs
      ' + + ids.map(id => '
    • ' + esc(id) + '
    • ').join('') + '
    '; + } + + // contributorsOnlineTitle is the presence summary: "3 online ยท 12 registered // (heartbeat within 15m)". The window is the hub's presence_window, the // same one the tracker's "(offline 13m)" caption is judged against. function contributorsOnlineTitle(online, total, window) { @@ -45431,7 +45458,7 @@

    GitHub Projects sync

    } function configTooltipPointerOver(target) { - const info = target && target.closest ? target.closest('.config-info') : null; + const info = target && target.closest ? target.closest('.config-info, .contributor-online-trigger') : null; if (info) { scheduleConfigTooltipOpen(info); return; } if (configTooltipOwns(target)) { cancelConfigTooltipClose(); return; } // Pointer is over something else: a sibling, a modal overlay that now @@ -45441,13 +45468,13 @@

    GitHub Projects sync

    function configTooltipPointerOut(target, relatedTarget) { if (configTooltipOwns(relatedTarget)) return; - if (relatedTarget && relatedTarget.closest && relatedTarget.closest('.config-info')) return; - const info = target && target.closest ? target.closest('.config-info') : null; + if (relatedTarget && relatedTarget.closest && relatedTarget.closest('.config-info, .contributor-online-trigger')) return; + const info = target && target.closest ? target.closest('.config-info, .contributor-online-trigger') : null; if (info || configTooltipOwns(target)) scheduleConfigTooltipHide(); } function configTooltipFocusIn(target) { - const info = target && target.closest ? target.closest('.config-info') : null; + const info = target && target.closest ? target.closest('.config-info, .contributor-online-trigger') : null; if (info) { positionConfigTooltip(info); return; } if (configTooltipOwns(target)) { cancelConfigTooltipClose(); return; } if (configTooltipIsOpen()) hideConfigTooltip(); @@ -45463,7 +45490,7 @@

    GitHub Projects sync

    document.addEventListener('focusin', (e) => configTooltipFocusIn(e.target)); document.addEventListener('focusout', (e) => configTooltipFocusOut(e.target, e.relatedTarget)); document.addEventListener('click', (e) => { if (configTooltipIsOpen() && !configTooltipOwns(e.target)) hideConfigTooltip(); }); - window.addEventListener('scroll', () => { if (configTooltipIsOpen()) hideConfigTooltip(); }, true); + window.addEventListener('scroll', (e) => { if (configTooltipIsOpen() && !configTooltipOwns(e.target)) hideConfigTooltip(); }, true); window.addEventListener('resize', () => { if (configTooltipIsOpen()) hideConfigTooltip(); }); // โ”€โ”€ Event delegation for actions with user-controlled data โ”€โ”€