feat: open single file from disk with linked autosave#4
Merged
Conversation
Add an "Open File" button to the workspace sidebar that opens one file via showOpenFilePicker and keeps it linked, so edits autosave back to that exact file on disk independently of folder-workspace mode. New single-file handle API in disk-workspace.js (openSingleFile, linkSingleFile, writeSingleFile, unlinkSingleFile, unlinkAllSingleFiles, restoreSingleFiles) with IndexedDB-persisted handles that survive reloads, plus M.wsOpenDiskFile() in workspace.js. Fixes found via multi-agent review: - critical: edits never reached disk — per-keystroke autosave (cloud-share.js saveToLocalStorage) only wrote in folder mode; added single-file write-back branch + pagehide/beforeunload flush - major: request readwrite permission in-gesture on open; per-id write serialization queue; guard delete/rename so single-linked files never trigger folder-mode removeEntry/renameFileInPath; don't truncate the last file; unlink single-file handles on folder connect/reconnect instead of orphaning them - minor: no redundant write on open, orphan-handle pruning, persistence-failure warning, preserve .txt/.log extension on rename, no auto cloud copy for local files Verified live + 30 passing disk-workspace.spec.js tests, no regressions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
# Conflicts: # README.md
The .claude/ directory holds machine-specific Claude Code config, a scheduled-task lock, launch.json, and session worktrees — none of which belong in the repo. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…branch}})
docker/metadata-action used type=sha,prefix={{branch}}- but {{branch}} is
empty on pull_request events, producing an invalid tag :-<sha>. Use a static
sha- prefix; branch/PR identity is still captured by the ref-based tag rules.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What
Adds an "Open File" button to the workspace sidebar that opens a single file from disk via
showOpenFilePickerand keeps it linked — edits autosave straight back to that exact file on disk, independently of the existing folder-backed workspace mode.Originally requested because clicking New Document → Open Folder only let you connect a whole folder; there was no way to open and edit one file from disk.
How it works
disk-workspace.js— new single-file handle API:openSingleFile,linkSingleFile,hasSingleFile,writeSingleFile,unlinkSingleFile,unlinkAllSingleFiles,restoreSingleFiles. Handles are persisted to IndexedDB (file:<id>keys) so links survive reloads.workspace.js—M.wsOpenDiskFile()reads the picked file into a deduped, manually-named workspace entry and links its handle; delete/rename paths are guarded so single-linked files never trigger folder-mode I/O.cloud-share.js— the real per-keystroke autosave now writes back to the linked file.index.html— thews-open-filebutton.Bugs found via multi-agent review and fixed
A deep multi-agent review (4 dimensions × adversarial verification, 16 verified findings) caught that the first implementation looked done but didn't actually save to disk on the main path. All fixed:
saveToLocalStorage) only had a folder-mode branchpagehide/beforeunloadflushreadwritepermission in the click gesture on openhasSingleFileguards skip folder-moderemoveEntry/renameFileInPathunlinkAllSingleFiles()on rebuild.mdforced onto.txt, unwanted cloud copyTesting
disk-workspace.spec.js: 30 passing, no regressions (the one pre-existing modal-click flake fails identically onmain).🤖 Generated with Claude Code