void icon indicating copy to clipboard operation
void copied to clipboard

Store each chat in its own key

Open steaks opened this issue 6 months ago • 3 comments

#481 Store each chat in it's own key

Performance Tests

These are performance tests for _readAllThreads. This is the function that could have worse performance. Attempted to make chat length somewhat representative when testing.

| Number of Chats | Time in ms |
| --------------- | ---------- |
| 100             | 46ms       |
| 150             | 60ms       |
| 200             | 79ms       |

The performance seems good. I could use some help testing performance if anyone has a large chat history!

steaks avatar May 29 '25 22:05 steaks

Hey @andrewpareles, is this what you had in mind for the architecture?

steaks avatar May 29 '25 22:05 steaks

Yeah, generally! Just one small detail - I think we should have another storage item that's an array of all the chats IDs. That way we don't have to list all the keys and filter with a startsWith.

Storage service should effectively be this:

{
    CHAT_IDS: [threadId_1, threadId_2, threadId_3, ...],
    [threadId_n]: ...chat info...
}

andrewpareles avatar May 30 '25 10:05 andrewpareles

:+1: added a chatIds storage item

steaks avatar May 30 '25 16:05 steaks