feat(ui): optional auto-save with manual save, Ctrl+S and unsaved-changes indicator - #227
Open
tomasmorello wants to merge 4 commits into
Open
feat(ui): optional auto-save with manual save, Ctrl+S and unsaved-changes indicator#227tomasmorello wants to merge 4 commits into
tomasmorello wants to merge 4 commits into
Conversation
Previously the editor always uploaded file contents 500ms after every keystroke, making it easy to persist half-finished or broken configs. - add a persisted auto-save flag (on by default, stored in localStorage) with a toggle switch in the editor toolbar - add a diskette save button to the text editor toolbar and the dockman.yml viewer header, enabled only when there are unsaved changes - add CTRL+S / CMD+S to save pending changes immediately; with auto-save enabled it flushes the debounce instead of waiting - track per-file dirty state and show a new 'Unsaved' indicator; warn via beforeunload when closing the tab with unsaved changes - fix a listener leak in MonacoEditor where onDidChangeContent handlers were re-registered on every reload without disposing the old ones
When auto-save is off, edits are now kept as an in-memory draft per file, so switching between tabs no longer discards unsaved changes. The draft is restored into the editor on return and cleared once the file is saved. Files with unsaved changes are marked with an amber dot on the left of the file tree, kept visually distinct from the docker status indicator on the right.
Give each file its own monaco model (unique per host/alias context) and keep it alive via keepCurrentModel, instead of recreating the editor and calling setValue on every file switch. This preserves the full undo/redo stack and unsaved content when moving between tabs. Content is reloaded when the active filename changes, and the auto-save tooltip now notes that unsaved changes survive tab switches but are lost on a full page reload.
Dirty state was set on any content change and never cleared until save, so undoing all edits (CTRL+Z back to the original) still showed the file as unsaved. Track the on-disk content as a baseline and mark a file dirty only when the editor content actually differs from it.
|
@tomasmorello is attempting to deploy a commit to the r334's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Closes #226
What
Makes auto-save optional. Current auto-save-on-every-keystroke stays the default;
users can now switch to manual saving to avoid persisting half-finished edits.
Changes
and Ctrl/Cmd+S (also flushes the debounce when auto-save is on; prevents the
browser save dialog).
restored when returning to the tab.
distinct from the existing docker status indicator on the right.
model (
keepCurrentModel) instead of recreating the editor +setValueon everyswitch. As a side effect this also fixed a listener leak where
onDidChangeContenthandlers were re-registered without disposal.(Ctrl+Z back to the original) correctly clears the "unsaved" state.
Design notes / limitations
reload (surfaced in the toggle's tooltip). Monaco has no public API to persist
the undo stack, so this is by design.
keepCurrentModel, models are not disposed while the app is open — memorygrows slightly per opened file until reload. Negligible for this use case;
disposing on tab-close could be a follow-up.
opts out.
How to test
dot appears then clears on save.
still there; save with the disk button or Ctrl+S ‚Üí indicator clears.
Scope
UI only — all changes are under
ui/src/pages/compose. No backend/proto changes.