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.

Add feature to display selected search engine in log panel

LearningCircuit4000f17d0dc9
diff --git a/src/local_deep_research/web/static/css/styles.css b/src/local_deep_research/web/static/css/styles.css
index e2ed60e3c7..d5651b89d3 100644
--- a/src/local_deep_research/web/static/css/styles.css
+++ b/src/local_deep_research/web/static/css/styles.css
@@ -1383,6 +1383,18 @@ textarea:focus, input[type="text"]:focus {
border-color: rgba(255, 193, 7, 0.2);
}
+/* Styling for search engine selection log entries */
+.console-log-entry[data-log-type="info"][data-engine-selected="true"] {
+ background-color: rgba(64, 191, 255, 0.05);
+ border-left: 2px solid var(--accent-tertiary);
+ padding-left: calc(0.5rem - 2px);
+ font-weight: 500;
+}
+
+.console-log-entry[data-log-type="info"][data-engine-selected="true"] .log-message {
+ color: var(--accent-tertiary);
+}
+
/* Update existing error message styling if needed */
.error-message {
display: none;
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 98a45878e2..1451c4f153 100644
--- a/src/local_deep_research/web/static/js/components/logpanel.js
+++ b/src/local_deep_research/web/static/js/components/logpanel.js
@@ -13,7 +13,7 @@
connectedResearchId: null, // Track which research we're connected to
currentFilter: 'all' // Track current filter type
};
-
+
/**
* Initialize the log panel
* @param {string} researchId - Optional research ID to load logs for
@@ -22,32 +22,32 @@
// Check if already initialized
if (window._logPanelState.initialized) {
console.log('Log panel already initialized, checking if research ID has changed');
-
+
// If we're already connected to this research, do nothing
if (window._logPanelState.connectedResearchId === researchId) {
console.log('Already connected to research ID:', researchId);
return;
}
-
+
// If the research ID has changed, we'll update our connection
console.log('Research ID changed from', window._logPanelState.connectedResearchId, 'to', researchId);
window._logPanelState.connectedResearchId = researchId;
}
-
+
console.log('Initializing shared log panel, research ID:', researchId);
-
+
// Check if we're on a research-specific page (progress, results)
- const isResearchPage = window.location.pathname.includes('/research/progress/') ||
+ const isResearchPage = window.location.pathname.includes('/research/progress/') ||
window.location.pathname.includes('/research/results/') ||
document.getElementById('research-progress') ||
document.getElementById('research-results');
-
+
// Get all log panels on the page (there might be duplicates)
const logPanels = document.querySelectorAll('.collapsible-log-panel');
-
+
if (logPanels.length > 1) {
console.warn(`Found ${logPanels.length} log panels, removing duplicates`);
-
+
// Keep only the first one and remove others
for (let i = 1; i < logPanels.length; i++) {
console.log(`Removing duplicate log panel #${i}`);
@@ -57,24 +57,24 @@
console.error('No log panel found in the DOM!');
return;
}
-
+
// Get log panel elements with both old and new names for compatibility
let logPanelToggle = document.getElementById('log-panel-toggle');
let logPanelContent = document.getElementById('log-panel-content');
-
+
// Fallback to the old element IDs if needed
if (!logPanelToggle) logPanelToggle = document.getElementById('logToggle');
if (!logPanelContent) logPanelContent = document.getElementById('logPanel');
-
+
if (!logPanelToggle || !logPanelContent) {
console.warn('Log panel elements not found, skipping initialization');
return;
}
-
+
// Handle visibility based on page type
if (!isResearchPage) {
console.log('Not on a research-specific page, hiding log panel');
-
+
// Hide the log panel on non-research pages
const panel = logPanelContent.closest('.collapsible-log-panel');
if (panel) {
@@ -93,12 +93,12 @@
panel.style.display = 'flex';
}
}
-
+
console.log('Log panel elements found, setting up handlers');
-
+
// Mark as initialized to prevent double initialization
window._logPanelState.initialized = true;
-
+
// Check for CSS issue - if the panel's computed style has display:none, the panel won't be visible
const computedStyle = window.getComputedStyle(logPanelContent);
console.log('Log panel CSS visibility:', {
@@ -107,13 +107,13 @@
height: computedStyle.height,
overflow: computedStyle.overflow
});
-
+
// Ensure the panel is visible in the DOM
if (computedStyle.display === 'none') {
console.warn('Log panel has display:none - forcing display:flex');
logPanelContent.style.display = 'flex';
}
-
+
// Ensure we have a console log container
const consoleLogContainer = document.getElementById('console-log-container');
if (!consoleLogContainer) {
@@ -122,15 +122,15 @@
// Add placeholder message
consoleLogContainer.innerHTML = '<div class="empty-log-message">No logs available. Expand panel to load logs.</div>';
}
-
+
// Set up toggle click handler
logPanelToggle.addEventListener('click', function() {
console.log('Log panel toggle clicked');
-
+
// Toggle collapsed state
logPanelContent.classList.toggle('collapsed');
logPanelToggle.classList.toggle('collapsed');
-
+
// Update toggle icon
const toggleIcon = logPanelToggle.querySelector('.toggle-icon');
if (toggleIcon) {
@@ -138,14 +138,14 @@
toggleIcon.className = 'fas fa-chevron-right toggle-icon';
} else {
toggleIcon.className = 'fas fa-chevron-down toggle-icon';
-
+
// Load logs if not already loaded
if (!logPanelContent.dataset.loaded && researchId) {
console.log('First expansion of log panel, loading logs');
loadLogsForResearch(researchId);
logPanelContent.dataset.loaded = 'true';
}
-
+
// Process any queued logs
if (window._logPanelState.queuedLogs.length > 0) {
console.log(`Processing ${window._logPanelState.queuedLogs.length} queued logs`);
@@ -156,34 +156,34 @@
}
}
}
-
+
// Track expanded state
window._logPanelState.expanded = !logPanelContent.classList.contains('collapsed');
});
-
+
// Set up filter button click handlers
const filterButtons = document.querySelectorAll('.log-filter .filter-buttons button');
filterButtons.forEach(button => {
button.addEventListener('click', function() {
const type = this.textContent.toLowerCase();
console.log(`Filtering logs by type: ${type}`);
-
+
// Update active state
filterButtons.forEach(btn => btn.classList.remove('selected'));
this.classList.add('selected');
-
+
// Apply filtering
filterLogsByType(type);
});
});
-
+
// Start with panel collapsed and fix initial chevron direction
logPanelContent.classList.add('collapsed');
const initialToggleIcon = logPanelToggle.querySelector('.toggle-icon');
if (initialToggleIcon) {
initialToggleIcon.className = 'fas fa-chevron-right toggle-icon';
}
-
+
// Initialize the log count
const logIndicators = document.querySelectorAll('.log-indicator');
if (logIndicators.length > 0) {
@@ -194,19 +194,19 @@
} else {
console.warn('No log indicators found for initialization');
}
-
+
// Check CSS display property of the log panel
const logPanel = document.querySelector('.collapsible-log-panel');
if (logPanel) {
const panelStyle = window.getComputedStyle(logPanel);
console.log('Log panel CSS display:', panelStyle.display);
-
+
if (panelStyle.display === 'none') {
console.warn('Log panel has CSS display:none - forcing display:flex');
logPanel.style.display = 'flex';
}
}
-
+
// Pre-load logs if hash includes #logs
if (window.location.hash === '#logs' && researchId) {
console.log('Auto-loading logs due to #logs in URL');
@@ -214,7 +214,7 @@
logPanelToggle.click();
}, 500);
}
-
+
// DEBUG: Force expand the log panel if URL has debug parameter
if (window.location.search.includes('debug=logs') || window.location.hash.includes('debug')) {
console.log('DEBUG: Force-expanding log panel');
@@ -224,11 +224,11 @@
}
}, 800);
}
-
+
// Register global functions to ensure they work across modules
window.addConsoleLog = addConsoleLog;
window.filterLogsByType = filterLogsByType;
-
+
// Add a connector to socket.js
// Track when we last received this exact message to avoid re-adding within 10 seconds
const processedMessages = new Map();
@@ -237,21 +237,21 @@
const message = logEntry.message || logEntry.content || '';
const messageKey = `${message}-${logEntry.type || 'info'}`;
const now = Date.now();
-
+
// Check if we've seen this message recently (within 10 seconds)
if (processedMessages.has(messageKey)) {
const lastProcessed = processedMessages.get(messageKey);
const timeDiff = now - lastProcessed;
-
+
if (timeDiff < 10000) { // 10 seconds
console.log(`Skipping duplicate socket message received within ${timeDiff}ms:`, message);
return;
}
}
-
+
// Update our tracking
processedMessages.set(messageKey, now);
-
+
// Clean up old entries (keep map from growing indefinitely)
if (processedMessages.size > 100) {
// Remove entries older than 60 seconds
@@ -261,14 +261,14 @@
}
}
}
-
+
// Process the log entry
addLogEntryToPanel(logEntry);
};
-
+
console.log('Log panel initialized');
}
-
+
/**
* Load logs for a specific research
* @param {string} researchId - The research ID to load logs for
@@ -280,32 +280,32 @@
if (logContent) {
logContent.innerHTML = '<div class="loading-spinner centered"><div class="spinner"></div><div style="margin-left: 10px;">Loading logs...</div></div>';
}
-
+
console.log('Loading logs for research ID:', researchId);
-
+
// Fetch logs from API
const response = await fetch(`/research/api/logs/${researchId}`);
const data = await response.json();
-
+
console.log('Logs API response:', data);
-
+
// Initialize array to hold all logs from different sources
const allLogs = [];
-
+
// Track seen messages to avoid duplicate content with different timestamps
const seenMessages = new Map();
-
+
// Process progress_log if available
if (data.progress_log && typeof data.progress_log === 'string') {
try {
const progressLogs = JSON.parse(data.progress_log);
if (Array.isArray(progressLogs) && progressLogs.length > 0) {
console.log(`Found ${progressLogs.length} logs in progress_log`);
-
+
// Process progress logs
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)) {
@@ -314,7 +314,7 @@
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) {
@@ -322,15 +322,15 @@
}
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
let logType = 'info';
if (logItem.metadata) {
- if (logItem.metadata.phase === 'iteration_complete' ||
+ if (logItem.metadata.phase === 'iteration_complete' ||
logItem.metadata.phase === 'report_complete' ||
logItem.metadata.phase === 'complete' ||
logItem.metadata.is_milestone === true) {
@@ -339,12 +339,12 @@
logType = 'error';
}
}
-
+
// Add message keywords for better type detection
if (logType !== 'milestone') {
const msg = logItem.message.toLowerCase();
- if (msg.includes('complete') ||
- msg.includes('finished') ||
+ if (msg.includes('complete') ||
+ msg.includes('finished') ||
msg.includes('starting phase') ||
msg.includes('generated report')) {
logType = 'milestone';
@@ -352,7 +352,7 @@
logType = 'error';
}
}
-
+
// Create a log entry object with a unique ID for deduplication
const logEntry = {
id: `${logItem.time}-${hashString(logItem.message)}`,
@@ -362,10 +362,10 @@
metadata: logItem.metadata || {},
source: 'progress_log'
};
-
+
// Track this message to avoid showing exact duplicates with different timestamps
seenMessages.set(messageKey, logEntry);
-
+
// Add to all logs array
allLogs.push(logEntry);
});
@@ -374,15 +374,15 @@
console.error('Error parsing progress_log:', e);
}
}
-
+
// Standard logs array processing
if (data && Array.isArray(data.logs)) {
console.log(`Processing ${data.logs.length} standard logs`);
-
+
// Process each standard log
data.logs.forEach(log => {
if (!log.timestamp && !log.time) return; // Skip invalid logs
-
+
// Skip duplicates based on message content
const messageKey = normalizeMessage(log.message || log.content || '');
if (seenMessages.has(messageKey)) {
@@ -391,7 +391,7 @@
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) {
@@ -400,7 +400,7 @@
return; // Skip this duplicate
}
}
-
+
// Create standardized log entry
const logEntry = {
id: `${log.timestamp || log.time}-${hashString(log.message || log.content || '')}`,
@@ -410,50 +410,50 @@
metadata: log.metadata || {},
source: 'standard_logs'
};
-
+
// Track this message
seenMessages.set(messageKey, logEntry);
-
+
// Add to all logs array
allLogs.push(logEntry);
});
}
-
+
// Clear container
if (logContent) {
if (allLogs.length === 0) {
logContent.innerHTML = '<div class="empty-log-message">No logs available for this research.</div>';
return;
}
-
+
logContent.innerHTML = '';
-
+
// Normalize timestamps - in case there are logs with mismatched AM/PM time zones
// This attempts to ensure logs are in a proper chronological order
normalizeTimestamps(allLogs);
-
+
// Deduplicate logs by ID and sort by timestamp (oldest first)
const uniqueLogsMap = new Map();
allLogs.forEach(log => {
// Use the ID as the key for deduplication
uniqueLogsMap.set(log.id, log);
});
-
+
// Convert map back to array
const uniqueLogs = Array.from(uniqueLogsMap.values());
-
+
// Sort logs by timestamp (oldest first)
const sortedLogs = uniqueLogs.sort((a, b) => {
return new Date(a.time) - new Date(b.time);
});
-
+
console.log(`Displaying ${sortedLogs.length} logs after deduplication (from original ${allLogs.length})`);
-
+
// Add each log entry to panel
sortedLogs.forEach(log => {
addLogEntryToPanel(log, false); // False means don't increment counter
});
-
+
// Update log count indicator
const logIndicators = document.querySelectorAll('.log-indicator');
if (logIndicators.length > 0) {
@@ -463,10 +463,10 @@
});
}
}
-
+
} catch (error) {
console.error('Error loading logs:', error);
-
+
// Show error in log panel
const logContent = document.getElementById('console-log-container');
if (logContent) {
@@ -474,7 +474,7 @@
}
}
}
-
+
/**
* Normalize a message for deduplication comparison
* @param {string} message - The message to normalize
@@ -485,7 +485,7 @@
// Remove extra whitespace and lowercase
return message.trim().toLowerCase();
}
-
+
/**
* Normalize timestamps across logs to ensure consistent ordering
* @param {Array} logs - The logs to normalize
@@ -493,7 +493,7 @@
function normalizeTimestamps(logs) {
// Find the most common date in the logs (ignoring the time)
const dateFrequency = new Map();
-
+
logs.forEach(log => {
try {
const date = new Date(log.time);
@@ -504,28 +504,28 @@
console.error('Error parsing date:', log.time);
}
});
-
+
// Find the most frequent date
let mostCommonDate = null;
let highestFrequency = 0;
-
+
dateFrequency.forEach((count, date) => {
if (count > highestFrequency) {
highestFrequency = count;
mostCommonDate = date;
}
});
-
+
console.log(`Most common date: ${mostCommonDate} with ${highestFrequency} occurrences`);
-
+
if (!mostCommonDate) return; // Can't normalize without a common date
-
+
// Normalize all logs to the most common date
logs.forEach(log => {
try {
const date = new Date(log.time);
const dateStr = date.toISOString().split('T')[0];
-
+
// If this log is from a different date, adjust it to the most common date
// while preserving the time portion
if (dateStr !== mostCommonDate) {
@@ -533,7 +533,7 @@
date.setFullYear(parseInt(year));
date.setMonth(parseInt(month) - 1); // Months are 0-indexed
date.setDate(parseInt(day));
-
+
// Update the log time
log.time = date.toISOString();
log.id = `${log.time}-${hashString(log.message)}`;
@@ -544,7 +544,7 @@
}
});
}
-
+
/**
* Simple hash function for strings
* @param {string} str - String to hash
@@ -560,7 +560,7 @@
}
return hash.toString();
}
-
+
/**
* Add a log entry to the console - public API
* @param {string} message - Log message
@@ -569,7 +569,7 @@
*/
function addConsoleLog(message, level = 'info', metadata = null) {
console.log(`[${level.toUpperCase()}] ${message}`);
-
+
const timestamp = new Date().toISOString();
const logEntry = {
id: `${timestamp}-${hashString(message)}`,
@@ -578,29 +578,29 @@
type: level,
metadata: metadata || { type: level }
};
-
+
// Queue log entries if panel is not expanded yet
if (!window._logPanelState.expanded) {
window._logPanelState.queuedLogs.push(logEntry);
console.log('Queued log entry for later display');
-
+
// Update log count even if not displaying yet
updateLogCounter(1);
-
+
// Auto-expand log panel on first log
const logPanelToggle = document.getElementById('log-panel-toggle');
if (logPanelToggle) {
console.log('Auto-expanding log panel because logs are available');
logPanelToggle.click();
}
-
+
return;
}
-
+
// Add directly to panel if it's expanded
addLogEntryToPanel(logEntry, true);
}
-
+
/**
* Add a log entry directly to the panel
* @param {Object} logEntry - The log entry to add
@@ -608,37 +608,37 @@
*/
function addLogEntryToPanel(logEntry, incrementCounter = true) {
console.log('Adding log entry to panel:', logEntry);
-
+
const consoleLogContainer = document.getElementById('console-log-container');
if (!consoleLogContainer) {
console.warn('Console log container not found');
return;
}
-
+
// Clear empty message if present
const emptyMessage = consoleLogContainer.querySelector('.empty-log-message');
if (emptyMessage) {
emptyMessage.remove();
}
-
+
// Ensure the log entry has an ID
if (!logEntry.id) {
const timestamp = logEntry.time || logEntry.timestamp || new Date().toISOString();
const message = logEntry.message || logEntry.content || 'No message';
logEntry.id = `${timestamp}-${hashString(message)}`;
}
-
+
// More robust deduplication: First check by ID if available
if (logEntry.id) {
const existingEntryById = consoleLogContainer.querySelector(`.console-log-entry[data-log-id="${logEntry.id}"]`);
if (existingEntryById) {
console.log('Skipping duplicate log entry by ID:', logEntry.id);
-
+
// Increment counter on existing entry
let counter = parseInt(existingEntryById.dataset.counter || '1');
counter++;
existingEntryById.dataset.counter = counter;
-
+
// Update visual counter badge
if (counter > 1) {
let counterBadge = existingEntryById.querySelector('.duplicate-counter');
@@ -649,41 +649,41 @@
}
counterBadge.textContent = `(${counter}×)`;
}
-
+
// Still update the global counter if needed
if (incrementCounter) {
updateLogCounter(1);
}
-
+
return;
}
}
-
+
// Secondary check for duplicate by message content (for backward compatibility)
const existingEntries = consoleLogContainer.querySelectorAll('.console-log-entry');
if (existingEntries.length > 0) {
const message = logEntry.message || logEntry.content || '';
const logType = (logEntry.type || 'info').toLowerCase();
-
+
// Start from the end since newest logs are now at the bottom
for (let i = existingEntries.length - 1; i >= Math.max(0, existingEntries.length - 10); i--) {
// Only check the 10 most recent entries for efficiency
const entry = existingEntries[i];
const entryMessage = entry.querySelector('.log-message')?.textContent;
const entryType = entry.dataset.logType;
-
+
// If message and type match, consider it a duplicate (unless it's a milestone)
- if (entryMessage === message &&
- entryType === logType &&
+ if (entryMessage === message &&
+ entryType === logType &&
logType !== 'milestone') {
-
+
console.log('Skipping duplicate log entry by content:', message);
-
+
// Increment counter on existing entry
let counter = parseInt(entry.dataset.counter || '1');
counter++;
entry.dataset.counter = counter;
-
+
// Update visual counter badge
if (counter > 1) {
let counterBadge = entry.querySelector('.duplicate-counter');
@@ -694,20 +694,20 @@
}
counterBadge.textContent = `(${counter}×)`;
}
-
+
// Still update the global counter if needed
if (incrementCounter) {
updateLogCounter(1);
}
-
+
return;
}
}
}
-
+
// Get the log template
const template = document.getElementById('console-log-entry-template');
-
+
// Determine log level - CHECK FOR DIRECT TYPE FIELD FIRST
let logLevel = 'info';
if (logEntry.type) {
@@ -715,7 +715,7 @@
} else if (logEntry.metadata && logEntry.metadata.type) {
logLevel = logEntry.metadata.type;
} else if (logEntry.metadata && logEntry.metadata.phase) {
- if (logEntry.metadata.phase === 'complete' ||
+ if (logEntry.metadata.phase === 'complete' ||
logEntry.metadata.phase === 'iteration_complete' ||
logEntry.metadata.phase === 'report_complete') {
logLevel = 'milestone';
@@ -725,19 +725,19 @@
} else if (logEntry.level) {
logLevel = logEntry.level;
}
-
+
// Format timestamp
const timestamp = new Date(logEntry.time || logEntry.timestamp || new Date());
const timeStr = timestamp.toLocaleTimeString();
-
+
// Get message
const message = logEntry.message || logEntry.content || 'No message';
-
+
if (template) {
// Create a new log entry from the template
const entry = document.importNode(template.content, true);
const logEntryElement = entry.querySelector('.console-log-entry');
-
+
// Add the log type as data attribute for filtering
if (logEntryElement) {
logEntryElement.dataset.logType = logLevel.toLowerCase();
@@ -748,14 +748,23 @@
if (logEntry.id) {
logEntryElement.dataset.logId = logEntry.id;
}
+
+ // Add special attribute for engine selection events
+ if (logEntry.metadata && logEntry.metadata.phase === 'engine_selected') {
+ logEntryElement.dataset.engineSelected = 'true';
+ // Store engine name as a data attribute
+ if (logEntry.metadata.engine) {
+ logEntryElement.dataset.engine = logEntry.metadata.engine;
+ }
+ }
}
-
+
// Set content
entry.querySelector('.log-timestamp').textContent = timeStr;
entry.querySelector('.log-badge').textContent = logLevel.charAt(0).toUpperCase() + logLevel.slice(1);
entry.querySelector('.log-badge').className = `log-badge ${logLevel.toLowerCase()}`;
entry.querySelector('.log-message').textContent = message;
-
+
// Add to container (at the end for oldest first)
consoleLogContainer.appendChild(entry);
} else {
@@ -768,33 +777,33 @@
if (logEntry.id) {
entry.dataset.logId = logEntry.id;
}
-
+
// Create log content
entry.innerHTML = `
<span class="log-timestamp">${timeStr}</span>
<span class="log-badge ${logLevel.toLowerCase()}">${logLevel.charAt(0).toUpperCase() + logLevel.slice(1)}</span>
<span class="log-message">${message}</span>
`;
-
+
// Add to container (at the end for oldest first)
consoleLogContainer.appendChild(entry);
}
-
+
// Check if the entry should be visible based on current filter
const currentFilter = window._logPanelState.currentFilter || 'all';
const shouldShow = checkLogVisibility(logLevel.toLowerCase(), currentFilter);
-
+
// Apply visibility based on the current filter
const newEntry = consoleLogContainer.lastElementChild;
if (newEntry) {
newEntry.style.display = shouldShow ? '' : 'none';
}
-
+
// Update log count using helper function if needed
if (incrementCounter) {
updateLogCounter(1);
}
-
+
// No need to scroll when loading all logs
// Scroll will be handled after all logs are loaded
if (incrementCounter) {
@@ -804,7 +813,7 @@
}, 0);
}
}
-
+
/**
* Helper function to update the log counter
* @param {number} increment - Amount to increment the counter by
@@ -814,14 +823,14 @@
if (logIndicators.length > 0) {
const currentCount = parseInt(logIndicators[0].textContent) || 0;
const newCount = currentCount + increment;
-
+
// Update all indicators
logIndicators.forEach(indicator => {
indicator.textContent = newCount;
});
}
}
-
+
/**
* Check if a log entry should be visible based on filter type
* @param {string} logType - The type of log (info, milestone, error)
@@ -844,43 +853,43 @@
return true; // Default to showing everything
}
}
-
+
/**
* Filter logs by type
* @param {string} filterType - The type to filter by (all, info, milestone, error)
*/
function filterLogsByType(filterType = 'all') {
console.log('Filtering logs by type:', filterType);
-
+
filterType = filterType.toLowerCase();
-
+
// Store current filter in shared state
window._logPanelState.currentFilter = filterType;
-
+
// Get all log entries from the DOM
const logEntries = document.querySelectorAll('.console-log-entry');
console.log(`Found ${logEntries.length} log entries to filter`);
-
+
let visibleCount = 0;
-
+
// Apply filters
logEntries.forEach(entry => {
// Use data attribute for log type
const logType = entry.dataset.logType || 'info';
-
+
// Determine visibility based on filter type
const shouldShow = checkLogVisibility(logType, filterType);
-
+
// Set display style based on filter result
entry.style.display = shouldShow ? '' : 'none';
-
+
if (shouldShow) {
visibleCount++;
}
});
-
+
console.log(`Filtering complete. Showing ${visibleCount} of ${logEntries.length} logs`);
-
+
// Show 'no logs' message if all logs are filtered out
const consoleContainer = document.getElementById('console-log-container');
if (consoleContainer && logEntries.length > 0) {
@@ -889,7 +898,7 @@
if (existingEmptyMessage) {
existingEmptyMessage.remove();
}
-
+
// Add empty message if needed
if (visibleCount === 0) {
console.log(`Adding 'no logs' message for filter: ${filterType}`);
@@ -900,7 +909,7 @@
}
}
}
-
+
// Expose public API
window.logPanel = {
initialize: initializeLogPanel,
@@ -908,33 +917,33 @@
filterLogs: filterLogsByType,
loadLogs: loadLogsForResearch
};
-
+
// Self-invoke to initialize when DOM content is loaded
document.addEventListener('DOMContentLoaded', function() {
console.log('DOM ready - checking if log panel should be initialized');
-
+
// Find research ID from URL if available
let researchId = null;
const urlMatch = window.location.pathname.match(/\/research\/(progress|results)\/(\d+)/);
if (urlMatch && urlMatch[2]) {
researchId = urlMatch[2];
console.log('Found research ID in URL:', researchId);
-
+
// Store the current research ID in the state
window._logPanelState.connectedResearchId = researchId;
}
-
+
// Check for research page elements
- const isResearchPage = window.location.pathname.includes('/research/progress/') ||
+ const isResearchPage = window.location.pathname.includes('/research/progress/') ||
window.location.pathname.includes('/research/results/') ||
document.getElementById('research-progress') ||
document.getElementById('research-results');
-
+
// Initialize log panel if on a research page
if (isResearchPage) {
console.log('On a research page, initializing log panel for research ID:', researchId);
initializeLogPanel(researchId);
-
+
// Extra check: If we have a research ID but panel not initialized properly
setTimeout(() => {
if (researchId && !window._logPanelState.initialized) {
@@ -946,4 +955,4 @@
console.log('Not on a research page, skipping log panel initialization');
}
});
-})();
\ No newline at end of file
+})();
diff --git a/src/local_deep_research/web/static/js/services/socket.js b/src/local_deep_research/web/static/js/services/socket.js
index 597245cfce..200b29c9cb 100644
--- a/src/local_deep_research/web/static/js/services/socket.js
+++ b/src/local_deep_research/web/static/js/services/socket.js
@@ -85,6 +85,29 @@ window.socket = (function() {
}
});
+ // Add handler for search engine selection events
+ socket.on('search_engine_selected', (data) => {
+ console.log('Received search_engine_selected event:', data);
+ if (data && data.engine) {
+ const engineName = data.engine;
+ const resultCount = data.result_count || 0;
+
+ // Add to log panel
+ if (typeof window.addConsoleLog === 'function') {
+ // Format engine name - capitalize first letter
+ const displayEngineName = engineName.charAt(0).toUpperCase() + engineName.slice(1);
+ const message = `Search engine selected: ${displayEngineName} (found ${resultCount} results)`;
+ window.addConsoleLog(message, 'info', {
+ type: 'info',
+ phase: 'engine_selected',
+ engine: engineName,
+ result_count: resultCount,
+ is_engine_selection: true
+ });
+ }
+ }
+ });
+
socket.on('disconnect', (reason) => {
console.log('Socket disconnected:', reason);
@@ -237,6 +260,30 @@ window.socket = (function() {
});
}
+ // Handle special engine selection events
+ if (data.event === 'search_engine_selected' || (data.engine && data.result_count !== undefined)) {
+ // Extract engine information
+ const engineName = data.engine || 'unknown';
+ const resultCount = data.result_count || 0;
+
+ // Log the event
+ console.log(`Search engine selected: ${engineName} (found ${resultCount} results)`);
+
+ // Add to log panel as an info message with special metadata
+ if (typeof window.addConsoleLog === 'function') {
+ // Format engine name - capitalize first letter
+ const displayEngineName = engineName.charAt(0).toUpperCase() + engineName.slice(1);
+ const message = `Search engine selected: ${displayEngineName} (found ${resultCount} results)`;
+ window.addConsoleLog(message, 'info', {
+ type: 'info',
+ phase: 'engine_selected',
+ engine: engineName,
+ result_count: resultCount,
+ is_engine_selection: true
+ });
+ }
+ }
+
// Initialize message tracking if not exists
window._processedSocketMessages = window._processedSocketMessages || new Map();