~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix(ui): improve settings notifications (#1349)
LearningCircuitdbc0185a2bff
diff --git a/src/local_deep_research/__version__.py b/src/local_deep_research/__version__.pyindex 19937bc3d1..51cd752de5 100644--- a/src/local_deep_research/__version__.py+++ b/src/local_deep_research/__version__.py@@ -1 +1 @@-__version__ = "1.3.16"+__version__ = "1.3.17"diff --git a/src/local_deep_research/web/static/js/components/settings.js b/src/local_deep_research/web/static/js/components/settings.jsindex 16e4272e71..a2c97f3ac6 100644--- a/src/local_deep_research/web/static/js/components/settings.js+++ b/src/local_deep_research/web/static/js/components/settings.js@@ -319,7 +319,7 @@return;}- // Get all inputs in settings form+ // Get all inputs in settings formconst inputs = settingsForm.querySelectorAll('input, textarea, select');let checkboxCount = 0;@@ -328,21 +328,20 @@// Skip if this is a button or submit inputif (input.type === 'button' || input.type === 'submit') return;+ // Skip if this input already has auto-save handlers attached+ // (prevents duplicate listeners when initAutoSaveHandlers is called multiple times)+ if (input.hasAttribute('data-autosave-initialized')) return;+ input.setAttribute('data-autosave-initialized', 'true');+// Set data-key attribute from name if not already setif (!input.getAttribute('data-key') && input.getAttribute('name')) {input.setAttribute('data-key', input.getAttribute('name'));}- // Remove existing listeners to avoid duplicates- input.removeEventListener('input', handleInputChange);- input.removeEventListener('keydown', handleInputChange);- input.removeEventListener('blur', handleInputChange);- input.removeEventListener('change', handleInputChange);-// For checkboxes, we use change eventif (input.type === 'checkbox') {checkboxCount++;- input.addEventListener('change', function(e) {+ input.addEventListener('change', function(e) {// For checkboxes, pass custom event type parameter to avoid issueshandleInputChange(e, 'change');});@@ -400,11 +399,9 @@const jsonPropertyControls = settingsForm.querySelectorAll('.ldr-json-property-control');jsonPropertyControls.forEach(control => {- // Remove existing listeners- control.removeEventListener('change', updateJsonFromControls);- control.removeEventListener('input', updateJsonFromControls);- control.removeEventListener('keydown', updateJsonFromControls);- control.removeEventListener('blur', updateJsonFromControls);+ // Skip if this control already has handlers attached+ if (control.hasAttribute('data-json-control-initialized')) return;+ control.setAttribute('data-json-control-initialized', 'true');if (control.type === 'checkbox') {control.addEventListener('change', function(e) {@@ -537,7 +534,6 @@const originalValue = originalSettings.hasOwnProperty(key) ? originalSettings[key] : undefined;const hasChanged = !areValuesEqual(value, originalValue);-if (hasChanged) {// Mark parent item as modifiedconst item = input.closest('.settings-item');@@ -2540,11 +2536,11 @@// Get the keys being saved for referenceconst savingKeys = Object.keys(formData);- // Store original values to show what changed+ // Store original values to show what changed (use originalSettings cache, not allSettings)const originalValues = {};savingKeys.forEach(key => {- const settingObj = allSettings.find(s => s.key === key);- originalValues[key] = settingObj ? settingObj.value : null;+ // originalSettings stores the values from when the page was loaded+ originalValues[key] = originalSettings.hasOwnProperty(key) ? originalSettings[key] : null;});@@ -2602,7 +2598,6 @@const settingIndex = allSettings.findIndex(s => s.key === key);if (settingIndex !== -1) {originalSettings[key] = allSettings[settingIndex].value;- console.log(`Updated originalSettings cache for ${key}:`, originalSettings[key]);}});@@ -2611,35 +2606,43 @@prepareRawJsonEditor();}- // Format a more informative message+ // Format a more informative message showing what changedlet successMessage = '';- if (savingKeys.length === 1) {- const key = savingKeys[0];- const settingObj = allSettings.find(s => s.key === key);- const oldValue = originalValues[key];- const newValue = settingObj ? settingObj.value : formData[key];+ try {+ if (savingKeys.length >= 1) {+ const key = savingKeys[0];+ const oldValue = originalValues[key];+ // Get new value from formData (what we sent) since allSettings might not be updated yet+ const newValue = formData[key];- // Format the display name for better readability- const displayName = key.split('.').pop().replace(/_/g, ' ');- const capitalizedName = displayName.charAt(0).toUpperCase() + displayName.slice(1);+ // Format the display name for better readability+ const displayName = key.split('.').pop().replace(/_/g, ' ');+ const capitalizedName = displayName.charAt(0).toUpperCase() + displayName.slice(1);- // Format the values for display- const oldDisplay = formatValueForDisplay(oldValue);- const newDisplay = formatValueForDisplay(newValue);+ // Format the values for display+ const oldDisplay = formatValueForDisplay(oldValue);+ const newDisplay = formatValueForDisplay(newValue);- successMessage = `${capitalizedName}: ${oldDisplay} → ${newDisplay}`;- } else {- // If multiple settings were updated, use the original message- successMessage = data.message || 'Settings saved successfully';+ if (savingKeys.length === 1) {+ successMessage = `${capitalizedName}: ${oldDisplay} → ${newDisplay}`;+ } else {+ successMessage = `${savingKeys.length} settings saved`;+ }+ } else {+ successMessage = 'Settings saved';+ }+ } catch (formatError) {+ console.error('Error formatting settings change message:', formatError);+ successMessage = 'Settings saved';}- // Show toast notification if ui.showMessage is available+ // Show banner notification if ui.showMessage is availableif (window.ui && window.ui.showMessage) {- window.ui.showMessage(successMessage, 'success', 3000);- // We're showing toast, so we pass true to skip showing the regular alert+ window.ui.showMessage(successMessage, 'success', 6000);+ // We're showing banner, so we pass true to skip showing the regular alertshowAlert(successMessage, 'success', true);} else {- // Fallback to regular alert, force showing it+ // Fallback to regular alertshowAlert(successMessage, 'success', false);}} else {diff --git a/src/local_deep_research/web/static/js/services/ui.js b/src/local_deep_research/web/static/js/services/ui.jsindex 581e0eaf32..6f5bbb0658 100644--- a/src/local_deep_research/web/static/js/services/ui.js+++ b/src/local_deep_research/web/static/js/services/ui.js@@ -2,6 +2,13 @@* UI utility functions*/+// Configuration constants+const UI_CONFIG = {+ NOTIFICATION_DURATION_MS: 6000,+ NOTIFICATION_Z_INDEX: 9999999,+ ALERT_DURATION_MS: 5000+};+// Note: sanitizer functions are available via Vite bundle or we use safe fallbacks/**@@ -107,66 +114,76 @@ function showError(container, message) {}}+/**+ * Get CSS variable value from document root+ * @param {string} varName - CSS variable name (e.g., '--success-color')+ * @param {string} fallback - Fallback value if variable not found+ * @returns {string} The CSS variable value+ */+function getCSSVariable(varName, fallback) {+ const value = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();+ return value || fallback;+}+/*** 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 = '';+function showMessage(message, type = 'success', duration = UI_CONFIG.NOTIFICATION_DURATION_MS) {+ // Get theme colors from CSS variables with fallbacks+ let accentColor, iconClass;switch (type) {case 'success':- icon = '<i class="fas fa-check-circle"></i>';+ accentColor = getCSSVariable('--success-color', '#0acf97');+ iconClass = 'fa-check-circle';break;case 'error':- icon = '<i class="fas fa-exclamation-circle"></i>';- break;- case 'info':- icon = '<i class="fas fa-info-circle"></i>';+ accentColor = getCSSVariable('--error-color', '#fa5c7c');+ iconClass = 'fa-exclamation-circle';break;case 'warning':- icon = '<i class="fas fa-exclamation-triangle"></i>';+ accentColor = getCSSVariable('--warning-color', '#f9bc0b');+ iconClass = 'fa-exclamation-triangle';+ break;+ case 'info':+ default:+ accentColor = getCSSVariable('--accent-primary', '#6e4ff6');+ iconClass = 'fa-info-circle';break;}- // Set the content (sanitize message to prevent XSS)- safeSetHTML(toast, `- ${icon}- <div class="toast-message">${message}</div>+ // Create or get notification banner+ let banner = document.getElementById('notification-banner');+ if (!banner) {+ banner = document.createElement('div');+ banner.id = 'notification-banner';+ banner.className = 'ldr-notification-banner';+ document.body.appendChild(banner);+ }++ // Apply dynamic accent color for border (static styles handled by CSS class)+ banner.style.borderBottom = `3px solid ${accentColor}`;++ // Set content with colored icon (sanitize message to prevent XSS)+ safeSetHTML(banner, `+ <i class="fas ${iconClass}" style="color: ${accentColor}; font-size: 1.1rem;"></i>+ <span>${message}</span>`, 'ui');- // Add to container- toastContainer.appendChild(toast);+ // Add ARIA attributes for accessibility+ banner.setAttribute('role', 'alert');+ banner.setAttribute('aria-live', 'polite');- // Show with animation- setTimeout(() => {- toast.classList.add('visible');- }, 10);+ // Slide in+ requestAnimationFrame(() => {+ banner.style.transform = 'translateY(0)';+ });- // Remove after duration+ // Slide out after durationsetTimeout(() => {- toast.classList.remove('visible');-- // Remove from DOM after animation- setTimeout(() => {- toast.remove();- }, 300);+ banner.style.transform = 'translateY(-100%)';}, duration);}@@ -401,94 +418,17 @@ function showAlert(message, type = 'info', skipIfToastShown = true) {alertContainer.appendChild(alert);alertContainer.style.display = 'block';- // Auto-hide after 5 seconds+ // Auto-hide after configured durationsetTimeout(() => {alert.remove();if (alertContainer.children.length === 0) {alertContainer.style.display = 'none';}- }, 5000);+ }, UI_CONFIG.ALERT_DURATION_MS);}-// 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 CSS for alert styles+// Add CSS for alert and notification stylesfunction addAlertStyles() {if (document.getElementById('alert-styles')) return;@@ -546,13 +486,35 @@ function addAlertStyles() {.alert-close:hover {opacity: 1;}++ /* Notification banner styles */+ .ldr-notification-banner {+ position: fixed;+ top: 0;+ left: 0;+ right: 0;+ padding: 14px 20px;+ background: var(--bg-secondary, #1e1e2d);+ color: var(--text-primary, #f5f5f5);+ text-align: center;+ z-index: ${UI_CONFIG.NOTIFICATION_Z_INDEX};+ font-weight: 500;+ font-size: 14px;+ display: flex;+ align-items: center;+ justify-content: center;+ gap: 12px;+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 15px rgba(110, 79, 246, 0.15);+ transform: translateY(-100%);+ transition: transform 0.3s ease;+ word-wrap: break-word;+ max-width: 100%;+ }`;document.head.appendChild(styleEl);}-// Add toast styles when the script loads-addToastStyles();// Add alert styles when the script loadsaddAlertStyles();