Summary
In ConversationStore.save(), the three operations (encode → write → setAttributes) share a single do/catch. If write succeeds but setAttributes throws, upsertInMemoryRecord is never called — the file lands on disk with new content but the in-memory sidebar shows stale state.
Fix
- Call
upsertInMemoryRecord immediately after write succeeds (not after setAttributes).
- Change
setAttributes to try? — treat it as best-effort; a permissions failure should not roll back an otherwise successful save.
Test coverage
This is test gap #2: add a test that stubs setAttributes to throw after a successful write and asserts in-memory state is updated correctly.
Summary
In
ConversationStore.save(), the three operations (encode → write → setAttributes) share a singledo/catch. Ifwritesucceeds butsetAttributesthrows,upsertInMemoryRecordis never called — the file lands on disk with new content but the in-memory sidebar shows stale state.Fix
upsertInMemoryRecordimmediately afterwritesucceeds (not aftersetAttributes).setAttributestotry?— treat it as best-effort; a permissions failure should not roll back an otherwise successful save.Test coverage
This is test gap #2: add a test that stubs
setAttributesto throw after a successful write and asserts in-memory state is updated correctly.