Skip to content

fix: getMostRecent relies on array position instead of updatedAt timestamp #50

@Cheezeiii365

Description

@Cheezeiii365

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglow priorityLow priority issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions