Skip to content

Conversation

@Jatin24062005
Copy link
Contributor

Fixes #1405 #1390

Changes:
Autosave now starts immediately when an authenticated user edits the default file for the first time.
Added preference check (preferences.autosave) to ensure autosave only starts if enabled.
Implemented first-change tracking using useRef to trigger immediate autosave only once.
Regular autosave (every 5 seconds) remains unchanged after the first edit.
Added a toast notification (Toast.AutosaveStarted) to inform users when autosave is enabled.

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • has no test errors (npm run test)
  • is from a uniquely-named feature branch and is up to date with the develop branch.
  • is descriptively named and links to an issue number, i.e. Fixes #123

@raclim
Copy link
Collaborator

raclim commented Mar 13, 2025

Thanks for taking a look into this!

I do think this is a good feature to take on, but needs some diving into the prior conversations and maybe some research on how other platforms are integrating it. I think what's currently in this PR might run into the potential issue that was raised where we might be saving too many sketches that the user didn't intend to.

I personally think the design raised in this comment (#1390 (comment)) might be a good approach, since it still signals to the user that they have unsaved changes without necessarily saving it first.

Another issue we may potentially want to address here is how autosave is implemented and could be communicated better to users. I don't have any ideas here yet, but I think there are a few different opinions on it within the linked issues! I think we might want to dig through those first, and continue the discussion for how this can be implemented there!

@raclim raclim closed this Mar 13, 2025
@Jatin24062005
Copy link
Contributor Author

Jatin24062005 commented Mar 13, 2025

I’ve reviewed the concerns, and the current implementation aligns with the expected behavior:

  1. Unauthenticated users can not save their sketches, and this is working as intended.

  2. Autosave only triggers if the user is authenticated and has explicitly enabled the autosave preference.

  3. Users who don’t want autosave can simply turn it off, and the behavior remains the same as before.

I can Provide you the Video how it working if you want?

@raclim
Copy link
Collaborator

raclim commented Mar 13, 2025

The concern about saving sketches does apply only to authenticated users, as unauthenticated ones are not allowed to save any sketches without an account. The main concern revolves around saving sketches that a user did not intend to save. In this current setup, this might happen if a user starts editing a sketch.

The autosave feature is currently also toggled "on" as a default within the user preferences in server/models/user.js, so this behavior will probably start as a default.

  autosave: { type: Boolean, default: true },

Although it's true that a user can turn it off, we probably want to avoid having this as a default and ensure that the user actively chooses to save the sketch first. I do think we should gear towards a design similar to the one raised in the linked comment (#1390 (comment)).

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

Successfully merging this pull request may close these issues.

Feature request: auto save before run

2 participants