Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync chats across machines #364

Open
sandeeps- opened this issue Nov 27, 2023 · 11 comments
Open

Sync chats across machines #364

sandeeps- opened this issue Nov 27, 2023 · 11 comments

Comments

@sandeeps-
Copy link

Is it possible to add an option to auto sync the chats across different machines? For example in chrome use the sync features.

Or add an option to change the location where the chats are stored; so the user can use a 3rd party sync service like dropbox, google drive, box etc to sync chats between multiple machines

@DustinWehr
Copy link

@Niek are you open to this if I work on it? I wouldn't get into complicated sync protocols. Probably some simple restriction such as: chats created from one session are read-only from other sessions.

I'm already doing a very hacky non-automated version of this in a fork of your repo, where i've added "Backup all JSON" and "import many JSON" choices next to the single-chat ones.

@Niek
Copy link
Owner

Niek commented Jan 31, 2024

Interesting idea, what would be an option is https://remote.storage/ (https://github.com/FrigadeHQ/remote-storage). However, when we implement this people should be aware that their data is stored on a 3rd party host.

@DustinWehr
Copy link

DustinWehr commented Feb 3, 2024

It could be opt-in, right? Put the remoteStorage config on the same page as the OpenAI key. Also, from a brief look at Storage.svelte, it seems plausible that end-to-end encryption of individual serialized Messages might not be too much work. What do you think?

I think 5apps is another company that offers free hosting for remoteStorage.

@DustinWehr
Copy link

Oh, or using json chat import/export. Maybe that's what you had it mind, since it would require very few changes to your code. I just made it so it won't import a json chat if there's already a Chat with the same hash of .messages. Would be very easy to include an end-to-end encryption option that way, also.

@DustinWehr
Copy link

Oh, or using json chat import/export. Maybe that's what you had it mind, since it would require very few changes to your code. I just made it so it won't import a json chat if there's already a Chat with the same hash of .messages. Would be very easy to include an end-to-end encryption option that way, also.

@Niek was easy to get a proof-of-concept working this way. Only problem for me is that the default community server from Frigate (I haven't gotten 5apps working) appears to enforce a size limit of 1 MB (uncompressed), smaller than google chrome's enforced localStorage limit. Incidentally, I recall seeing a note from you somewhere about thinking of switching to IndexDB to avoid localStorage's size limits.

@DustinWehr
Copy link

Oh, silly me. That limit appears to be per-key. Well, we should compress the chats as gracious users of the free server anyway. I'll do that, and also encryption. LMK if you want me to share it.

@Niek
Copy link
Owner

Niek commented Feb 6, 2024

Sounds great! If you can do a PR that would be amazing!

@DustinWehr
Copy link

DustinWehr commented Feb 18, 2024

FYI the remoteStorage of https://github.com/FrigadeHQ/remote-storage / https://remote.storage / npm remote-storage is not the standards-track, much older remoteStorage, which is https://github.com/remotestorage / https://remotestorage.io / npm remotestoragejs.

@DustinWehr
Copy link

DustinWehr commented Mar 3, 2024

Quick update; remoteStorage caching, which it uses for background syncing, uses too much localStorage, so I'm reworking this sync feature to make it efficient without remoteStorage caching. They supposedly support caching with IndexedDB too, but provide no way to choose it manually; it's only used if the environment has no localStorage. I don't want to force IndexedDB by changing the remoteStorage.js source only to find out that it's buggier.

@DustinWehr
Copy link

DustinWehr commented Apr 5, 2024

@sandeeps- @Niek I have a fork with sync running here https://chatgptweb-dust.vercel.app/. Hope to put it on github soon. There are a few very minor extra things added in this fork, just because I use them regularly, but with the exception of a couple new menu items (Backup all chats JSON and Restore many chats JSON) they are disabled by default with options added on the settings page.

Notes:

  • End-to-end encryption is mandatory.
  • Works with RemoteStorage accounts and Dropbox. For Dropbox, you'd have to get me to add your email to a whitelist, because I don't have the app approved for production yet. There is Google Drive support available, but I have it disabled because I had problems restricting the permissions.
  • If anybody wants to use their existing chats from niek.github.com, I could easily make a separate tiny PR for the "Backup all" and "Restore many" menu items. Alternatively/in addition, I could share the bookmarklet hack that I used to do this.
  • I implemented periodic autosyncing but decided to remove it till I'm confident the code works reliably without it. Can easily be added back. As it is now, you can make it sync automatically after local changes, but it won't automatically sync on device A after you make a change on device B.

Setup:

  1. Click the Enable syncing between your devices checkbox in the settings, which will reveal a RemoteStorage login widget. In the "IMPORTANT NOTES", there's a link to 5apps.com where you can make a free RemoteStorage account. There are probably other companies hosting servers too, and I'm told it's easy to run one's own.
  2. Click the First Device Setup button. A 12 character code will be generated, and from it an AES key derived and saved unencrypted to your browser's localStorage. Click Accept. You can see the code later by hovering over an element just above the setup buttons.
  3. There will be a new sync button next to the sort button in the sidebar. Click it. Alternatively, check the option Do a sync after every change you make from this device, and then make a local change. In either case, your chats will be encrypted with the AES key and then slowly (to avoid rate limiting) uploaded to the RS server. I have it going slower than necessary atm.
  4. On other devices, you login to the same RemoteStorage account, then click Additional device setup, then input the 12 character code from your first device and click save. After a few seconds a popup should tell you that you entered the right code. Click ok to start a sync.

@DustinWehr
Copy link

Here's the fork https://github.com/DustinWehr/chatgpt-web-syncing
@Niek lmk if you're still interested in a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants