The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(settings): tab resets cover every field of their tab
purple7b34eee85c60
diff --git a/src/lib/__tests__/every-tab-field-is-reset.test.ts b/src/lib/__tests__/every-tab-field-is-reset.test.tsnew file mode 100644index 00000000..47a10903--- /dev/null+++ b/src/lib/__tests__/every-tab-field-is-reset.test.ts@@ -0,0 +1,64 @@+/**+ * Jaeger B, B10: "Reset General to defaults" left Think budget standing and+ * "Reset Agent to defaults" left the sub-agent limits, although both fields+ * sit in those tabs. Every field a tab writes has to be in that tab's reset.+ *+ * Run: npx vitest run src/lib/__tests__/every-tab-field-is-reset.test.ts+ */+import { describe, it, expect, beforeEach } from 'vitest'+import { readFileSync } from 'node:fs'+import { join } from 'node:path'+import { useSettingsStore } from '../../stores/settingsStore'+import { DEFAULT_SETTINGS } from '../constants'+import { SETTINGS_TAB_RESET_KEYS, type SettingsTab } from '../settings-reset'++const { runSettingsReset } = await import('../run-settings-reset')++const page = readFileSync(join(__dirname, '../../components/settings/SettingsPage.tsx'), 'utf8')++/** The settings keys a stretch of SettingsPage.tsx writes. */+function writtenKeys(from: string, to: string): string[] {+ const start = page.indexOf(from)+ const end = page.indexOf(to, start + from.length)+ expect(start, from).toBeGreaterThan(-1)+ expect(end, to).toBeGreaterThan(start)+ return [...page.slice(start, end).matchAll(/updateSettings\(\{\s*(\w+)\s*:/g)].map((m) => m[1])+}++// The AI Backends and Voice tabs write through their own components and+// stores, the section-reset tests cover those.+const TABS: Partial<Record<SettingsTab, string[]>> = {+ general: writtenKeys("{tab === 'general' && (<>", "{tab === 'backends' && (<>"),+ agent: [+ ...writtenKeys("{tab === 'agent' && (<>", "{tab === 'voice-remote' && (<>"),+ // Rendered inside the Agent tab.+ ...writtenKeys('function CodexAgentSettings()', '\n}\n'),+ ],+}++beforeEach(() => useSettingsStore.setState({ settings: { ...DEFAULT_SETTINGS } }))++describe('B10: a tab reset covers every field of that tab', () => {+ for (const [tab, keys] of Object.entries(TABS)) {+ it(`${tab}: every field written in the tab is reset`, () => {+ expect(keys.length).toBeGreaterThan(0)+ const owned = SETTINGS_TAB_RESET_KEYS[tab as SettingsTab] as string[]+ expect(keys.filter((k) => !owned.includes(k))).toEqual([])+ })+ }++ it('Reset General restores Think budget', () => {+ useSettingsStore.getState().updateSettings({ thinkingBudget: 2048, maxTokens: 999 })+ runSettingsReset('section', 'general')+ expect(useSettingsStore.getState().settings.thinkingBudget).toBe(DEFAULT_SETTINGS.thinkingBudget)+ expect(useSettingsStore.getState().settings.maxTokens).toBe(DEFAULT_SETTINGS.maxTokens)+ })++ it('Reset Agent restores the sub-agent limits and the /loop passes', () => {+ useSettingsStore.getState().updateSettings({ subAgentMaxToolCalls: 50, subAgentMaxIterations: 20, loopMaxPasses: 7 })+ runSettingsReset('section', 'agent')+ const s = useSettingsStore.getState().settings+ expect([s.subAgentMaxToolCalls, s.subAgentMaxIterations, s.loopMaxPasses])+ .toEqual([DEFAULT_SETTINGS.subAgentMaxToolCalls, DEFAULT_SETTINGS.subAgentMaxIterations, DEFAULT_SETTINGS.loopMaxPasses])+ })+})diff --git a/src/lib/settings-reset.ts b/src/lib/settings-reset.tsindex aad376f4..e2b167c2 100644--- a/src/lib/settings-reset.ts+++ b/src/lib/settings-reset.ts@@ -12,10 +12,17 @@ export type SettingsTab = 'general' | 'backends' | 'agent' | 'voice-remote'// only the phone's tab name (GitHub #19), the rest is runtime server state. onboardingDone is a// lifecycle marker and is excluded everywhere (resetSettingsKeys also guards// against it).+//+// Jaeger B, B10: every field a tab shows belongs to that tab's list. Think+// budget, the sub-agent limits, the /loop passes and a few switches were+// missing, so "Reset General" and "Reset Agent" left them standing; the test+// in __tests__/every-tab-field-is-reset.test.ts reads the fields from+// SettingsPage.tsx and checks them against this map.export const SETTINGS_TAB_RESET_KEYS: Record<SettingsTab, (keyof Settings)[]> = {general: ['theme', 'userAvatarDataUrl',- 'temperature', 'topP', 'topK', 'maxTokens', 'contextWindowOverride',+ 'temperature', 'topP', 'topK', 'maxTokens', 'thinkingBudget', 'contextWindowOverride',+ 'emojiAutoReplace', 'enterKey', 'backgroundMediaTools', 'cloudTeasersEnabled','autoCompact', 'autoCompactThreshold', 'attachmentTokenLimit','gpuVendor', 'gpuIndices','imageGenTimeoutMinutes', 'videoGenTimeoutMinutes', 'chatFirstReplyTimeoutSeconds',@@ -24,9 +31,11 @@ export const SETTINGS_TAB_RESET_KEYS: Record<SettingsTab, (keyof Settings)[]> =agent: ['personasEnabled', 'defaultWorkspace','agentMaxToolCalls', 'agentMaxIterations',+ 'subAgentMaxToolCalls', 'subAgentMaxIterations', 'loopMaxPasses','searchProvider', 'braveApiKey', 'tavilyApiKey', 'exaApiKey', 'searchUserAgent','codexArchitectMode', 'codexArchitectModel', 'codexArchitectAllowCloud','codexRepoMapEnabled', 'codexRepoMapLimit', 'codexAutoApply', 'codexReviewMode',+ 'codexConfirmShell', 'codexCloudConfirmOptIn',],'voice-remote': ['remotePageTitle', 'shareNewChatsWithPhone'],}