Repository navigation
feat(updates): add beta channel opt-in and safe restart guard - #506
Conversation
…le (#463) Restart-to-install guard: - main process authorizes manager/owner PIN via authorizeMasterPin inside the 'restart-and-install' handler before quitAndInstall, returning {success,error} instead of restarting on denial - new UpdateInstallGuardDialog shows a prominent red warning (all systems down during install, automatic return after restart, avoid business hours) and requires an explicit 4-digit PIN confirm; cancelling or an invalid PIN can never trigger a restart - UpdateBadge 'restart now' now opens the dialog instead of restarting directly; useUpdateStatus.restartAndInstall forwards the PIN Beta channel opt-in (#503 contract): - Settings > Updates gains a beta/pre-release toggle that feature-detects updates:get/set-beta-channel on electronAPI and renders visibly disabled with an explanation when absent - persisted state stays in the main process; renderer reflects get result and optimistically updates only after a successful set i18n keys added under update.* in en/es/pt/fa; new unit tests in tests/update-ui.test.ts (npm run test:update-ui).
…ged-file lint warnings
Greptile SummaryThis PR adds a backend-authoritative Master PIN gate and explicit downtime warning before installing a downloaded update. It also adds a feature-detected beta-channel toggle that remains visibly disabled until the sibling IPC implementation is available.
Confidence Score: 5/5The PR appears safe to merge, with the restart authorization enforced in the main process and the unavailable beta IPC contract handled through explicit feature detection. The changed restart path checks both update readiness and the existing Master PIN authorization before reaching
|
| Filename | Overview |
|---|---|
| main/index.ts | Adds the authoritative update-readiness and Master PIN checks before invoking quitAndInstall(). |
| frontend/src/components/updates/UpdateInstallGuardDialog.tsx | Adds an explicit PIN confirmation dialog with prominent localized downtime warnings and safe cancellation behavior. |
| frontend/src/components/layout/UpdateBadge.tsx | Replaces the direct restart action with the guarded installation dialog. |
| frontend/src/components/settings/BetaChannelToggle.tsx | Adds a feature-detected beta-channel control with disabled guidance and persisted-state loading. |
| frontend/src/lib/updates/beta-channel.ts | Adds defensive normalization and orchestration helpers for the sibling-owned optional beta-channel API. |
| frontend/src/lib/updates/restart-install.ts | Adds strict four-digit PIN submission checks and guarded IPC-result normalization. |
| main/preload.ts | Updates the existing restart bridge to forward the approval PIN without implementing the sibling beta-channel contract. |
| tests/update-ui.test.ts | Covers restart-result normalization, PIN submission rules, beta API feature detection, and beta read/write normalization. |
Sequence Diagram
sequenceDiagram
actor Operator
participant Badge as Update Badge
participant Guard as Install Guard Dialog
participant Preload as Electron Preload
participant Main as Main Process
participant Auth as Master PIN Service
participant Updater as electron-updater
Operator->>Badge: Select Restart Now
Badge->>Guard: Open downtime warning and PIN prompt
Operator->>Guard: Enter PIN and explicitly confirm
Guard->>Preload: restartAndInstall(pin)
Preload->>Main: invoke restart-and-install
Main->>Main: Verify update is ready
Main->>Auth: authorizeMasterPin(pin)
alt Approval denied
Auth-->>Main: Error
Main-->>Guard: success: false
Guard-->>Operator: Keep dialog open and show error
else Approval granted
Auth-->>Main: Approved
Main->>Updater: quitAndInstall()
end
Reviews (1): Last reviewed commit: "no-mistakes(document): Updated release d..." | Re-trigger Greptile
Intent
Implement the in-app update UX for FloCafe's beta channel and safe restarts (epic #463, policy decision #503).
Restart-to-install confirmation guard: before quitAndInstall() runs, require manager or owner PIN approval reusing the app's existing master-PIN mechanism (authorizeMasterPin in main/services/master-pin.ts) - do not invent a parallel credential store. The confirmation dialog must show a prominent RED warning stating: all systems (POS, KDS, printing, reports) go down while the update installs; service comes back automatically once the app restarts; and this should not be done during business hours. If PIN approval fails or is cancelled, do not restart - there must be no UI path to restart-to-install without approval. This builds on the honest update-state model from App-side update state model: stop masking 404s as up-to-date #467 (main/index.ts restart-and-install handler, frontend settings updates panel); the guard is a gate before quitAndInstall, not a new update status.
Beta channel opt-in toggle in Settings > Updates: calls the IPC contract owned by the sibling flocafe-beta-release-channel workstream: updates:set-beta-channel(enabled: boolean) and updates:get-beta-channel(): boolean. That crew owns main-process + preload implementation of those channels, so this PR must NOT implement them and must feature-detect: if window.electronAPI lacks these methods (getBetaChannel/setBetaChannel), render the toggle visibly disabled with a short explanation so the PR stays correct whether or not the sibling PR has landed. Persisted state lives on the main-process side; the renderer only reflects what get-beta-channel returns and optimistically updates after a successful set.
Acceptance criteria: restart-to-install without manager/owner PIN approval is impossible from any UI path; red warning copy present and readable with explicit confirm required (cannot be dismissed into a restart by accident); toggle renders per feature-detection rules; new UI strings go through i18n (en/es/pt/fa json files, npm run i18n:check passes); unit tests for new guard/toggle logic following existing node:test patterns (tests/update-ui.test.ts, npm run test:update-ui); lint and builds pass. Constraints: no changes to release workflows or electron-builder config (sibling crew owns those); no changes to the beta-channel IPC main/preload implementation itself.
Environment notes for pipeline agents: the pipeline worktree starts WITHOUT node_modules - run npm ci at repo root before running any test/build/lint step. Evidence must be assertion/log-based only - do NOT attempt browser screenshot capture.
What Changed
quitAndInstall()can run.Risk Assessment
✅ Low: The change is bounded and correctly enforces the PIN gate before quitAndInstall while safely feature-detecting the sibling beta-channel API.
Testing
Validated renderer guard and beta-channel logic, update-state readiness, preload contract, Master PIN authorization, translations across en/es/pt/fa, and the main-process restart gate. Missing or wrong PINs did not call quitAndInstall; approved PIN did. Evidence was assertion/log-based per the explicit environment requirement; no screenshots were attempted.
Evidence: Main guard evidence
Main IPC guard exercised actual handler andauthorizeMasterPin: missing PIN denied, wrong PIN denied, approved PIN restarted once.Evidence: Focused update UI tests
Evidence: Translation integrity tests
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
npm cinpm run test:update-uinpm run test:update-statenpm run test:master-pinnpm run test:electron-api-contractnpm run test:translationsDisposable mocked-Electron execution of the actualmain/index.tsrestart handler with actualauthorizeMasterPin()✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.