Skip to content

Bug: Restoring previous versions doesn't work correctly (due to stale data) #934

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

Open
holdenmatt opened this issue Apr 15, 2025 · 0 comments

Comments

@holdenmatt
Copy link

I believe this is a bug caused by a stale data issue with SWR.

Steps:

  1. Create an artifact of some type (such as a sheet)
  2. Open it and make an edit, wait for it to save
  3. Make a 2nd edit, wait for it to save
  4. Click "View previous version", then "Restore this version" in the footer

Expected:

  • The previous version is restored

Actual:

  • Both edits are discarded, and document reverts to the first version (not the one that was visible on screen)

Note: This bug does NOT occur if you first focus on another window or tab, then return to the app's tab prior to clicking undo/restore (I think because SWR is revalidating on focus).

I believe the issue is that "revalidate" is set to false when we save new document versions, on this line:
https://github.com/vercel/ai-chatbot/blob/main/components/artifact.tsx#L164

So the client is working from stale data when it decides which document versions to delete. Changing "revalidate" to true there fixes the issue, but I'm not sure why it was there in the first place so I don't know if this will cause other issues?

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

1 participant