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(research): correct research-page init state machine + remove dead strategy fetch (#4875)

LearningCircuitb1547de9168d
diff --git a/src/local_deep_research/web/static/js/components/research.js b/src/local_deep_research/web/static/js/components/research.js
index bed6aace8a..b8e15c4294 100644
--- a/src/local_deep_research/web/static/js/components/research.js
+++ b/src/local_deep_research/web/static/js/components/research.js
@@ -1381,11 +1381,12 @@
// Load settings from the database
function loadSettings() {
SafeLogger.log('Loading settings from database...');
+ // A single async settings fetch gates initialization completion.
+ // The strategy dropdown is rendered and pre-selected server-side
+ // (research.html / get_available_strategies), so it needs no separate
+ // client fetch here.
let numApiCallsPending = 1;
- // Increase the API calls counter to include strategy loading
- numApiCallsPending = 3;
-
// Fetch the current settings from the settings API
fetch(URLS.SETTINGS_API.BASE, {
method: 'GET',
@@ -1696,74 +1697,26 @@
}
- // If all the calls to the settings API are finished, we're no
- // longer initializing.
- numApiCallsPending--;
- isInitializing = (numApiCallsPending === 0);
- SafeLogger.log('Settings loaded. isInitializing now:', isInitializing, 'pending calls:', numApiCallsPending);
- if (!isInitializing) onInitializationComplete();
+ // Population done; the shared settle step runs in .finally below.
})
.catch(error => {
SafeLogger.error('Error loading settings:', error);
// Fallback to localStorage if database fetch fails
fallbackToLocalStorageSettings();
-
- // Even if there's an error, we're done initializing
+ })
+ .finally(() => {
+ // Settle exactly once, whether the load succeeded or threw. Keeping
+ // this here (instead of duplicated in .then and .catch) means a
+ // throw inside onInitializationComplete() can't re-enter the chain
+ // and decrement the counter a second time, which would leave
+ // isInitializing stuck truthy and silently suppress settings
+ // auto-save.
numApiCallsPending--;
- isInitializing = (numApiCallsPending === 0);
- SafeLogger.log('Settings load error. isInitializing now:', isInitializing, 'pending calls:', numApiCallsPending);
+ isInitializing = (numApiCallsPending !== 0);
+ SafeLogger.log('Settings load settled. isInitializing now:', isInitializing, 'pending calls:', numApiCallsPending);
if (!isInitializing) onInitializationComplete();
});
-
- // Load search strategy setting
- fetch(URLS.SETTINGS_API.SEARCH_STRATEGY, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json'
- }
- })
- .then(response => {
- if (!response.ok) {
- throw new Error(`API error: ${response.status}`);
- }
- return response.json();
- })
- .then(data => {
- SafeLogger.log('Loaded strategy from database:', data);
-
- const strategySelect = document.getElementById('strategy');
- if (data && data.setting && data.setting.value && strategySelect) {
- const strategyValue = data.setting.value;
- SafeLogger.log('Setting strategy to:', strategyValue);
-
- // Update the select element
- strategySelect.value = strategyValue;
-
- // Save to localStorage
- // Strategy saved to DB
- }
-
- numApiCallsPending--;
- isInitializing = (numApiCallsPending === 0);
- SafeLogger.log('Strategy loaded. isInitializing now:', isInitializing, 'pending calls:', numApiCallsPending);
- if (!isInitializing) onInitializationComplete();
- })
- .catch(error => {
- SafeLogger.error('Error loading strategy:', error.message || error);
-
- // Fallback to localStorage
- const lastStrategy = null; // Strategy loaded from DB
- const strategySelect = document.getElementById('strategy');
- if (lastStrategy && strategySelect) {
- strategySelect.value = lastStrategy;
- }
-
- numApiCallsPending--;
- isInitializing = (numApiCallsPending === 0);
- SafeLogger.log('Strategy load error. isInitializing now:', isInitializing, 'pending calls:', numApiCallsPending);
- if (!isInitializing) onInitializationComplete();
- });
}
// Add a fallback function to use localStorage settings
diff --git a/src/local_deep_research/web/static/js/config/urls.js b/src/local_deep_research/web/static/js/config/urls.js
index 845f6d7280..5707a4445b 100644
--- a/src/local_deep_research/web/static/js/config/urls.js
+++ b/src/local_deep_research/web/static/js/config/urls.js
@@ -83,7 +83,6 @@ if (typeof URLS !== 'undefined') {
LLM_PROVIDER: '/settings/api/llm.provider',
LLM_CONFIG: '/settings/api/llm',
SEARCH_TOOL: '/settings/api/search.tool',
- SEARCH_STRATEGY: '/settings/api/search.search_strategy',
SEARCH_FAVORITES: '/settings/api/search-favorites',
SEARCH_FAVORITES_TOGGLE: '/settings/api/search-favorites/toggle',
SAVE_ALL_SETTINGS: '/settings/save_all_settings',