diff --git a/changelog.d/added-16243-activity-monitor-header-count.md b/changelog.d/added-16243-activity-monitor-header-count.md new file mode 100644 index 0000000000..3834a2799b --- /dev/null +++ b/changelog.d/added-16243-activity-monitor-header-count.md @@ -0,0 +1 @@ +- The Hive activity monitor's header now carries its own live item count pill next to the title — the sidebar badge's twin, written by the same render call with the same ↑ +N / ↓ −N cue and `prefers-reduced-motion` handling — so kiosk (`?kiosk=1`), pop-out (`?popout=1`), display mode (`?display=1`) and browser full screen, which all hide the sidebar, still show how many items the monitor is tracking. The pill is enlarged in the chrome-less views so it reads at 1920×1080 ([#16243](https://github.com/hivecommons/hive/issues/16243)). diff --git a/src/docs/streaming-the-activity-monitor.md b/src/docs/streaming-the-activity-monitor.md index 8436b4c041..759ad5f818 100644 --- a/src/docs/streaming-the-activity-monitor.md +++ b/src/docs/streaming-the-activity-monitor.md @@ -181,7 +181,10 @@ does **not** render tokens, secrets, settings, webhooks, chat, or the operator's agent terminals; `?kiosk=1` additionally hides the sidebar, topbar, avatar/settings menus, notices, the Welcome and NPS dialogs, and every other dashboard section, and renders dark regardless of any stored theme -(append `&theme=light` for a light stream). Do not point the streamer at a hive tracking private +(append `&theme=light` for a light stream). Because the sidebar is hidden, the +monitor's header carries its own live item count pill (the sidebar badge's twin, +with the same ↑/↓ delta cue), enlarged in kiosk, pop-out, display and full-screen +views so it reads at 1920×1080. Do not point the streamer at a hive tracking private repositories without reviewing what the tracker would show. The main `twitch.tv/hivecommons` stream never shows Matrix; it remains the diff --git a/src/pkg/dashboard/nav_count_delta.test.js b/src/pkg/dashboard/nav_count_delta.test.js index 048dd92582..61d610e952 100644 --- a/src/pkg/dashboard/nav_count_delta.test.js +++ b/src/pkg/dashboard/nav_count_delta.test.js @@ -91,7 +91,7 @@ function load() { } vm.runInContext(source('tracker-filter'), ctx); vm.runInContext(`const STAGE_TRACKER_WAITING_TOOLTIP_MAX = 5; const STAGE_TRACKER_WAIT_KIND_WORDS = {};`, ctx); - return { ctx, document, timers, element, badge: id => elements.get(id), + return { ctx, document, timers, element, badge: id => elements.get(id), remove: id => elements.delete(id), tick(ms = 1400) { now += ms; for (const [id, timer] of [...timers]) if (timer.at <= now) { timers.delete(id); timer.cb(); } @@ -173,6 +173,67 @@ test('real tracker renderer: new issues, PR removal, batching, filters, invalid assert.equal(delta(badge), undefined); }); +const HEADER = 'activity-monitor-header-badge'; +const mirror = (a, b) => { + assert.equal(b.textContent, a.textContent); + assert.equal(b.title, a.title); + assert.equal(b.attrs['data-zero'], a.attrs['data-zero']); + for (const k of ['data-count-delta', 'data-count-direction', 'data-count-phase', 'aria-label']) assert.equal(b.attrs[k], a.attrs[k], k); +}; + +test('header pill is the sidebar badge\'s twin: one render writes count, tooltip, zero marker and delta to both', () => { + const api = load(), sidebar = api.badge(IDS[0]), header = api.element(HEADER); + const render = items => api.ctx.renderStageTracker({ items }); + render([item(1), item(2, 'pr')]); + assert.equal(header.textContent, '2'); + assert.equal(header.attrs['data-zero'], undefined); + mirror(sidebar, header); + render([item(1), item(2, 'pr'), item(3), item(4)]); + assert.equal(delta(header), '↑ +2'); + mirror(sidebar, header); + render([item(1)]); + assert.equal(delta(header), '↓ -3'); + mirror(sidebar, header); + api.tick(); + assert.equal(delta(header), undefined); + assert.equal(api.timers.size, 0); + render([]); + assert.equal(header.textContent, '0'); + assert.equal(header.attrs['data-zero'], ''); + assert.equal(delta(header), '↓ -1'); + mirror(sidebar, header); + api.ctx.renderStageTracker(); + mirror(sidebar, header); + assert.equal(vm.runInContext('STAGE_TRACKER_COUNT_BADGE_IDS.includes(' + JSON.stringify(HEADER) + ')', api.ctx), true); +}); + +test('kiosk: the sidebar badge is absent and the header pill alone still counts and animates', () => { + const api = load(), header = api.element(HEADER); + api.remove(IDS[0]); + assert.equal(api.document.getElementById(IDS[0]), null); + const render = items => api.ctx.renderStageTracker({ items }); + render([item(1)]); + assert.equal(header.textContent, '1'); + assert.equal(delta(header), undefined); + render([item(1), item(2), item(3)]); + assert.equal(header.textContent, '3'); + assert.equal(delta(header), '↑ +2'); + assert.match(header.attrs['aria-label'], /increased by 2/); + api.tick(); + assert.equal(delta(header), undefined); + api.ctx.stageTrackerSidebarCountsUnknown(); + render([item(1), item(2), item(3), item(4), item(5)]); + assert.equal(header.textContent, '5'); + assert.equal(delta(header), undefined, 'unknown -> known seeds a new baseline on the header pill too'); + // The pill ships in the card header for every mode and is styled off + // the shared delta rules, not a second copy of them. + const sections = source('sections'); + assert.match(sections, /countHtml: STAGE_TRACKER_HEADER_COUNT_HTML/); + assert.match(sections, / { const api = load(), badge = api.badge(IDS[1]); const write = count => api.ctx.stageTrackerRenderWaiting({ waiting_on_human: { count, items: [] } }, 0); diff --git a/src/pkg/dashboard/static-src/css/design-system.css b/src/pkg/dashboard/static-src/css/design-system.css index 472b1a51d8..584d6aa5d1 100644 --- a/src/pkg/dashboard/static-src/css/design-system.css +++ b/src/pkg/dashboard/static-src/css/design-system.css @@ -84,15 +84,20 @@ .oc-nav-count--waiting:not([data-zero]) + .oc-nav-count { margin-left: var(--sp-1); } .oc-nav-count--waiting:not([data-zero]) { --component-status: var(--status-attention); background: color-mix(in srgb, var(--component-status) 16%, transparent); border-color: color-mix(in srgb, var(--component-status) 50%, transparent); color: var(--component-status); } .oc-nav-count--waiting[data-zero] { display: none; } + /* The activity monitor's own count pill (hivecommons/hive#16243): the + sidebar badge's twin inside the section title, so every chrome-less + view still shows the count. Same .badge-count recipe, title-cluster + letter case, and a tooltip rather than a nav row. */ + .ham-header-count { flex: none; text-transform: none; letter-spacing: 0; font-variant-numeric: tabular-nums; } /* A short, out-of-flow net delta on explicitly wired navigation counts. Keep the zero waiting badge visible just long enough to show its drop. */ - .oc-nav-count[data-count-delta] { position: relative; } + .oc-nav-count[data-count-delta], .ham-header-count[data-count-delta] { position: relative; } .oc-nav-item:has(> .oc-nav-count[data-count-delta]) { overflow: visible; z-index: 1; } #activity-monitor-waiting-badge[data-zero][data-count-delta] { display: inline-flex; position: absolute; right: 3rem; visibility: hidden; padding: 0; border: 0; } - .oc-nav-count[data-count-delta]::after { + .oc-nav-count[data-count-delta]::after, .ham-header-count[data-count-delta]::after { content: attr(data-count-delta); position: absolute; bottom: calc(100% + 2px); right: 0; visibility: visible; pointer-events: none; z-index: 1; padding: var(--sp-0) var(--sp-2); border-radius: var(--r-pill); background: var(--surface); color: var(--brand); border: 1px solid var(--brand); @@ -102,6 +107,10 @@ #knowledge-sidebar-badge[data-count-delta]::after { bottom: auto; top: 50%; right: calc(100% + var(--sp-1)); translate: 0 -50%; } + /* The header pill's cue rides inside the pill ("57 ↑ +3") rather than + floating above it: the card edge is right there, and the number must + still read from across a room on a wall display. */ + .ham-header-count[data-count-delta]::after { position: static; margin-left: var(--sp-2); white-space: nowrap; } [data-count-direction="up"] { --nav-count-start: 3px; } [data-count-direction="down"] { --nav-count-start: -3px; } [data-count-phase="a"]::after { animation: nav-count-a 220ms ease-out; } diff --git a/src/pkg/dashboard/static-src/css/popout.css b/src/pkg/dashboard/static-src/css/popout.css index cf53fae2cd..1ddd8c9298 100644 --- a/src/pkg/dashboard/static-src/css/popout.css +++ b/src/pkg/dashboard/static-src/css/popout.css @@ -36,6 +36,11 @@ body.ham-chromeless .ham-sticky { top: 0; } body.ham-chromeless .ham-cols { top: var(--ham-sticky-bar-h); } + /* The title's count pill is the only count a wall can see: at 1920x1080 + it reads from across a room. Kiosk sets no ham-chromeless, so it is + named too. 1.375rem is 22px at the default root size. */ + body.kiosk-mode .ham-header-count, body.ham-chromeless .ham-header-count { font-size: var(--fs-2xl); min-height: 1.6em; padding: 0 var(--sp-3); } + body.kiosk-mode .ham-header-count[data-count-delta]::after, body.ham-chromeless .ham-header-count[data-count-delta]::after { font-size: var(--fs-lg); } /* Header tools: ⧉ pop out, ⛶ full screen and 📺 display sit beside the gear and share its chip styling; the return link is a pop-out-only text pill. */ .ham-header-tool { width: auto; min-width: 15px; padding: 0 var(--sp-1); font-size: var(--fs-2xs); line-height: 1; color: var(--muted); white-space: nowrap; } diff --git a/src/pkg/dashboard/static-src/js/nav-count-delta.js b/src/pkg/dashboard/static-src/js/nav-count-delta.js index c06c2c08b0..5aa44cc841 100644 --- a/src/pkg/dashboard/static-src/js/nav-count-delta.js +++ b/src/pkg/dashboard/static-src/js/nav-count-delta.js @@ -47,8 +47,29 @@ state.timer = setTimeout(state.clear, NAV_COUNT_CUE_MS); } + // One count, several pills. The tracker's item count is shown in the + // sidebar and again in the monitor's own header (hivecommons/hive#16243) + // so the chrome-less views — kiosk, pop-out, display, full screen — + // which hide the sidebar still show it. Every bound element receives + // the same text, tooltip, zero marker and delta cue from one call; a + // target that is not in the DOM is skipped, the others still update. + function navCountBind(ids, count, label, live = true) { + const known = Number.isSafeInteger(count) && count >= 0; + for (const id of ids) { + const el = document.getElementById(id); + if (!el) continue; + if (known) { + el.textContent = String(count); + el.title = label; + if (count) el.removeAttribute('data-zero'); else el.setAttribute('data-zero', ''); + } + navCountDelta(el, count, label, live); + } + } + const STAGE_TRACKER_COUNT_BADGE_IDS = Object.freeze(['activity-monitor-sidebar-badge', 'activity-monitor-header-badge']); + function stageTrackerSidebarCountsUnknown() { - for (const id of ['activity-monitor-sidebar-badge', 'activity-monitor-waiting-badge']) { + for (const id of STAGE_TRACKER_COUNT_BADGE_IDS.concat('activity-monitor-waiting-badge')) { navCountDelta(document.getElementById(id), null); } } diff --git a/src/pkg/dashboard/static-src/js/sections.js b/src/pkg/dashboard/static-src/js/sections.js index 545e27a8c8..505202a67e 100644 --- a/src/pkg/dashboard/static-src/js/sections.js +++ b/src/pkg/dashboard/static-src/js/sections.js @@ -81,6 +81,11 @@ + '' + '' + ''; + // The monitor's own item count (hivecommons/hive#16243): the sidebar + // badge's twin, written by the same navCountBind call in + // renderStageTracker so kiosk, pop-out, display and full screen — which + // hide the sidebar — still show the count and its ↑/↓ cue. + const STAGE_TRACKER_HEADER_COUNT_HTML = '0'; // Display controls (hivecommons/hive#15929): the overlay // stageTrackerDisplayControlsInit() appends to the body in display mode // only. Full screen and Keep awake are explicit clicks; their disabled / @@ -121,7 +126,7 @@ 'logs-section': { title: '📋 Agent Logs', summary: 'logs' }, 'agents-section': { title: '🤖 Agents', summary: '0 running / 0 total' }, 'agent-activity-section': { title: '📡 Agent activity', summary: '0 working / 0 total' }, - 'activity-monitor-section': { title: '📍 Hive activity monitor', summary: '0 items', actionIds: ['activity-monitor-settings'], settingsHtml: sectionSettingsGear('Hive activity monitor', 'toggleStageTrackerSettings', 'Configure Hive activity monitor sounds — open buzz, merge zap, your own WAV files, volume', ' aria-haspopup="true" aria-expanded="false" aria-controls="activity-monitor-settings"') + STAGE_TRACKER_HEADER_TOOLS_HTML }, + 'activity-monitor-section': { title: '📍 Hive activity monitor', summary: '0 items', actionIds: ['activity-monitor-settings'], settingsHtml: sectionSettingsGear('Hive activity monitor', 'toggleStageTrackerSettings', 'Configure Hive activity monitor sounds — open buzz, merge zap, your own WAV files, volume', ' aria-haspopup="true" aria-expanded="false" aria-controls="activity-monitor-settings"') + STAGE_TRACKER_HEADER_TOOLS_HTML, countHtml: STAGE_TRACKER_HEADER_COUNT_HTML }, 'faq-section': { title: '❓ FAQ', summary: 'questions' }, }); // Section help marks (#10915). Each entry's help sentence is word for word @@ -205,7 +210,9 @@ function sectionCardHeader(opts) { opts = opts || {}; const id = opts.id || ''; - const title = opts.titleHtml || esc(opts.title || id || 'Section'); + // countHtml: a live count pill that reads as part of the title + // ("Hive activity monitor · 57"), before the help mark and the gear. + const title = (opts.titleHtml || esc(opts.title || id || 'Section')) + (opts.countHtml || ''); const bodyId = opts.bodyId || (id + '-body'); const action = opts.action || 'toggleSection'; const keyAction = opts.keyAction || 'sectionHeaderKey'; @@ -263,7 +270,7 @@ if (!body) return; const bodyId = sectionId + '-body'; const template = document.createElement('template'); - template.innerHTML = sectionCardShell({ id: sectionId, title: cfg.title, summaryHtml: cfg.summary, bodyId: bodyId, badgeHtml: cfg.badgeHtml, subtitleHtml: cfg.subtitleHtml, settingsHtml: cfg.settingsHtml }, ''); + template.innerHTML = sectionCardShell({ id: sectionId, title: cfg.title, summaryHtml: cfg.summary, bodyId: bodyId, badgeHtml: cfg.badgeHtml, subtitleHtml: cfg.subtitleHtml, settingsHtml: cfg.settingsHtml, countHtml: cfg.countHtml }, ''); const card = template.content.firstElementChild; const newHeader = card.querySelector('.dash-card-header'); const badges = newHeader.querySelector('.dash-card-badges'); diff --git a/src/pkg/dashboard/static-src/js/tracker-filter-render.js b/src/pkg/dashboard/static-src/js/tracker-filter-render.js index eec8afd7ff..b7b9459b31 100644 --- a/src/pkg/dashboard/static-src/js/tracker-filter-render.js +++ b/src/pkg/dashboard/static-src/js/tracker-filter-render.js @@ -122,13 +122,12 @@ // disagree: the pill is the default view's row count (owner: rows, // not items — a covering PR shares its issue's row); needs-attention // is the warn-coloured header suffix and the pill's tooltip, counted - // over every item regardless of filter. + // over every item regardless of filter. The same count lands on the + // monitor header's own pill, the one chrome-less views can see. const attentionAll = d.items.filter(stageTrackerNeedsAttention).length; const counts = stageTrackerCountsText(page, allRows, attention, stageTrackerOpenCounts(d), attentionAll, stageTrackerFoldedCount(d.items, ctx)); setSectionSummary('activity-monitor-section', counts.header.replace(/(\d+) needs? attention/, m => `${m}`)); - const badge = document.getElementById('activity-monitor-sidebar-badge'); - if (badge) { badge.textContent = String(counts.badge); badge.title = counts.badgeTitle; if (counts.badge) badge.removeAttribute('data-zero'); else badge.setAttribute('data-zero', ''); } - navCountDelta(badge, counts.badge, counts.badgeTitle, !!data || countRefresh); + navCountBind(STAGE_TRACKER_COUNT_BADGE_IDS, counts.badge, counts.badgeTitle, !!data || countRefresh); stageTrackerRenderWaiting(d, nowMs, !!data || countRefresh); const labelsEl = document.getElementById('activity-monitor-labels'); if (labelsEl) setIfChanged(labelsEl, stageTrackerLabelsHtml(stageTrackerLabelFacets(d.items, f))); diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 68ac24c95d..6ee9318b9f 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -5536,15 +5536,20 @@ .oc-nav-count--waiting:not([data-zero]) + .oc-nav-count { margin-left: var(--sp-1); } .oc-nav-count--waiting:not([data-zero]) { --component-status: var(--status-attention); background: color-mix(in srgb, var(--component-status) 16%, transparent); border-color: color-mix(in srgb, var(--component-status) 50%, transparent); color: var(--component-status); } .oc-nav-count--waiting[data-zero] { display: none; } + /* The activity monitor's own count pill (hivecommons/hive#16243): the + sidebar badge's twin inside the section title, so every chrome-less + view still shows the count. Same .badge-count recipe, title-cluster + letter case, and a tooltip rather than a nav row. */ + .ham-header-count { flex: none; text-transform: none; letter-spacing: 0; font-variant-numeric: tabular-nums; } /* A short, out-of-flow net delta on explicitly wired navigation counts. Keep the zero waiting badge visible just long enough to show its drop. */ - .oc-nav-count[data-count-delta] { position: relative; } + .oc-nav-count[data-count-delta], .ham-header-count[data-count-delta] { position: relative; } .oc-nav-item:has(> .oc-nav-count[data-count-delta]) { overflow: visible; z-index: 1; } #activity-monitor-waiting-badge[data-zero][data-count-delta] { display: inline-flex; position: absolute; right: 3rem; visibility: hidden; padding: 0; border: 0; } - .oc-nav-count[data-count-delta]::after { + .oc-nav-count[data-count-delta]::after, .ham-header-count[data-count-delta]::after { content: attr(data-count-delta); position: absolute; bottom: calc(100% + 2px); right: 0; visibility: visible; pointer-events: none; z-index: 1; padding: var(--sp-0) var(--sp-2); border-radius: var(--r-pill); background: var(--surface); color: var(--brand); border: 1px solid var(--brand); @@ -5554,6 +5559,10 @@ #knowledge-sidebar-badge[data-count-delta]::after { bottom: auto; top: 50%; right: calc(100% + var(--sp-1)); translate: 0 -50%; } + /* The header pill's cue rides inside the pill ("57 ↑ +3") rather than + floating above it: the card edge is right there, and the number must + still read from across a room on a wall display. */ + .ham-header-count[data-count-delta]::after { position: static; margin-left: var(--sp-2); white-space: nowrap; } [data-count-direction="up"] { --nav-count-start: 3px; } [data-count-direction="down"] { --nav-count-start: -3px; } [data-count-phase="a"]::after { animation: nav-count-a 220ms ease-out; } @@ -6876,6 +6885,11 @@ body.ham-chromeless .ham-sticky { top: 0; } body.ham-chromeless .ham-cols { top: var(--ham-sticky-bar-h); } + /* The title's count pill is the only count a wall can see: at 1920x1080 + it reads from across a room. Kiosk sets no ham-chromeless, so it is + named too. 1.375rem is 22px at the default root size. */ + body.kiosk-mode .ham-header-count, body.ham-chromeless .ham-header-count { font-size: var(--fs-2xl); min-height: 1.6em; padding: 0 var(--sp-3); } + body.kiosk-mode .ham-header-count[data-count-delta]::after, body.ham-chromeless .ham-header-count[data-count-delta]::after { font-size: var(--fs-lg); } /* Header tools: ⧉ pop out, ⛶ full screen and 📺 display sit beside the gear and share its chip styling; the return link is a pop-out-only text pill. */ .ham-header-tool { width: auto; min-width: 15px; padding: 0 var(--sp-1); font-size: var(--fs-2xs); line-height: 1; color: var(--muted); white-space: nowrap; } @@ -9488,6 +9502,11 @@

Where to get help

+ '' + '' + ''; + // The monitor's own item count (hivecommons/hive#16243): the sidebar + // badge's twin, written by the same navCountBind call in + // renderStageTracker so kiosk, pop-out, display and full screen — which + // hide the sidebar — still show the count and its ↑/↓ cue. + const STAGE_TRACKER_HEADER_COUNT_HTML = '0'; // Display controls (hivecommons/hive#15929): the overlay // stageTrackerDisplayControlsInit() appends to the body in display mode // only. Full screen and Keep awake are explicit clicks; their disabled / @@ -9528,7 +9547,7 @@

Where to get help

'logs-section': { title: '📋 Agent Logs', summary: 'logs' }, 'agents-section': { title: '🤖 Agents', summary: '0 running / 0 total' }, 'agent-activity-section': { title: '📡 Agent activity', summary: '0 working / 0 total' }, - 'activity-monitor-section': { title: '📍 Hive activity monitor', summary: '0 items', actionIds: ['activity-monitor-settings'], settingsHtml: sectionSettingsGear('Hive activity monitor', 'toggleStageTrackerSettings', 'Configure Hive activity monitor sounds — open buzz, merge zap, your own WAV files, volume', ' aria-haspopup="true" aria-expanded="false" aria-controls="activity-monitor-settings"') + STAGE_TRACKER_HEADER_TOOLS_HTML }, + 'activity-monitor-section': { title: '📍 Hive activity monitor', summary: '0 items', actionIds: ['activity-monitor-settings'], settingsHtml: sectionSettingsGear('Hive activity monitor', 'toggleStageTrackerSettings', 'Configure Hive activity monitor sounds — open buzz, merge zap, your own WAV files, volume', ' aria-haspopup="true" aria-expanded="false" aria-controls="activity-monitor-settings"') + STAGE_TRACKER_HEADER_TOOLS_HTML, countHtml: STAGE_TRACKER_HEADER_COUNT_HTML }, 'faq-section': { title: '❓ FAQ', summary: 'questions' }, }); // Section help marks (#10915). Each entry's help sentence is word for word @@ -9612,7 +9631,9 @@

Where to get help

function sectionCardHeader(opts) { opts = opts || {}; const id = opts.id || ''; - const title = opts.titleHtml || esc(opts.title || id || 'Section'); + // countHtml: a live count pill that reads as part of the title + // ("Hive activity monitor · 57"), before the help mark and the gear. + const title = (opts.titleHtml || esc(opts.title || id || 'Section')) + (opts.countHtml || ''); const bodyId = opts.bodyId || (id + '-body'); const action = opts.action || 'toggleSection'; const keyAction = opts.keyAction || 'sectionHeaderKey'; @@ -9670,7 +9691,7 @@

Where to get help

if (!body) return; const bodyId = sectionId + '-body'; const template = document.createElement('template'); - template.innerHTML = sectionCardShell({ id: sectionId, title: cfg.title, summaryHtml: cfg.summary, bodyId: bodyId, badgeHtml: cfg.badgeHtml, subtitleHtml: cfg.subtitleHtml, settingsHtml: cfg.settingsHtml }, ''); + template.innerHTML = sectionCardShell({ id: sectionId, title: cfg.title, summaryHtml: cfg.summary, bodyId: bodyId, badgeHtml: cfg.badgeHtml, subtitleHtml: cfg.subtitleHtml, settingsHtml: cfg.settingsHtml, countHtml: cfg.countHtml }, ''); const card = template.content.firstElementChild; const newHeader = card.querySelector('.dash-card-header'); const badges = newHeader.querySelector('.dash-card-badges'); @@ -20209,8 +20230,29 @@

All labels

state.timer = setTimeout(state.clear, NAV_COUNT_CUE_MS); } + // One count, several pills. The tracker's item count is shown in the + // sidebar and again in the monitor's own header (hivecommons/hive#16243) + // so the chrome-less views — kiosk, pop-out, display, full screen — + // which hide the sidebar still show it. Every bound element receives + // the same text, tooltip, zero marker and delta cue from one call; a + // target that is not in the DOM is skipped, the others still update. + function navCountBind(ids, count, label, live = true) { + const known = Number.isSafeInteger(count) && count >= 0; + for (const id of ids) { + const el = document.getElementById(id); + if (!el) continue; + if (known) { + el.textContent = String(count); + el.title = label; + if (count) el.removeAttribute('data-zero'); else el.setAttribute('data-zero', ''); + } + navCountDelta(el, count, label, live); + } + } + const STAGE_TRACKER_COUNT_BADGE_IDS = Object.freeze(['activity-monitor-sidebar-badge', 'activity-monitor-header-badge']); + function stageTrackerSidebarCountsUnknown() { - for (const id of ['activity-monitor-sidebar-badge', 'activity-monitor-waiting-badge']) { + for (const id of STAGE_TRACKER_COUNT_BADGE_IDS.concat('activity-monitor-waiting-badge')) { navCountDelta(document.getElementById(id), null); } } @@ -20726,13 +20768,12 @@

All labels

// disagree: the pill is the default view's row count (owner: rows, // not items — a covering PR shares its issue's row); needs-attention // is the warn-coloured header suffix and the pill's tooltip, counted - // over every item regardless of filter. + // over every item regardless of filter. The same count lands on the + // monitor header's own pill, the one chrome-less views can see. const attentionAll = d.items.filter(stageTrackerNeedsAttention).length; const counts = stageTrackerCountsText(page, allRows, attention, stageTrackerOpenCounts(d), attentionAll, stageTrackerFoldedCount(d.items, ctx)); setSectionSummary('activity-monitor-section', counts.header.replace(/(\d+) needs? attention/, m => `${m}`)); - const badge = document.getElementById('activity-monitor-sidebar-badge'); - if (badge) { badge.textContent = String(counts.badge); badge.title = counts.badgeTitle; if (counts.badge) badge.removeAttribute('data-zero'); else badge.setAttribute('data-zero', ''); } - navCountDelta(badge, counts.badge, counts.badgeTitle, !!data || countRefresh); + navCountBind(STAGE_TRACKER_COUNT_BADGE_IDS, counts.badge, counts.badgeTitle, !!data || countRefresh); stageTrackerRenderWaiting(d, nowMs, !!data || countRefresh); const labelsEl = document.getElementById('activity-monitor-labels'); if (labelsEl) setIfChanged(labelsEl, stageTrackerLabelsHtml(stageTrackerLabelFacets(d.items, f)));