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 results page: add log panel functionality and update paths

hashedviking4a463d523cfc
diff --git a/src/local_deep_research/web/static/js/components/results.js b/src/local_deep_research/web/static/js/components/results.js
index d58c79b4b7..45946ecdcf 100644
--- a/src/local_deep_research/web/static/js/components/results.js
+++ b/src/local_deep_research/web/static/js/components/results.js
@@ -6,7 +6,6 @@
// Component state
let currentResearchId = null;
let researchData = null;
- let researchLogs = [];
// DOM Elements
let resultsContainer = null;
@@ -14,8 +13,6 @@
let exportPdfBtn = null;
let exportMarkdownBtn = null;
let backToHistoryBtn = null;
- let logsContainer = null;
- let logsTabs = null;
/**
* Initialize the results component
@@ -26,9 +23,13 @@
if (!currentResearchId) {
console.error('No research ID found');
- window.ui.showError('No research results found. Please start a new research.');
+ if (window.ui && window.ui.showError) {
+ window.ui.showError('No research results found. Please start a new research.');
+ } else {
+ alert('No research results found. Please start a new research.');
+ }
setTimeout(() => {
- window.location.href = '/';
+ window.location.href = '/research';
}, 3000);
return;
}
@@ -39,8 +40,6 @@
exportPdfBtn = document.getElementById('download-pdf-btn');
exportMarkdownBtn = document.getElementById('export-markdown-btn');
backToHistoryBtn = document.getElementById('back-to-history');
- logsContainer = document.getElementById('logs-container');
- logsTabs = document.querySelectorAll('.log-tab');
if (!resultsContainer) {
console.error('Required DOM elements not found for results component');
@@ -53,12 +52,140 @@
// Load research results
loadResearchResults();
- // Load research logs
- loadResearchLogs();
+ // Set up log panel for this research
+ initializeLogPanel();
console.log('Results component initialized for research ID:', currentResearchId);
}
+ /**
+ * Initialize log panel functionality
+ */
+ function initializeLogPanel() {
+ if (window.loadLogsForResearch && currentResearchId) {
+ try {
+ console.log('Loading logs for research ID:', currentResearchId);
+ window.loadLogsForResearch(currentResearchId);
+ } catch (error) {
+ console.error('Error loading research logs:', error);
+ }
+ } else if (currentResearchId) {
+ // Fallback to manually load logs if the global function isn't available
+ try {
+ const logContainer = document.getElementById('console-log-container');
+ const logToggle = document.getElementById('log-panel-toggle');
+
+ if (logContainer && logToggle) {
+ // Set up log panel toggle
+ logToggle.addEventListener('click', function() {
+ const panel = document.querySelector('.collapsible-log-panel');
+ if (panel) {
+ panel.classList.toggle('expanded');
+ const icon = panel.querySelector('.toggle-icon');
+ if (icon) {
+ icon.classList.toggle('fa-chevron-down');
+ icon.classList.toggle('fa-chevron-up');
+ }
+ }
+ });
+
+ // Load logs from API
+ fetchLogsForResearch(currentResearchId);
+ }
+ } catch (error) {
+ console.error('Error setting up fallback log handling:', error);
+ }
+ }
+ }
+
+ /**
+ * Fetch logs from API and display them
+ */
+ async function fetchLogsForResearch(researchId) {
+ try {
+ if (!window.api || !window.api.getResearchLogs) {
+ console.warn('API service not available for logs');
+ return;
+ }
+
+ const logsData = await window.api.getResearchLogs(researchId);
+
+ if (logsData && logsData.logs && Array.isArray(logsData.logs)) {
+ displayLogs(logsData.logs);
+ }
+ } catch (error) {
+ console.error('Error fetching logs:', error);
+ }
+ }
+
+ /**
+ * Display logs in the log panel
+ */
+ function displayLogs(logs) {
+ const logContainer = document.getElementById('console-log-container');
+ const logIndicator = document.getElementById('log-indicator');
+
+ if (!logContainer) return;
+
+ // Clear existing logs
+ logContainer.innerHTML = '';
+
+ if (logs.length === 0) {
+ logContainer.innerHTML = '<div class="empty-log-message">No logs available for this research.</div>';
+ if (logIndicator) logIndicator.textContent = '0';
+ return;
+ }
+
+ // Get the template
+ const template = document.getElementById('console-log-entry-template');
+
+ // Format and display each log
+ logs.forEach(log => {
+ let entry;
+
+ if (template) {
+ // Use template if available
+ entry = document.importNode(template.content, true).querySelector('.console-log-entry');
+
+ // Set log data
+ entry.querySelector('.log-timestamp').textContent = formatLogTimestamp(log.time);
+
+ const badge = entry.querySelector('.log-badge');
+ badge.textContent = log.type || 'info';
+ badge.className = `log-badge log-badge-${log.type || 'info'}`;
+
+ entry.querySelector('.log-message').textContent = log.message;
+
+ } else {
+ // Fallback if template is not available
+ entry = document.createElement('div');
+ entry.className = 'console-log-entry';
+ entry.innerHTML = `
+ <span class="log-timestamp">${formatLogTimestamp(log.time)}</span>
+ <span class="log-badge log-badge-${log.type || 'info'}">${log.type || 'info'}</span>
+ <span class="log-message">${log.message}</span>
+ `;
+ }
+
+ logContainer.appendChild(entry);
+ });
+
+ // Update log count
+ if (logIndicator) logIndicator.textContent = logs.length;
+ }
+
+ /**
+ * Format log timestamp
+ */
+ function formatLogTimestamp(timestamp) {
+ try {
+ const date = new Date(timestamp);
+ return date.toLocaleTimeString([], {hour: '2-digit', minute: '2-digit', second: '2-digit'});
+ } catch (e) {
+ return timestamp || '';
+ }
+ }
+
/**
* Extract research ID from URL
* @returns {string|null} The research ID or null if not found
@@ -92,20 +219,6 @@
});
}
- // Set up log tabs if they exist
- if (logsTabs) {
- logsTabs.forEach(tab => {
- tab.addEventListener('click', () => {
- const filterType = tab.dataset.type || 'all';
- filterLogs(filterType);
-
- // Update active tab
- logsTabs.forEach(t => t.classList.remove('active'));
- tab.classList.add('active');
- });
- });
- }
-
// Set up table of contents click events
document.addEventListener('click', function(e) {
if (e.target && e.target.matches('.toc-link')) {
@@ -126,10 +239,16 @@
*/
async function loadResearchResults() {
// Show loading state
- window.ui.showSpinner(resultsContainer, 'Loading research results...');
+ if (window.ui && window.ui.showSpinner) {
+ window.ui.showSpinner(resultsContainer, 'Loading research results...');
+ }
try {
// Get research results - using getReport instead of undefined getResearchResults
+ if (!window.api || !window.api.getReport) {
+ throw new Error('API service not available');
+ }
+
researchData = await window.api.getReport(currentResearchId);
if (!researchData || !researchData.content) {
@@ -140,8 +259,14 @@
renderResults(researchData);
} catch (error) {
console.error('Error loading research results:', error);
- window.ui.hideSpinner(resultsContainer);
- window.ui.showError('Error loading research results: ' + error.message);
+ if (window.ui && window.ui.hideSpinner) {
+ window.ui.hideSpinner(resultsContainer);
+ }
+ if (window.ui && window.ui.showError) {
+ window.ui.showError('Error loading research results: ' + error.message);
+ } else {
+ resultsContainer.innerHTML = `<div class="error-message">Error loading research results: ${error.message}</div>`;
+ }
}
}
@@ -151,7 +276,9 @@
*/
function renderResults(data) {
// Hide spinner
- window.ui.hideSpinner(resultsContainer);
+ if (window.ui && window.ui.hideSpinner) {
+ window.ui.hideSpinner(resultsContainer);
+ }
// Set page title
document.title = `${data.title || 'Research Results'} - Local Deep Research`;
@@ -164,8 +291,13 @@
// Render content
if (data.content) {
// Render markdown
- const renderedHtml = window.ui.renderMarkdown(data.content);
- resultsContainer.innerHTML = renderedHtml;
+ if (window.ui && window.ui.renderMarkdown) {
+ const renderedHtml = window.ui.renderMarkdown(data.content);
+ resultsContainer.innerHTML = renderedHtml;
+ } else {
+ // Simple fallback - treat as pre-formatted text
+ resultsContainer.innerHTML = `<pre>${data.content}</pre>`;
+ }
// Generate table of contents
generateTableOfContents();
@@ -190,7 +322,10 @@
// Research title
if (data.title) {
- document.querySelector('h1.page-title').textContent = data.title;
+ const titleElement = document.querySelector('h1.page-title');
+ if (titleElement) {
+ titleElement.textContent = data.title;
+ }
}
// Query
@@ -200,12 +335,16 @@
// Mode
if (data.mode) {
- metadata.push(`<div class="metadata-item"><span>Mode:</span> ${window.formatting.formatMode(data.mode)}</div>`);
+ const formattedMode = window.formatting && window.formatting.formatMode ?
+ window.formatting.formatMode(data.mode) : data.mode;
+ metadata.push(`<div class="metadata-item"><span>Mode:</span> ${formattedMode}</div>`);
}
// Completed date
if (data.completed_at) {
- metadata.push(`<div class="metadata-item"><span>Completed:</span> ${window.formatting.formatDate(data.completed_at)}</div>`);
+ const formattedDate = window.formatting && window.formatting.formatDate ?
+ window.formatting.formatDate(data.completed_at) : data.completed_at;
+ metadata.push(`<div class="metadata-item"><span>Completed:</span> ${formattedDate}</div>`);
}
// Duration
@@ -233,7 +372,10 @@
const headings = resultsContainer.querySelectorAll('h2, h3, h4');
if (headings.length === 0) {
- tocContainer.closest('.toc-container').style.display = 'none';
+ const tocParent = tocContainer.closest('.toc-container');
+ if (tocParent) {
+ tocParent.style.display = 'none';
+ }
return;
}
@@ -279,14 +421,20 @@
}
try {
+ if (!window.pdf || !window.pdf.downloadPdf) {
+ throw new Error('PDF service not available');
+ }
+
// Generate and download PDF
window.pdf.downloadPdf(
researchData.title || 'Research Results',
researchData.content,
{
query: researchData.query,
- mode: window.formatting.formatMode(researchData.mode),
- completed: window.formatting.formatDate(researchData.completed_at),
+ mode: window.formatting && window.formatting.formatMode ?
+ window.formatting.formatMode(researchData.mode) : researchData.mode,
+ completed: window.formatting && window.formatting.formatDate ?
+ window.formatting.formatDate(researchData.completed_at) : researchData.completed_at,
sources: researchData.sources_count
}
);
@@ -300,7 +448,9 @@
}, 1000);
} catch (error) {
console.error('Error generating PDF:', error);
- window.ui.showError('Error generating PDF: ' + error.message);
+ if (window.ui && window.ui.showError) {
+ window.ui.showError('Error generating PDF: ' + error.message);
+ }
// Reset button state
if (exportPdfBtn) {
@@ -323,6 +473,10 @@
}
try {
+ if (!window.api || !window.api.getMarkdownExport) {
+ throw new Error('API service not available');
+ }
+
// Get raw markdown content
const response = await window.api.getMarkdownExport(currentResearchId);
@@ -343,7 +497,9 @@
URL.revokeObjectURL(url);
// Show success message
- window.ui.showMessage('Markdown file downloaded successfully');
+ if (window.ui && window.ui.showMessage) {
+ window.ui.showMessage('Markdown file downloaded successfully');
+ }
// Reset button state
if (exportMarkdownBtn) {
@@ -352,7 +508,9 @@
}
} catch (error) {
console.error('Error generating Markdown:', error);
- window.ui.showError('Error generating Markdown: ' + error.message);
+ if (window.ui && window.ui.showError) {
+ window.ui.showError('Error generating Markdown: ' + error.message);
+ }
// Reset button state
if (exportMarkdownBtn) {
@@ -362,94 +520,6 @@
}
}
- /**
- * Load research logs from API
- */
- async function loadResearchLogs() {
- if (!currentResearchId || !logsContainer) return;
-
- try {
- // Get research logs
- const response = await window.api.getResearchLogs(currentResearchId);
-
- if (response && response.logs) {
- researchLogs = response.logs;
- renderLogs(researchLogs);
- }
- } catch (error) {
- console.error('Error loading research logs:', error);
- if (logsContainer) {
- logsContainer.innerHTML = '<div class="error-message">Failed to load research logs.</div>';
- }
- }
- }
-
- /**
- * Render research logs
- * @param {Array} logs - The logs to render
- */
- function renderLogs(logs) {
- if (!logsContainer) return;
-
- if (!logs || logs.length === 0) {
- logsContainer.innerHTML = '<div class="empty-logs">No logs yet. Research logs will appear here as they occur.</div>';
- return;
- }
-
- const logItems = logs.map(log => {
- const type = log.type || 'info';
- const time = formatLogTime(log.time);
- const message = log.message || '';
-
- return `
- <div class="log-item log-${type}" data-type="${type}">
- <span class="log-time">${time}</span>
- <span class="log-message">${message}</span>
- </div>
- `;
- });
-
- logsContainer.innerHTML = logItems.join('');
- }
-
- /**
- * Format log timestamp
- * @param {string} timeStr - ISO timestamp
- * @returns {string} Formatted time
- */
- function formatLogTime(timeStr) {
- if (!timeStr) return '';
-
- try {
- const date = new Date(timeStr);
- return date.toLocaleTimeString(undefined, {
- hour: '2-digit',
- minute: '2-digit',
- second: '2-digit'
- });
- } catch (e) {
- return timeStr;
- }
- }
-
- /**
- * Filter logs by type
- * @param {string} filterType - The type to filter by
- */
- function filterLogs(filterType = 'all') {
- if (!logsContainer) return;
-
- const logItems = logsContainer.querySelectorAll('.log-item');
-
- logItems.forEach(item => {
- if (filterType === 'all' || item.dataset.type === filterType) {
- item.style.display = '';
- } else {
- item.style.display = 'none';
- }
- });
- }
-
// Initialize on DOM content loaded
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initializeResults);
diff --git a/src/local_deep_research/web/static/js/services/formatting.js b/src/local_deep_research/web/static/js/services/formatting.js
new file mode 100644
index 0000000000..25a720409d
--- /dev/null
+++ b/src/local_deep_research/web/static/js/services/formatting.js
@@ -0,0 +1,119 @@
+/**
+ * Utility functions for formatting data
+ */
+
+/**
+ * Format a status string to be more user-friendly
+ * @param {string} status - The status string
+ * @returns {string} The formatted status string
+ */
+function formatStatus(status) {
+ switch(status) {
+ case 'in_progress': return 'In Progress';
+ case 'completed': return 'Completed';
+ case 'failed': return 'Failed';
+ case 'suspended': return 'Suspended';
+ default: return status.charAt(0).toUpperCase() + status.slice(1);
+ }
+}
+
+/**
+ * Format a research mode string to be more user-friendly
+ * @param {string} mode - The mode string
+ * @returns {string} The formatted mode string
+ */
+function formatMode(mode) {
+ switch(mode) {
+ case 'quick': return 'Quick Summary';
+ case 'detailed': return 'Detailed Report';
+ default: return mode.charAt(0).toUpperCase() + mode.slice(1);
+ }
+}
+
+/**
+ * Format a date string with optional duration
+ * @param {string} date - The date string in ISO format
+ * @param {number|null} duration - Optional duration in seconds
+ * @returns {string} The formatted date string
+ */
+function formatDate(date, duration = null) {
+ if (!date) return 'Unknown';
+
+ try {
+ const dateObj = new Date(date);
+ const options = {
+ year: 'numeric',
+ month: 'short',
+ day: 'numeric',
+ hour: '2-digit',
+ minute: '2-digit'
+ };
+
+ let formattedDate = dateObj.toLocaleDateString('en-US', options);
+
+ if (duration) {
+ // Format the duration
+ const minutes = Math.floor(duration / 60);
+ const seconds = duration % 60;
+
+ if (minutes > 0) {
+ formattedDate += ` (${minutes}m ${seconds}s)`;
+ } else {
+ formattedDate += ` (${seconds}s)`;
+ }
+ }
+
+ return formattedDate;
+ } catch (e) {
+ console.error('Error formatting date:', e);
+ return date; // Return the original date if there's an error
+ }
+}
+
+/**
+ * Format a duration in seconds to a readable string
+ * @param {number} seconds - Duration in seconds
+ * @returns {string} Formatted duration string
+ */
+function formatDuration(seconds) {
+ if (!seconds || isNaN(seconds)) return 'Unknown';
+
+ const minutes = Math.floor(seconds / 60);
+ const remainingSeconds = Math.floor(seconds % 60);
+
+ if (minutes === 0) {
+ return `${remainingSeconds}s`;
+ } else {
+ return `${minutes}m ${remainingSeconds}s`;
+ }
+}
+
+/**
+ * Capitalize the first letter of a string
+ * @param {string} string - The string to capitalize
+ * @returns {string} The capitalized string
+ */
+function capitalizeFirstLetter(string) {
+ if (!string) return '';
+ return string.charAt(0).toUpperCase() + string.slice(1);
+}
+
+/**
+ * Format a number with thousands separators
+ * @param {number} num - The number to format
+ * @returns {string} Formatted number
+ */
+function formatNumber(num) {
+ if (num === null || num === undefined) return '0';
+ return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
+}
+
+// Export the functions to make them available to other modules
+window.formatting = {
+ formatStatus,
+ formatMode,
+ formatDate,
+ formatDuration,
+ formatNumber,
+ capitalizeFirstLetter
+};
\ No newline at end of file
diff --git a/src/local_deep_research/web/static/js/services/ui.js b/src/local_deep_research/web/static/js/services/ui.js
new file mode 100644
index 0000000000..0e831e015d
--- /dev/null
+++ b/src/local_deep_research/web/static/js/services/ui.js
@@ -0,0 +1,304 @@
+/**
+ * UI utility functions
+ */
+
+/**
+ * Update a progress bar UI element
+ * @param {string|Element} fillElementId - The ID or element to fill
+ * @param {string|Element} percentageElementId - The ID or element to show percentage
+ * @param {number} percentage - The percentage to set
+ */
+function updateProgressBar(fillElementId, percentageElementId, percentage) {
+ const progressFill = typeof fillElementId === 'string' ? document.getElementById(fillElementId) : fillElementId;
+ const progressPercentage = typeof percentageElementId === 'string' ? document.getElementById(percentageElementId) : percentageElementId;
+
+ if (progressFill && progressPercentage) {
+ // Convert any value to a percentage between 0-100
+ const safePercentage = Math.min(100, Math.max(0, percentage || 0));
+
+ // Update the width of the fill element
+ progressFill.style.width = `${safePercentage}%`;
+
+ // Update the percentage text
+ progressPercentage.textContent = `${Math.round(safePercentage)}%`;
+
+ // Add classes for visual feedback
+ if (safePercentage >= 100) {
+ progressFill.classList.add('complete');
+ } else {
+ progressFill.classList.remove('complete');
+ }
+ }
+}
+
+/**
+ * Show a loading spinner
+ * @param {string|Element} container - The container ID or element to add the spinner to
+ * @param {string} message - Optional message to show with the spinner
+ */
+function showSpinner(container, message = 'Loading...') {
+ const containerEl = typeof container === 'string' ? document.getElementById(container) : container;
+
+ if (containerEl) {
+ containerEl.innerHTML = '';
+
+ const spinnerHTML = `
+ <div class="loading-spinner centered">
+ <div class="spinner"></div>
+ ${message ? `<div class="spinner-message">${message}</div>` : ''}
+ </div>
+ `;
+
+ containerEl.innerHTML = spinnerHTML;
+ }
+}
+
+/**
+ * Hide a loading spinner
+ * @param {string|Element} container - The container ID or element with the spinner
+ */
+function hideSpinner(container) {
+ const containerEl = typeof container === 'string' ? document.getElementById(container) : container;
+
+ if (containerEl) {
+ const spinner = containerEl.querySelector('.loading-spinner');
+ if (spinner) {
+ spinner.remove();
+ }
+ }
+}
+
+/**
+ * Show an error message
+ * @param {string|Element} container - The container ID or element to add the error to
+ * @param {string} message - The error message
+ */
+function showError(container, message) {
+ const containerEl = typeof container === 'string' ? document.getElementById(container) : container;
+
+ if (containerEl) {
+ const errorHTML = `
+ <div class="error-message">
+ <i class="fas fa-exclamation-circle"></i>
+ <span>${message}</span>
+ </div>
+ `;
+
+ containerEl.innerHTML = errorHTML;
+ }
+}
+
+/**
+ * Show a notification message
+ * @param {string} message - The message to display
+ * @param {string} type - Message type: 'success', 'error', 'info', 'warning'
+ * @param {number} duration - How long to show the message in ms
+ */
+function showMessage(message, type = 'success', duration = 3000) {
+ // Check if the toast container exists
+ let toastContainer = document.getElementById('toast-container');
+
+ // Create it if it doesn't exist
+ if (!toastContainer) {
+ toastContainer = document.createElement('div');
+ toastContainer.id = 'toast-container';
+ document.body.appendChild(toastContainer);
+ }
+
+ // Create a new toast
+ const toast = document.createElement('div');
+ toast.className = `toast toast-${type}`;
+
+ // Add icon based on type
+ let icon = '';
+ switch (type) {
+ case 'success':
+ icon = '<i class="fas fa-check-circle"></i>';
+ break;
+ case 'error':
+ icon = '<i class="fas fa-exclamation-circle"></i>';
+ break;
+ case 'info':
+ icon = '<i class="fas fa-info-circle"></i>';
+ break;
+ case 'warning':
+ icon = '<i class="fas fa-exclamation-triangle"></i>';
+ break;
+ }
+
+ // Set the content
+ toast.innerHTML = `
+ ${icon}
+ <div class="toast-message">${message}</div>
+ `;
+
+ // Add to container
+ toastContainer.appendChild(toast);
+
+ // Show with animation
+ setTimeout(() => {
+ toast.classList.add('visible');
+ }, 10);
+
+ // Remove after duration
+ setTimeout(() => {
+ toast.classList.remove('visible');
+
+ // Remove from DOM after animation
+ setTimeout(() => {
+ toast.remove();
+ }, 300);
+ }, duration);
+}
+
+/**
+ * Format and render Markdown content
+ * @param {string|Element} container - The container ID or element to render markdown into
+ * @param {string} markdown - The markdown content
+ */
+function renderMarkdown(container, markdown) {
+ const containerEl = typeof container === 'string' ? document.getElementById(container) : container;
+
+ if (containerEl && window.marked) {
+ // Add a wrapper for proper styling
+ containerEl.innerHTML = `<div class="markdown-content">${window.marked.parse(markdown)}</div>`;
+
+ // Highlight code blocks if highlight.js is available
+ if (window.hljs) {
+ containerEl.querySelectorAll('pre code').forEach((block) => {
+ window.hljs.highlightBlock(block);
+ });
+ }
+ }
+}
+
+/**
+ * Create a dynamic favicon
+ * @param {string} emoji - The emoji to use for the favicon
+ */
+function createDynamicFavicon(emoji = '⚡') {
+ // Create a canvas element
+ const canvas = document.createElement('canvas');
+ canvas.width = 64;
+ canvas.height = 64;
+
+ // Get the 2D drawing context
+ const ctx = canvas.getContext('2d');
+
+ // Clear the canvas
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+
+ // Set font
+ ctx.font = '48px Arial';
+ ctx.textAlign = 'center';
+ ctx.textBaseline = 'middle';
+
+ // Draw the emoji
+ ctx.fillText(emoji, 32, 32);
+
+ // Convert to data URL
+ const dataUrl = canvas.toDataURL('image/png');
+
+ // Create or update the favicon link
+ let link = document.querySelector('link[rel="icon"]');
+ if (!link) {
+ link = document.createElement('link');
+ link.rel = 'icon';
+ document.head.appendChild(link);
+ }
+
+ // Set the new favicon
+ link.href = dataUrl;
+}
+
+// Add CSS for toast messages
+function addToastStyles() {
+ if (document.getElementById('toast-styles')) return;
+
+ const styleEl = document.createElement('style');
+ styleEl.id = 'toast-styles';
+ styleEl.textContent = `
+ #toast-container {
+ position: fixed;
+ top: 20px;
+ right: 20px;
+ z-index: 9999;
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+ }
+
+ .toast {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ background-color: var(--card-bg, #2a2a2a);
+ color: var(--text-color, #fff);
+ padding: 12px 16px;
+ border-radius: 8px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
+ max-width: 350px;
+ transform: translateX(120%);
+ opacity: 0;
+ transition: transform 0.3s ease, opacity 0.3s ease;
+ border-left: 4px solid transparent;
+ }
+
+ .toast.visible {
+ transform: translateX(0);
+ opacity: 1;
+ }
+
+ .toast i {
+ font-size: 1.2rem;
+ }
+
+ .toast-success {
+ border-left-color: var(--success-color, #28a745);
+ }
+
+ .toast-success i {
+ color: var(--success-color, #28a745);
+ }
+
+ .toast-error {
+ border-left-color: var(--danger-color, #dc3545);
+ }
+
+ .toast-error i {
+ color: var(--danger-color, #dc3545);
+ }
+
+ .toast-info {
+ border-left-color: var(--info-color, #17a2b8);
+ }
+
+ .toast-info i {
+ color: var(--info-color, #17a2b8);
+ }
+
+ .toast-warning {
+ border-left-color: var(--warning-color, #ffc107);
+ }
+
+ .toast-warning i {
+ color: var(--warning-color, #ffc107);
+ }
+ `;
+
+ document.head.appendChild(styleEl);
+}
+
+// Add toast styles when the script loads
+addToastStyles();
+
+// Export the UI functions
+window.ui = {
+ updateProgressBar,
+ showSpinner,
+ hideSpinner,
+ showError,
+ showMessage,
+ renderMarkdown,
+ createDynamicFavicon
+};
\ No newline at end of file