Skip to content

fix(main): make desktop update state reporting honest - #483

Merged
khaira777 merged 12 commits into
mainfrom
fm/flocafe-467-update-state-model
Aug 23, 2026
Merged

khaira777 merged 12 commits into
mainfrom
fm/flocafe-467-update-state-model

Conversation

@khaira777

@khaira777 khaira777 commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Follow-up correction for Greptile review on FloCafe PR #483 (issue #467, no merge): in frontend/src/app/(dashboard)/settings/page.tsx, disable the Check for Updates action when status is ready-to-install because the main process intentionally ignores checks while a staged update awaits installation; use the reviewer-suggested disabled condition, preserving the existing checking/available/downloading guards. Keep the ready-to-install/restart flow honest and do not add a Restart-Now confirmation dialog. Preserve all prior #467 requirements and pipeline fixes. Commit and push this correction to the existing PR, rerun required validation, and resolve the Greptile review thread. Do not merge.

What Changed

  • Added a unified Electron updater state model with explicit status and failure classifications, including offline, missing-manifest, staged-install, store-managed, Linux-managed, and development states.
  • Updated updater IPC synchronization and Settings UI with localized status/error messaging, browser-aware controls, and disabled checks while an update is checking, available, downloading, or ready to install.
  • Added unpacked-artifact marking during packaging and comprehensive update-state test coverage.

Risk Assessment

✅ Low: The reviewed updater state transitions, artifact classification, renderer synchronization, UI guards, translations, and accepted #467 requirements are consistent with no substantiated source defect.

Testing

Update-state tests passed and the desktop frontend build compiled successfully. Browser UI evidence could not be captured because no browser connection was available; transient dependencies/build output were removed afterward. Linters and the full suite were not run per phase constraints.

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed (7) ✅
  • ⚠️ main/index.ts:176 - The serialization guard only blocks checks after updaterPhase becomes download. A second check can still start through the Help menu while the first is checking; its later checking-for-update event can reset the shared phase to check after the first emits update-available, causing a subsequent download error to be classified as check-failed/unknown instead of check-failed/download-failed. Guard while storedUpdateStatus.status === 'checking' or use an in-flight attempt token.

🔧 Fix: Guard overlapping updater checks during active operations
1 warning still open:

  • ⚠️ main/update-state.ts:131 - The check-phase matcher treats any error text containing app-update.yml as check-failed/manifest-missing. A packaged build whose existing config is unreadable can produce EACCES ... app-update.yml, which is then shown as “No update package was found” instead of an unknown/configuration failure. Restrict this branch to missing-file/config-specific signatures or inspect the structured error while preserving true 404/channel-file mappings.

🔧 Fix: Restrict updater config errors to evidence-backed missing-file matches
1 error still open:

  • 🚨 main/index.ts:203 - A packaged non-store build whose resources/app-update.yml is missing is classified as dev-mode and returns before classifyUpdateError runs. That can hide a broken NSIS/ZIP/AppImage artifact as an expected development install and silently disable update checks. Distinguish explicitly unpacked/dev artifacts from packaged builds, or let packaged missing-config errors become check-failed/manifest-missing.

🔧 Fix: Surface packaged updater config failures honestly
2 issues (1 error, 1 warning) still open:

  • 🚨 main/index.ts:203 - The packaged-versus-unpacked decision still relies on isDev (NODE_ENV === 'development' || !app.isPackaged) at the changed branch around line 203, rather than an explicit artifact classifier. The repository’s electron-builder --dir workflow produces an unpacked directory while Electron can still report app.isPackaged === true; with no NODE_ENV=development and no app-update.yml, this path reaches missingUpdateConfigState(false, ...) and reports check-failed/manifest-missing instead of dev-mode. Conversely, a packaged non-store executable launched with NODE_ENV=development takes the dev-mode branch and suppresses updater checks. This contradicts the required criterion: “Preserve dev-mode only for explicitly unpacked/development artifacts. For packaged non-store builds, a missing resources/app-update.yml must be classified as the honest check-failed/manifest-missing state.” Use an explicit runtime artifact classification and cover the actual packaged/unpacked boundary.
  • ⚠️ main/index.ts:201 - !fs.existsSync(configPath) conflates an absent config with any stat failure. If a packaged build’s resources directory is unreadable (EACCES) or has another I/O error, existsSync returns false and line 213 reports manifest-missing before autoUpdater can surface the structured unreadable-config error that classifyUpdateError correctly maps to check-failed/unknown. Distinguish ENOENT from other filesystem errors (or let the updater classify them) so unreadable/configuration failures retain an honest generic failure reason.

🔧 Fix: Preserve structured updater configuration probe failures
1 error still open:

  • 🚨 main/index.ts:218 - isDev still controls the missing-config branch. With a packaged non-store build launched under NODE_ENV=development, a missing app-update.yml is silently reported as dev-mode instead of check-failed/manifest-missing; unpacked electron-builder --dir artifacts can likewise be misclassified based on app.isPackaged. Use an explicit runtime artifact classifier so only genuinely unpacked/development artifacts use dev-mode.

🔧 Fix: Classify updater mode by runtime artifact
2 issues (1 error, 1 warning) still open:

  • 🚨 main/update-state.ts:41 - The path heuristic treats any packaged executable under a directory named mac, win-unpacked, or linux-unpacked as development/unpacked. For example, a real packaged app at /tmp/mac/Flo Cafe.app/... returns true, so main/index.ts:224-227 reports dev-mode and skips config probing. This contradicts the required criterion that a packaged non-store build with missing app-update.yml must be check-failed/manifest-missing, even under development-like paths. Detect the actual unpacked artifact boundary rather than arbitrary parent-directory names.
  • ⚠️ frontend/src/hooks/useUpdateStatus.ts:32 - The initial IPC seed can overwrite a newer live event: if getUpdateStatus() reads downloading, then update-downloaded arrives and the listener sets ready-to-install, the stale IPC response later sets the renderer back to downloading, hiding the restart action until another updater event. Guard the seed against any live event received after subscription, or add a monotonic status revision.

🔧 Fix: Harden artifact classification and stale update seeding
1 error still open:

  • 🚨 main/update-state.ts:40 - The classifier still cannot distinguish this repository’s electron-builder --dir output from an installed package. That artifact can run with app.isPackaged === true and process.defaultApp === false, so line 40 returns false; checkForUpdates() then maps missing resources/app-update.yml at line 245 to check-failed/manifest-missing instead of the approved dev/unpacked behavior. Use an explicit artifact marker or supported launch-boundary signal without directory-name heuristics, and cover both artifact types behaviorally.

🔧 Fix: Mark unpacked builds without path heuristics
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • npm ci --ignore-scripts
  • npm run test:update-state
  • cd frontend && npm ci --ignore-scripts
  • NEXT_BUILD_MODE=desktop npm run build
  • Chrome connection check; no browser was available
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR introduces a unified desktop updater state model and keeps renderer state synchronized with the main process.

  • Disables update checks while an update is checking, available, downloading, or ready to install.
  • Adds explicit failure, offline, managed-install, development, and staged-install states with localized messaging.
  • Marks unpacked build artifacts explicitly and expands updater-state test coverage.

Confidence Score: 5/5

The PR appears safe to merge with no blocking updater-state failure remaining.

No blocking failure remains; the previously actionable install-ready update check is now disabled while the staged update awaits restart.

Important Files Changed

Filename Overview
frontend/src/app/(dashboard)/settings/page.tsx Updates the Settings UI for the expanded updater states and correctly disables checks when installation is ready.
frontend/src/hooks/useUpdateStatus.ts Synchronizes persisted and live updater state while preventing a stale initial response from replacing a newer event.
main/index.ts Centralizes updater transitions, guards concurrent and install-ready checks, and persists honest updater state for IPC.
main/update-state.ts Defines and classifies updater states, failures, runtime artifact modes, and IPC payloads.
scripts/mark-unpacked-artifact.cjs Marks unpacked packaging output so runtime updater behavior can distinguish it from installed artifacts.
tests/update-state.test.ts Adds focused coverage for updater classification, synchronization, serialization, and artifact-boundary behavior.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Desktop updater state] --> B{Current status}
  B -->|checking / available / downloading| C[Disable update check]
  B -->|ready-to-install| D[Disable update check and offer restart]
  B -->|store-managed / linux-managed| E[Hide in-app update controls]
  B -->|failure / offline| F[Show localized status and details]
  B -->|idle / completed check| G[Allow update check]
Loading

Reviews (5): Last reviewed commit: "no-mistakes(review): Mark unpacked build..." | Re-trigger Greptile

@khaira777
khaira777 force-pushed the fm/flocafe-467-update-state-model branch from 9b9b88b to fa783a9 Compare August 23, 2026 17:04
@khaira777 khaira777 changed the title fix(main): surface honest updater states fix(main): make desktop update state reporting honest Aug 23, 2026
@khaira777
khaira777 force-pushed the fm/flocafe-467-update-state-model branch from ab56649 to bd42de9 Compare August 23, 2026 18:54
…as up-to-date

Implements the app-side update state model for #467 (epic #463):

- Add main/update-state.ts: pure, unit-tested state machine with a
  persisted status enum (not-checked-yet | checking | up-to-date |
  available | downloading | ready-to-install | check-failed | offline |
  store-managed | linux-managed | dev-mode), error classification by
  electron-updater error code and phase, one-shot seeding helpers, and
  the IPC derivation function.
- main/index.ts: replace the substring mask that rendered 404/Cannot
  find latest/ENOENT errors as up-to-date; channel-file-not-found and
  404-class errors now map to check-failed (manifest-missing), network
  codes to offline, and download-phase failures to check-failed
  (download-failed). Classifications are logged at info level and an
  error path can never emit up-to-date. All transitions (including
  linux-managed/store-managed/dev-mode seeds) go through one stored
  state so renderer reloads recover it via get-update-status; store
  builds seed store-managed at startup instead of skipping silently.
- Renderer: extend the UpdateStatus.status union in electron.d.ts,
  thread reason/error through useUpdateStatus (plus an isElectron flag),
  and rework the Settings updates tab to render honest per-state panels
  with friendly failure copy and raw details behind a disclosure.
  Update controls are hidden entirely outside the desktop app instead
  of showing a dead Check button. New i18n keys added to en/es/pt/fa.

Tests: tests/update-state.test.ts covers every error class -> state
mapping, the full IPC derivation table, and one-shot seeding; wired
into npm test as test:update-state.

Discovered but not implemented here (out of scope): Restart-Now
confirmation dialog before quitAndInstall (code-scout F5).
@khaira777
khaira777 force-pushed the fm/flocafe-467-update-state-model branch from bd42de9 to 7c411f8 Compare August 23, 2026 19:03
@khaira777
khaira777 merged commit 4ddc30c into main Aug 23, 2026
13 checks passed
@khaira777
khaira777 deleted the fm/flocafe-467-update-state-model branch August 23, 2026 19:09
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.

1 participant