Skip to content

~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.

fix(logpanel): group Loguru aliases in filters (#5231)

LearningCircuit7091bcbae10b
diff --git a/changelog.d/5231.bugfix.md b/changelog.d/5231.bugfix.md
new file mode 100644
index 0000000000..1004fbe135
--- /dev/null
+++ b/changelog.d/5231.bugfix.md
@@ -0,0 +1 @@
+Group CRITICAL and FATAL research logs under Errors, and SUCCESS logs under Milestones, while preserving their original severity labels and styling.
diff --git a/src/local_deep_research/web/static/js/components/logpanel.js b/src/local_deep_research/web/static/js/components/logpanel.js
index 6f73b516b6..29ebca47e4 100644
--- a/src/local_deep_research/web/static/js/components/logpanel.js
+++ b/src/local_deep_research/web/static/js/components/logpanel.js
@@ -11,8 +11,10 @@
// Shared log helpers extracted to utils/log-helpers.js for testability
const {
+ bumpCount,
checkLogVisibility,
emptyCounts,
+ getDisplayLogCategory,
hashString,
normalizeMessage,
normalizeTimestamps,
@@ -640,29 +642,27 @@
/**
* Map a rendered log type to its pruning priority without changing the
- * type stored in the DOM. Loguru's standard levels are normalized
- * explicitly so CRITICAL/FATAL remain as diagnostic as ERROR. SUCCESS is
- * treated like a milestone: it represents a completed operation and
- * should outlive routine TRACE/DEBUG/INFO noise, but not warnings/errors.
+ * type stored in the DOM. Loguru alias levels are first folded into
+ * their display category by getDisplayLogCategory (utils/log-helpers.js),
+ * so CRITICAL/FATAL remain as diagnostic as ERROR and SUCCESS is treated
+ * like a milestone: it represents a completed operation and should
+ * outlive routine TRACE/DEBUG/INFO noise, but not warnings/errors.
* Future types fall into the routine tier so they cannot bypass the cap.
*
* @param {string} type - Lowercase rendered log type.
* @returns {'info'|'milestone'|'warning'|'error'} Pruning priority.
*/
function getPruneTier(type) {
- switch (type) {
+ switch (getDisplayLogCategory(type)) {
case 'trace':
case 'debug':
case 'info':
return 'info';
- case 'success':
case 'milestone':
return 'milestone';
case 'warning':
return 'warning';
case 'error':
- case 'critical':
- case 'fatal':
return 'error';
default:
return 'info';
@@ -1440,12 +1440,11 @@
let countersChanged = false;
if (incrementCounter && element) {
const logType = (element.dataset.logType || 'info').toLowerCase();
- if (Object.prototype.hasOwnProperty.call(
+ bumpCount(
window._logPanelState.counts,
- logType
- )) {
- window._logPanelState.counts[logType]++;
- }
+ getDisplayLogCategory(logType),
+ 1
+ );
countersChanged = true;
}
@@ -1458,15 +1457,11 @@
const removed = pruneToCap(consoleLogContainer, renderCap, totalCount);
if (removed.length > 0) {
for (const prunedType of removed) {
- if (Object.prototype.hasOwnProperty.call(
+ bumpCount(
window._logPanelState.counts,
- prunedType
- )) {
- window._logPanelState.counts[prunedType] = Math.max(
- 0,
- window._logPanelState.counts[prunedType] - 1
- );
- }
+ getDisplayLogCategory(prunedType),
+ -1
+ );
}
countersChanged = true;
}
@@ -1728,6 +1723,7 @@
let total = 0;
logContent.querySelectorAll('.ldr-console-log-entry').forEach((entry) => {
const t = (entry.dataset.logType || 'info').toLowerCase();
+ const displayCategory = getDisplayLogCategory(t);
// Count every rendered entry toward the total so the header
// indicator and All badge stay accurate for categories
// outside the four tracked buckets (e.g. DEBUG, which is
@@ -1736,9 +1732,7 @@
// increments stay conditional on the bucket being tracked
// so unknown types don't pollute the filter badges.
total++;
- if (Object.prototype.hasOwnProperty.call(counts, t)) {
- counts[t]++;
- }
+ bumpCount(counts, displayCategory, 1);
if (entry.dataset.logId) {
renderedIds.add(entry.dataset.logId);
}
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.js
index 8e70031f3f..95012577cf 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
@@ -22,15 +22,55 @@
return { info: 0, milestone: 0, warning: 0, error: 0 };
}
+ /**
+ * Adjust one tracked per-category count in place. Categories the
+ * counts object does not track are ignored (the hasOwnProperty guard
+ * also keeps hostile keys like "__proto__" inert), and the result is
+ * floored at zero so a decrement can never drive a bucket negative.
+ * @param {{info: number, milestone: number, warning: number, error: number}} counts
+ * - Counts object from emptyCounts(), mutated in place.
+ * @param {string} key - Display category to adjust.
+ * @param {number} delta - Signed adjustment, e.g. +1 or -1.
+ */
+ function bumpCount(counts, key, delta) {
+ if (Object.prototype.hasOwnProperty.call(counts, key)) {
+ counts[key] = Math.max(0, counts[key] + delta);
+ }
+ }
+
+ /**
+ * Map a raw log severity to the existing UI category that should count
+ * and filter it. The raw severity remains on the rendered row so its
+ * dataset, CSS class, and badge label are preserved.
+ *
+ * @param {string} logType - Raw log severity.
+ * @returns {string} Display category or custom type, normalized to lowercase.
+ */
+ function getDisplayLogCategory(logType) {
+ const normalizedType = typeof logType === 'string'
+ ? logType.toLowerCase()
+ : '';
+ switch (normalizedType) {
+ case 'critical':
+ case 'fatal':
+ return 'error';
+ case 'success':
+ return 'milestone';
+ default:
+ return normalizedType;
+ }
+ }
+
/**
* Decide whether a log entry of the given type should be visible
* under a filter selection. Matches the plural/singular variants the
* UI may emit (e.g. "milestones" vs "milestone").
- * @param {string} logType - 'info' | 'milestone' | 'warning' | 'error'
+ * @param {string} logType - Raw rendered log severity.
* @param {string} filterType - selected filter ('all', 'info', 'milestone', ...)
* @returns {boolean}
*/
function checkLogVisibility(logType, filterType) {
+ const displayCategory = getDisplayLogCategory(logType);
switch (filterType) {
case 'all':
return true;
@@ -38,16 +78,17 @@
// 'info' must show ONLY info entries. The old implementation
// returned true for every type, which made the 'Info'
// filter button a no-op (clicking it did nothing visible).
- return logType === 'info';
+ return displayCategory === 'info';
case 'milestone':
case 'milestones': // Handle plural form too
- return logType === 'milestone';
+ return displayCategory === 'milestone';
case 'warning':
case 'warnings':
- return logType === 'warning' || logType === 'error';
+ return displayCategory === 'warning' ||
+ displayCategory === 'error';
case 'error':
case 'errors': // Handle plural form too
- return logType === 'error';
+ return displayCategory === 'error';
default:
return true; // Default to showing everything
}
@@ -158,8 +199,10 @@
}
window.LdrLogHelpers = {
+ bumpCount,
checkLogVisibility,
emptyCounts,
+ getDisplayLogCategory,
hashString,
normalizeMessage,
normalizeTimestamps,
diff --git a/tests/js/components/logpanel.test.js b/tests/js/components/logpanel.test.js
index 6e438b3cf5..b2325b917f 100644
--- a/tests/js/components/logpanel.test.js
+++ b/tests/js/components/logpanel.test.js
@@ -1099,6 +1099,45 @@ describe('filter buttons', () => {
expect(errorEntry.style.display).toBe('');
});
+ it('groups Loguru aliases in filters, including rows added while active', () => {
+ setupPanelDom({ page: 'progress', researchId: null });
+ window._logPanelState.expanded = true;
+ logPanel.addLog('critical-before-filter', 'CRITICAL');
+ logPanel.addLog('fatal-before-filter', 'FATAL');
+ logPanel.addLog('success-before-filter', 'SUCCESS');
+ logPanel.addLog('info-before-filter', 'INFO');
+
+ const critical = document.querySelector('.ldr-log-critical');
+ const fatal = document.querySelector('.ldr-log-fatal');
+ const success = document.querySelector('.ldr-log-success');
+ const info = document.querySelector('.ldr-log-info');
+
+ logPanel.filterLogs('error');
+ expect(critical.style.display).toBe('');
+ expect(fatal.style.display).toBe('');
+ expect(success.style.display).toBe('none');
+ expect(info.style.display).toBe('none');
+
+ logPanel.filterLogs('warning');
+ expect(critical.style.display).toBe('');
+ expect(fatal.style.display).toBe('');
+ expect(success.style.display).toBe('none');
+
+ logPanel.filterLogs('milestone');
+ expect(success.style.display).toBe('');
+ expect(critical.style.display).toBe('none');
+ expect(fatal.style.display).toBe('none');
+
+ logPanel.filterLogs('error');
+ logPanel.addLog('fatal-after-filter', 'FATAL');
+ const lateFatal = Array.from(document.querySelectorAll(
+ '.ldr-log-fatal'
+ )).find((row) => row.querySelector(
+ '.ldr-log-message'
+ ).textContent === 'fatal-after-filter');
+ expect(lateFatal.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
@@ -1267,6 +1306,40 @@ describe('per-category counters', () => {
expect(window._logPanelState.counts.warning).toBe(0);
});
+ it('groups live Loguru aliases without rewriting their rendered severity', () => {
+ setupPanelDom({ page: 'progress', researchId: null });
+ window._logPanelState.expanded = true;
+
+ logPanel.addLog('critical-event', 'CRITICAL');
+ logPanel.addLog('fatal-event', 'FATAL');
+ logPanel.addLog('successful-operation', 'SUCCESS');
+
+ expect(window._logPanelState.counts).toEqual({
+ info: 0,
+ milestone: 1,
+ warning: 0,
+ error: 2,
+ });
+ expect(getFilterCount('error')).toBe(2);
+ expect(getFilterCount('milestone')).toBe(1);
+ expect(getFilterCount('all')).toBe(3);
+
+ const rows = Array.from(document.querySelectorAll(
+ '.ldr-console-log-entry'
+ ));
+ expect(rows.map((row) => row.dataset.logType)).toEqual([
+ 'critical',
+ 'fatal',
+ 'success',
+ ]);
+ expect(rows.map((row) => row.querySelector(
+ '.ldr-log-badge'
+ ).textContent)).toEqual(['CRITICAL', 'FATAL', 'SUCCESS']);
+ expect(rows[0].classList.contains('ldr-log-critical')).toBe(true);
+ expect(rows[1].classList.contains('ldr-log-fatal')).toBe(true);
+ expect(rows[2].classList.contains('ldr-log-success')).toBe(true);
+ });
+
it('updates the filter button badges after addLog', () => {
setupPanelDom({ page: 'progress' });
window._logPanelState.expanded = true;
@@ -1364,6 +1437,9 @@ describe('per-category counters', () => {
{ 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' },
+ { timestamp: '2026-05-08T12:00:04Z', message: 'c1', log_type: 'CRITICAL' },
+ { timestamp: '2026-05-08T12:00:05Z', message: 'f1', log_type: 'FATAL' },
+ { timestamp: '2026-05-08T12:00:06Z', message: 's1', log_type: 'SUCCESS' },
]),
})
);
@@ -1377,12 +1453,24 @@ describe('per-category counters', () => {
await logPanel.loadLogs('test-research-batch-counters');
- // Counters must reflect the 4 entries just inserted.
+ // Alias severities join the matching display bucket without changing
+ // the raw type stored on each rendered row.
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.error).toBe(3);
+ expect(window._logPanelState.counts.milestone).toBe(2);
expect(window._logPanelState.counts.warning).toBe(0);
- expect(getFilterCount('all')).toBe(4);
+ expect(getFilterCount('error')).toBe(3);
+ expect(getFilterCount('milestone')).toBe(2);
+ expect(getFilterCount('all')).toBe(7);
+ expect(Array.from(document.querySelectorAll(
+ '.ldr-console-log-entry'
+ )).map((entry) => entry.dataset.logType)).toContain('critical');
+ expect(Array.from(document.querySelectorAll(
+ '.ldr-console-log-entry'
+ )).map((entry) => entry.dataset.logType)).toContain('fatal');
+ expect(Array.from(document.querySelectorAll(
+ '.ldr-console-log-entry'
+ )).map((entry) => entry.dataset.logType)).toContain('success');
});
});
@@ -2659,10 +2747,13 @@ describe('addLog — live pruning integration', () => {
}
});
- it('prunes older CRITICAL before newer ERROR in their shared tier', () => {
+ it('prunes older CRITICAL and decrements its shared Errors counter', () => {
const container = setupLivePanel(1);
logPanel.addLog('critical-first', 'CRITICAL');
+ expect(window._logPanelState.counts.error).toBe(1);
+ expect(getBadge('error')).toBe(1);
+
logPanel.addLog('error-second', 'ERROR');
expect(Array.from(container.children).map((entry) => entry.dataset.logType))
@@ -2678,6 +2769,28 @@ describe('addLog — live pruning integration', () => {
expect(document.querySelector('.ldr-log-indicator').textContent).toBe('1');
});
+ it('prunes older SUCCESS and decrements its shared Milestones counter', () => {
+ const container = setupLivePanel(1);
+
+ logPanel.addLog('success-first', 'SUCCESS');
+ expect(window._logPanelState.counts.milestone).toBe(1);
+ expect(getBadge('milestone')).toBe(1);
+
+ logPanel.addLog('milestone-second', 'MILESTONE');
+
+ expect(Array.from(container.children).map((entry) => entry.dataset.logType))
+ .toEqual(['milestone']);
+ expect(window._logPanelState.counts).toEqual({
+ info: 0,
+ milestone: 1,
+ warning: 0,
+ error: 0,
+ });
+ expect(getBadge('milestone')).toBe(1);
+ expect(getBadge('all')).toBe(1);
+ expect(document.querySelector('.ldr-log-indicator').textContent).toBe('1');
+ });
+
it('floors a fractional renderedLimit without draining the panel', () => {
const container = setupLivePanel(2.5);
diff --git a/tests/js/utils/log-helpers.test.js b/tests/js/utils/log-helpers.test.js
index 2c3864a172..8a721baa26 100644
--- a/tests/js/utils/log-helpers.test.js
+++ b/tests/js/utils/log-helpers.test.js
@@ -10,8 +10,10 @@
import '@js/utils/log-helpers.js';
const {
+ bumpCount,
checkLogVisibility,
emptyCounts,
+ getDisplayLogCategory,
hashString,
normalizeMessage,
normalizeTimestamps,
@@ -72,6 +74,18 @@ describe('checkLogVisibility', () => {
expect(checkLogVisibility('warning', 'errors')).toBe(false);
});
+ it('groups Loguru aliases under the matching display filters', () => {
+ for (const type of ['critical', 'fatal', 'CRITICAL', 'FATAL']) {
+ expect(checkLogVisibility(type, 'error')).toBe(true);
+ expect(checkLogVisibility(type, 'errors')).toBe(true);
+ expect(checkLogVisibility(type, 'warning')).toBe(true);
+ expect(checkLogVisibility(type, 'milestone')).toBe(false);
+ }
+ expect(checkLogVisibility('success', 'milestone')).toBe(true);
+ expect(checkLogVisibility('SUCCESS', 'milestones')).toBe(true);
+ expect(checkLogVisibility('success', 'error')).toBe(false);
+ });
+
it('unknown filter defaults to showing everything', () => {
expect(checkLogVisibility('info', 'bogus')).toBe(true);
expect(checkLogVisibility('error', '')).toBe(true);
@@ -79,6 +93,22 @@ describe('checkLogVisibility', () => {
});
});
+describe('getDisplayLogCategory', () => {
+ it('maps diagnostic aliases into existing UI categories', () => {
+ expect(getDisplayLogCategory('CRITICAL')).toBe('error');
+ expect(getDisplayLogCategory('fatal')).toBe('error');
+ expect(getDisplayLogCategory('SUCCESS')).toBe('milestone');
+ });
+
+ it('normalizes but otherwise preserves primary and custom types', () => {
+ expect(getDisplayLogCategory('WARNING')).toBe('warning');
+ expect(getDisplayLogCategory('DEBUG')).toBe('debug');
+ expect(getDisplayLogCategory('NOTICE')).toBe('notice');
+ expect(getDisplayLogCategory('constructor')).toBe('constructor');
+ expect(getDisplayLogCategory('__proto__')).toBe('__proto__');
+ });
+});
+
describe('emptyCounts', () => {
it('returns a fresh object on each call (mutations do not leak)', () => {
const a = emptyCounts();
@@ -99,6 +129,39 @@ describe('emptyCounts', () => {
});
});
+describe('bumpCount', () => {
+ it('adjusts tracked categories in place by the given delta', () => {
+ const counts = emptyCounts();
+ bumpCount(counts, 'error', 1);
+ bumpCount(counts, 'error', 1);
+ bumpCount(counts, 'milestone', 1);
+ expect(counts.error).toBe(2);
+ expect(counts.milestone).toBe(1);
+ bumpCount(counts, 'error', -1);
+ expect(counts.error).toBe(1);
+ });
+
+ it('floors at zero so a decrement cannot drive a bucket negative', () => {
+ const counts = emptyCounts();
+ bumpCount(counts, 'warning', -1);
+ expect(counts.warning).toBe(0);
+ });
+
+ it('ignores untracked categories, including inherited keys', () => {
+ const counts = emptyCounts();
+ bumpCount(counts, 'debug', 1);
+ bumpCount(counts, '__proto__', 1);
+ bumpCount(counts, 'constructor', 1);
+ expect(counts).toEqual({
+ info: 0,
+ milestone: 0,
+ warning: 0,
+ error: 0,
+ });
+ expect(Object.prototype.constructor).toBe(Object);
+ });
+});
+
describe('hashString', () => {
it('returns "0" for empty/null/undefined', () => {
expect(hashString('')).toBe('0');