Summary
ConversationStore.getMostRecent() in packages/main/src/conversationStore.ts uses Array.find() (first positional match) to return the most recent conversation, relying on the implicit invariant that the index array is always sorted newest-first.
Problem
The invariant holds today (create() uses unshift), but updateMeta() can bump updatedAt on an older conversation without re-sorting the array. If a non-newest conversation gets a newer updatedAt, getMostRecent will silently return the wrong entry.
This is a latent bug — not currently triggered in production, but fragile.
Suggested approach
Rather than patching getMostRecent alone, consider re-sorting the index after updateMeta bumps updatedAt, so the "newest-first" invariant remains globally reliable for all consumers.
References
- File:
packages/main/src/conversationStore.ts, lines ~144-151
- Related:
updateMeta at line ~129, create at line ~104
Summary
ConversationStore.getMostRecent()inpackages/main/src/conversationStore.tsusesArray.find()(first positional match) to return the most recent conversation, relying on the implicit invariant that the index array is always sorted newest-first.Problem
The invariant holds today (
create()usesunshift), butupdateMeta()can bumpupdatedAton an older conversation without re-sorting the array. If a non-newest conversation gets a newerupdatedAt,getMostRecentwill silently return the wrong entry.This is a latent bug — not currently triggered in production, but fragile.
Suggested approach
Rather than patching
getMostRecentalone, consider re-sorting the index afterupdateMetabumpsupdatedAt, so the "newest-first" invariant remains globally reliable for all consumers.References
packages/main/src/conversationStore.ts, lines ~144-151updateMetaat line ~129,createat line ~104