Add autosave support for File System Access API#330
Merged
tracygardner merged 2 commits intomainfrom Feb 27, 2026
Merged
Conversation
Once a user saves their project via the file picker (File System Access API), the returned FileSystemFileHandle is stored. The 30-second autosave interval now also writes to that file handle automatically, keeping the saved file in sync without prompting the user again. https://claude.ai/code/session_01SD7tmTxQf83oQYKAjTHUuV
When a new file or example was opened, currentFileHandle was never cleared, so the 30-second autosave kept writing back to the previously saved file. Now clearFileHandle() is called in all four load paths (file input, drag-and-drop, load example, new project) to reset the handle whenever the active project changes. https://claude.ai/code/session_01SD7tmTxQf83oQYKAjTHUuV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds autosave functionality for files saved via the File System Access API, allowing users to automatically save their work back to the same file without showing the file picker on subsequent saves.
Key Changes
currentFileHandlemodule-level variable to track the last explicitly saved file handle from the File System Access APIexportCode()to store the file handle when a user explicitly saves via the file pickerautoSaveToFile()function that writes workspace data to the previously saved file handle without user interactionmain.jsto call bothsaveWorkspace()(localStorage) andautoSaveToFile()(file system) every 30 secondsautoSaveToFile()to gracefully handle cases where the file handle is unavailable or invalidImplementation Details
https://claude.ai/code/session_01SD7tmTxQf83oQYKAjTHUuV