YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
test(evals): verify preset deletion through settings persistence
louisd8089625fb03
diff --git a/evals/coding-agent/README.md b/evals/coding-agent/README.mdindex e987db96a..00288be72 100644--- a/evals/coding-agent/README.md+++ b/evals/coding-agent/README.md@@ -9,7 +9,7 @@ This is an agent eval suite, not a unit-test suite. Every case contains:- saved prompt, transcript, candidate patch, grader output, runtime fingerprint, and result;- repeated-trial reporting with success rate, `pass@k`, and `pass^k`.-The current app corpus contains 48 git-mined regressions. See+The current app corpus contains 49 git-mined regressions. See[DESIGN.md](./DESIGN.md) for the Anthropic guidance, source contract, andhistory-mining workflow. The companion website manifest uses this same harness.@@ -259,3 +259,20 @@ budget changes, verification/auth-cache bypass, no-op and missing-sourcecontrols. No dependencies, actual encryption, attestation, model calls, nativeapp or provider access are exercised; this is request construction, not proofof sampler enforcement, response quality or agent isolation.++## Preset deletion through settings persistence++`app-preset-deletion-save-recovery` calls the real settings provider update,+settings write queue, dependency reassignment and conversation persistence.+Thirteen outcomes exercise task/chat write failure and retry, partial progress,+hidden destinations, newer selections after discovery, preserved content and+unrelated references, queued updates, and final settings-save failure. The+historical parent has nine behavioral failures and four preserved passes.++Run `bun test evals/coding-agent/calibrate-preset-save.test.js` for the hidden+grader controls. The standalone suite uses synthetic native filesystem/store,+HTTP, event and UI state ports; React binding is simulated without running mount+effects. It does not prove rendered UI rollback, native filesystem durability,+cross-process races, or recovery after the final store save fails. No installed+packages or native build is needed. Source setup errors cannot establish the+regression. Actual model trials and enforced trial isolation remain separate.diff --git a/evals/coding-agent/calibrate-preset-save.test.js b/evals/coding-agent/calibrate-preset-save.test.jsnew file mode 100644index 000000000..8a9b0e2e1--- /dev/null+++ b/evals/coding-agent/calibrate-preset-save.test.js@@ -0,0 +1,29 @@+// screenpipe — AI that knows everything you've seen, said, or heard+// https://screenpipe.com+import { afterAll, expect, test } from 'bun:test';+import { execFileSync, spawnSync } from 'node:child_process';+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { dirname, join, resolve } from 'node:path';+import { tmpdir } from 'node:os';+const repo=resolve(import.meta.dir,'../..'),prefix='apps/screenpipe-app-tauri/';+const item=JSON.parse(readFileSync(join(import.meta.dir,'cases.json'),'utf8')).cases.find(c=>c.id==='app-preset-deletion-save-recovery');+const paths=['tsconfig.json','lib/hooks/use-settings.tsx','lib/ai-preset-deletion.ts','lib/active-ai-preset.ts','lib/chat-storage.ts','lib/chat-dedup.ts','lib/chat-merge.ts','lib/chat/ephemeral-side-conversation.ts','lib/chat/external-chat-parser.ts','lib/hooks/managed-settings.ts','lib/desktop-remote-control.ts','lib/app-entitlement.ts','lib/telemetry-env.ts','lib/utils/font-size.ts','lib/live-views/onboarding-activation.ts','lib/utils/sidebar-nav-layout.ts','lib/utils/chat-title.ts','lib/auth-guard.tsx','lib/utils/tauri.ts','lib/hooks/use-is-enterprise-build.ts','components/settings/settings-write-queue.ts'];+function sources(ref){return Object.fromEntries(paths.filter(p=>ref!==item.base_ref||p!=='lib/ai-preset-deletion.ts').map(p=>[p,execFileSync('git',['-c','core.commitGraph=false','show',`${ref}:${prefix}${p}`],{cwd:repo,encoding:'utf8'})]));}+const broken=sources(item.base_ref),fixed=sources(item.oracle_ref);+const fixture='evals/coding-agent/graders/preset-save-recovery.test.js',grader=readFileSync(join(repo,fixture));+const root=mkdtempSync(join(tmpdir(),'preset-save-calibration-'));afterAll(()=>rmSync(root,{recursive:true,force:true}));+function grade(name,sources){const cwd=join(root,name);for(const [path,source] of Object.entries(sources)){const file=join(cwd,prefix,path);mkdirSync(dirname(file),{recursive:true});writeFileSync(file,source);}mkdirSync(dirname(join(cwd,fixture)),{recursive:true});writeFileSync(join(cwd,fixture),grader);return spawnSync(process.execPath,['test','../../'+fixture],{cwd:join(cwd,prefix),encoding:'utf8',timeout:30_000,env:{PATH:dirname(process.execPath)}});}+function fails(r){expect(r.error).toBeUndefined();expect(r.signal).toBeNull();expect(r.status).toBe(1);expect(r.stderr).toContain('expect(received)');expect(r.stderr).not.toContain('Cannot find module');expect(r.stderr).not.toContain('Unhandled error');}+function replace(source,old,next){expect(source.split(old)).toHaveLength(2);return source.replace(old,next);}+const settings='lib/hooks/use-settings.tsx',helper='lib/ai-preset-deletion.ts',chat='lib/chat-storage.ts';+test('parent has intended failures and preserved settings behavior',()=>{const r=grade('parent',broken);fails(r);expect(r.stderr).toContain('9 fail');expect(r.stderr).toContain('4 pass');});+test('reference passes real settings and conversation persistence outcomes',()=>{const r=grade('reference',fixed);expect(r.status).toBe(0);expect(r.stderr).toContain('13 pass');});+test('equivalent internal helper names are accepted',()=>{const renamed=Object.fromEntries(Object.entries(fixed).map(([p,s])=>[p,s.replaceAll('saveWithPresetReassignment','persistPresetDependencies').replaceAll('reassignConversationPreset','updateConversationPresetDependency')]));expect(grade('renamed',renamed).status).toBe(0);});+test('unused correct helpers cannot conceal broken settings wiring',()=>fails(grade('unwired',{...broken,[helper]:fixed[helper],[chat]:fixed[chat]})));+test('premature settings persistence before dependency success is rejected',()=>fails(grade('early-save',{...fixed,[settings]:replace(fixed[settings],'await saveWithPresetReassignment(current, newSettings, async (reassigned) => {','await setSettingsStripped(store, newSettings); await saveAndEncrypt(store); await saveWithPresetReassignment(current, newSettings, async (reassigned) => {')})));+test('ignoring a task update failure is rejected',()=>fails(grade('ignore-task-failure',{...fixed,[helper]:replace(fixed[helper],'if (!result.ok || resultBody.success !== true) {','if (false) {')})));+test('hidden explicit conversation destinations cannot be skipped',()=>fails(grade('skip-hidden',{...fixed,[helper]:replace(fixed[helper],'if (config.run_in?.chat_id) chatIds.add(config.run_in.chat_id);','/* deliberately omit explicit destinations */')})));+test('overwriting a newer conversation selection is rejected',()=>fails(grade('stale-selection',{...fixed,[chat]:replace(fixed[chat],'if (!conv?.presetId || !removedIds.has(conv.presetId)) return;','if (!conv) return;')})));+test('success without updating active and open selections is rejected',()=>fails(grade('no-active-effects',{...fixed,[helper]:replace(fixed[helper],'const active = readActiveAiPresetId();','return; const active = readActiveAiPresetId();')})));+test('blanket settings refusal cannot pass preserved updates',()=>fails(grade('deny-all',{...fixed,[settings]:replace(fixed[settings],'assertValidAiPresetUpdate(value);','throw new Error("synthetic blanket denial"); assertValidAiPresetUpdate(value);')})));+test('missing actual settings source is a setup failure',()=>{const source={...fixed};delete source[settings];const r=grade('missing',source);expect(r.status).toBe(1);expect(r.stderr).toContain('Cannot find module');expect(r.stderr).toContain('0 pass');});diff --git a/evals/coding-agent/cases.json b/evals/coding-agent/cases.jsonindex 2be4e4627..892a8b92e 100644--- a/evals/coding-agent/cases.json+++ b/evals/coding-agent/cases.json@@ -1,7 +1,7 @@{"schema_version": 1,"suite": "screenpipe-app-coding-agent-regressions",- "dataset_version": "2026-09-19.5",+ "dataset_version": "2026-09-19.6","suite_type": "regression","owner": "screenpipe engineering","policy": {@@ -1548,6 +1548,41 @@],"command": "\"${BUN_BIN:-bun}\" test evals/coding-agent/graders/private-reasoning-budget.test.ts"}+ },+ {+ "id": "app-preset-deletion-save-recovery",+ "name": "Reassign preset dependencies before committing deletion",+ "source": {+ "kind": "git_regression",+ "fix_commit": "923294f6848b0aaf5800aee3b33b1f07a9eb9c3f"+ },+ "base_ref": "18661dfab746eb2d1f37e224ef8c4f91841473ff",+ "oracle_ref": "923294f6848b0aaf5800aee3b33b1f07a9eb9c3f",+ "oracle_paths": [+ "apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx",+ "apps/screenpipe-app-tauri/lib/ai-preset-deletion.ts",+ "apps/screenpipe-app-tauri/lib/chat-storage.ts"+ ],+ "tags": [+ "regression",+ "escaped-failure",+ "settings",+ "automation",+ "persistence",+ "retry"+ ],+ "prompt": "Deleting an AI preset leaves scheduled tasks and saved conversations referring to a preset that no longer exists. Fix the actual settings update path so affected task chains, saved conversations including hidden explicit task destinations, legacy conversation settings, activity settings, open chat selections and the active selection move to a surviving default before deletion is committed. Preserve unrelated presets, wildcard/default task references, conversation content and timestamps, and a newer conversation selection made after dependency discovery. Deduplicate rewritten task chains. Discovery, task-write or conversation-write failures must reject deletion, retain the original durable preset and support retry after partial dependency success without rewriting already-repaired task references. A failed final settings save must not announce committed changes or update active/open selections. Model edits and reordering must not trigger dependency work; empty preset lists must be refused. Concurrent queued unrelated settings updates must preserve both changes. No particular helper name or extraction is required. UI rendering, native filesystem guarantees and retry after a failed final store save are outside this task.",+ "agent_timeout_seconds": 1200,+ "grader": {+ "timeout_seconds": 60,+ "fixtures": [+ {+ "local_path": "graders/preset-save-recovery.test.js",+ "destination_path": "evals/coding-agent/graders/preset-save-recovery.test.js"+ }+ ],+ "command": "cd apps/screenpipe-app-tauri && \"${BUN_BIN:-bun}\" test ../../evals/coding-agent/graders/preset-save-recovery.test.js"+ }}]}diff --git a/evals/coding-agent/graders/preset-save-recovery.test.js b/evals/coding-agent/graders/preset-save-recovery.test.jsnew file mode 100644index 000000000..3a747d425--- /dev/null+++ b/evals/coding-agent/graders/preset-save-recovery.test.js@@ -0,0 +1,96 @@+// screenpipe — AI that knows everything you've seen, said, or heard+// https://screenpipe.com+import { beforeEach, afterEach, expect, mock, test } from 'bun:test';+import { posix } from 'node:path';+import { existsSync } from 'node:fs';+function mockAppModule(specifier,factory){+ mock.module(specifier,factory);+ const stem=new URL('../../../apps/screenpipe-app-tauri/'+specifier.slice(2),import.meta.url).pathname;+ for(const suffix of ['.ts','.tsx','.js'])if(existsSync(stem+suffix)){mock.module(stem+suffix,factory);break;}+}+let s;+const clone=x=>structuredClone(x);+const storage=new Map();+globalThis.window={localStorage:{getItem:k=>storage.get(k)??null,setItem:(k,v)=>storage.set(k,String(v)),removeItem:k=>storage.delete(k)},location:{pathname:'/settings'}};+globalThis.localStorage=window.localStorage;+globalThis.fetch=async()=>{s.unexpected.push('network');throw Error('Network forbidden');};+const react={createContext:()=>({Provider:'provider'}),createElement:(type,props,...children)=>({type,props:{...props,children}}),useState:value=>[typeof value==='function'?value():value,()=>{}],useEffect:()=>{},useRef:value=>({current:value}),useContext:()=>undefined};+mock.module('react',()=>({...react,default:react}));+mock.module('react/jsx-dev-runtime',()=>({jsxDEV:(type,props)=>({type,props})}));+mock.module('react/jsx-runtime',()=>({jsx:(type,props)=>({type,props}),jsxs:(type,props)=>({type,props})}));+mock.module('posthog-js',()=>({default:{capture:()=>{},identify:()=>{}}}));+mock.module('@tauri-apps/api/core',()=>({invoke:async(name)=>{s.unexpected.push('invoke:'+name);throw Error('Unexpected native command');}}));+mock.module('@tauri-apps/api/path',()=>({homeDir:async()=>'/synthetic',join:async(...parts)=>posix.join(...parts)}));+mock.module('@tauri-apps/api/app',()=>({getVersion:async()=>'0.0.0'}));+mock.module('@tauri-apps/plugin-os',()=>({platform:()=>'macos'}));+mock.module('@tauri-apps/api/event',()=>({emit:async(name)=>{s.events.push(name);},listen:async()=>()=>{}}));+const store={get:async()=>clone(s.settings),set:async(k,value)=>{s.settings=clone(value);s.order.push('settings:set');},save:async()=>{if(s.failSettings)throw Error('synthetic settings failure');s.diskSettings=clone(s.settings);s.order.push('settings:save');},onKeyChange:()=>()=>{}};+mock.module('@tauri-apps/plugin-store',()=>({Store:{load:async()=>store}}));+mockAppModule('@/lib/utils/tauri',()=>({commands:{getScreenpipeBaseDir:async()=>({status:'ok',data:'/synthetic'}),getChatsDir:async()=>({status:'ok',data:'/synthetic/chats'}),reencryptStore:async()=>{},getCloudToken:async()=>({status:'ok',data:null})}}));+mockAppModule('@/lib/analytics-id',()=>({cacheAnalyticsId:()=>{},cacheAnalyticsEnabled:()=>{}}));+mockAppModule('@/lib/analytics/settings-change',()=>({captureSettingsChange:()=>{}}));+mockAppModule('@/lib/analytics/onboarding-h1-follow-up',()=>({captureOnboardingH1FollowUp:()=>{}}));+mockAppModule('@/lib/auth-guard',()=>({installAuthInterceptor:()=>()=>{}}));+mockAppModule('@/lib/hooks/use-is-enterprise-build',()=>({isResolvedConsumerBuild:async()=>true}));+mockAppModule('@/lib/web-url',()=>({screenpipeWebUrl:path=>'https://screenpipe.invalid'+path}));+mockAppModule('@/lib/browser-state-cache',()=>({deleteCachedBrowserState:async()=>{}}));+mockAppModule('@/lib/stores/chat-store',()=>({useChatStore:{getState:()=>({sessions:s.sessions,actions:{patch:(id,update)=>Object.assign(s.sessions[id],update)}})}}));+mockAppModule('@/lib/api',()=>({localFetch:async(path,init)=>{+ s.requests.push({path,init});if(path==='/pipes'){if(s.failDiscovery)return Response.json({error:'unavailable'},{status:503});return Response.json({data:s.pipes});}+ const pipe=s.pipes.find(p=>path===`/pipes/${encodeURIComponent(p.config.name)}/config`);if(!pipe){s.unexpected.push(path);throw Error('Unknown task');}+ if(s.failPipe===pipe.config.name)return Response.json({success:false},{status:503});Object.assign(pipe.config,JSON.parse(init.body));s.order.push('pipe:'+pipe.config.name);return Response.json({success:true});+}}));+mock.module('@tauri-apps/plugin-fs',()=>({+ exists:async path=>path==='/synthetic/chats'||s.files.has(path),mkdir:async()=>{},+ readTextFile:async path=>{if(!s.files.has(path))throw Error('missing file');const text=s.files.get(path);if(s.advanceSelectionOnRead){s.advanceSelectionOnRead=false;const newer=JSON.parse(text);newer.presetId='c';newer.rev++;s.files.set(path,JSON.stringify(newer));}return text;},+ writeTextFile:async(path,text)=>{if(s.failChat)throw Error('synthetic chat failure');s.files.set(path,text);},+ rename:async(from,to)=>{s.files.set(to,s.files.get(from));s.files.delete(from);s.order.push('chat:'+to);},remove:async path=>{s.files.delete(path);},+ readDir:async()=>[...s.files.keys()].filter(p=>p.endsWith('.json')).map(p=>({name:posix.basename(p),isFile:true,isDirectory:false})),+ stat:async()=>({mtime:new Date(100),isFile:true,isDirectory:false})+}));+const settingsModule=await import('../../../apps/screenpipe-app-tauri/lib/hooks/use-settings');+const chat=await import('../../../apps/screenpipe-app-tauri/lib/chat-storage');+const active=await import('../../../apps/screenpipe-app-tauri/lib/active-ai-preset');+let api;+function put(id,presetId){s.files.set(`/synthetic/chats/${id}.json`,JSON.stringify({id,title:id,presetId,createdAt:100,updatedAt:100,rev:1,messages:[{id:id+'-m',role:'user',content:'synthetic preserved message',timestamp:100}]}));}+function removeB(){return api.updateSettings({aiPresets:s.settings.aiPresets.filter(p=>p.id!=='b')});}+beforeEach(async()=>{+ storage.clear();s={settings:{...clone(settingsModule.createDefaultSettingsObject()),deviceId:'synthetic-device',user:null,aiPresets:['a','b','c'].map(id=>({id,provider:'native-ollama',model:'synthetic-model',defaultPreset:id==='a'})),activitiesAiPresetId:'b',chatHistory:{conversations:[{id:'legacy',presetId:'b'}],activeConversationId:null}},diskSettings:null,files:new Map(),sessions:{open:{id:'open',presetId:'b'},other:{id:'other',presetId:'c'}},pipes:[],requests:[],events:[],unexpected:[],order:[],failDiscovery:false,failPipe:null,failChat:false,failSettings:false};+ chat.__resetChatStorageCachesForTests();chat.__resetConversationWriteQueuesForTests();api=settingsModule.SettingsProvider({children:null}).props.value;await api.reloadStore();s.diskSettings=clone(s.settings);s.order=[];s.events=[];s.requests=[];active.writeActiveAiPresetId('b');+});+afterEach(()=>expect(s.unexpected).toEqual([]));+test('settings save reassigns task, conversation and active references before deletion',async()=>{+ s.pipes=[{config:{name:'scheduled / task',preset:['b','c','a','*']}},{config:{name:'unrelated',preset:'c'}}];put('saved','b');put('unrelated','c');await removeB();+ expect(s.pipes[0].config.preset).toEqual(['a','c','*']);expect((await chat.loadConversationFile('saved')).presetId).toBe('a');expect((await chat.loadConversationFile('unrelated')).presetId).toBe('c');expect(s.diskSettings.aiPresets.map(p=>p.id)).toEqual(['a','c']);expect(s.diskSettings.activitiesAiPresetId).toBe('a');expect(s.diskSettings.chatHistory.conversations[0].presetId).toBe('a');expect(active.readActiveAiPresetId()).toBe('a');expect(s.sessions.open.presetId).toBe('a');expect(s.sessions.other.presetId).toBe('c');expect(s.order.findIndex(x=>x.startsWith('chat:'))).toBeLessThan(s.order.indexOf('settings:save'));+});+test('failed task write rejects deletion and retry completes without losing original preset',async()=>{+ s.pipes=[{config:{name:'task',preset:'b'}}];s.failPipe='task';await expect(removeB()).rejects.toThrow();expect(s.diskSettings.aiPresets.map(p=>p.id)).toEqual(['a','b','c']);expect(active.readActiveAiPresetId()).toBe('b');s.failPipe=null;await removeB();expect(s.pipes[0].config.preset).toBe('a');expect(s.diskSettings.aiPresets.map(p=>p.id)).toEqual(['a','c']);+});+test('model edits preserve references without task discovery',async()=>{await api.updateSettings({aiPresets:s.settings.aiPresets.map(p=>({...p,model:'updated-model'}))});expect(s.requests).toEqual([]);expect(s.diskSettings.aiPresets).toHaveLength(3);expect(active.readActiveAiPresetId()).toBe('b');});+for(const kind of ['discovery','chat'])test(`${kind} failure leaves durable preset and active selection available for retry`,async()=>{+ s.pipes=[{config:{name:'task',preset:'b'}}];put('saved','b');s.failDiscovery=kind==='discovery';s.failChat=kind==='chat';await expect(removeB()).rejects.toThrow();expect(s.diskSettings.aiPresets.map(p=>p.id)).toEqual(['a','b','c']);expect(active.readActiveAiPresetId()).toBe('b');s.failDiscovery=false;s.failChat=false;await removeB();expect((await chat.loadConversationFile('saved')).presetId).toBe('a');expect(s.diskSettings.aiPresets.map(p=>p.id)).toEqual(['a','c']);+});+test('partial task success followed by failure retries only outstanding references',async()=>{+ s.pipes=[{config:{name:'first',preset:'b'}},{config:{name:'second',preset:'b'}}];s.failPipe='second';await expect(removeB()).rejects.toThrow();expect(s.pipes.map(p=>p.config.preset)).toEqual(['a','b']);expect(s.diskSettings.aiPresets).toHaveLength(3);s.failPipe=null;await removeB();expect(s.pipes.map(p=>p.config.preset)).toEqual(['a','a']);expect(s.requests.filter(r=>r.path==='/pipes/first/config')).toHaveLength(1);expect(s.diskSettings.aiPresets).toHaveLength(2);+});+test('hidden explicit chat destinations are repaired and conversation content survives',async()=>{+ put('hidden','b');let conv=JSON.parse(s.files.get('/synthetic/chats/hidden.json'));conv.hidden=true;s.files.set('/synthetic/chats/hidden.json',JSON.stringify(conv));const winner={...clone(conv),id:'visible-twin',hidden:false,presetId:'c',messages:[...conv.messages,{id:'completed-reply',role:'assistant',content:'preserved answer',timestamp:110}]};s.files.set('/synthetic/chats/visible-twin.json',JSON.stringify(winner));expect((await chat.listConversations()).map(c=>c.id)).toEqual(['visible-twin']);s.pipes=[{config:{name:'hidden-target',run_in:{chat_id:'hidden'}}}];await removeB();const saved=await chat.loadConversationFile('hidden');expect(saved.presetId).toBe('a');expect(saved.messages).toEqual(conv.messages);expect(saved.updatedAt).toBe(conv.updatedAt);expect(saved.hidden).toBe(true);+});+test('a surviving default is selected when the deleted preset was default',async()=>{+ s.settings.aiPresets=s.settings.aiPresets.map(p=>({...p,defaultPreset:p.id==='b'}));s.diskSettings=clone(s.settings);s.pipes=[{config:{name:'task',preset:'b'}}];await api.updateSettings({aiPresets:s.settings.aiPresets.filter(p=>p.id!=='b').map(p=>({...p,defaultPreset:p.id==='c'}))});expect(s.pipes[0].config.preset).toBe('c');expect(active.readActiveAiPresetId()).toBe('c');expect(s.diskSettings.activitiesAiPresetId).toBe('c');+});+test('unrelated task defaults and wildcard references are never rewritten',async()=>{+ s.pipes=[{config:{name:'default',preset:'default'}},{config:{name:'wild',preset:'*'}},{config:{name:'other',preset:'c'}}];put('other','c');await removeB();expect(s.requests.filter(r=>r.init?.method==='POST')).toEqual([]);expect(s.pipes.map(p=>p.config.preset)).toEqual(['default','*','c']);expect((await chat.loadConversationFile('other')).presetId).toBe('c');+});+test('empty preset updates fail before side effects',async()=>{+ await expect(api.updateSettings({aiPresets:[]})).rejects.toThrow();expect(s.diskSettings.aiPresets).toHaveLength(3);expect(s.requests).toEqual([]);expect(active.readActiveAiPresetId()).toBe('b');+});+test('queued unrelated setting update does not resurrect the deleted preset',async()=>{+ s.pipes=[{config:{name:'task',preset:'b'}}];await Promise.all([removeB(),api.updateSettings({fontSize:'18px'})]);expect(s.diskSettings.aiPresets.map(p=>p.id)).toEqual(['a','c']);expect(s.diskSettings.fontSize).toBe('18px');expect(s.pipes[0].config.preset).toBe('a');+});+test('newer conversation selection after dependency discovery is preserved',async()=>{+ put('saved','b');s.advanceSelectionOnRead=true;await removeB();expect((await chat.loadConversationFile('saved')).presetId).toBe('c');expect(s.diskSettings.aiPresets.map(p=>p.id)).toEqual(['a','c']);+});+test('failure to save settings does not announce committed dependency changes',async()=>{+ s.failSettings=true;await expect(removeB()).rejects.toThrow();expect(s.diskSettings.aiPresets).toHaveLength(3);expect(active.readActiveAiPresetId()).toBe('b');expect(s.sessions.open.presetId).toBe('b');expect(s.events).not.toContain('pipe-config-updated');+});