Web app: keep unsaved work in the browser instead of the leave-page box (#10220) (#10221)

* claim: #10220

* Web app: keep unsaved work in the browser instead of the leave-page box (#10220)

A new preference, off by default, on Preferences > General > Saving (web
app only): "Keep unsaved work in this browser instead of asking when the
tab closes". With it on, each open design with unsaved changes keeps a
copy in the browser's private storage (keep-<page>-<design>.sc/.json),
written once the design has been still for 0.8 s (at most 4 s after the
first change it lacks) and again on pagehide or when the page is hidden.
While every copy is current, beforeunload doesn't ask. A copy goes when
its design is saved, closed, or the preference is turned off.

The next visit offers the copies newer than their design's last save in
SolidCraft's own window, "Restore unsaved design: <name>, changed
<time>?", one window for several, with Restore, Open saved version, and
Discard. A page holds a Web Lock while it runs, so another open tab's
copies are never offered or removed.

With the preference off, the single autosave and the browser's prompt
work exactly as before.

* Web app: the restore window comes from the UI kit's recovery module (#10220)

The kit's text and divider helpers are private to the UI crate, so the
"Restore unsaved design?" window moves to recovery_ui
(browser_copies_window), beside the desktop recovery window, and the web
shell only maps its answer. Also keeps the window handle for the page
listeners instead of using the one moved into the app.

* Web app: restore window buttons sit in one row (#10220)

* Web app: keep unsaved work and still ask, unless told not to (#10220)

Keeping a copy in the browser no longer replaces the browser's leave-page
box by itself. A second option, shown once work is kept and on by default,
leaves the box in place; off, the box appears only while a copy isn't current.

* Web app: kept-copy review fixes (#10220)

A failed write of a kept copy waits 30 s before the next try, a recovery
copy is dropped only after the remembered saved file has opened, the
preference is documented under its current label, and the ui.prefs list
is sorted again.
This commit is contained in:
raykholo
2026-11-04 21:26:23 +00:00
committed by GitHub
parent 5562d9c6c8
commit 3aee35fe01
12 changed files with 1013 additions and 13 deletions
+13
View File
@@ -305,3 +305,16 @@ browser can write to a folder it saves back to that file, otherwise it works on
in the browser. Use **Rename** beside a stored file to change its name. Autosave and recovery
stay in the browser's private storage in every browser. Exports such as STEP and STL are
downloaded.
By default, closing or reloading the tab while a design has unsaved changes shows your browser's
own "Leave site?" box. To keep your work instead, turn on **Preferences → General → Saving →
Keep unsaved work in this browser**. SolidCraft then keeps a copy of each open design's unsaved
changes in this browser's private storage, updated about a second after each change and again
when the tab is hidden. Turning it on alone doesn't skip the box: it is skipped only when **Still
ask when the tab closes** is also off and every kept copy is current. A change made in the last
moment before closing can still bring the box up while its copy is written. On your next visit,
SolidCraft asks **Restore unsaved design: <name>, changed <time>?** (one window lists them all when
there are several). **Restore** opens the design with its changes, still unsaved, **Open saved
version** opens its file as last saved, and **Discard** drops the copy. A copy older than the
design's last save isn't offered. Closing a design inside SolidCraft (its tab's ×, **File → Close**
or Ctrl+W) still asks **Save changes to <name>?**, and **Don't Save** drops its copy.
+2
View File
@@ -722,6 +722,8 @@ One setting per line, sorted by name. A change that adds a setting adds its own
- `home_fit_size` (0.1…1, default 1: how much of the view the model fills when Home, Fit, an opened design or a navigator view change frames it, with `navigator_fit` on or off; 1 fills the room between the panels, the compass and the navigation bar, as before; #10091)
- `joint_rotation_coarse` (default 10°): coarse Assembly Move rotation step, in 0.001…180°.
- `joint_rotation_fine` (default 0.1°): fine Assembly Move rotation step, in 0.001…180°.
- `keep_unsaved_also_asks` (default true; web app, with `keep_unsaved_in_browser` on: the browser's "leave site?" box still appears when the tab closes with unsaved work; off, it appears only while a copy isn't current yet, #10220)
- `keep_unsaved_in_browser` (default false; web app: each open design's unsaved changes are kept current in the browser's private storage, and the next visit offers them back in a "Restore unsaved design?" window with Restore, Open saved version and Discard; off, nothing is kept, #10220)
- `keep_work_on_tab_switch` (default false: each design tab keeps its open dialog or tool, with what was picked and typed in it, and its toolbar tab while another design is shown, and has them back when it is shown again; off, a switch cancels them and shows MODEL, #9360)
- `language` (`en`, `ar`, `ja`, `de`, `fr`, `he`, `ko`, `ms`, `ru`, `uk`, `zh`; see [localization](localization.md))
- `length_decimals`