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.

cleanup: remove dead Jinja macros from settings templates (#3179)

LearningCircuit4cac47d89b6b
diff --git a/src/local_deep_research/web/static/js/components/settings.js b/src/local_deep_research/web/static/js/components/settings.js
index 83772c0a36..a18246ad27 100644
--- a/src/local_deep_research/web/static/js/components/settings.js
+++ b/src/local_deep_research/web/static/js/components/settings.js
@@ -28,6 +28,7 @@
// Store save timers for each setting key
let saveTimers = {};
let pendingSaveData = {};
+ let lastSettingsUpdateTimestamp = 0;
// Cache keys - same as research.js for shared caching
const CACHE_KEYS = {
@@ -2489,6 +2490,13 @@
function handleSettingsSubmit(e) {
e.preventDefault();
+ // Cancel any pending auto-save timers to prevent stale overwrites
+ Object.keys(saveTimers).forEach(key => {
+ clearTimeout(saveTimers[key]);
+ });
+ saveTimers = {};
+ pendingSaveData = {};
+
// Clear any previous errors
document.querySelectorAll('.ldr-settings-error').forEach(element => {
element.classList.remove('ldr-settings-error');
@@ -2726,6 +2734,9 @@
originalValues[key] = originalSettings.hasOwnProperty(key) ? originalSettings[key] : null;
});
+ // Capture timestamp before fetch so stale responses can be discarded
+ const requestTimestamp = Date.now();
+ lastSettingsUpdateTimestamp = requestTimestamp;
fetch(URLS.SETTINGS_API.SAVE_ALL_SETTINGS, {
method: 'POST',
@@ -2754,7 +2765,10 @@
if (!sourceElement || savingKeys.length > 1) {
// Update global state
if (data.settings) {
- allSettings = processSettings(data.settings);
+ // Only apply if no newer request has been dispatched since this one
+ if (requestTimestamp >= lastSettingsUpdateTimestamp) {
+ allSettings = processSettings(data.settings);
+ }
}
} else {
// Update just the changed setting in our allSettings array
@@ -4051,15 +4065,16 @@
// Load settings from API if on settings dashboard
if (settingsContent) {
- // First fetch the model and search engine data to have it ready
- // when needed, but don't wait for it to complete
- Promise.all([fetchModelProviders(), fetchSearchEngines()]).then(() => {
- // Then load settings
- loadSettings();
- }).catch(err => {
- SafeLogger.error("Error fetching providers/engines initially", err);
- // Still try to load settings even if fetching options fails
- loadSettings();
+ // Load settings immediately (doesn't depend on providers/engines)
+ loadSettings();
+
+ // Pre-fetch model and search engine data in background
+ // These will be cached for later dropdown initialization
+ fetchModelProviders().catch(err => {
+ SafeLogger.error("Error fetching model providers", err);
+ });
+ fetchSearchEngines().catch(err => {
+ SafeLogger.error("Error fetching search engines", err);
});
}
diff --git a/src/local_deep_research/web/templates/components/settings_form.html b/src/local_deep_research/web/templates/components/settings_form.html
index 720bce2cbf..7e0469bd78 100644
--- a/src/local_deep_research/web/templates/components/settings_form.html
+++ b/src/local_deep_research/web/templates/components/settings_form.html
@@ -312,38 +312,3 @@
{% endif %}
</div>
{% endmacro %}
-
-{% macro render_settings_section(section_title, section_id, settings, form_id='settings-form') %}
- <div class="ldr-settings-section">
- <div class="ldr-settings-section-header" data-target="{{ section_id }}">
- <div class="ldr-settings-section-title">
- {{ section_title }}
- </div>
- <div class="ldr-settings-toggle-icon">
- <i aria-hidden="true" class="fas fa-chevron-down"></i>
- </div>
- </div>
- <div id="{{ section_id }}" class="ldr-settings-section-body">
- {% for setting in settings %}
- {{ render_setting(setting, form_id) }}
- {% endfor %}
- </div>
- </div>
-{% endmacro %}
-
-{% macro render_settings_form(settings_by_category, form_id, form_action) %}
- <form id="{{ form_id }}" action="{{ form_action }}" method="POST" class="ldr-settings-form">
- {% for category, settings in settings_by_category.items() %}
- {{ render_settings_section(category, category|lower|replace(' ', '-'), settings, form_id) }}
- {% endfor %}
-
- <div class="ldr-form-actions">
- <button type="reset" class="btn ldr-btn-outline">
- <i aria-hidden="true" class="fas fa-undo"></i> Reset Changes
- </button>
- <button type="submit" class="btn btn-primary">
- <i aria-hidden="true" class="fas fa-save"></i> Save Changes
- </button>
- </div>
- </form>
-{% endmacro %}
diff --git a/src/local_deep_research/web/templates/settings_dashboard.html b/src/local_deep_research/web/templates/settings_dashboard.html
index 82ac395d8e..3ef742ffc0 100644
--- a/src/local_deep_research/web/templates/settings_dashboard.html
+++ b/src/local_deep_research/web/templates/settings_dashboard.html
@@ -1,6 +1,5 @@
{% extends "base.html" %}
{% from "components/settings_form.html" import render_setting %}
-{% from "components/custom_dropdown.html" import render_dropdown %}
{% set active_page = 'settings' %}