~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
feat(logpanel): per-category counters in Research Logs filter row (#4898)
S622b0c94384d
diff --git a/changelog.d/+logpanel-per-category-counters.feature.md b/changelog.d/+logpanel-per-category-counters.feature.mdnew file mode 100644index 0000000000..6bb7b10bbb--- /dev/null+++ b/changelog.d/+logpanel-per-category-counters.feature.md@@ -0,0 +1 @@+Add a per-category entry counter next to each filter button in the Research Logs panel (All, Milestones, Info, Warning, Errors). Counts reflect entries currently rendered in the DOM and update on insert, prune, and batch load, so users can see at a glance which categories still have entries when the global DOM cap is hit.diff --git a/src/local_deep_research/web/static/css/styles.css b/src/local_deep_research/web/static/css/styles.cssindex 7ab484e23e..799bf89cba 100644--- a/src/local_deep_research/web/static/css/styles.css+++ b/src/local_deep_research/web/static/css/styles.css@@ -2256,6 +2256,29 @@ textarea:focus, input[type="text"]:focus {border-color: var(--accent-primary);}+/* Per-filter entry count shown next to each filter button label.+ Visually de-emphasized so the label still reads as the primary+ content of the button. Lives next to .ldr-small-btn so the+ selected-state selector below reads naturally. */+.ldr-filter-count {+ display: inline-block;+ margin-left: 0.3rem;+ padding: 0 0.35rem;+ min-width: 1.25rem;+ text-align: center;+ font-size: 0.65rem;+ font-weight: 500;+ color: var(--text-secondary);+ background-color: var(--bg-tertiary);+ border-radius: 8px;+ line-height: 1.2;+}++.ldr-small-btn.ldr-selected .ldr-filter-count {+ color: var(--accent-primary);+ background-color: rgba(255, 255, 255, 0.85);+}+/* Settings card styles */.ldr-settings-card {background-color: var(--bg-secondary);diff --git a/src/local_deep_research/web/static/js/components/logpanel.js b/src/local_deep_research/web/static/js/components/logpanel.jsindex 112e2b9c56..1cbcd2c717 100644--- a/src/local_deep_research/web/static/js/components/logpanel.js+++ b/src/local_deep_research/web/static/js/components/logpanel.js@@ -12,6 +12,7 @@// Shared log helpers extracted to utils/log-helpers.js for testabilityconst {checkLogVisibility,+ emptyCounts,hashString,normalizeMessage,normalizeTimestamps,@@ -30,6 +31,15 @@expanded: false,queuedLogs: [],logCount: 0,+ // Per-category counts derived from entries currently in the DOM.+ // Updated on insert (addLogEntryToPanel) and prune (see the+ // ordered-prune path in addLogEntryToPanel). Used to render the+ // per-filter count badges next to the filter button labels, so+ // users can see at a glance which categories still have entries+ // after the global DOM cap starts flushing the head of the log.+ // Shape lives in emptyCounts() (utils/log-helpers.js) so the+ // state init, batch-load reset, and test beforeEach can't drift.+ counts: emptyCounts(),initialized: false, // Track initialization stateconnectedResearchId: null, // Track which research we're connected tocurrentFilter: 'all', // Track current filter type@@ -281,7 +291,17 @@const filterButtons = document.querySelectorAll('.ldr-log-filter .ldr-filter-buttons button');filterButtons.forEach(button => {button.addEventListener('click', function() {- const type = this.textContent.toLowerCase();+ // Prefer the explicit data-filter-type attribute so the+ // click target is decoupled from the button label text+ // (which now includes a live count badge). The fallback+ // must read the label's text node only — pulling the+ // whole textContent would pull the badge text too, e.g.+ // "Errors 0" or "Info 12", which would never match a+ // filter case and would silently fall through the+ // checkLogVisibility default to "show everything".+ const type = this.dataset.filterType ||+ (this.firstChild &&+ this.firstChild.textContent.trim().toLowerCase());SafeLogger.log(`Filtering logs by type: ${type}`);// Update active state@@ -685,6 +705,22 @@logContent.firstElementChild.remove();}+ // Reset and recompute per-category counts from the DOM+ // after the batch insert + prune. Counting off the DOM+ // (rather than summing from `allLogs`) ensures the+ // badges always match what's actually rendered, even if+ // a future refactor adds a third insertion path that+ // bypasses `addLogEntryToPanel`. Shape comes from+ // emptyCounts() so it stays in sync with the state init.+ window._logPanelState.counts = emptyCounts();+ logContent.querySelectorAll('.ldr-console-log-entry').forEach((entry) => {+ const t = (entry.dataset.logType || 'info').toLowerCase();+ if (window._logPanelState.counts[t] !== undefined) {+ window._logPanelState.counts[t]++;+ }+ });+ updateFilterCounters();+// Update log count indicatorconst logIndicators = document.querySelectorAll('.ldr-log-indicator');if (logIndicators.length > 0) {@@ -988,14 +1024,28 @@if (entries.length > MAX_LOG_ENTRIES) {const toRemove = entries.length - MAX_LOG_ENTRIES;for (let i = 0; i < toRemove; i++) {+ // Read the log type before removing so we can decrement+ // the matching per-category count for the per-filter+ // badges. Unknown types default to 'info' to match the+ // createLogEntryElement fallback below.+ const prunedType = (entries[i].dataset.logType || 'info').toLowerCase();entries[i].remove();+ if (window._logPanelState.counts[prunedType] !== undefined) {+ window._logPanelState.counts[prunedType]--;+ }}updateLogCounter(-toRemove);+ updateFilterCounters();}// Update log count using helper function if neededif (incrementCounter && element) {+ const logType = (element.dataset.logType || 'info').toLowerCase();+ if (window._logPanelState.counts[logType] !== undefined) {+ window._logPanelState.counts[logType]++;+ }updateLogCounter(1);+ updateFilterCounters();}// No need to scroll when loading all logs@@ -1025,6 +1075,36 @@}}+ /**+ * Refresh the per-filter count badges (and the "All" total derived+ * from them) from window._logPanelState.counts. Called whenever the+ * per-category counts change — on insert, prune, or batch load —+ * so the badges always reflect what's currently in the DOM. Safe to+ * call before the filter buttons are rendered: the querySelectorAll+ * returns an empty NodeList and the loop is a no-op.+ */+ function updateFilterCounters() {+ const counts = window._logPanelState.counts || {};+ const total = (counts.info || 0) ++ (counts.milestone || 0) ++ (counts.warning || 0) ++ (counts.error || 0);+ const badges = document.querySelectorAll('.ldr-filter-count');+ badges.forEach((badge) => {+ const key = badge.dataset.filterCount;+ // String() coercion is required: happy-dom (the test DOM)+ // drops numeric 0 when assigned to textContent, so a "0"+ // count would render as an empty badge. Real browsers+ // coerce to "0" automatically, but the explicit String()+ // is harmless there and keeps the test environment honest.+ if (key === 'all') {+ badge.textContent = String(total);+ } else if (Object.prototype.hasOwnProperty.call(counts, key)) {+ badge.textContent = String(counts[key]);+ }+ });+ }+/*** Filter logs by type* @param {string} filterType - The type to filter by (all, info, milestone, error)diff --git a/src/local_deep_research/web/static/js/utils/log-helpers.js b/src/local_deep_research/web/static/js/utils/log-helpers.jsindex 43b88f6180..c76fd4c26b 100644--- a/src/local_deep_research/web/static/js/utils/log-helpers.js+++ b/src/local_deep_research/web/static/js/utils/log-helpers.js@@ -11,6 +11,17 @@(function() {'use strict';+ /**+ * Fresh per-category counts object. Single source of truth for the+ * shape of window._logPanelState.counts — logpanel.js state init,+ * the batch-load reset, and the unit-test beforeEach all use this+ * helper, so adding a new category is a one-line change here.+ * @returns {{info: number, milestone: number, warning: number, error: number}}+ */+ function emptyCounts() {+ return { info: 0, milestone: 0, warning: 0, error: 0 };+ }+/*** Decide whether a log entry of the given type should be visible* under a filter selection. Matches the plural/singular variants the@@ -136,6 +147,7 @@window.LdrLogHelpers = {checkLogVisibility,+ emptyCounts,hashString,normalizeMessage,normalizeTimestamps,diff --git a/src/local_deep_research/web/templates/components/log_panel.html b/src/local_deep_research/web/templates/components/log_panel.htmlindex 2d5e701e7f..fe6f1a6b0a 100644--- a/src/local_deep_research/web/templates/components/log_panel.html+++ b/src/local_deep_research/web/templates/components/log_panel.html@@ -8,11 +8,21 @@<div class="ldr-log-controls"><div class="ldr-log-filter"><div class="ldr-filter-buttons">- <button class="ldr-small-btn ldr-selected" onclick="window.filterLogsByType('all')">All</button>- <button class="ldr-small-btn" onclick="window.filterLogsByType('milestone')">Milestones</button>- <button class="ldr-small-btn" onclick="window.filterLogsByType('info')">Info</button>- <button class="ldr-small-btn" onclick="window.filterLogsByType('warning')">Warning</button>- <button class="ldr-small-btn" onclick="window.filterLogsByType('error')">Errors</button>+ <button class="ldr-small-btn ldr-selected" data-filter-type="all" onclick="window.filterLogsByType('all')">+ All <span class="ldr-filter-count" data-filter-count="all">0</span>+ </button>+ <button class="ldr-small-btn" data-filter-type="milestone" onclick="window.filterLogsByType('milestone')">+ Milestones <span class="ldr-filter-count" data-filter-count="milestone">0</span>+ </button>+ <button class="ldr-small-btn" data-filter-type="info" onclick="window.filterLogsByType('info')">+ Info <span class="ldr-filter-count" data-filter-count="info">0</span>+ </button>+ <button class="ldr-small-btn" data-filter-type="warning" onclick="window.filterLogsByType('warning')">+ Warning <span class="ldr-filter-count" data-filter-count="warning">0</span>+ </button>+ <button class="ldr-small-btn" data-filter-type="error" onclick="window.filterLogsByType('error')">+ Errors <span class="ldr-filter-count" data-filter-count="error">0</span>+ </button></div></div><div class="ldr-log-download">diff --git a/tests/js/components/logpanel.test.js b/tests/js/components/logpanel.test.jsindex e307b01e3d..49186bc1a2 100644--- a/tests/js/components/logpanel.test.js+++ b/tests/js/components/logpanel.test.js@@ -15,11 +15,18 @@*/let logPanel;+let emptyCounts;beforeAll(async () => {// logpanel.js destructures window.LdrLogHelpers at IIFE-time.await import('@js/utils/log-helpers.js');+ // log-helpers.js is an IIFE that only exposes its surface via+ // window.LdrLogHelpers — it has no module exports, so we can't+ // destructure from the import. Wire the helper through window+ // so the beforeEach below can call it.+ emptyCounts = window.LdrLogHelpers.emptyCounts;+// Stubs the IIFE expects to find on window.window.escapeHtml = (s) => String(s ?? '').replace(/[&<>"']/g, '');window.URLBuilder = {@@ -65,6 +72,7 @@ beforeEach(() => {window._logPanelState.queuedLogs = [];window._logPanelState.expanded = false;window._logPanelState.logCount = 0;+ window._logPanelState.counts = emptyCounts();window._logPanelState.currentFilter = 'all';window._logPanelState.autoscroll = true;// Force re-binding of click handlers in tests that call initialize();@@ -99,11 +107,11 @@ function setupPanelDom({ page = 'progress', researchId } = {}) {<div class="ldr-log-controls"><div class="ldr-log-filter"><div class="ldr-filter-buttons">- <button class="ldr-small-btn ldr-selected">All</button>- <button class="ldr-small-btn">Milestones</button>- <button class="ldr-small-btn">Info</button>- <button class="ldr-small-btn">Warning</button>- <button class="ldr-small-btn">Errors</button>+ <button class="ldr-small-btn ldr-selected" data-filter-type="all" onclick="window.filterLogsByType('all')">All <span class="ldr-filter-count" data-filter-count="all">0</span></button>+ <button class="ldr-small-btn" data-filter-type="milestone" onclick="window.filterLogsByType('milestone')">Milestones <span class="ldr-filter-count" data-filter-count="milestone">0</span></button>+ <button class="ldr-small-btn" data-filter-type="info" onclick="window.filterLogsByType('info')">Info <span class="ldr-filter-count" data-filter-count="info">0</span></button>+ <button class="ldr-small-btn" data-filter-type="warning" onclick="window.filterLogsByType('warning')">Warning <span class="ldr-filter-count" data-filter-count="warning">0</span></button>+ <button class="ldr-small-btn" data-filter-type="error" onclick="window.filterLogsByType('error')">Errors <span class="ldr-filter-count" data-filter-count="error">0</span></button></div></div><button id="log-autoscroll-button" class="ldr-selected"></button>@@ -575,17 +583,17 @@ describe('toggle handler — non-progress page', () => {});describe('filter buttons', () => {+ // Helper: locate a filter button via its inner count span instead of+ // its full textContent (which now includes the live count badge).+ const findButton = (filterType) =>+ document.querySelector(+ `.ldr-log-filter .ldr-filter-buttons button:has([data-filter-count="${filterType}"])`+ );+it('moves .ldr-selected to the clicked button', () => {setupPanelDom({ page: 'progress' });- const buttons = document.querySelectorAll(- '.ldr-log-filter .ldr-filter-buttons button'- );- const allBtn = Array.from(buttons).find(- (b) => b.textContent.toLowerCase() === 'all'- );- const errorsBtn = Array.from(buttons).find(- (b) => b.textContent.toLowerCase() === 'errors'- );+ const allBtn = findButton('all');+ const errorsBtn = findButton('error');expect(allBtn.classList.contains('ldr-selected')).toBe(true);errorsBtn.click();@@ -596,16 +604,14 @@ describe('filter buttons', () => {it('updates _logPanelState.currentFilter to the clicked type', () => {setupPanelDom({ page: 'progress' });- const buttons = document.querySelectorAll(- '.ldr-log-filter .ldr-filter-buttons button'- );- const errorsBtn = Array.from(buttons).find(- (b) => b.textContent.toLowerCase() === 'errors'- );+ const errorsBtn = findButton('error');errorsBtn.click();- expect(window._logPanelState.currentFilter).toBe('errors');+ // The data-filter-type attribute is the canonical source of+ // truth for the click handler now (so we don't have to parse+ // the button label, which includes the count badge text).+ expect(window._logPanelState.currentFilter).toBe('error');});it('hides entries whose log type does not match the filter', () => {@@ -620,11 +626,7 @@ describe('filter buttons', () => {const entries = container.querySelectorAll('.ldr-console-log-entry');expect(entries.length).toBe(2);- const errorsBtn = Array.from(- document.querySelectorAll(- '.ldr-log-filter .ldr-filter-buttons button'- )- ).find((b) => b.textContent.toLowerCase() === 'errors');+ const errorsBtn = findButton('error');errorsBtn.click();const infoEntry = container.querySelector('.ldr-log-info');@@ -632,6 +634,78 @@ describe('filter buttons', () => {expect(infoEntry.style.display).toBe('none');expect(errorEntry.style.display).toBe('');});++ it("falls back to the button's label text (excluding the badge) when data-filter-type is missing", () => {+ // Regression guard for a code-review catch on #4898: the legacy+ // fallback used the full button.textContent, which now contains+ // the live count badge (e.g. "Errors 0"). That's not a valid+ // filter type and would slip through checkLogVisibility's+ // default (show everything). The fallback must read only the+ // label, so a legacy button labelled "Errors" still resolves+ // to the singular/plural-accepted 'errors' filter and works+ // as before.+ //+ // We build the DOM by hand here (instead of setupPanelDom) so+ // we can inject the legacy button *before* initialize() binds+ // click handlers — appending a button afterwards leaves it+ // un-handled and would exercise a never-reached path.+ document.body.innerHTML = `+ <div class="ldr-collapsible-log-panel">+ <div class="ldr-log-panel-header" id="log-panel-toggle">+ <i class="fas fa-chevron-right ldr-toggle-icon"></i>+ </div>+ <div class="ldr-log-panel-content collapsed" id="log-panel-content">+ <div class="ldr-log-controls">+ <div class="ldr-log-filter">+ <div class="ldr-filter-buttons">+ <button class="ldr-small-btn ldr-selected" data-filter-type="all" onclick="window.filterLogsByType('all')">All <span class="ldr-filter-count" data-filter-count="all">0</span></button>+ <button class="ldr-small-btn" data-filter-type="milestone" onclick="window.filterLogsByType('milestone')">Milestones <span class="ldr-filter-count" data-filter-count="milestone">0</span></button>+ <button class="ldr-small-btn" data-filter-type="info" onclick="window.filterLogsByType('info')">Info <span class="ldr-filter-count" data-filter-count="info">0</span></button>+ <button class="ldr-small-btn" data-filter-type="warning" onclick="window.filterLogsByType('warning')">Warning <span class="ldr-filter-count" data-filter-count="warning">0</span></button>+ </div>+ </div>+ <button id="log-autoscroll-button" class="ldr-selected"></button>+ </div>+ <div class="ldr-console-log" id="console-log-container"></div>+ </div>+ </div>+ <template id="console-log-entry-template">+ <div class="ldr-console-log-entry">+ <span class="ldr-log-timestamp"></span>+ <span class="ldr-log-badge"></span>+ <span class="ldr-log-message"></span>+ </div>+ </template>+ `;+ const wrapper = document.createElement('div');+ wrapper.id = 'research-progress';+ const panel = document.querySelector('.ldr-collapsible-log-panel');+ document.body.insertBefore(wrapper, panel);+ wrapper.appendChild(panel);++ // Inject the legacy button BEFORE initialize() runs so the+ // click handler in initializeLogPanel binds to it.+ const legacy = document.createElement('button');+ legacy.className = 'ldr-small-btn';+ // No data-filter-type — simulating a button that survived a+ // partial migration. The count badge is still inside.+ legacy.innerHTML = 'Errors <span class="ldr-filter-count" data-filter-count="error">0</span>';+ document.querySelector('.ldr-filter-buttons').appendChild(legacy);++ logPanel.initialize(`rid-legacy-${Math.random().toString(36).slice(2)}`);++ legacy.click();++ // 'errors' (plural) is accepted by checkLogVisibility as an+ // alias for 'error' (utils/log-helpers.js). The point is that+ // currentFilter must be exactly the label text — not+ // 'errors 0', which would slip through every case and+ // silently fall through to show-all.+ expect(window._logPanelState.currentFilter).toBe('errors');+ // And filterLogsByType must have applied the visible state+ // change, not silently fall through to show-all.+ expect(legacy.classList.contains('ldr-selected')).toBe(true);+ });});describe('queued logs', () => {@@ -679,3 +753,124 @@ describe('queued logs', () => {expect(container.querySelector('.ldr-console-log-entry')).not.toBeNull();});});++describe('per-category counters', () => {+ function getFilterCount(key) {+ const el = document.querySelector(+ `.ldr-filter-count[data-filter-count="${key}"]`+ );+ if (!el) return null;+ // textContent is the rendered string ("0", "1", ...).+ const trimmed = el.textContent.trim();+ return trimmed === '' ? 0 : parseInt(trimmed, 10);+ }++ it('increments the matching category count when addLog is called', () => {+ setupPanelDom({ page: 'progress' });+ window._logPanelState.expanded = true;++ // Use distinct messages so the 10-newest content dedup doesn't+ // collapse adjacent inserts of the same text.+ logPanel.addLog('hello info one', 'info');+ logPanel.addLog('hello info two', 'info');+ logPanel.addLog('boom error', 'error');+ logPanel.addLog('milestone!', 'milestone');++ expect(window._logPanelState.counts.info).toBe(2);+ expect(window._logPanelState.counts.error).toBe(1);+ expect(window._logPanelState.counts.milestone).toBe(1);+ expect(window._logPanelState.counts.warning).toBe(0);+ });++ it('updates the filter button badges after addLog', () => {+ setupPanelDom({ page: 'progress' });+ window._logPanelState.expanded = true;++ logPanel.addLog('a-info', 'info');+ logPanel.addLog('b-warning', 'warning');+ logPanel.addLog('c-warning', 'warning');+ logPanel.addLog('d-error', 'error');++ expect(getFilterCount('info')).toBe(1);+ expect(getFilterCount('warning')).toBe(2);+ expect(getFilterCount('error')).toBe(1);+ expect(getFilterCount('milestone')).toBe(0);+ // 'all' badge is the sum of the per-category counts.+ expect(getFilterCount('all')).toBe(4);+ });++ it('renders a "0" badge for never-touched categories', () => {+ setupPanelDom({ page: 'progress' });+ // No addLog calls. The badges should all read "0" so the user+ // can see at a glance that no entries of that type exist.+ expect(getFilterCount('info')).toBe(0);+ expect(getFilterCount('milestone')).toBe(0);+ expect(getFilterCount('warning')).toBe(0);+ expect(getFilterCount('error')).toBe(0);+ expect(getFilterCount('all')).toBe(0);+ });++ it('does not double-count when a duplicate is deduped', () => {+ setupPanelDom({ page: 'progress' });+ window._logPanelState.expanded = true;++ logPanel.addLog('same-msg', 'info');+ logPanel.addLog('same-msg', 'info');++ // Content dedup collapses the second insert, so the per-category+ // counter must NOT bump.+ expect(window._logPanelState.counts.info).toBe(1);+ expect(getFilterCount('info')).toBe(1);+ });++ it('decrements the matching category count when the cap prunes an entry', () => {+ setupPanelDom({ page: 'progress' });+ window._logPanelState.expanded = true;++ // Fill the DOM up to the cap with distinct info entries.+ const base = new Date('2026-05-08T12:00:00Z').getTime();+ for (let i = 0; i < MAX_LOG_ENTRIES; i++) {+ vi.setSystemTime(new Date(base + i * 1000));+ logPanel.addLog(`info-${i}`, 'info');+ }+ // One more insert triggers the prune path. The head (oldest+ // info-0) is removed and the per-category counter drops by one.+ logPanel.addLog('info-overflow', 'info');++ expect(window._logPanelState.counts.info).toBe(MAX_LOG_ENTRIES);+ expect(getFilterCount('info')).toBe(MAX_LOG_ENTRIES);+ expect(getFilterCount('all')).toBe(MAX_LOG_ENTRIES);+ });++ it('recomputes counts from the DOM after batch load', async () => {+ // Setup fetch BEFORE setupPanelDom — initialize() inside setupPanelDom+ // triggers its own loadLogs that will race our explicit call otherwise.+ globalThis.fetch = vi.fn(() =>+ Promise.resolve({+ json: () =>+ Promise.resolve([+ { timestamp: '2026-05-08T12:00:00Z', message: 'i1', log_type: 'info' },+ { timestamp: '2026-05-08T12:00:01Z', message: 'i2', log_type: 'info' },+ { timestamp: '2026-05-08T12:00:02Z', message: 'e1', log_type: 'error' },+ { timestamp: '2026-05-08T12:00:03Z', message: 'm1', log_type: 'milestone' },+ ]),+ })+ );++ setupPanelDom({ page: 'progress' });+ window._logPanelState.expanded = true;++ // Wait for initialize()'s internal loadLogs to settle so our explicit+ // call below is not deduped by the in-flight guard.+ await new Promise((resolve) => setTimeout(resolve, 10));++ await logPanel.loadLogs('test-research-batch-counters');++ // Counters must reflect the 4 entries just inserted.+ expect(window._logPanelState.counts.info).toBe(2);+ expect(window._logPanelState.counts.error).toBe(1);+ expect(window._logPanelState.counts.milestone).toBe(1);+ expect(window._logPanelState.counts.warning).toBe(0);+ expect(getFilterCount('all')).toBe(4);+ });+});diff --git a/tests/js/utils/log-helpers.test.js b/tests/js/utils/log-helpers.test.jsindex 145d41aaeb..8daf4b3c49 100644--- a/tests/js/utils/log-helpers.test.js+++ b/tests/js/utils/log-helpers.test.js@@ -11,6 +11,7 @@ import '@js/utils/log-helpers.js';const {checkLogVisibility,+ emptyCounts,hashString,normalizeMessage,normalizeTimestamps,@@ -78,6 +79,26 @@ describe('checkLogVisibility', () => {});});+describe('emptyCounts', () => {+ it('returns a fresh object on each call (mutations do not leak)', () => {+ const a = emptyCounts();+ const b = emptyCounts();+ expect(a).not.toBe(b);+ a.info = 99;+ expect(b.info).toBe(0);+ });++ it('initialises every category to zero with the expected keys', () => {+ const counts = emptyCounts();+ expect(counts).toEqual({+ info: 0,+ milestone: 0,+ warning: 0,+ error: 0,+ });+ });+});+describe('hashString', () => {it('returns "0" for empty/null/undefined', () => {expect(hashString('')).toBe('0');