iansinnott / prompta

ChatGPT UI that is keyboard-centric, mobile friendly, and searchable.
https://chat.prompta.dev
MIT License
154 stars 13 forks source link

Sync v2 #18

Closed iansinnott closed 9 months ago

iansinnott commented 9 months ago

Add sync functionality.

Now syncing actually works 🎉 . It required setting up a sync server for VLCN. This was roughly what the initial p2p implementation was meant to accomplish, but it was ineffective without an always-on peer. Thus we have a server now.

The source is under sync-server if you want to run your own. I've deployed a public instance which can be used without configuration.

This is a beta feature. I've only done light testing on my own system so there may well be issues, especially related to schema migrations.

Sync as backup

The sync server stores a copy of messages and threads and it does so using standard sqlite3 on a standard file system. In other words, it should be more stable than the wasm-sqlite on top of indexedDB that Prompta uses in the browser. Not complaining—i've been very happy with wasm-sqlite so far. However, we've had issues with data corruption in the browser (hopefully solved now with VLCN v0.16).

Point being, enabling sync even if you don't use Prompta on another device will back up your messages. In the case of a corrupted browser database you can reset and re-enter the sync key to pull the data back down.


This also adds in functionality to restore data from a prior database version, although this is likely only useful in dev. If you have to reset the database you can attempt to restore previous data using the cmd+k menu.