Repository navigation
Conversation
…ave on close (storytold#4847) Turning AutoSave on for a workbook without an .xlsx file runs Save As first; AutoSave turns on only once the workbook has a file, and the switch shows on only when AutoSave can save the active workbook. Unsaved changes are saved in batches: after 10 changes, or 30 s after the first unsaved change. A failed save turns AutoSave off and says why. Closing a workbook or quitting with AutoSave on saves it instead of asking. The title bar shows Saving…, Saved or Not saved to a file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. CodeRabbit Verify
|
This branch has not been deployed
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.
AutoSave now works for a new workbook: turning it on asks where to save first. Changes are saved in batches instead of rewriting the file every couple of seconds, and closing a workbook with AutoSave on saves it instead of asking.
Fixes #4847. Part of #4082: covers the CSV case reported there, not the macOS reopen problem.
What the user saw
Cause
toggle_autosaveonly flippedUiState::autosave.SheetApp::autosavethen skipped every workbook whose path was not.xlsx, and ignored the result offile.save. Closing never looked at AutoSave.What changed
All in
crates/ui-egui:toggle_autosave,app/files.rs): for a workbook without an .xlsx file, Save As runs first. AutoSave turns on only if the workbook then has an .xlsx file, so a cancelled save leaves it off. Without a file picker (web), it stays off with a message. Turning it off is unchanged.SheetApp::autosave_active): the switch and the Options checkbox are on only when the preference is on and the active workbook has an .xlsx file. With the preference on, a workbook without a file shows the switch off, and clicking it asks where to save that workbook instead of turning AutoSave off.SheetApp::autosave): unsaved changes are collected in a batch (GridState::autosave_batch), counted withDocState::revision. The batch is saved when 10 changes have piled up, or 30 s after its first change, whichever comes first. As before, it waits while a cell or text box is being edited. Switching workbooks starts a new batch. The repaint request waits for the batch's deadline instead of firing every 2 s.continue_quit,app/quit.rs) and when closing one workbook (its window's close button runswindow.close, or File › Close:open_dialogintercepts the engine's Save Changes request and closes the workbook as answering Save would). A workbook without a file, or one whose save fails, is still asked about. This overlaps Save latest edits before quitting with AutoSave #2973.SheetApp::autosave_status): next to the switch, while the preference is on, "Saving…" while changes wait for their batch, "Saved" once the file has them, and "Not saved to a file" for a workbook AutoSave can't write to.The engine's
file.saveand the persisted preference (#1995) are untouched. Version history and a registered command for the switch are left for their own issues.Tests
New:
turning_autosave_on_asks_to_save_a_workbook_without_a_file: with no file picker, AutoSave stays off and a message shows; a cancelled save leaves it off; a picked file is saved as .xlsx and AutoSave turns on. With the preference on, a workbook without a file shows the switch off, and clicking it saves that workbook first.autosave_waits_after_a_single_change: one fresh change is not saved yet and waits in a batch.autosave_saves_a_burst_of_changes_at_once: enough changes in a row are saved before the delay, and the save leaves the workbook clean.autosave_status_follows_the_unsaved_changes: the status reads differently while changes wait and once they are saved, differs again for a workbook with no file, and is absent while AutoSave is off.closing_with_autosave_saves_instead_of_asking(tests/it/file_menu.rs): with AutoSave on, closing the window writes the change to the file and closes without asking; a new workbook without a file is still asked about.closing_a_workbook_window_with_autosave_saves_instead_of_asking(tests/it/file_menu.rs):window.closeon a workbook with AutoSave on writes the change and closes it without asking.Changed:
a_logic_only_tick_autosaves_a_dirty_workbook_oncebackdates the batch past the 30 s delay instead oflast_autosavepast 2 s. It checks the same thing.autosave_survives_a_restartgives its workbook an .xlsx path first, since AutoSave now turns on only for a workbook with a file.Verification
Local run on Linux (CachyOS, Hyprland/Wayland), rustc 1.100.0, on top of
main3bed16a:cargo test -p gridcraft-ui-egui --no-fail-fast: every binary passes except 2 tests intests/it,interaction::column_autocomplete_folds_case_beyond_asciiandinteraction::language_switch_renders_the_ribbon_and_persists. They panic with "No glyph for ẞ" because this machine has noCRAFT_FONTS_DIR. They fail the same way onmainwithout this change.toggle_autosaveput back,turning_autosave_on_asks_to_save_a_workbook_without_a_filefails. Without theopen_dialogchange,closing_a_workbook_window_with_autosave_saves_instead_of_askingfails.cargo clippy -p gridcraft-ui-egui --all-targets -- -D warnings: clean.cargo fmt --all -- --check: clean.cargo xtask layers,cargo xtask assets,cargo xtask wasm,cargo xtask parity(no change todocs/parity-checklist.md),cargo xtask i18n-report: ran, no errors.New user-facing strings are in English only, through the translation system. The switch's label and tooltip are unchanged.
Accessibility
No new control. The switch and the Options checkbox are the same widgets. The status next to the switch is a plain text label in the title bar's dim text colour, read by screen readers, and it doesn't rely on colour. The new messages use the existing message box, which is reachable and dismissible by keyboard.
🤖 Generated with Claude Code