~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
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
import DOMPurify from 'dompurify';
const template = readFileSync(resolve(__dirname, '../../src/local_deep_research/web/templates/components/embedding_performance_hint.html'), 'utf8');
const component = template
.replace(/\{%[\s\S]*?%\}/g, '')
.replace(/\{\{[\s\S]*?\}\}/g, '');
// Same component rendered with an embedding_hint_id, as collection_details.html does.
const componentWithId = template
.replace(/\{% if embedding_hint_id %\}([\s\S]*?)\{% endif %\}/g, '$1')
.replace(/\{\{\s*embedding_hint_id\s*\}\}/g, 'index-hint')
.replace(/\{%[\s\S]*?%\}/g, '');
const baseTitle = 'Create searchable embeddings';
const tipTitle = 'Create searchable embeddings. High CPU usage?';
const describedControls = `
<button id="index-btn" data-embedding-hint-describedby="index-hint" title="${baseTitle}" data-embedding-hint-title="${tipTitle}">Index</button>
<button id="reindex-btn" aria-describedby="other-help" data-embedding-hint-describedby="index-hint" title="Re-index">Re-Index</button>
<span id="other-help">Other help</span>`;
const settingUrl = '/settings/api/app.warnings.dismiss_embedding_performance';
const response = (value, ok = true, extra = {}) => ({ ok, json: async () => ({ value, editable: true, ...extra }) });
const errorResponse = body => ({ ok: false, json: async () => body });
const hints = () => Array.from(document.querySelectorAll('[data-embedding-performance-hint]'));
const buttons = () => Array.from(document.querySelectorAll('[data-dismiss-embedding-hint]'));
const allVisible = () => hints().every(hint => !hint.hidden);
const allHidden = () => hints().every(hint => hint.hidden);
beforeEach(() => {
vi.resetModules();
document.body.innerHTML = DOMPurify.sanitize(component + component);
window.api = { getCsrfToken: () => 'test-csrf' };
globalThis.safeFetchWithAuth = vi.fn().mockResolvedValue(response(false));
});
afterEach(() => {
document.body.innerHTML = '';
delete window.api;
});
async function start() {
await import('../../src/local_deep_research/web/static/js/embedding_performance_hint.js');
await vi.waitFor(() => expect(safeFetchWithAuth).toHaveBeenCalledWith(settingUrl));
}
it('renders hidden and stays hidden until the preference has loaded', async () => {
expect(allHidden()).toBe(true);
let finishLoad;
safeFetchWithAuth.mockImplementation(() => new Promise(complete => { finishLoad = complete; }));
await start();
expect(allHidden()).toBe(true);
finishLoad(response(false));
await vi.waitFor(() => expect(allVisible()).toBe(true));
});
it('keeps every copy hidden when the account has dismissed the tip', async () => {
safeFetchWithAuth.mockResolvedValue(response(true));
await start();
await new Promise(r => setTimeout(r, 0));
expect(allHidden()).toBe(true);
});
it.each([false, 'false'])('reveals tips for preference %s', async value => {
safeFetchWithAuth.mockResolvedValue(response(value));
await start();
await vi.waitFor(() => expect(allVisible()).toBe(true));
expect(buttons()).toHaveLength(2);
});
it('removes the dismiss control when the setting is not editable', async () => {
safeFetchWithAuth.mockResolvedValue(response(false, true, { editable: false }));
await start();
await vi.waitFor(() => expect(allVisible()).toBe(true));
expect(buttons()).toHaveLength(0);
});
it('saves with CSRF and hides all copies only after the save succeeds', async () => {
let finishSave;
safeFetchWithAuth.mockImplementation((_url, options) => {
if (options) return new Promise(complete => { finishSave = complete; });
return Promise.resolve(response(false));
});
await start();
await vi.waitFor(() => expect(allVisible()).toBe(true));
buttons()[0].click();
expect(buttons().every(button => button.disabled)).toBe(true);
expect(allVisible()).toBe(true);
expect(safeFetchWithAuth).toHaveBeenLastCalledWith(settingUrl, {
method: 'PUT',
headers: { 'Content-Type': 'application/json', 'X-CSRFToken': 'test-csrf' },
body: JSON.stringify({ value: true })
});
finishSave(response(true));
await vi.waitFor(() => expect(allHidden()).toBe(true));
});
it('reports a rejected save and allows retry without hiding the tips', async () => {
await start();
await vi.waitFor(() => expect(allVisible()).toBe(true));
safeFetchWithAuth.mockResolvedValueOnce(errorResponse(null));
buttons()[0].click();
await vi.waitFor(() => expect(buttons().every(button => !button.disabled)).toBe(true));
expect(allVisible()).toBe(true);
expect(document.querySelector('[data-embedding-hint-error]').textContent).toContain('Please try again');
safeFetchWithAuth.mockResolvedValueOnce(response(true));
buttons()[0].click();
await vi.waitFor(() => expect(allHidden()).toBe(true));
});
it('surfaces the server error message when a save is refused', async () => {
await start();
await vi.waitFor(() => expect(allVisible()).toBe(true));
safeFetchWithAuth.mockResolvedValueOnce(errorResponse({ error: 'Settings are locked' }));
buttons()[0].click();
await vi.waitFor(() => expect(buttons().every(button => !button.disabled)).toBe(true));
expect(allVisible()).toBe(true);
expect(document.querySelector('[data-embedding-hint-error]').textContent)
.toBe('Could not save dismissal: Settings are locked');
});
it('fails open when the preference request is not ok', async () => {
safeFetchWithAuth.mockResolvedValue(errorResponse({ error: 'Failed to retrieve settings' }));
await start();
await vi.waitFor(() => expect(allVisible()).toBe(true));
expect(buttons()).toHaveLength(2);
});
it('fails open when preference loading rejects', async () => {
safeFetchWithAuth.mockRejectedValue(new Error('Offline'));
await start();
await vi.waitFor(() => expect(allVisible()).toBe(true));
});
describe('controls described by the tip', () => {
beforeEach(() => {
document.body.innerHTML = DOMPurify.sanitize(describedControls + componentWithId);
});
const indexBtn = () => document.getElementById('index-btn');
const reindexBtn = () => document.getElementById('reindex-btn');
it('reference the tip only while it is shown and drop it on dismissal', async () => {
expect(document.getElementById('index-hint')).not.toBeNull();
await start();
await vi.waitFor(() => expect(allVisible()).toBe(true));
expect(indexBtn().getAttribute('aria-describedby')).toBe('index-hint');
expect(indexBtn().getAttribute('title')).toBe(tipTitle);
expect(reindexBtn().getAttribute('aria-describedby')).toBe('other-help index-hint');
safeFetchWithAuth.mockResolvedValueOnce(response(true));
buttons()[0].click();
await vi.waitFor(() => expect(allHidden()).toBe(true));
expect(indexBtn().hasAttribute('aria-describedby')).toBe(false);
expect(indexBtn().getAttribute('title')).toBe(baseTitle);
expect(reindexBtn().getAttribute('aria-describedby')).toBe('other-help');
expect(reindexBtn().getAttribute('title')).toBe('Re-index');
});
it('never reference an already-dismissed tip', async () => {
safeFetchWithAuth.mockResolvedValue(response(true));
await start();
await new Promise(r => setTimeout(r, 0));
expect(allHidden()).toBe(true);
expect(indexBtn().hasAttribute('aria-describedby')).toBe(false);
expect(indexBtn().getAttribute('title')).toBe(baseTitle);
expect(reindexBtn().getAttribute('aria-describedby')).toBe('other-help');
});
});