~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(settings): let search reach non-selected providers' settings (#6899)
LearningCircuit8f2828622823
diff --git a/changelog.d/6587.bugfix.md b/changelog.d/6587.bugfix.mdnew file mode 100644index 0000000000..602f4dffad--- /dev/null+++ b/changelog.d/6587.bugfix.md@@ -0,0 +1 @@+Searching the settings page no longer hides other providers' settings: while a provider like Ollama is selected, typing e.g. "openai" now surfaces the OpenAI credentials section, so switching and saving the provider first is no longer required to enter another provider's API key.diff --git a/src/local_deep_research/web/static/js/components/settings.js b/src/local_deep_research/web/static/js/components/settings.jsindex 417b85f860..b549b3c7da 100644--- a/src/local_deep_research/web/static/js/components/settings.js+++ b/src/local_deep_research/web/static/js/components/settings.js@@ -1796,7 +1796,7 @@* @param {string} tab - The current tab* @returns {Object} - The organized settings*/- function organizeSettings(settings, tab) {+ function organizeSettings(settings, tab, { ignoreProviderScope = false } = {}) {const providerSetting = (settings.find(setting => setting.key === 'llm.provider')|| allSettings.find(setting => setting.key === 'llm.provider')@@ -1928,7 +1928,13 @@// scoping below still applies. An early return here used to// bypass the tab filter entirely and render the complete list// in every tab for the empty-provider state (#6586).+ // Search bypasses the scope (#6587) for any non-empty query,+ // not only one that names another provider: matching rows+ // belong to the query, not to whichever provider is selected.+ // Without this, another provider's credentials are+ // unreachable until the user switches AND saves the provider.if (+ !ignoreProviderScope &&selectedProvider &&providerPrefix === 'llm' &&providerSettingPrefixes.has(providerSubKey) &&@@ -3904,8 +3910,12 @@);});- // Organize settings to avoid duplicate groups- const groupedSettings = organizeSettings(filteredSettings, 'all');+ // Organize settings to avoid duplicate groups. Search ignores the+ // provider scope (#6587): matching rows belong to the query, not+ // to whichever provider happens to be selected.+ const groupedSettings = organizeSettings(filteredSettings, 'all', {+ ignoreProviderScope: true,+ });// Build HTMLlet html = '';diff --git a/tests/js/components/settings-cross-provider-search-runtime.test.js b/tests/js/components/settings-cross-provider-search-runtime.test.jsnew file mode 100644index 0000000000..f358dc4203--- /dev/null+++ b/tests/js/components/settings-cross-provider-search-runtime.test.js@@ -0,0 +1,191 @@+/**+ * Cross-provider settings search (#6587): while `llm.provider` selects one+ * provider, the settings search must still surface OTHER providers'+ * settings — the provider scoping that hides them from the browsed list+ * must not swallow explicit search queries. Before the fix, the search+ * path routed through `organizeSettings`, whose provider filter+ * unconditionally dropped other providers' rows, so credentials for a+ * non-selected provider were unreachable without switching AND saving+ * the provider first.+ */++import '@js/config/urls.js';+import '@js/services/api.js';+import '@js/utils/alert-helpers.js';+import '@js/utils/provider-options.js';+import '@js/utils/value-helpers.js';++const flushPromises = async (turns = 12) => {+ for (let turn = 0; turn < turns; turn += 1) await Promise.resolve();+};++function jsonResponse(payload, status = 200) {+ return new Response(JSON.stringify(payload), {+ status,+ headers: { 'Content-Type': 'application/json' },+ });+}++function setting(overrides) {+ return {+ category: 'general',+ description: '',+ editable: true,+ max_value: null,+ min_value: null,+ options: null,+ step: null,+ visible: true,+ ...overrides,+ };+}++afterEach(() => {+ vi.restoreAllMocks();+ vi.unstubAllGlobals();+ vi.useRealTimers();+ delete window.ui;+ delete window.modelProvidersRequestInProgress;+ delete window.searchEnginesRequestInProgress;+ delete window.modelDropdownsInitialized;+ delete window.searchEngineDropdownInitialized;+ delete window.setupCustomDropdown;+ delete window.updateDropdownOptions;+ document.body.replaceChildren();+});++it('searches into non-selected providers while provider scoping stays on for browsing (#6587)', async () => {+ vi.useFakeTimers();+ document.head.insertAdjacentHTML(+ 'beforeend',+ '<meta name="csrf-token" content="csrf-cross-provider-search">',+ );+ document.body.innerHTML = `+ <form id="settings-form">+ <input id="settings-search">+ <button type="button" class="ldr-settings-tab active" data-tab="all">All</button>+ <div id="settings-alert"></div>+ <div id="settings-content"></div>+ <button id="reset-to-defaults-button" type="button">Reset defaults</button>+ <button id="toggle-raw-config" type="button"><span id="toggle-text"></span></button>+ <section id="raw-config" style="display: none">+ <textarea id="raw_config_editor"></textarea>+ </section>+ <div id="llm.model-empty-warning" style="display: none"></div>+ </form>+ `;++ const settings = {+ 'llm.provider': setting({+ category: 'llm_general',+ name: 'Provider',+ type: 'LLM',+ ui_element: 'select',+ value: 'ollama',+ options: [+ { value: 'openai', label: 'OpenAI API' },+ { value: 'anthropic', label: 'Anthropic API' },+ { value: 'ollama', label: 'Ollama (Local)' },+ ],+ }),+ 'llm.ollama.api_key': setting({+ category: 'llm_ollama',+ name: 'Ollama API Key',+ type: 'LLM',+ ui_element: 'password',+ value: '',+ }),+ 'llm.openai.api_key': setting({+ category: 'llm_openai',+ name: 'OpenAI API Key',+ type: 'LLM',+ ui_element: 'password',+ value: '',+ }),+ 'llm.anthropic.api_key': setting({+ category: 'llm_anthropic',+ name: 'Anthropic API Key',+ type: 'LLM',+ ui_element: 'password',+ value: '',+ }),+ 'llm.model': setting({+ category: 'llm_general',+ name: 'Model',+ type: 'LLM',+ ui_element: 'select',+ value: 'llama3',+ }),+ };++ const fetchMock = vi.fn((url) => {+ if (url === URLS.SETTINGS_API.BASE) {+ return Promise.resolve(jsonResponse({ status: 'success', settings }));+ }+ if (url === URLS.SETTINGS_API.AVAILABLE_MODELS) {+ return Promise.resolve(jsonResponse({+ providers: {+ ollama_models: [{ value: 'llama3', label: 'Llama 3' }],+ openai_models: [{ value: 'gpt-4o', label: 'GPT-4o' }],+ },+ provider_options: [+ { value: 'ollama', label: 'Ollama' },+ { value: 'openai', label: 'OpenAI' },+ ],+ }));+ }+ if (url === URLS.SETTINGS_API.AVAILABLE_SEARCH_ENGINES) {+ return Promise.resolve(jsonResponse({+ engine_options: [{ value: 'searxng', label: 'SearXNG' }],+ }));+ }+ if (url === '/settings/api/data-location') {+ return Promise.resolve(jsonResponse({+ data_directory: '/tmp/ldr',+ security_notice: { encrypted: false },+ }));+ }+ if (url === URLS.SETTINGS_API.BACKUP_STATUS) {+ return Promise.resolve(jsonResponse({ enabled: false, count: 0, backups: [] }));+ }+ throw new Error(`Unexpected request: ${url}`);+ });+ vi.stubGlobal('fetch', fetchMock);+ window.ui = { showMessage: vi.fn() };+ window.matchMedia = vi.fn(() => ({ matches: false }));+ window.setupCustomDropdown = vi.fn(() => ({ setValue: vi.fn() }));+ window.updateDropdownOptions = vi.fn();++ await import('@js/components/settings.js');+ if (document.readyState === 'loading') {+ document.dispatchEvent(new Event('DOMContentLoaded'));+ }+ await flushPromises();+ await vi.advanceTimersByTimeAsync(301);++ // Browsed "all" list stays provider-scoped: ollama visible, the+ // other two providers hidden (existing behavior, unchanged).+ expect(document.getElementById('setting-llm-ollama-api_key')).not.toBeNull();+ expect(document.getElementById('setting-llm-openai-api_key')).toBeNull();+ expect(document.getElementById('setting-llm-anthropic-api_key')).toBeNull();++ // Searching for another provider's settings must surface them+ // WITHOUT switching (and saving) the provider first (#6587).+ const settingsSearch = document.getElementById('settings-search');+ settingsSearch.value = 'openai';+ settingsSearch.dispatchEvent(new Event('input', { bubbles: true }));+ await vi.advanceTimersByTimeAsync(251);++ expect(document.getElementById('setting-llm-openai-api_key')).not.toBeNull();+ // Search still text-matches: anthropic does not match "openai".+ expect(document.getElementById('setting-llm-anthropic-api_key')).toBeNull();+ // The selected provider's own key does not match "openai" either.+ expect(document.getElementById('setting-llm-ollama-api_key')).toBeNull();++ // Clearing the search restores provider scoping for browsing.+ settingsSearch.value = '';+ settingsSearch.dispatchEvent(new Event('input', { bubbles: true }));+ await vi.advanceTimersByTimeAsync(251);+ expect(document.getElementById('setting-llm-ollama-api_key')).not.toBeNull();+ expect(document.getElementById('setting-llm-openai-api_key')).toBeNull();+});