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(ui): use Light for the System theme in light mode (#6736)

LearningCircuitd3e1d99677a6
diff --git a/changelog.d/+system-light-default.misc.md b/changelog.d/+system-light-default.misc.md
new file mode 100644
index 0000000000..2e40336705
--- /dev/null
+++ b/changelog.d/+system-light-default.misc.md
@@ -0,0 +1 @@
+The System theme now uses Light when your operating system prefers light mode. Dark mode still uses Hashed, and explicitly selected themes, including Sepia, are unchanged.
diff --git a/src/local_deep_research/web/static/js/services/theme.js b/src/local_deep_research/web/static/js/services/theme.js
index c79ac66218..cbf6780b87 100644
--- a/src/local_deep_research/web/static/js/services/theme.js
+++ b/src/local_deep_research/web/static/js/services/theme.js
@@ -73,8 +73,8 @@
*/
function getEffectiveTheme(theme) {
if (theme === 'system') {
- // Sepia is the default light theme - easier on eyes for research/reading
- return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'hashed' : 'sepia';
+ // Follow the OS preference using the default light and dark palettes.
+ return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'hashed' : 'light';
}
return theme;
}
diff --git a/src/local_deep_research/web/templates/base.html b/src/local_deep_research/web/templates/base.html
index af36a3d09e..c929d8bb49 100644
--- a/src/local_deep_research/web/templates/base.html
+++ b/src/local_deep_research/web/templates/base.html
@@ -27,7 +27,7 @@
}
var effectiveTheme = theme;
if (theme === 'system') {
- effectiveTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'hashed' : 'sepia';
+ effectiveTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'hashed' : 'light';
}
document.documentElement.setAttribute('data-theme', effectiveTheme);
})();
diff --git a/tests/accessibility_tests/wcag-compliance.spec.js b/tests/accessibility_tests/wcag-compliance.spec.js
index 8339848393..ca0ec166c9 100644
--- a/tests/accessibility_tests/wcag-compliance.spec.js
+++ b/tests/accessibility_tests/wcag-compliance.spec.js
@@ -10,8 +10,8 @@ import { createAxeBuilder, getCriticalViolations, formatViolations } from './axe
const BASE_URL = process.env.BASE_URL || 'http://localhost:5000';
const TEST_TIMEOUT = 30000;
-// Color-contrast is excluded because the default theme (sepia/solarized-light)
-// has text colors that don't meet WCAG AA 4.5:1 contrast ratios.
+// Color-contrast is excluded because several selectable themes (e.g. sepia)
+// have text colors that don't meet WCAG AA 4.5:1 contrast ratios.
// This is a systemic theme design issue tracked separately.
const AXE_DISABLE_RULES = ['color-contrast'];
diff --git a/tests/js/services/theme-bootstrap-runtime.test.js b/tests/js/services/theme-bootstrap-runtime.test.js
new file mode 100644
index 0000000000..d133560668
--- /dev/null
+++ b/tests/js/services/theme-bootstrap-runtime.test.js
@@ -0,0 +1,47 @@
+/** Execute the actual pre-render theme script so it cannot drift from theme.js. */
+import { readFileSync } from 'node:fs';
+import { resolve } from 'node:path';
+
+const template = readFileSync(resolve(
+ __dirname, '../../../src/local_deep_research/web/templates/base.html',
+), 'utf8');
+const metadata = Object.fromEntries(['system', 'light', 'hashed', 'sepia']
+ .map(id => [id, { label: id }]));
+// Supply only the server-rendered values; execute the checked-in browser logic.
+const bootstrap = template.match(/<script>([\s\S]*?)<\/script>/)[1]
+ .replace('{{ get_themes_json()|safe }}', JSON.stringify(Object.keys(metadata)))
+ .replace('{{ get_theme_metadata()|safe }}', JSON.stringify(metadata))
+ .replace('{{ session.username|default("anonymous", true)|tojson }}', JSON.stringify('reader'));
+
+// This source comes from our template above, never from user-controlled input.
+const applyInitialTheme = new Function(bootstrap); // eslint-disable-line no-new-func
+
+beforeEach(() => {
+ localStorage.clear();
+ document.documentElement.removeAttribute('data-theme');
+});
+
+afterEach(() => {
+ localStorage.clear();
+ delete window.LDR_THEME_METADATA;
+ vi.restoreAllMocks();
+});
+
+it.each([
+ { preference: null, dark: false, expected: 'light' },
+ { preference: null, dark: true, expected: 'hashed' },
+ { preference: 'system', dark: false, expected: 'light' },
+ { preference: 'system', dark: true, expected: 'hashed' },
+ { preference: 'sepia', dark: false, expected: 'sepia' },
+ { preference: 'sepia', dark: true, expected: 'sepia' },
+ { preference: 'light', dark: true, expected: 'light' },
+])('applies $expected before rendering for preference=$preference, dark=$dark', ({ preference, dark, expected }) => {
+ vi.spyOn(window, 'matchMedia').mockReturnValue({ matches: dark });
+ if (preference) localStorage.setItem('ldr-theme-reader', preference);
+
+ applyInitialTheme();
+
+ expect(document.documentElement.dataset.theme).toBe(expected);
+ // Resolving System must not turn it into an explicit saved Light/Hashed choice.
+ expect(localStorage.getItem('ldr-theme-reader')).toBe(preference);
+});
diff --git a/tests/js/services/theme-lifecycle-runtime.test.js b/tests/js/services/theme-lifecycle-runtime.test.js
index 3a8e93e86e..8740728388 100644
--- a/tests/js/services/theme-lifecycle-runtime.test.js
+++ b/tests/js/services/theme-lifecycle-runtime.test.js
@@ -149,12 +149,19 @@ it('reacts to a system color-scheme change only for the system preference', () =
mediaQuery.matches = false;
mediaListeners[0]();
- expect(document.documentElement.dataset.theme).toBe('sepia');
+ expect(document.documentElement.dataset.theme).toBe('light');
+
+ expect(theme.getCurrentTheme()).toBe('system');
- theme.setTheme('nord', false);
mediaQuery.matches = true;
mediaListeners[0]();
- expect(document.documentElement.dataset.theme).toBe('nord');
+ expect(document.documentElement.dataset.theme).toBe('hashed');
+
+ theme.setTheme('sepia', false);
+ mediaQuery.matches = false;
+ mediaListeners[0]();
+ expect(document.documentElement.dataset.theme).toBe('sepia');
+ expect(theme.getCurrentTheme()).toBe('sepia');
});
it('wires one dropdown change to the migrated settings PUT with CSRF', async () => {
diff --git a/tests/js/services/theme.test.js b/tests/js/services/theme.test.js
index 0da2aa9161..f809a41cd9 100644
--- a/tests/js/services/theme.test.js
+++ b/tests/js/services/theme.test.js
@@ -62,15 +62,16 @@ describe('themeService', () => {
});
describe('getEffectiveTheme', () => {
- it('resolves system to sepia when prefers-color-scheme is light', () => {
+ it('resolves system to light when prefers-color-scheme is light', () => {
// happy-dom matchMedia returns false for dark mode by default
- expect(theme.getEffectiveTheme('system')).toBe('sepia');
+ expect(theme.getEffectiveTheme('system')).toBe('light');
});
it('returns the theme itself for non-system themes', () => {
expect(theme.getEffectiveTheme('hashed')).toBe('hashed');
expect(theme.getEffectiveTheme('light')).toBe('light');
expect(theme.getEffectiveTheme('nord')).toBe('nord');
+ expect(theme.getEffectiveTheme('sepia')).toBe('sepia');
});
});
@@ -102,7 +103,7 @@ describe('themeService', () => {
it('resolves system theme before applying', () => {
theme.applyTheme('system');
const applied = document.documentElement.getAttribute('data-theme');
- expect(['sepia', 'hashed']).toContain(applied);
+ expect(applied).toBe('light');
});
it('dispatches themechange event', () => {
diff --git a/tests/ui_tests/test_navigation_and_theme_ci.js b/tests/ui_tests/test_navigation_and_theme_ci.js
index 689d9ab27b..ea1c2e1f76 100644
--- a/tests/ui_tests/test_navigation_and_theme_ci.js
+++ b/tests/ui_tests/test_navigation_and_theme_ci.js
@@ -286,11 +286,14 @@ async function testThemeSwitchingAndPersistence(page) {
fail(`GENUINE DEFECT: theme switch did not persist to localStorage -- expected "${targetTheme}", got "${afterSwitch.storedRaw}" (key: ${afterSwitch.storageKey})`);
}
- // 'system' resolves to 'hashed' or 'sepia' depending on OS color-scheme
+ // 'system' resolves to 'hashed' or 'light' depending on OS color-scheme
// preference (getEffectiveTheme() in theme.js); every other theme's
// data-theme equals the raw value 1:1.
if (targetTheme === 'system') {
- if (afterSwitch.dataTheme === 'hashed' || afterSwitch.dataTheme === 'sepia') {
+ const expectedSystemTheme = await page.evaluate(() => (
+ window.matchMedia('(prefers-color-scheme: dark)').matches ? 'hashed' : 'light'
+ ));
+ if (afterSwitch.dataTheme === expectedSystemTheme) {
pass(`Theme switching: <html data-theme> resolved "system" to "${afterSwitch.dataTheme}"`);
} else {
fail(`GENUINE DEFECT: "system" theme resolved to unexpected data-theme="${afterSwitch.dataTheme}"`);