From f24b541edba7d2599c49b701e833c2692b7b9933 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Fri, 30 Oct 2026 15:04:31 -0400 Subject: [PATCH 1/4] =?UTF-8?q?=E2=9C=A8=20Animate=20live=20sidebar=20coun?= =?UTF-8?q?t=20deltas=20without=20extra=20polling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andy Anderson --- changelog.d/added-nav-count-deltas.md | 1 + src/docs/dashboard-sections.md | 8 + src/pkg/dashboard/nav_count_delta.test.js | 260 ++++++++++++++++++ src/pkg/dashboard/stage_tracker_ui_test.go | 2 +- .../dashboard/stage_tracker_waiting.test.js | 3 +- .../static-src/css/design-system.css | 27 ++ .../dashboard/static-src/js/contributors.js | 12 +- src/pkg/dashboard/static-src/js/knowledge.js | 27 +- .../static-src/js/nav-count-delta.js | 53 ++++ .../static-src/js/tracker-filter-render.js | 7 +- .../dashboard/static-src/js/tracker-merged.js | 3 +- .../static-src/js/tracker-waiting.js | 15 +- src/pkg/dashboard/static-src/manifest.txt | 1 + src/pkg/dashboard/static/index.html | 144 ++++++++-- 14 files changed, 525 insertions(+), 38 deletions(-) create mode 100644 changelog.d/added-nav-count-deltas.md create mode 100644 src/pkg/dashboard/nav_count_delta.test.js create mode 100644 src/pkg/dashboard/static-src/js/nav-count-delta.js diff --git a/changelog.d/added-nav-count-deltas.md b/changelog.d/added-nav-count-deltas.md new file mode 100644 index 0000000000..04022dce2b --- /dev/null +++ b/changelog.d/added-nav-count-deltas.md @@ -0,0 +1 @@ +- Tracker, online-contributor and Knowledge sidebar count pills briefly show the actual signed increase or decrease on live updates, with directional amber feedback and a static reduced-motion alternative. diff --git a/src/docs/dashboard-sections.md b/src/docs/dashboard-sections.md index 7b807078b6..0cdc2f6148 100644 --- a/src/docs/dashboard-sections.md +++ b/src/docs/dashboard-sections.md @@ -18,6 +18,14 @@ Hive has two release lines. **v5** is the stable line. **v6** is the newer line. For short definitions of the names the dashboard uses, see the [dashboard glossary](dashboard-glossary.md). For how the dashboard is built, see the [spoke dashboard guide](dashboard.md). +### Live sidebar count feedback + +The Hive activity monitor, Contributors and Knowledge navigation pills briefly show an upward or downward arrow and the actual signed count change. The number remains readable and the link works as before. Reduced-motion preferences keep the feedback static; there is no extra polling or repeated announcement on unchanged refreshes. + +The tracker’s gold pill counts default-view **rows** (issues, except folded review notes, plus PRs not drawn under an issue); its orange pill counts **waiting-on-you items**. These are not separate issue and PR totals. Contributors animates only **online** in online/registered, using the existing registered-profile heartbeat window, not connected sockets or changes in registered totals. Knowledge counts **facts**, the sum of layer `total_pages` values, when enabled; its disabled zero does not mean stored facts were deleted. + +Initial or unknown counts and route/filter redraws do not animate. After reconnection, feedback describes only the observed net numeric change, not whether an item was merged, closed or otherwise removed. + ## Words used on this page These words have a special meaning in Hive. Each entry explains them again the first time it uses them. diff --git a/src/pkg/dashboard/nav_count_delta.test.js b/src/pkg/dashboard/nav_count_delta.test.js new file mode 100644 index 0000000000..ac676c365f --- /dev/null +++ b/src/pkg/dashboard/nav_count_delta.test.js @@ -0,0 +1,260 @@ +// Execute the shipped helper and real badge writers, with a tiny DOM and +// deterministic clock. No browser, polling loop or Go process is started. +const test = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const path = require('node:path'); +const vm = require('node:vm'); +const source = name => fs.readFileSync(path.join(__dirname, 'static-src/js', name + '.js'), 'utf8'); +const fn = (file, name) => { + const found = source(file).match(new RegExp('(?:async )?function ' + name + '\\([^\\n]*\\) \\{[\\s\\S]*?\\n \\}')); + assert.ok(found, name); + return found[0]; +}; +const IDS = ['activity-monitor-sidebar-badge', 'activity-monitor-waiting-badge', 'contributors-sidebar-badge', 'knowledge-sidebar-badge']; + +function load() { + let now = 0, nextTimer = 0; + const timers = new Map(), elements = new Map(); + function element(id) { + const attrs = {}; + const el = { id, attrs, textContent: '', hidden: false, title: '', + setAttribute(k, v) { attrs[k] = String(v); }, + removeAttribute(k) { delete attrs[k]; }, + querySelector() { return null; }, + 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 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); }, + }); + vm.runInContext(source('nav-count-delta'), ctx); + vm.runInContext(` + var _kbCache = null, _kbInitialLoad = true, _kbRendered = false, _kbSetupView = 'none'; + var _cachedContributors = [], _stageTracker = null, _stageTrackerMoves = {}, _stageTrackerEvents = []; + var _stageTrackerFilter = {repo: 'filtered-out'}, _stageTrackerGroup = 'none', _stageTrackerCelebrating = {}; + function refreshSectionCardShell() {} + function setSectionSummary() {} + function contributorsSectionSummary() { return ''; } + function formatNumber(n) { return Number(n).toLocaleString('en-US'); } + function renderKnowledge() {} + function fetchBeadSynthStatus() {} + function fetchFactHistory() {} + function stageTrackerNoteMerges() {} + function stageTrackerNoteOpened() {} + function stageTrackerNoteMoves() {} + function stageTrackerSyncToolbar() {} + function stageTrackerWorkers() { return []; } + function stageTrackerNoteTuckSetting() { return false; } + function stageTrackerSharedPRs() { return {}; } + function stageTrackerRepoChipOn() { return false; } + function stageTrackerRepoChipSetting() { return ''; } + function stageTrackerTrainContiguous(rows) { return rows; } + function stageTrackerRegressionHandled() { return false; } + function stageTrackerOpenCounts() { return null; } + function stageTrackerRenderLabelDialog() {} + function stageTrackerMotionEffect() { return ''; } + function stageTrackerMotionSetting() { return ''; } + function stageTrackerReducedMotion() { return false; } + function stageTrackerSelectionSync() {} + function stageTrackerWaitingToast() {} + function stageTrackerActedAgo() { return ''; } + function setIfChanged(el, text) { el.innerHTML = text; } + `, ctx); + for (const [file, names] of [ + ['knowledge', ['sidebarPairBadgeText', 'setSidebarPairBadge', 'setSidebarCountBadge', 'kbTotalFactsFromStats', 'kbFactsLabel', 'kbSidebarFactCount', 'fetchKnowledgeStats']], + ['contributors', ['contributorsOnlineTitle', 'updateContributorBadge']], + ['tracker-waiting', ['stageTrackerWaitingOnYou', 'stageTrackerWaitingTitle', 'stageTrackerWaitKindWords', 'stageTrackerRenderWaiting']], + ['tracker-words-stage', ['stageTrackerDefaultFilter']], + ['tracker-filter-render', ['renderStageTracker']], + ['tracker-merged', ['stageTrackerMergingHoldRelease']], + ]) { + for (const name of names) vm.runInContext(fn(file, name), ctx); + } + for (const name of ['STAGE_TRACKER_AGE_MS', 'STAGE_TRACKER_SORTS', 'STAGE_TRACKER_ACTED_FILTERS', 'STAGE_TRACKER_PAGE_SIZES', 'STAGE_TRACKER_DEFAULT_PAGE_SIZE', 'STAGE_TRACKER_ATTENTION_STAGES']) { + const declaration = source(name === 'STAGE_TRACKER_ACTED_FILTERS' ? 'tracker-row' : 'tracker-words-stage').match(new RegExp('const ' + name + ' = [^\\n]+')); + assert.ok(declaration, name); + vm.runInContext(declaration[0], ctx); + } + 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), + tick(ms = 1400) { + now += ms; + for (const [id, timer] of [...timers]) if (timer.at <= now) { timers.delete(id); timer.cb(); } + }, + }; +} +const delta = badge => badge.attrs['data-count-delta']; +const item = (number, kind = 'issue', extra = {}) => ({ repo: 'o/r', number, kind, ...extra }); +const stats = (...counts) => ({ enabled: true, layers: counts.map(total_pages => ({ type: 'project', total_pages })) }); +const knowledge = async (api, payload) => { + api.ctx.fetch = async url => ({ ok: true, json: async () => url === '/api/knowledge/stats' ? payload : [] }); + await api.ctx.fetchKnowledgeStats(); +}; + +for (const id of IDS) { + test(id + ': initial/unchanged/unknown/zero, rapid changes, cleanup and rerender', () => { + const api = load(), badge = api.badge(id), write = (n, live = true) => api.ctx.navCountDelta(badge, n, 'Count ' + n, live); + write(0); + assert.equal(delta(badge), undefined); + write(0); + assert.equal(api.timers.size, 0); + write(3); + assert.equal(delta(badge), '↑ +3'); + assert.match(badge.attrs['aria-label'], /increased by 3/); + const phase = badge.attrs['data-count-phase']; + api.tick(500); + write(5); + assert.equal(delta(badge), '↑ +2'); + assert.notEqual(badge.attrs['data-count-phase'], phase); + assert.equal(api.timers.size, 1); + write(3); + assert.equal(delta(badge), '↓ -2'); + write(3); + assert.equal(api.timers.size, 1); + api.tick(); + assert.equal(delta(badge), undefined); + assert.equal(api.timers.size, 0); + assert.equal(badge.attrs['aria-label'], 'Count 3'); + write(0); + assert.equal(delta(badge), '↓ -3', 'zero is a known value'); + for (const invalid of [null, undefined, NaN, -1, '8', Infinity, 1.5]) { + write(invalid); + write(8); + assert.equal(delta(badge), undefined, 'unknown -> known seeds, not a synthetic increase'); + } + write(9, false); + assert.equal(delta(badge), undefined, 'cached/route redraw does not animate'); + write(9); + assert.equal(delta(badge), undefined, 'redraw advanced the baseline'); + write(10); + const replacement = api.element(id); + api.ctx.navCountDelta(replacement, 10, 'Count 10'); + assert.equal(delta(badge), undefined); + assert.equal(delta(replacement), undefined); + assert.equal(api.timers.size, 0, 'replacement cancels the old element timer'); + }); +} + +test('real tracker renderer: new issues, PR removal, batching, filters, invalid payloads', () => { + const api = load(), badge = api.badge(IDS[0]), render = items => api.ctx.renderStageTracker({ items }); + render([item(1), item(2, 'pr')]); + assert.equal(badge.textContent, '2'); + assert.equal(delta(badge), undefined); + render([item(1), item(2, 'pr'), item(3)]); + assert.equal(delta(badge), '↑ +1'); + render([item(1), item(3)]); + assert.equal(delta(badge), '↓ -1'); + render([item(1), item(3), item(4), item(5), item(6)]); + assert.equal(delta(badge), '↑ +3'); + api.tick(); + api.ctx.renderStageTracker(); + assert.equal(delta(badge), undefined); + // A PR under a listed issue shares its row, not a new count. + render([item(1), item(3), item(4), item(5), item(6), item(7, 'pr', { nested_under: 1 })]); + assert.equal(delta(badge), undefined); + api.ctx.renderStageTracker({ status: 'initializing' }); + render([]); + assert.equal(badge.textContent, '0'); + assert.equal(delta(badge), undefined); +}); + +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); + write(2); + write(5); + assert.equal(delta(badge), '↑ +3'); + write(0); + assert.equal(badge.textContent, '0'); + assert.equal(delta(badge), '↓ -5'); + write(undefined); + write(3); + assert.equal(delta(badge), undefined); + assert.equal(api.timers.size, 0); + assert.equal(delta(api.badge(IDS[0])), undefined); +}); + +test('a merged PR count delayed by the existing hold animates when that hold releases', () => { + const api = load(), badge = api.badge(IDS[0]); + api.ctx._stageTrackerMergingHold = {}; + api.ctx.holding = true; + api.ctx.stageTrackerMergingHoldView = d => api.ctx.holding ? { ...d, items: d.items.concat(item(2, 'pr')) } : d; + api.ctx.renderStageTracker({ items: [item(1)] }); + assert.equal(badge.textContent, '2'); + api.ctx.holding = false; + api.ctx.stageTrackerMergingHoldRelease(); + assert.equal(badge.textContent, '1'); + assert.equal(delta(badge), '↓ -1'); + api.tick(); + api.ctx.renderStageTracker(); + assert.equal(delta(badge), undefined, 'later cached redraw does not replay the release'); +}); + +test('contributors use online only, not active sockets or denominator changes', () => { + const api = load(), badge = api.badge(IDS[2]); + const write = (online, registered = 12, active = 99) => api.ctx.updateContributorBadge({ online, registered, active, presence_window: '15m' }); + write(2); + assert.equal(badge.textContent, '2/12'); + write(2, 20, 1); + assert.equal(delta(badge), undefined); + write(5, 20); + assert.equal(delta(badge), '↑ +3'); + write(3, 21); + assert.equal(delta(badge), '↓ -2'); + write(0); + assert.equal(badge.textContent, '0/12'); + assert.equal(delta(badge), '↓ -3'); + write(undefined); + assert.equal(badge.textContent, '0/12', 'unknown does not replace display with a fabricated zero'); + write(4); + assert.equal(delta(badge), undefined); +}); + +test('knowledge uses numeric layer fact totals, independent of formatting and disabled priming', async () => { + const api = load(), badge = api.badge(IDS[3]); + await knowledge(api, stats(1000, 20)); + assert.equal(badge.textContent, 1020); + assert.equal(delta(badge), undefined); + await knowledge(api, stats(1000, 20)); + assert.equal(delta(badge), undefined); + await knowledge(api, stats(1001, 22)); + assert.equal(delta(badge), '↑ +3'); + await knowledge(api, stats(1000, 21)); + assert.equal(delta(badge), '↓ -2'); + await knowledge(api, { enabled: true }); + assert.equal(badge.textContent, 1021); + await knowledge(api, stats()); + assert.equal(badge.textContent, 0); + assert.equal(delta(badge), undefined); + await knowledge(api, stats(2)); + assert.equal(delta(badge), '↑ +2'); + await knowledge(api, { enabled: false, layers: [] }); + assert.equal(delta(badge), undefined, 'disabling priming is not fact deletion'); + assert.equal(api.timers.size, 0); +}); + +test('reduced motion keeps static signed feedback; hidden tabs advance without animation', () => { + const api = load(), badge = api.badge(IDS[2]); + api.ctx.window.matchMedia = () => ({ matches: true }); + api.ctx.navCountDelta(badge, 1, '1 online'); + api.ctx.navCountDelta(badge, 4, '4 online'); + assert.equal(delta(badge), '↑ +3', 'feedback remains readable with reduced motion'); + // CSS, not a JS listener, disables motion (including preference changes + // during a cue). Keep that shipped rule covered alongside behavior. + const css = fs.readFileSync(path.join(__dirname, 'static-src/css/design-system.css'), 'utf8'); + assert.match(css, /@media \(prefers-reduced-motion: reduce\) \{\s*\[data-count-phase\]::after \{ animation: none; \}/); + api.document.hidden = true; + api.ctx.navCountDelta(badge, 7, '7 online'); + assert.equal(delta(badge), undefined); + api.document.hidden = false; + api.ctx.navCountDelta(badge, 7, '7 online'); + assert.equal(delta(badge), undefined); + assert.equal(api.timers.size, 0); +}); diff --git a/src/pkg/dashboard/stage_tracker_ui_test.go b/src/pkg/dashboard/stage_tracker_ui_test.go index 60a235754c..67f573b713 100644 --- a/src/pkg/dashboard/stage_tracker_ui_test.go +++ b/src/pkg/dashboard/stage_tracker_ui_test.go @@ -26,7 +26,7 @@ func TestStageTrackerSectionWiring(t *testing.T) { `id="oc-waiting-on-you" data-action="showWaitingOnYou"`, `id="activity-monitor-waiting" data-action="hamFilter" data-arg0="waitingOnYou" data-arg1="toggle"`, `if (f.waitingOnYou && !item.waiting_on_you) return false;`, - `function stageTrackerRenderWaiting(d, nowMs)`, + `function stageTrackerRenderWaiting(d, nowMs, live = true)`, `function stageTrackerWaitingToast(w, nowMs)`, `if (typeof window.hiveKioskMode === 'function' && window.hiveKioskMode()) return;`, `const STAGE_TRACKER_WAITING_FILTER_PARAM = 'waiting-on-you';`, diff --git a/src/pkg/dashboard/stage_tracker_waiting.test.js b/src/pkg/dashboard/stage_tracker_waiting.test.js index 4c89c3274a..846970be2e 100644 --- a/src/pkg/dashboard/stage_tracker_waiting.test.js +++ b/src/pkg/dashboard/stage_tracker_waiting.test.js @@ -18,6 +18,7 @@ function pick(re, what) { function load(env) { const src = [ + fs.readFileSync(path.join(__dirname, 'static-src/js/nav-count-delta.js'), 'utf8'), 'var toasts = [];', 'var navigated = [];', 'var filtered = [];', @@ -40,7 +41,7 @@ function load(env) { pick(/function stageTrackerWaitingOnYou\(d\) \{[\s\S]*?\n \}\n/, 'stageTrackerWaitingOnYou'), pick(/function stageTrackerWaitKindWords\(kind\) \{[^\n]*\n/, 'stageTrackerWaitKindWords'), pick(/function stageTrackerWaitingTitle\(w, nowMs\) \{[\s\S]*?\n \}\n/, 'stageTrackerWaitingTitle'), - pick(/function stageTrackerRenderWaiting\(d, nowMs\) \{[\s\S]*?\n \}\n/, 'stageTrackerRenderWaiting'), + pick(/function stageTrackerRenderWaiting\(d, nowMs, live = true\) \{[\s\S]*?\n \}\n/, 'stageTrackerRenderWaiting'), pick(/function stageTrackerWaitingToast\(w, nowMs\) \{[\s\S]*?\n \}\n/, 'stageTrackerWaitingToast'), pick(/function stageTrackerWaitingToastText\(w\) \{[\s\S]*?\n \}\n/, 'stageTrackerWaitingToastText'), pick(/function showWaitingOnYou\(\) \{[\s\S]*?\n \}\n/, 'showWaitingOnYou'), diff --git a/src/pkg/dashboard/static-src/css/design-system.css b/src/pkg/dashboard/static-src/css/design-system.css index 41957ae967..f7993761b6 100644 --- a/src/pkg/dashboard/static-src/css/design-system.css +++ b/src/pkg/dashboard/static-src/css/design-system.css @@ -84,6 +84,33 @@ .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; } + /* 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-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; + font-size: 0; padding: 0; border: 0; + } + .oc-nav-count[data-count-delta]::after { + content: attr(data-count-delta); position: absolute; bottom: calc(100% + 2px); right: 0; + pointer-events: none; z-index: 1; padding: 0 4px; border-radius: var(--r-pill); + background: var(--surface); color: var(--brand); border: 1px solid var(--brand); + font-size: var(--fs-2xs); line-height: 1.4; font-variant-numeric: tabular-nums; + } + #contributors-sidebar-badge[data-count-delta]::after, + #knowledge-sidebar-badge[data-count-delta]::after { + bottom: auto; top: 50%; right: calc(100% + var(--sp-1)); translate: 0 -50%; + } + [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; } + [data-count-phase="b"]::after { animation: nav-count-b 220ms ease-out; } + @keyframes nav-count-a { from { opacity: 0; transform: translateY(var(--nav-count-start)); } to { opacity: 1; transform: translateY(0); } } + @keyframes nav-count-b { from { opacity: 0; transform: translateY(var(--nav-count-start)); } to { opacity: 1; transform: translateY(0); } } + @media (prefers-reduced-motion: reduce) { + [data-count-phase]::after { animation: none; } + } /* pill size steps */ .token-model-chip { padding: 4px 10px; font-size: var(--fs-sm); } .nous-config-pill { padding: 3px 10px; font-size: var(--fs-sm); } diff --git a/src/pkg/dashboard/static-src/js/contributors.js b/src/pkg/dashboard/static-src/js/contributors.js index 3c1f4af243..0e5410074c 100644 --- a/src/pkg/dashboard/static-src/js/contributors.js +++ b/src/pkg/dashboard/static-src/js/contributors.js @@ -493,12 +493,17 @@ refreshSectionCardShell('contributors-section'); const sidebarBadge = document.getElementById('contributors-sidebar-badge'); const statusBadge = document.getElementById('contributors-status-badge'); - if (!pool) return; - const onlineCount = Number(pool.online) || 0; - const totalCount = Number(pool.registered) || 0; + if (!pool || !Number.isSafeInteger(pool.online) || pool.online < 0 || + !Number.isSafeInteger(pool.registered) || pool.registered < 0) { + navCountDelta(sidebarBadge, null); + return; + } + const onlineCount = pool.online; + 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); + navCountDelta(sidebarBadge, onlineCount, 'Contributors: ' + tip); setSectionSummary('contributors-section', contributorsSectionSummary(_cachedContributors || [], pool)); if (statusBadge) { statusBadge.textContent = `${onlineCount} online / ${totalCount} registered`; @@ -530,4 +535,3 @@ } // fetchContributors() + fetchLeaderboard() — deferred to _deferredInit - diff --git a/src/pkg/dashboard/static-src/js/knowledge.js b/src/pkg/dashboard/static-src/js/knowledge.js index 173320d116..0b0abc7ba7 100644 --- a/src/pkg/dashboard/static-src/js/knowledge.js +++ b/src/pkg/dashboard/static-src/js/knowledge.js @@ -150,6 +150,16 @@ return formatNumber(total) + ' fact' + (total === 1 ? '' : 's'); } + // Validate the same layer totals used by the displayed facts badge. + // Missing layers are unknown, not an empty knowledge base. + function kbSidebarFactCount(stats) { + if (!stats || typeof stats.enabled !== 'boolean') return null; + if (!stats.enabled) return 0; + if (!Array.isArray(stats.layers) || stats.layers.some(l => !l || !Number.isSafeInteger(l.total_pages) || l.total_pages < 0)) return null; + const count = kbTotalFactsFromStats(stats); + return Number.isSafeInteger(count) ? count : null; + } + // ── Document Sources ── const DOC_CONTENT_ICONS = { 'text/html': '🌐', 'application/pdf': '📄', 'text/plain': '📝', 'text/markdown': '📝', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': '📋' }; @@ -228,13 +238,21 @@ const [r, , , docsR] = await Promise.all([fetch('/api/knowledge/stats'), fetchBeadSynthStatus(), fetchFactHistory(), fetch('/api/knowledge/documents')]); if (!r.ok) return; const prev = _kbCache; - _kbCache = await r.json(); + const next = await r.json(); + const kbBadge = document.getElementById('knowledge-sidebar-badge'); + const kbFacts = kbSidebarFactCount(next); + if (kbFacts === null) { + navCountDelta(kbBadge, null); + return; + } + _kbCache = next; _kbCache._documents = (docsR && docsR.ok) ? await docsR.json() : []; setSectionSummary('knowledge-section', kbFactsLabel(kbTotalFactsFromStats(_kbCache))); - var kbBadge = document.getElementById('knowledge-sidebar-badge'); if (kbBadge) { - var kbFacts = kbTotalFactsFromStats(_kbCache); - setSidebarCountBadge(kbBadge, _kbCache && _kbCache.enabled ? kbFacts : 0, kbFactsLabel(kbFacts)); + // Toggling priming changes what the badge shows, not stored facts. + if (prev && prev.enabled !== _kbCache.enabled) navCountDelta(kbBadge, null); + setSidebarCountBadge(kbBadge, kbFacts, kbFactsLabel(kbTotalFactsFromStats(_kbCache))); + navCountDelta(kbBadge, kbFacts, kbFactsLabel(kbFacts)); } if (_kbInitialLoad && _kbCache && _kbCache.enabled) { _kbSetupView = 'none'; @@ -2397,4 +2415,3 @@ await kcSyncNow(name); setTimeout(() => kbLoadIntegrationsModal(_kbIntegrationSelected), 1500); } - diff --git a/src/pkg/dashboard/static-src/js/nav-count-delta.js b/src/pkg/dashboard/static-src/js/nav-count-delta.js new file mode 100644 index 0000000000..3aa2e728c8 --- /dev/null +++ b/src/pkg/dashboard/static-src/js/nav-count-delta.js @@ -0,0 +1,53 @@ + // Only explicitly wired navigation counts participate. Keep raw-number + // baselines outside the DOM: filters/routes can redraw without live data. + const NAV_COUNT_CUE_MS = 1400; + const _navCountDeltas = new Map(); + function navCountDelta(badge, count, label, live = true) { + if (!badge) return; + let state = _navCountDeltas.get(badge.id); + const replaced = state && state.badge !== badge; + if (replaced) state.clear(); + if (!state || replaced) { + state = { badge, count: null, timer: null, phase: false, delta: '', label: '' }; + state.clear = () => { + if (state.timer !== null) clearTimeout(state.timer); + state.timer = null; + state.delta = ''; + badge.removeAttribute('data-count-delta'); + badge.removeAttribute('data-count-direction'); + badge.removeAttribute('data-count-phase'); + if (state.label) badge.setAttribute('aria-label', state.label); + }; + _navCountDeltas.set(badge.id, state); + } + if (!Number.isSafeInteger(count) || count < 0) { + state.clear(); + state.count = null; + return; + } + state.label = label; + const previous = state.count; + state.count = count; + if (previous === null || previous === count || replaced) { + badge.setAttribute('aria-label', label + state.delta); + return; + } + state.clear(); + // Re-rendering cached rows is not a new observation. A reconnect is + // simply a net count change; never claim it was a merge/open event. + if (!live || document.hidden) return; + const delta = count - previous; + state.delta = ', ' + (delta > 0 ? 'increased' : 'decreased') + ' by ' + Math.abs(delta); + badge.setAttribute('aria-label', label + state.delta); + badge.setAttribute('data-count-delta', (delta > 0 ? '↑ +' : '↓ ') + delta); + badge.setAttribute('data-count-direction', delta > 0 ? 'up' : 'down'); + state.phase = !state.phase; + badge.setAttribute('data-count-phase', state.phase ? 'a' : 'b'); + state.timer = setTimeout(state.clear, NAV_COUNT_CUE_MS); + } + + function stageTrackerSidebarCountsUnknown() { + for (const id of ['activity-monitor-sidebar-badge', 'activity-monitor-waiting-badge']) { + navCountDelta(document.getElementById(id), null); + } + } 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 71a9d7dc71..27a0629c86 100644 --- a/src/pkg/dashboard/static-src/js/tracker-filter-render.js +++ b/src/pkg/dashboard/static-src/js/tracker-filter-render.js @@ -51,7 +51,7 @@ _stageTrackerPollErrorSince = 0; } - function renderStageTracker(data) { + function renderStageTracker(data, countRefresh = false) { if (data && typeof data === 'object') { _stageTracker = data; stageTrackerNoteMerges(data); stageTrackerNoteOpened(data); stageTrackerNoteMoves(data); } // Row-action feedback rides the payload: a result toast leaves and a // row stops "acting" once the item it targets reads a new state. @@ -62,6 +62,7 @@ // Rows under a "Merging" hold the payload already dropped ride along (#15245). const d = typeof stageTrackerMergingHoldView === 'function' ? stageTrackerMergingHoldView(_stageTracker, _stageTrackerMergingHold, nowMs) : _stageTracker; if (!d || d.status === 'initializing' || !Array.isArray(d.items)) { + stageTrackerSidebarCountsUnknown(); setIfChanged(el, '
Waiting for the first scan…
'); return; } @@ -108,7 +109,8 @@ 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', ''); } - stageTrackerRenderWaiting(d, nowMs); + navCountDelta(badge, 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))); stageTrackerRenderLabelDialog(); @@ -206,4 +208,3 @@ _stageTrackerNudgeAt = Date.now(); fetchStageTracker(); } - diff --git a/src/pkg/dashboard/static-src/js/tracker-merged.js b/src/pkg/dashboard/static-src/js/tracker-merged.js index 2732784dd9..8b861d8aa7 100644 --- a/src/pkg/dashboard/static-src/js/tracker-merged.js +++ b/src/pkg/dashboard/static-src/js/tracker-merged.js @@ -191,7 +191,7 @@ _stageTrackerMergingHoldTimer = 0; if (!_stageTracker || typeof _stageTracker !== 'object') return; stageTrackerNoteMerges(_stageTracker); - renderStageTracker(); + renderStageTracker(undefined, true); } /* ---- tracker-cues: merged — pinned row, glyph flight, "Merged" chip --- @@ -901,4 +901,3 @@ // (items only ever list open work and the audit side list is pr_merged // only); when a recently_closed list lands, mark those issue keys true // in stageTrackerMergeState and they will zap through the same path. - diff --git a/src/pkg/dashboard/static-src/js/tracker-waiting.js b/src/pkg/dashboard/static-src/js/tracker-waiting.js index cd12e36ba6..69352c6709 100644 --- a/src/pkg/dashboard/static-src/js/tracker-waiting.js +++ b/src/pkg/dashboard/static-src/js/tracker-waiting.js @@ -27,8 +27,9 @@ // older spoke sends items without the header block. function stageTrackerWaitingOnYou(d) { const w = d && d.waiting_on_human; - if (w && Array.isArray(w.items)) return { count: Number(w.count) || w.items.length, items: w.items }; - const items = (Array.isArray(d?.items) ? d.items : []).filter(it => it && it.waiting_on_you && !it.nested_under) + if (w) return { count: Array.isArray(w.items) && Number.isSafeInteger(w.count) && w.count >= 0 ? w.count : null, items: Array.isArray(w.items) ? w.items : [] }; + if (!Array.isArray(d?.items)) return { count: null, items: [] }; + const items = d.items.filter(it => it && it.waiting_on_you && !it.nested_under) .map(it => ({ repo: it.repo, number: it.number, type: it.kind, kind: it.wait_kind || 'other-human-wait', since: it.stage_since, who: 'operator' })); return { count: items.length, items }; } @@ -50,15 +51,21 @@ // Sidebar badge + topbar pill. Called from renderStageTracker on every // payload; the pill hides at zero, the badge keeps data-zero. - function stageTrackerRenderWaiting(d, nowMs) { + function stageTrackerRenderWaiting(d, nowMs, live = true) { const w = stageTrackerWaitingOnYou(d); - const title = stageTrackerWaitingTitle(w, nowMs); const badge = document.getElementById('activity-monitor-waiting-badge'); + if (w.count === null) { + navCountDelta(badge, null); + _stageTrackerWaitingPrevCount = null; + return; + } + const title = stageTrackerWaitingTitle(w, nowMs); if (badge) { badge.textContent = String(w.count); badge.title = title; badge.setAttribute('aria-label', w.count + ' waiting on you'); if (w.count) badge.removeAttribute('data-zero'); else badge.setAttribute('data-zero', ''); + navCountDelta(badge, w.count, w.count + ' waiting on you', live); } const pill = document.getElementById('oc-waiting-on-you'); if (pill) { diff --git a/src/pkg/dashboard/static-src/manifest.txt b/src/pkg/dashboard/static-src/manifest.txt index 2a7cd02568..4c4556e660 100644 --- a/src/pkg/dashboard/static-src/manifest.txt +++ b/src/pkg/dashboard/static-src/manifest.txt @@ -71,6 +71,7 @@ js/tracker-row.js js/tracker-motion.js js/tracker-filter.js js/tracker-filter-state.js +js/nav-count-delta.js js/tracker-filter-render.js js/tracker-filter-fetch.js js/tracker-actions.js diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index a918d7bacd..802255a7d2 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -5455,6 +5455,33 @@ .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; } + /* 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-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; + font-size: 0; padding: 0; border: 0; + } + .oc-nav-count[data-count-delta]::after { + content: attr(data-count-delta); position: absolute; bottom: calc(100% + 2px); right: 0; + pointer-events: none; z-index: 1; padding: 0 4px; border-radius: var(--r-pill); + background: var(--surface); color: var(--brand); border: 1px solid var(--brand); + font-size: var(--fs-2xs); line-height: 1.4; font-variant-numeric: tabular-nums; + } + #contributors-sidebar-badge[data-count-delta]::after, + #knowledge-sidebar-badge[data-count-delta]::after { + bottom: auto; top: 50%; right: calc(100% + var(--sp-1)); translate: 0 -50%; + } + [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; } + [data-count-phase="b"]::after { animation: nav-count-b 220ms ease-out; } + @keyframes nav-count-a { from { opacity: 0; transform: translateY(var(--nav-count-start)); } to { opacity: 1; transform: translateY(0); } } + @keyframes nav-count-b { from { opacity: 0; transform: translateY(var(--nav-count-start)); } to { opacity: 1; transform: translateY(0); } } + @media (prefers-reduced-motion: reduce) { + [data-count-phase]::after { animation: none; } + } /* pill size steps */ .token-model-chip { padding: 4px 10px; font-size: var(--fs-sm); } .nous-config-pill { padding: 3px 10px; font-size: var(--fs-sm); } @@ -19123,6 +19150,59 @@

All labels

stageTrackerRenderLabelDialog(); } + // Only explicitly wired navigation counts participate. Keep raw-number + // baselines outside the DOM: filters/routes can redraw without live data. + const NAV_COUNT_CUE_MS = 1400; + const _navCountDeltas = new Map(); + function navCountDelta(badge, count, label, live = true) { + if (!badge) return; + let state = _navCountDeltas.get(badge.id); + const replaced = state && state.badge !== badge; + if (replaced) state.clear(); + if (!state || replaced) { + state = { badge, count: null, timer: null, phase: false, delta: '', label: '' }; + state.clear = () => { + if (state.timer !== null) clearTimeout(state.timer); + state.timer = null; + state.delta = ''; + badge.removeAttribute('data-count-delta'); + badge.removeAttribute('data-count-direction'); + badge.removeAttribute('data-count-phase'); + if (state.label) badge.setAttribute('aria-label', state.label); + }; + _navCountDeltas.set(badge.id, state); + } + if (!Number.isSafeInteger(count) || count < 0) { + state.clear(); + state.count = null; + return; + } + state.label = label; + const previous = state.count; + state.count = count; + if (previous === null || previous === count || replaced) { + badge.setAttribute('aria-label', label + state.delta); + return; + } + state.clear(); + // Re-rendering cached rows is not a new observation. A reconnect is + // simply a net count change; never claim it was a merge/open event. + if (!live || document.hidden) return; + const delta = count - previous; + state.delta = ', ' + (delta > 0 ? 'increased' : 'decreased') + ' by ' + Math.abs(delta); + badge.setAttribute('aria-label', label + state.delta); + badge.setAttribute('data-count-delta', (delta > 0 ? '↑ +' : '↓ ') + delta); + badge.setAttribute('data-count-direction', delta > 0 ? 'up' : 'down'); + state.phase = !state.phase; + badge.setAttribute('data-count-phase', state.phase ? 'a' : 'b'); + state.timer = setTimeout(state.clear, NAV_COUNT_CUE_MS); + } + + function stageTrackerSidebarCountsUnknown() { + for (const id of ['activity-monitor-sidebar-badge', 'activity-monitor-waiting-badge']) { + navCountDelta(document.getElementById(id), null); + } + } function stageTrackerPagerHtml(page) { if (page.pages <= 1) return ''; return ``; @@ -19176,7 +19256,7 @@

All labels

_stageTrackerPollErrorSince = 0; } - function renderStageTracker(data) { + function renderStageTracker(data, countRefresh = false) { if (data && typeof data === 'object') { _stageTracker = data; stageTrackerNoteMerges(data); stageTrackerNoteOpened(data); stageTrackerNoteMoves(data); } // Row-action feedback rides the payload: a result toast leaves and a // row stops "acting" once the item it targets reads a new state. @@ -19187,6 +19267,7 @@

All labels

// Rows under a "Merging" hold the payload already dropped ride along (#15245). const d = typeof stageTrackerMergingHoldView === 'function' ? stageTrackerMergingHoldView(_stageTracker, _stageTrackerMergingHold, nowMs) : _stageTracker; if (!d || d.status === 'initializing' || !Array.isArray(d.items)) { + stageTrackerSidebarCountsUnknown(); setIfChanged(el, '
Waiting for the first scan…
'); return; } @@ -19233,7 +19314,8 @@

All labels

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', ''); } - stageTrackerRenderWaiting(d, nowMs); + navCountDelta(badge, 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))); stageTrackerRenderLabelDialog(); @@ -19331,7 +19413,6 @@

All labels

_stageTrackerNudgeAt = Date.now(); fetchStageTracker(); } - async function fetchStageTracker() { try { if (!_stageTrackerSig && !_stageTrackerEtag) stageTrackerLoadGrouping(); @@ -21936,7 +22017,7 @@

All labels

_stageTrackerMergingHoldTimer = 0; if (!_stageTracker || typeof _stageTracker !== 'object') return; stageTrackerNoteMerges(_stageTracker); - renderStageTracker(); + renderStageTracker(undefined, true); } /* ---- tracker-cues: merged — pinned row, glyph flight, "Merged" chip --- @@ -22646,7 +22727,6 @@

All labels

// (items only ever list open work and the audit side list is pr_merged // only); when a recently_closed list lands, mark those issue keys true // in stageTrackerMergeState and they will zap through the same path. - /* ---- Merge queue popover (hivecommons/hive#15395) ---------------------- The sticky bar's "Merge queue" chip lists every merge train in the payload in merge order — #, title, state, ETA — so an operator can @@ -23552,8 +23632,9 @@

All labels

// older spoke sends items without the header block. function stageTrackerWaitingOnYou(d) { const w = d && d.waiting_on_human; - if (w && Array.isArray(w.items)) return { count: Number(w.count) || w.items.length, items: w.items }; - const items = (Array.isArray(d?.items) ? d.items : []).filter(it => it && it.waiting_on_you && !it.nested_under) + if (w) return { count: Array.isArray(w.items) && Number.isSafeInteger(w.count) && w.count >= 0 ? w.count : null, items: Array.isArray(w.items) ? w.items : [] }; + if (!Array.isArray(d?.items)) return { count: null, items: [] }; + const items = d.items.filter(it => it && it.waiting_on_you && !it.nested_under) .map(it => ({ repo: it.repo, number: it.number, type: it.kind, kind: it.wait_kind || 'other-human-wait', since: it.stage_since, who: 'operator' })); return { count: items.length, items }; } @@ -23575,15 +23656,21 @@

All labels

// Sidebar badge + topbar pill. Called from renderStageTracker on every // payload; the pill hides at zero, the badge keeps data-zero. - function stageTrackerRenderWaiting(d, nowMs) { + function stageTrackerRenderWaiting(d, nowMs, live = true) { const w = stageTrackerWaitingOnYou(d); - const title = stageTrackerWaitingTitle(w, nowMs); const badge = document.getElementById('activity-monitor-waiting-badge'); + if (w.count === null) { + navCountDelta(badge, null); + _stageTrackerWaitingPrevCount = null; + return; + } + const title = stageTrackerWaitingTitle(w, nowMs); if (badge) { badge.textContent = String(w.count); badge.title = title; badge.setAttribute('aria-label', w.count + ' waiting on you'); if (w.count) badge.removeAttribute('data-zero'); else badge.setAttribute('data-zero', ''); + navCountDelta(badge, w.count, w.count + ' waiting on you', live); } const pill = document.getElementById('oc-waiting-on-you'); if (pill) { @@ -37038,6 +37125,16 @@

All labels

return formatNumber(total) + ' fact' + (total === 1 ? '' : 's'); } + // Validate the same layer totals used by the displayed facts badge. + // Missing layers are unknown, not an empty knowledge base. + function kbSidebarFactCount(stats) { + if (!stats || typeof stats.enabled !== 'boolean') return null; + if (!stats.enabled) return 0; + if (!Array.isArray(stats.layers) || stats.layers.some(l => !l || !Number.isSafeInteger(l.total_pages) || l.total_pages < 0)) return null; + const count = kbTotalFactsFromStats(stats); + return Number.isSafeInteger(count) ? count : null; + } + // ── Document Sources ── const DOC_CONTENT_ICONS = { 'text/html': '🌐', 'application/pdf': '📄', 'text/plain': '📝', 'text/markdown': '📝', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': '📋' }; @@ -37116,13 +37213,21 @@

All labels

const [r, , , docsR] = await Promise.all([fetch('/api/knowledge/stats'), fetchBeadSynthStatus(), fetchFactHistory(), fetch('/api/knowledge/documents')]); if (!r.ok) return; const prev = _kbCache; - _kbCache = await r.json(); + const next = await r.json(); + const kbBadge = document.getElementById('knowledge-sidebar-badge'); + const kbFacts = kbSidebarFactCount(next); + if (kbFacts === null) { + navCountDelta(kbBadge, null); + return; + } + _kbCache = next; _kbCache._documents = (docsR && docsR.ok) ? await docsR.json() : []; setSectionSummary('knowledge-section', kbFactsLabel(kbTotalFactsFromStats(_kbCache))); - var kbBadge = document.getElementById('knowledge-sidebar-badge'); if (kbBadge) { - var kbFacts = kbTotalFactsFromStats(_kbCache); - setSidebarCountBadge(kbBadge, _kbCache && _kbCache.enabled ? kbFacts : 0, kbFactsLabel(kbFacts)); + // Toggling priming changes what the badge shows, not stored facts. + if (prev && prev.enabled !== _kbCache.enabled) navCountDelta(kbBadge, null); + setSidebarCountBadge(kbBadge, kbFacts, kbFactsLabel(kbTotalFactsFromStats(_kbCache))); + navCountDelta(kbBadge, kbFacts, kbFactsLabel(kbFacts)); } if (_kbInitialLoad && _kbCache && _kbCache.enabled) { _kbSetupView = 'none'; @@ -39285,7 +39390,6 @@ await kcSyncNow(name); setTimeout(() => kbLoadIntegrationsModal(_kbIntegrationSelected), 1500); } - // ── Vault Management ── function kbOpenVaults() { @@ -40631,12 +40735,17 @@ refreshSectionCardShell('contributors-section'); const sidebarBadge = document.getElementById('contributors-sidebar-badge'); const statusBadge = document.getElementById('contributors-status-badge'); - if (!pool) return; - const onlineCount = Number(pool.online) || 0; - const totalCount = Number(pool.registered) || 0; + if (!pool || !Number.isSafeInteger(pool.online) || pool.online < 0 || + !Number.isSafeInteger(pool.registered) || pool.registered < 0) { + navCountDelta(sidebarBadge, null); + return; + } + const onlineCount = pool.online; + 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); + navCountDelta(sidebarBadge, onlineCount, 'Contributors: ' + tip); setSectionSummary('contributors-section', contributorsSectionSummary(_cachedContributors || [], pool)); if (statusBadge) { statusBadge.textContent = `${onlineCount} online / ${totalCount} registered`; @@ -40668,7 +40777,6 @@ } // fetchContributors() + fetchLeaderboard() — deferred to _deferredInit - // ── System resource gauge history for sparklines ── // NOTE: these mini-sparklines still read this in-memory array, which resets // on reload. The disk/mem/cpu percentages ARE now persisted server-side in From 95bf6548194c46fdb6024186742a4f7b745136ca Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Fri, 30 Oct 2026 15:21:23 -0400 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=90=9B=20Use=20spacing=20tokens=20for?= =?UTF-8?q?=20sidebar=20count=20delta=20cues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andy Anderson --- src/pkg/dashboard/static-src/css/design-system.css | 2 +- src/pkg/dashboard/static/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pkg/dashboard/static-src/css/design-system.css b/src/pkg/dashboard/static-src/css/design-system.css index f7993761b6..dec944b1ea 100644 --- a/src/pkg/dashboard/static-src/css/design-system.css +++ b/src/pkg/dashboard/static-src/css/design-system.css @@ -94,7 +94,7 @@ } .oc-nav-count[data-count-delta]::after { content: attr(data-count-delta); position: absolute; bottom: calc(100% + 2px); right: 0; - pointer-events: none; z-index: 1; padding: 0 4px; border-radius: var(--r-pill); + pointer-events: none; z-index: 1; padding: var(--sp-0) var(--sp-1); border-radius: var(--r-pill); background: var(--surface); color: var(--brand); border: 1px solid var(--brand); font-size: var(--fs-2xs); line-height: 1.4; font-variant-numeric: tabular-nums; } diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 802255a7d2..98165b6cec 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -5465,7 +5465,7 @@ } .oc-nav-count[data-count-delta]::after { content: attr(data-count-delta); position: absolute; bottom: calc(100% + 2px); right: 0; - pointer-events: none; z-index: 1; padding: 0 4px; border-radius: var(--r-pill); + pointer-events: none; z-index: 1; padding: var(--sp-0) var(--sp-1); border-radius: var(--r-pill); background: var(--surface); color: var(--brand); border: 1px solid var(--brand); font-size: var(--fs-2xs); line-height: 1.4; font-variant-numeric: tabular-nums; } From 36985830e582b3f0efd18b01ba12b6b935528f7c Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Fri, 30 Oct 2026 15:40:34 -0400 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=90=9B=20Preserve=20style=20ratchets?= =?UTF-8?q?=20for=20zero-count=20sidebar=20cues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andy Anderson --- src/pkg/dashboard/static-src/css/design-system.css | 4 ++-- src/pkg/dashboard/static/index.html | 4 ++-- src/pkg/dashboard/webstatic/style_ratchet_test.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pkg/dashboard/static-src/css/design-system.css b/src/pkg/dashboard/static-src/css/design-system.css index dec944b1ea..472b1a51d8 100644 --- a/src/pkg/dashboard/static-src/css/design-system.css +++ b/src/pkg/dashboard/static-src/css/design-system.css @@ -90,11 +90,11 @@ .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; - font-size: 0; padding: 0; border: 0; + visibility: hidden; padding: 0; border: 0; } .oc-nav-count[data-count-delta]::after { content: attr(data-count-delta); position: absolute; bottom: calc(100% + 2px); right: 0; - pointer-events: none; z-index: 1; padding: var(--sp-0) var(--sp-1); border-radius: var(--r-pill); + 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); font-size: var(--fs-2xs); line-height: 1.4; font-variant-numeric: tabular-nums; } diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 98165b6cec..33d84f7d46 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -5461,11 +5461,11 @@ .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; - font-size: 0; padding: 0; border: 0; + visibility: hidden; padding: 0; border: 0; } .oc-nav-count[data-count-delta]::after { content: attr(data-count-delta); position: absolute; bottom: calc(100% + 2px); right: 0; - pointer-events: none; z-index: 1; padding: var(--sp-0) var(--sp-1); border-radius: var(--r-pill); + 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); font-size: var(--fs-2xs); line-height: 1.4; font-variant-numeric: tabular-nums; } diff --git a/src/pkg/dashboard/webstatic/style_ratchet_test.go b/src/pkg/dashboard/webstatic/style_ratchet_test.go index c69a9de0e1..34a5b7ff10 100644 --- a/src/pkg/dashboard/webstatic/style_ratchet_test.go +++ b/src/pkg/dashboard/webstatic/style_ratchet_test.go @@ -26,7 +26,7 @@ type styleRatchetCounts struct { // removes raw styling — but they must not go UP. var styleRatchetBaselines = map[string]styleRatchetCounts{ "operator static/index.html": { - inlineStyles: 1427, + inlineStyles: 1425, rawColors: 135, rawFontSizes: 601, rawPadding: 204, From 35dc47b5a74a6b079d5e48b76e67cae83949f34f Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Fri, 30 Oct 2026 16:55:19 -0400 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=90=9B=20Keep=20Knowledge=20loading?= =?UTF-8?q?=20when=20remote=20fact=20counts=20are=20unavailable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andy Anderson --- src/docs/dashboard-sections.md | 2 +- src/pkg/dashboard/nav_count_delta.test.js | 32 ++++++++++++++++++- src/pkg/dashboard/static-src/js/knowledge.js | 23 +++++++------ .../static-src/js/nav-count-delta.js | 1 + src/pkg/dashboard/static/index.html | 24 ++++++++------ 5 files changed, 60 insertions(+), 22 deletions(-) diff --git a/src/docs/dashboard-sections.md b/src/docs/dashboard-sections.md index 0cdc2f6148..e8a9246a4b 100644 --- a/src/docs/dashboard-sections.md +++ b/src/docs/dashboard-sections.md @@ -22,7 +22,7 @@ For short definitions of the names the dashboard uses, see the [dashboard glossa The Hive activity monitor, Contributors and Knowledge navigation pills briefly show an upward or downward arrow and the actual signed count change. The number remains readable and the link works as before. Reduced-motion preferences keep the feedback static; there is no extra polling or repeated announcement on unchanged refreshes. -The tracker’s gold pill counts default-view **rows** (issues, except folded review notes, plus PRs not drawn under an issue); its orange pill counts **waiting-on-you items**. These are not separate issue and PR totals. Contributors animates only **online** in online/registered, using the existing registered-profile heartbeat window, not connected sockets or changes in registered totals. Knowledge counts **facts**, the sum of layer `total_pages` values, when enabled; its disabled zero does not mean stored facts were deleted. +The tracker’s gold pill counts default-view **rows** (issues, except folded review notes, plus PRs not drawn under an issue); its orange pill counts **waiting-on-you items**. These are not separate issue and PR totals. Contributors animates only **online** in online/registered, using the existing registered-profile heartbeat window, not connected sockets or changes in registered totals. Knowledge counts **facts**, the sum of layer `total_pages` values, when enabled; its disabled zero does not mean stored facts were deleted. If a remote layer is unhealthy, Knowledge still loads its available facts, marks the count as partial in its accessible label and tooltip, and suppresses delta feedback until a complete count is known again. Initial or unknown counts and route/filter redraws do not animate. After reconnection, feedback describes only the observed net numeric change, not whether an item was merged, closed or otherwise removed. diff --git a/src/pkg/dashboard/nav_count_delta.test.js b/src/pkg/dashboard/nav_count_delta.test.js index ac676c365f..b226c2163e 100644 --- a/src/pkg/dashboard/nav_count_delta.test.js +++ b/src/pkg/dashboard/nav_count_delta.test.js @@ -42,7 +42,8 @@ function load() { function setSectionSummary() {} function contributorsSectionSummary() { return ''; } function formatNumber(n) { return Number(n).toLocaleString('en-US'); } - function renderKnowledge() {} + var knowledgeRenders = 0; + function renderKnowledge() { knowledgeRenders++; } function fetchBeadSynthStatus() {} function fetchFactHistory() {} function stageTrackerNoteMerges() {} @@ -230,6 +231,8 @@ test('knowledge uses numeric layer fact totals, independent of formatting and di assert.equal(delta(badge), '↓ -2'); await knowledge(api, { enabled: true }); assert.equal(badge.textContent, 1021); + assert.equal(badge.attrs['aria-label'], 'Knowledge fact count unavailable'); + assert.equal(api.ctx._kbInitialLoad, false); await knowledge(api, stats()); assert.equal(badge.textContent, 0); assert.equal(delta(badge), undefined); @@ -240,6 +243,33 @@ test('knowledge uses numeric layer fact totals, independent of formatting and di assert.equal(api.timers.size, 0); }); +test('an unhealthy Knowledge layer still loads and refreshes known facts without a synthetic delta', async () => { + const api = load(), badge = api.badge(IDS[3]); + const partial = { enabled: true, layers: [ + { type: 'project', total_pages: 5, healthy: true }, + { type: 'global', healthy: false }, + ] }; + await knowledge(api, partial); + assert.equal(badge.textContent, 5); + assert.equal(delta(badge), undefined); + assert.equal(badge.attrs['aria-label'], '5 facts known; some layer counts unavailable'); + assert.equal(api.ctx.knowledgeRenders, 1, 'first load renders despite the unhealthy remote'); + assert.equal(api.ctx._kbInitialLoad, false); + assert.equal(api.ctx._kbCache.layers[1].healthy, false); + assert.ok(Array.isArray(api.ctx._kbCache._documents), 'document fetch still reaches the cache'); + await knowledge(api, stats(7)); + assert.equal(badge.textContent, 7); + assert.equal(delta(badge), undefined, 'partial -> complete seeds a new baseline'); + await knowledge(api, stats(10)); + assert.equal(delta(badge), '↑ +3'); + await knowledge(api, partial); + assert.equal(badge.textContent, 5, 'known facts refresh when a layer later becomes unhealthy'); + assert.equal(delta(badge), undefined, 'missing remote counts are not fact deletion'); + assert.equal(api.timers.size, 0); + assert.equal(api.ctx._kbCache.layers[1].healthy, false); + assert.equal(api.ctx.knowledgeRenders, 3, 'changed layer sets keep rendering'); +}); + test('reduced motion keeps static signed feedback; hidden tabs advance without animation', () => { const api = load(), badge = api.badge(IDS[2]); api.ctx.window.matchMedia = () => ({ matches: true }); diff --git a/src/pkg/dashboard/static-src/js/knowledge.js b/src/pkg/dashboard/static-src/js/knowledge.js index 0b0abc7ba7..a60de19e0d 100644 --- a/src/pkg/dashboard/static-src/js/knowledge.js +++ b/src/pkg/dashboard/static-src/js/knowledge.js @@ -238,21 +238,24 @@ const [r, , , docsR] = await Promise.all([fetch('/api/knowledge/stats'), fetchBeadSynthStatus(), fetchFactHistory(), fetch('/api/knowledge/documents')]); if (!r.ok) return; const prev = _kbCache; - const next = await r.json(); - const kbBadge = document.getElementById('knowledge-sidebar-badge'); - const kbFacts = kbSidebarFactCount(next); - if (kbFacts === null) { - navCountDelta(kbBadge, null); - return; - } - _kbCache = next; + _kbCache = await r.json(); _kbCache._documents = (docsR && docsR.ok) ? await docsR.json() : []; setSectionSummary('knowledge-section', kbFactsLabel(kbTotalFactsFromStats(_kbCache))); + const kbBadge = document.getElementById('knowledge-sidebar-badge'); if (kbBadge) { + const kbFacts = kbSidebarFactCount(_kbCache); + const kbShown = kbTotalFactsFromStats(_kbCache); + const hasLayers = Array.isArray(_kbCache.layers); + const title = kbFacts !== null ? kbFactsLabel(kbShown) : hasLayers + ? kbFactsLabel(kbShown) + ' known; some layer counts unavailable' + : 'Knowledge fact count unavailable'; // Toggling priming changes what the badge shows, not stored facts. if (prev && prev.enabled !== _kbCache.enabled) navCountDelta(kbBadge, null); - setSidebarCountBadge(kbBadge, kbFacts, kbFactsLabel(kbTotalFactsFromStats(_kbCache))); - navCountDelta(kbBadge, kbFacts, kbFactsLabel(kbFacts)); + // Partial layer stats still refresh the section and its known + // facts. Only the delta baseline needs a complete numeric total. + if (kbFacts !== null || hasLayers) setSidebarCountBadge(kbBadge, _kbCache.enabled ? kbShown : 0, title); + else kbBadge.title = title; + navCountDelta(kbBadge, kbFacts, title); } if (_kbInitialLoad && _kbCache && _kbCache.enabled) { _kbSetupView = 'none'; 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 3aa2e728c8..c06c2c08b0 100644 --- a/src/pkg/dashboard/static-src/js/nav-count-delta.js +++ b/src/pkg/dashboard/static-src/js/nav-count-delta.js @@ -21,6 +21,7 @@ _navCountDeltas.set(badge.id, state); } if (!Number.isSafeInteger(count) || count < 0) { + if (label) state.label = label; state.clear(); state.count = null; return; diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 33d84f7d46..1ae0519732 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -19173,6 +19173,7 @@

All labels

_navCountDeltas.set(badge.id, state); } if (!Number.isSafeInteger(count) || count < 0) { + if (label) state.label = label; state.clear(); state.count = null; return; @@ -37213,21 +37214,24 @@

All labels

const [r, , , docsR] = await Promise.all([fetch('/api/knowledge/stats'), fetchBeadSynthStatus(), fetchFactHistory(), fetch('/api/knowledge/documents')]); if (!r.ok) return; const prev = _kbCache; - const next = await r.json(); - const kbBadge = document.getElementById('knowledge-sidebar-badge'); - const kbFacts = kbSidebarFactCount(next); - if (kbFacts === null) { - navCountDelta(kbBadge, null); - return; - } - _kbCache = next; + _kbCache = await r.json(); _kbCache._documents = (docsR && docsR.ok) ? await docsR.json() : []; setSectionSummary('knowledge-section', kbFactsLabel(kbTotalFactsFromStats(_kbCache))); + const kbBadge = document.getElementById('knowledge-sidebar-badge'); if (kbBadge) { + const kbFacts = kbSidebarFactCount(_kbCache); + const kbShown = kbTotalFactsFromStats(_kbCache); + const hasLayers = Array.isArray(_kbCache.layers); + const title = kbFacts !== null ? kbFactsLabel(kbShown) : hasLayers + ? kbFactsLabel(kbShown) + ' known; some layer counts unavailable' + : 'Knowledge fact count unavailable'; // Toggling priming changes what the badge shows, not stored facts. if (prev && prev.enabled !== _kbCache.enabled) navCountDelta(kbBadge, null); - setSidebarCountBadge(kbBadge, kbFacts, kbFactsLabel(kbTotalFactsFromStats(_kbCache))); - navCountDelta(kbBadge, kbFacts, kbFactsLabel(kbFacts)); + // Partial layer stats still refresh the section and its known + // facts. Only the delta baseline needs a complete numeric total. + if (kbFacts !== null || hasLayers) setSidebarCountBadge(kbBadge, _kbCache.enabled ? kbShown : 0, title); + else kbBadge.title = title; + navCountDelta(kbBadge, kbFacts, title); } if (_kbInitialLoad && _kbCache && _kbCache.enabled) { _kbSetupView = 'none';