fix(settings): preserve valid legacy font fallback

This commit is contained in:
Mohamed Boudra
2026-08-24 14:27:22 +02:00
parent 8fdca94ead
commit 4724d1d9b7
2 changed files with 15 additions and 1 deletions
@@ -705,6 +705,20 @@ describe("appearance settings", () => {
expect((await loadAppSettingsFromStorage(deps)).uiBaseFontSize).toBe(16);
});
it("falls back to a valid legacy interface scale when the explicit base size is invalid", async () => {
const deps = makeDeps({
storage: createInMemoryKeyValueStorage({
[APP_SETTINGS_KEY]: JSON.stringify({ uiBaseFontSize: "abc", uiFontSize: 17 }),
}),
});
const result = await loadAppSettingsFromStorage(deps);
const persisted = JSON.parse(deps.storage.entries.get(APP_SETTINGS_KEY) ?? "null");
expect(result.uiBaseFontSize).toBe(15);
expect(persisted).toMatchObject({ uiBaseFontSize: 15, uiFontSize: 17 });
});
it("clamps the UI base font size into range and rejects non-numeric values", async () => {
const deps = makeDeps({
storage: createInMemoryKeyValueStorage({
@@ -182,7 +182,7 @@ const StoredAppSettingsSchema = z
monoFontFamily: sanitizedFontFamily().catch(""),
uiBaseFontSize: clampedNumber(MIN_UI_BASE_FONT_SIZE, MAX_UI_BASE_FONT_SIZE)
.optional()
.catch(DEFAULT_UI_BASE_FONT_SIZE),
.catch(undefined),
contentFontSize: clampedNumber(MIN_CONTENT_FONT_SIZE, MAX_CONTENT_FONT_SIZE)
.optional()
.catch(DEFAULT_CONTENT_FONT_SIZE),