Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/added-16243-activity-monitor-header-count.md
Original file line number Diff line number Diff line change
@@ -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)).
5 changes: 4 additions & 1 deletion src/docs/streaming-the-activity-monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
63 changes: 62 additions & 1 deletion src/pkg/dashboard/nav_count_delta.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down Expand Up @@ -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, /<span id="activity-monitor-header-badge" class="badge-count ham-header-count" data-zero/);
const css = fs.readFileSync(path.join(__dirname, 'static-src/css/design-system.css'), 'utf8');
assert.match(css, /\.oc-nav-count\[data-count-delta\]::after, \.ham-header-count\[data-count-delta\]::after \{/);
});

test('real waiting badge writer: independent count, explicit zero and invalid header', () => {
const api = load(), badge = api.badge(IDS[1]);
const write = count => api.ctx.stageTrackerRenderWaiting({ waiting_on_human: { count, items: [] } }, 0);
Expand Down
13 changes: 11 additions & 2 deletions src/pkg/dashboard/static-src/css/design-system.css
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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; }
Expand Down
5 changes: 5 additions & 0 deletions src/pkg/dashboard/static-src/css/popout.css
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
23 changes: 22 additions & 1 deletion src/pkg/dashboard/static-src/js/nav-count-delta.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
13 changes: 10 additions & 3 deletions src/pkg/dashboard/static-src/js/sections.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@
+ '<button type="button" class="config-info section-settings-gear ham-header-tool ham-fullscreen-btn" id="activity-monitor-fullscreen" data-action="toggleStageTrackerFullscreen" data-stop="1" aria-pressed="false" title="Full screen — fill the screen with the activity monitor (f, Esc exits)" aria-label="Full screen — fill the screen with the activity monitor (f, Esc exits)">⛶</button>'
+ '<button type="button" class="config-info section-settings-gear ham-header-tool ham-display-btn" id="activity-monitor-display" data-action="toggleStageTrackerDisplay" data-stop="1" aria-pressed="false" title="Display — show the activity monitor as a wall view with no row actions (d; Esc or d leaves)" aria-label="Display — show the activity monitor as a wall view with no row actions (d; Esc or d leaves)">📺</button>'
+ '<button type="button" class="ham-popout-return" id="activity-monitor-return" data-action="stageTrackerReturnToDashboard" data-stop="1" title="Focus the main dashboard window and close this pop-out">⤶ Return to dashboard</button>';
// 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 = '<span id="activity-monitor-header-badge" class="badge-count ham-header-count" data-zero title="Open items in the hive activity monitor" aria-label="0 items">0</span>';
// 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 /
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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');
Expand Down
7 changes: 3 additions & 4 deletions src/pkg/dashboard/static-src/js/tracker-filter-render.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => `<span class="text-warn">${m}</span>`));
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)));
Expand Down
Loading
Loading