Persistent chat history #1

Merged
riki merged 1 commit from push-sxmuwrnkqzkk into main 2026-04-02 16:48:39 +02:00
Owner

Implement persistent chat history by saving messages into an SQLite database.

Since it has to be possible to correlate history with specific rooms, this also implements a table storing existing rooms and their metadata (currently only who created the room.)

Messages use bespoke snowflake IDs as their primary key, that is Unix timestamps coupled with a sequence counter. Our snowflake is tailored towards running on a single machine, and has 56 bits for a Unix timestamp (millis) with an 8 bit sequence counter for handling concurrent writes in the same millisecond. You would have to send 256 messages in a millisecond to cause a collision which is not realistic in our case.

Implement persistent chat history by saving messages into an SQLite database. Since it has to be possible to correlate history with specific rooms, this also implements a table storing existing rooms and their metadata (currently only who created the room.) Messages use bespoke snowflake IDs as their primary key, that is Unix timestamps coupled with a sequence counter. Our snowflake is tailored towards running on a single machine, and has 56 bits for a Unix timestamp (millis) with an 8 bit sequence counter for handling concurrent writes in the same millisecond. You would have to send 256 messages in a millisecond to cause a collision which is not realistic in our case.
riki force-pushed push-sxmuwrnkqzkk from 7cd9e33551 to 7d9e9e398b 2026-04-02 16:35:32 +02:00 Compare
riki force-pushed push-sxmuwrnkqzkk from 7d9e9e398b to eb31667944 2026-04-02 16:42:29 +02:00 Compare
riki force-pushed push-sxmuwrnkqzkk from eb31667944 to 4c030c99f0 2026-04-02 16:45:15 +02:00 Compare
riki changed title from WIP: Persistent chat history to Persistent chat history 2026-04-02 16:45:25 +02:00
riki merged commit 5425a34784 into main 2026-04-02 16:48:39 +02:00
riki deleted branch push-sxmuwrnkqzkk 2026-04-02 16:48:39 +02:00
riki referenced this pull request from a commit 2026-04-02 16:48:39 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mofu/mofu!1
No description provided.