Skip to content

Make the built-in updater more robust and remove reliance on a specific update path - #257

Merged
ZFordDev merged 5 commits into
mainfrom
254-make-the-built-in-updater-more-robust-and-remove-reliance-on-a-specific-update-path
Sep 1, 2026
Merged

Make the built-in updater more robust and remove reliance on a specific update path#257
ZFordDev merged 5 commits into
mainfrom
254-make-the-built-in-updater-more-robust-and-remove-reliance-on-a-specific-update-path

Conversation

@ZFordDev

@ZFordDev ZFordDev commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Summary

Makes the built-in updater more robust and removes reliance on a single update path (issue #254).

Previously a downloaded update was tied to the Tools → Update → "Restart to Update" sequence, and simply closing SnapDock did not reliably apply it. This PR makes a downloaded update a persistent pending update that remains until successfully applied, and provides several equivalent ways to apply it.

Changes by phase

1. Persistent pending-update state

  • New src/modules/updater/pendingUpdate.js: writes/reads/clears a pending-update.json marker in the application-data directory when a download finishes.
  • The renderer can query the persisted state at startup via the new update:pending IPC, so a previously-downloaded update is recognized without re-downloading.

2. Multiple apply paths

  • Closing SnapDock (or Save → Close Project) while an update is pending now applies it (finishWindowClosequitAndInstall), making the long-standing "close to update" prompt truthful.
  • The status-bar ready indicator is now clickable to apply the update.
  • The existing Tools menu action is retained.
  • setupUpdater() now returns a handle (hasPendingUpdate() / applyPendingUpdate()) so the main process can drive applies independently of the UI.

3. Centralized updater state machine

  • ui/dropdownMenus.js now drives both the Tools button and footer from a single state: idle/available/checking/downloading/ready/installing/upToDate/error/disabled.
  • Added CSS modifiers for every state (header.css, footer.css); removed dead #update.* styles in modal.css that targeted a nonexistent #update ID.
  • Distinct available (detected, not downloaded) vs ready (downloaded) states.

4. Robustness & recovery

  • pendingUpdate.resolvePendingUpdate() compares the running version against the marker on startup to distinguish applied / ready / stale (interrupted install). Stale/interrupted markers are cleared and a recovery message is shown.
  • Install markers are no longer cleared optimistically before quitAndInstall(); they survive the install so success is verifiable on next launch.
  • Added an explicit GitHub publish provider to package.json so the update feed is not resolved implicitly from repository.url.

5. Documentation

  • Updated the bundled user guide and (in a separate DocsHub repo, not yet pushed) the online snapdock docs.

Verification

  • Renderer bundle builds cleanly (node scripts/bundle.js).
  • npm test passes with the same 2 pre-existing link-navigation failures already present on main (Windows path-separator issue, unrelated to this work).

Files changed

  • src/modules/updater/pendingUpdate.js (new)
  • src/modules/updater/download.js
  • src/modules/updater/index.js
  • src/modules/ui/dropdownMenus.js
  • src/preload.js
  • src/styles/components/header.css
  • src/styles/components/footer.css
  • src/styles/components/modal.css
  • main.js
  • package.json
  • assets/resources/docs/user_guide.md

Closes #254

Add a pending-update.json marker in userData so a downloaded update
survives closing and reopening SnapDock. The update is written when
electron-updater finishes downloading and cleared on install. The
renderer can query the persisted state at startup via update:pending
so a previously-downloaded update is recognized without re-downloading.
Drive the Tools->Update button and footer indicator from a single updater
state (idle/available/checking/downloading/ready/installing/upToDate/
error/disabled) so they never drift out of sync. The state machine also:

- Recognizes a persisted pending update at startup and surfaces the ready
  state immediately without re-downloading.
- Adds an explicit 'available' state distinct from 'ready' (downloaded),
  so a newly-detected update is not incorrectly labeled as installable.
- Wires the footer indicator to download (available) or install (ready)
  on click, giving a second apply path beyond the Tools menu.
- Adds CSS modifiers for every state (header.css + footer.css) and removes
  dead #update styles in modal.css that targeted a nonexistent ID.
Closing SnapDock while an update is downloaded and pending now applies it,
making the long-standing 'close to update' prompt truthful. finishWindowClose
checks for a persisted pending update first and routes through quitAndInstall()
so the update is applied after unsaved changes are resolved. setupUpdater now
returns a handle exposing hasPendingUpdate()/applyPendingUpdate() so the main
process can drive update application independently of the UI path.

Combined with the clickable footer and Tools menu action, a downloaded
update can now be applied via several equivalent exit/restart routes.
…onfig (#254)

Recovery:
- pendingUpdate.resolvePendingUpdate() compares the running version against
  the persisted pending marker on startup. If the app now runs the pending
  version, the update applied → marker cleared. If it is still on the old
  version, the update remains ready to apply. If neither matches, the install
  was interrupted → the stale marker is cleared and the UI surfaces a recovery
  message.
- installUpdate no longer clears the marker before quitAndInstall() so the
  marker survives the install and lets us detect success/failure on next
  launch (previously it was cleared optimistically).

Config:
- Add an explicit github publish block (owner/repo) to electron-builder so
  the update feed is not resolved implicitly from repository.url, removing
  reliance on a specific/assumed update path.
Document that a downloaded update stays pending until applied and can be
applied from the Tools menu, the status-bar indicator, or by closing
SnapDock.
@ZFordDev
ZFordDev merged commit bc33ab6 into main Sep 1, 2026
4 checks passed
@ZFordDev
ZFordDev deleted the 254-make-the-built-in-updater-more-robust-and-remove-reliance-on-a-specific-update-path branch September 1, 2026 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make the built-in updater more robust and remove reliance on a specific update path

1 participant