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): preserve repeated diagnostic progress logs (#5116)

S1cf5e4a04820
diff --git a/changelog.d/5116.bugfix.md b/changelog.d/5116.bugfix.md
new file mode 100644
index 0000000000..974fc265e5
--- /dev/null
+++ b/changelog.d/5116.bugfix.md
@@ -0,0 +1 @@
+Research Logs panel no longer collapses repeated error or milestone entries from the persisted-log loader. The 60-second content deduplication window now applies only to repeated info messages for both response shapes returned by `/api/research/<id>/logs` (the top-level array and the `progress_log` envelope), each entry's log type is resolved from its `log_type`/`type`/`level` metadata before falling back to keyword heuristics, the parser preserves the server's stable database `id` (falling back to a derived `timestamp+hash` key only when no id is supplied), and the timestamp-normalization pass leaves that server-provided id in place when re-stamping outlier dates — so distinct persisted rows with identical timestamp and message keep their individual timestamps and remain visible for inspection even when the run spans multiple calendar days.
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 9607b83804..0685ec986c 100644
--- a/src/local_deep_research/web/static/js/components/logpanel.js
+++ b/src/local_deep_research/web/static/js/components/logpanel.js
@@ -592,28 +592,13 @@
progressLogs.forEach(logItem => {
if (!logItem.time || !logItem.message) return; // Skip invalid logs
- // Skip if we've seen this exact message before
const messageKey = normalizeMessage(logItem.message);
- if (seenMessages.has(messageKey)) {
- // Only consider logs within 1 minute of each other as duplicates
- const previousLog = seenMessages.get(messageKey);
- const previousTime = new Date(previousLog.time);
- const currentTime = new Date(logItem.time);
- const timeDiff = Math.abs(currentTime - previousTime) / 1000; // in seconds
-
- if (timeDiff < 60) { // Within 1 minute
- // Use the newer timestamp if available
- if (currentTime > previousTime) {
- previousLog.time = logItem.time;
- }
- return; // Skip this duplicate
- }
-
- // If we get here, it's the same message but far apart in time (e.g., a repeated step)
- // We'll include it as a separate entry
- }
- // Determine log type based on metadata
+ // Determine log type before applying content dedup.
+ // Only routine info entries are safe to collapse;
+ // repeated errors and milestones carry diagnostic
+ // and progress information even when their text is
+ // identical.
let logType = 'info';
if (logItem.metadata) {
if (logItem.metadata.phase === 'iteration_complete' ||
@@ -639,6 +624,27 @@
}
}
+ // Collapse only repeated info messages within one
+ // minute. Keep the previous-type check so an info
+ // message cannot be collapsed into a diagnostic
+ // error or milestone with the same text.
+ if (logType === 'info' && seenMessages.has(messageKey)) {
+ const previousLog = seenMessages.get(messageKey);
+ if (previousLog.type === 'info') {
+ const previousTime = new Date(previousLog.time);
+ const currentTime = new Date(logItem.time);
+ const timeDiff = Math.abs(currentTime - previousTime) / 1000; // in seconds
+
+ if (timeDiff < 60) { // Within 1 minute
+ // Use the newer timestamp if available
+ if (currentTime > previousTime) {
+ previousLog.time = logItem.time;
+ }
+ return; // Skip this duplicate
+ }
+ }
+ }
+
// Create a log entry object with a unique ID for deduplication
const logEntry = {
id: `${logItem.time}-${hashString(logItem.message)}`,
@@ -672,30 +678,59 @@
logsArray.forEach(log => {
if (!log.timestamp && !log.time) return; // Skip invalid logs
- // Skip duplicates based on message content
+ // Resolve log type from metadata first so we don't collapse
+ // a diagnostic error or milestone into a routine info entry
+ // that happens to share its text.
+ let logType = (log.log_type || log.type || log.level || 'info').toLowerCase();
+ const messageText = (log.message || log.content || '').toLowerCase();
+ if (logType === 'info' || logType === '') {
+ if (messageText.includes('complete') ||
+ messageText.includes('finished') ||
+ messageText.includes('starting phase') ||
+ messageText.includes('generated report')) {
+ logType = 'milestone';
+ } else if (messageText.includes('error') ||
+ messageText.includes('failed')) {
+ logType = 'error';
+ }
+ }
+
const messageKey = normalizeMessage(log.message || log.content || '');
- if (seenMessages.has(messageKey)) {
- // Only consider logs within 1 minute of each other as duplicates
+
+ // Collapse only repeated info messages within one minute, and
+ // only when the previously-seen entry is also info.
+ if (logType === 'info' && seenMessages.has(messageKey)) {
const previousLog = seenMessages.get(messageKey);
- const previousTime = new Date(previousLog.time);
- const currentTime = new Date(log.timestamp || log.time);
- const timeDiff = Math.abs(currentTime - previousTime) / 1000; // in seconds
-
- if (timeDiff < 60) { // Within 1 minute
- // Use the newer timestamp if available
- if (currentTime > previousTime) {
- previousLog.time = log.timestamp || log.time;
+ if (previousLog.type === 'info') {
+ const previousTime = new Date(previousLog.time);
+ const currentTime = new Date(log.timestamp || log.time);
+ const timeDiff = Math.abs(currentTime - previousTime) / 1000; // in seconds
+
+ if (timeDiff < 60) { // Within 1 minute
+ // Use the newer timestamp if available
+ if (currentTime > previousTime) {
+ previousLog.time = log.timestamp || log.time;
+ }
+ return; // Skip this duplicate
}
- return; // Skip this duplicate
}
}
- // Create standardized log entry
+ // Create standardized log entry. Prefer the persisted
+ // database id when the server provides one — the
+ // /api/research/<id>/logs endpoint returns a stable
+ // row id and deliberately orders equal timestamps by
+ // it, so two distinct rows with identical timestamp
+ // + message must remain distinguishable here. The
+ // timestamp+hash fallback covers payloads that lack
+ // an id (older socket events, hand-rolled fixtures).
const logEntry = {
- id: `${log.timestamp || log.time}-${hashString(log.message || log.content || '')}`,
+ id: log.id != null && log.id !== ''
+ ? String(log.id)
+ : `${log.timestamp || log.time}-${hashString(log.message || log.content || '')}`,
time: log.timestamp || log.time,
message: log.message || log.content || 'No message',
- type: log.log_type || log.type || log.level || 'info',
+ type: logType,
metadata: log.metadata || {},
source: 'standard_logs'
};
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 c76fd4c26b..8e70031f3f 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
@@ -136,7 +136,19 @@
// Update the log time
log.time = date.toISOString();
- log.id = `${log.time}-${hashString(log.message)}`;
+ // Only derive a fallback id when the entry does not
+ // already carry one. The standard-array loader preserves
+ // the server-provided database id for distinct persisted
+ // rows; re-deriving from `time + hash` here would collide
+ // two rows that share (timestamp, message) but differ
+ // only by id, and the downstream `uniqueLogsMap` would
+ // then collapse one of them before render. Mirror the
+ // parser's "absent" check (null / undefined / '') so the
+ // two layers stay in agreement on what counts as a real
+ // id.
+ if (log.id == null || log.id === '') {
+ log.id = `${log.time}-${hashString(log.message)}`;
+ }
SafeLogger.log(`Normalized timestamp for "${log.message.substring(0, 30)}..." from ${dateStr} to ${mostCommonDate}`);
}
} catch {
diff --git a/tests/js/components/logpanel.test.js b/tests/js/components/logpanel.test.js
index da048a38e3..ce9c82a065 100644
--- a/tests/js/components/logpanel.test.js
+++ b/tests/js/components/logpanel.test.js
@@ -640,6 +640,252 @@ describe('addLog — content dedup bypass for non-info categories', () => {
});
});
+describe('loadLogsForResearch — progress_log content dedup', () => {
+ function progressEntry(message, time, metadata = {}) {
+ return { message, time, metadata };
+ }
+
+ async function loadProgressLogs(entries) {
+ globalThis.fetch = vi.fn(() =>
+ Promise.resolve({
+ json: () =>
+ Promise.resolve({
+ progress_log: JSON.stringify(entries),
+ }),
+ })
+ );
+ await logPanel.loadLogs('progress-log-dedup');
+ return document.querySelectorAll('.ldr-console-log-entry');
+ }
+
+ it('keeps identical error progress entries within one minute', async () => {
+ const entries = await loadProgressLogs([
+ progressEntry('request failed', '2026-05-08T12:00:00Z', {
+ phase: 'error',
+ }),
+ progressEntry('request failed', '2026-05-08T12:00:01Z', {
+ phase: 'error',
+ }),
+ ]);
+
+ expect(entries).toHaveLength(2);
+ expect(Array.from(entries).map((entry) => entry.dataset.logType)).toEqual([
+ 'error',
+ 'error',
+ ]);
+ });
+
+ it('keeps identical milestone progress entries within one minute', async () => {
+ const entries = await loadProgressLogs([
+ progressEntry('iteration complete', '2026-05-08T12:00:00Z', {
+ phase: 'complete',
+ }),
+ progressEntry('iteration complete', '2026-05-08T12:00:01Z', {
+ phase: 'complete',
+ }),
+ ]);
+
+ expect(entries).toHaveLength(2);
+ expect(Array.from(entries).map((entry) => entry.dataset.logType)).toEqual([
+ 'milestone',
+ 'milestone',
+ ]);
+ });
+
+ it('still collapses identical info progress entries within one minute', async () => {
+ const entries = await loadProgressLogs([
+ progressEntry('searching sources', '2026-05-08T12:00:00Z'),
+ progressEntry('searching sources', '2026-05-08T12:00:01Z'),
+ ]);
+
+ expect(entries).toHaveLength(1);
+ expect(entries[0].dataset.logType).toBe('info');
+ });
+
+ it('keeps identical info progress entries more than one minute apart', async () => {
+ const entries = await loadProgressLogs([
+ progressEntry('searching sources', '2026-05-08T12:00:00Z'),
+ progressEntry('searching sources', '2026-05-08T12:01:01Z'),
+ ]);
+
+ expect(entries).toHaveLength(2);
+ expect(Array.from(entries).every((entry) =>
+ entry.dataset.logType === 'info'
+ )).toBe(true);
+ });
+});
+
+describe('loadLogsForResearch — standard-array content dedup', () => {
+ function standardEntry(message, time, logType = 'info') {
+ return { timestamp: time, message, log_type: logType };
+ }
+
+ async function loadStandardLogs(entries) {
+ globalThis.fetch = vi.fn(() =>
+ Promise.resolve({
+ json: () => Promise.resolve(entries),
+ })
+ );
+ await logPanel.loadLogs('standard-array-dedup');
+ return document.querySelectorAll('.ldr-console-log-entry');
+ }
+
+ it('keeps identical error standard entries within one minute', async () => {
+ const entries = await loadStandardLogs([
+ standardEntry('request failed', '2026-05-08T12:00:00Z', 'error'),
+ standardEntry('request failed', '2026-05-08T12:00:01Z', 'error'),
+ ]);
+
+ expect(entries).toHaveLength(2);
+ expect(Array.from(entries).map((entry) => entry.dataset.logType)).toEqual([
+ 'error',
+ 'error',
+ ]);
+ });
+
+ it('keeps identical milestone standard entries within one minute', async () => {
+ const entries = await loadStandardLogs([
+ standardEntry('iteration complete', '2026-05-08T12:00:00Z', 'milestone'),
+ standardEntry('iteration complete', '2026-05-08T12:00:01Z', 'milestone'),
+ ]);
+
+ expect(entries).toHaveLength(2);
+ expect(Array.from(entries).map((entry) => entry.dataset.logType)).toEqual([
+ 'milestone',
+ 'milestone',
+ ]);
+ });
+
+ it('still collapses identical info standard entries within one minute', async () => {
+ const entries = await loadStandardLogs([
+ standardEntry('searching sources', '2026-05-08T12:00:00Z'),
+ standardEntry('searching sources', '2026-05-08T12:00:01Z'),
+ ]);
+
+ expect(entries).toHaveLength(1);
+ expect(entries[0].dataset.logType).toBe('info');
+ });
+
+ it('keeps identical info standard entries more than one minute apart', async () => {
+ const entries = await loadStandardLogs([
+ standardEntry('searching sources', '2026-05-08T12:00:00Z'),
+ standardEntry('searching sources', '2026-05-08T12:01:01Z'),
+ ]);
+
+ expect(entries).toHaveLength(2);
+ expect(Array.from(entries).every((entry) =>
+ entry.dataset.logType === 'info'
+ )).toBe(true);
+ });
+
+ it('keeps distinct persisted rows with identical timestamp and message when the server provides stable ids', async () => {
+ // Mirrors the real /api/research/<id>/logs response contract:
+ // top-level array of {id, message, timestamp, log_type}, where
+ // id is a stable database row id and the server orders equal
+ // timestamps by it. Two distinct rows must survive into the
+ // rendered DOM even when their (timestamp, message) tuples
+ // collide. log_type is uppercase to verify metadata-first
+ // classification; the message text is deliberately neutral so
+ // it does NOT trigger the keyword fallback (no "error",
+ // "failed", "complete", "finished", "starting phase",
+ // "generated report").
+ const entries = await loadStandardLogs([
+ {
+ id: 1042,
+ message: 'Service unavailable',
+ timestamp: '2026-05-08T12:00:00Z',
+ log_type: 'ERROR',
+ },
+ {
+ id: 1043,
+ message: 'Service unavailable',
+ timestamp: '2026-05-08T12:00:00Z',
+ log_type: 'ERROR',
+ },
+ ]);
+
+ expect(entries).toHaveLength(2);
+ expect(Array.from(entries).map((entry) => entry.dataset.logType)).toEqual([
+ 'error',
+ 'error',
+ ]);
+ // Order-independent assertion: with identical timestamps the
+ // batch loader's reverse-iteration insert produces a stable
+ // but implementation-defined ordering — the contract under
+ // test is that BOTH rows survive, not the exact slot.
+ expect(Array.from(entries).map((entry) => entry.dataset.logId)
+ .sort()).toEqual(['1042', '1043']);
+ });
+
+ it('keeps distinct persisted milestone rows with identical timestamp and message when the server provides stable ids', async () => {
+ // Same production contract as above, but for MILESTONE-class
+ // rows with a neutral message ("phase change") that the
+ // keyword heuristic would leave alone. Locking both severities
+ // in pins the full uniqueLogsMap contract: ids are the
+ // canonical key once the server supplies them, and metadata
+ // (not keyword matching) decides the category.
+ const entries = await loadStandardLogs([
+ {
+ id: 'row-a',
+ message: 'Phase change acknowledged',
+ timestamp: '2026-05-08T12:00:00Z',
+ log_type: 'MILESTONE',
+ },
+ {
+ id: 'row-b',
+ message: 'Phase change acknowledged',
+ timestamp: '2026-05-08T12:00:00Z',
+ log_type: 'MILESTONE',
+ },
+ ]);
+
+ expect(entries).toHaveLength(2);
+ expect(Array.from(entries).map((entry) => entry.dataset.logType)).toEqual([
+ 'milestone',
+ 'milestone',
+ ]);
+ expect(Array.from(entries).map((entry) => entry.dataset.logId)
+ .sort()).toEqual(['row-a', 'row-b']);
+ });
+
+ it('keeps distinct persisted error rows when an outlier date forces normalizeTimestamps to re-stamp their times', async () => {
+ // Crosses normalizeTimestamps and the final uniqueLogsMap dedup:
+ // five rows in, three on the majority date and two outliers on a
+ // different day. Without the "preserve existing id" guard in
+ // normalizeTimestamps, the two outlier rows are re-keyed to the
+ // same `${time}-${hash(message)}` string (their timestamps and
+ // messages are identical post-normalization), so the uniqueLogsMap
+ // collapses one of them and only four rows reach the DOM. The
+ // production probe cited in review rendered four from five; the
+ // fix must produce five. log_type is uppercase and the message is
+ // deliberately neutral so neither path relies on the keyword
+ // fallback.
+ const majorityTime = '2026-05-08T12:00:00Z';
+ const outlierTime = '2026-05-09T12:00:00Z';
+ const sharedMessage = 'Service unavailable';
+ const entries = await loadStandardLogs([
+ { id: 'row-one', message: sharedMessage, timestamp: majorityTime, log_type: 'ERROR' },
+ { id: 'row-two', message: sharedMessage, timestamp: majorityTime, log_type: 'ERROR' },
+ { id: 'row-three', message: sharedMessage, timestamp: majorityTime, log_type: 'ERROR' },
+ { id: 'row-four', message: sharedMessage, timestamp: outlierTime, log_type: 'ERROR' },
+ { id: 'row-five', message: sharedMessage, timestamp: outlierTime, log_type: 'ERROR' },
+ ]);
+
+ expect(entries).toHaveLength(5);
+ expect(Array.from(entries).every((entry) =>
+ entry.dataset.logType === 'error'
+ )).toBe(true);
+ // Order-independent: uniqueLogsMap + the batch loader's reverse
+ // iteration produce a stable but implementation-defined ordering
+ // for ties. The contract under test is that all five server ids
+ // survive normalization + dedup and reach the DOM.
+ expect(Array.from(entries).map((entry) => entry.dataset.logId)
+ .sort()).toEqual([
+ 'row-five', 'row-four', 'row-one', 'row-three', 'row-two',
+ ]);
+ });
+});
+
/**
* Toggle handler tests — locks in the contract introduced by PR #3851.
*
diff --git a/tests/js/utils/log-helpers.test.js b/tests/js/utils/log-helpers.test.js
index 8daf4b3c49..2c3864a172 100644
--- a/tests/js/utils/log-helpers.test.js
+++ b/tests/js/utils/log-helpers.test.js
@@ -180,6 +180,74 @@ describe('normalizeTimestamps', () => {
expect(outlier.id).toMatch(/^2026-04-01.*-/);
});
+ it('preserves an existing id when re-stamping an outlier date', () => {
+ // The standard-array loader preserves the server-provided database
+ // id for distinct persisted rows. Re-deriving from `time + hash`
+ // here would collide two rows that share (timestamp, message) but
+ // differ only by id, so normalizeTimestamps must leave the id
+ // alone when one is already present.
+ const logs = [
+ {time: '2026-04-01T10:00:00.000Z', message: 'a', id: 'row-1'},
+ {time: '2026-04-01T11:00:00.000Z', message: 'b', id: 'row-2'},
+ {time: '2026-04-01T12:00:00.000Z', message: 'c', id: 'row-3'},
+ {time: '2026-04-02T15:30:00.000Z', message: 'outlier', id: 'row-4'},
+ ];
+ normalizeTimestamps(logs);
+ const outlier = logs[3];
+ expect(outlier.time.startsWith('2026-04-01')).toBe(true);
+ expect(outlier.id).toBe('row-4');
+ });
+
+ it('preserves distinct existing ids across multiple outliers that share a message', () => {
+ // Two outlier rows on the same minority date, with identical
+ // (timestamp, message) tuples but distinct server ids. Before the
+ // fix both rows were re-keyed to the same `time+hash` value and
+ // the downstream uniqueLogsMap collapsed one of them. The fix
+ // must keep both ids intact so the dedup layer sees them as two
+ // distinct rows.
+ const logs = [
+ {time: '2026-04-01T10:00:00.000Z', message: 'shared', id: 'row-a'},
+ {time: '2026-04-01T11:00:00.000Z', message: 'shared', id: 'row-b'},
+ {time: '2026-04-01T12:00:00.000Z', message: 'shared', id: 'row-c'},
+ {time: '2026-04-02T10:00:00.000Z', message: 'shared', id: 'row-d'},
+ {time: '2026-04-02T10:00:00.000Z', message: 'shared', id: 'row-e'},
+ ];
+ normalizeTimestamps(logs);
+ const ids = logs.map((log) => log.id);
+ expect(ids).toEqual(['row-a', 'row-b', 'row-c', 'row-d', 'row-e']);
+ });
+
+ it('treats numeric ids (including 0) as present', () => {
+ // The parser accepts `log.id != null && log.id !== ''` as "has
+ // id". normalizeTimestamps must agree on that boundary so a
+ // server that hands out `0` as a valid id never gets it clobbered
+ // by the time+hash fallback.
+ const logs = [
+ {time: '2026-04-01T10:00:00.000Z', message: 'a', id: 0},
+ {time: '2026-04-01T11:00:00.000Z', message: 'b', id: 1},
+ {time: '2026-04-01T12:00:00.000Z', message: 'c', id: 2},
+ {time: '2026-04-02T15:30:00.000Z', message: 'outlier', id: 7},
+ ];
+ normalizeTimestamps(logs);
+ expect(logs.map((log) => log.id)).toEqual([0, 1, 2, 7]);
+ });
+
+ it('still derives a fallback id when an outlier has no id at all', () => {
+ // The progress_log envelope payload doesn't ship server ids, so
+ // for that path normalizeTimestamps is the first place a derived
+ // id ever appears. Regression guard: the new "preserve existing
+ // id" branch must not accidentally swallow the fallback too.
+ const logs = [
+ {time: '2026-04-01T10:00:00.000Z', message: 'a'},
+ {time: '2026-04-01T11:00:00.000Z', message: 'b'},
+ {time: '2026-04-02T15:30:00.000Z', message: 'outlier'},
+ ];
+ normalizeTimestamps(logs);
+ const outlier = logs[2];
+ expect(outlier.time.startsWith('2026-04-01')).toBe(true);
+ expect(outlier.id).toMatch(/^2026-04-01.*-/);
+ });
+
it('does nothing when logs is empty', () => {
const logs = [];
expect(() => normalizeTimestamps(logs)).not.toThrow();