Skip to content

fix(main): harden window readiness and offline startup handling - #515

Merged
khaira777 merged 7 commits into
mainfrom
fm/flocafe-514-window-readiness-review-fix
Aug 24, 2026
Merged

khaira777 merged 7 commits into
mainfrom
fm/flocafe-514-window-readiness-review-fix

Conversation

@khaira777

@khaira777 khaira777 commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Synchronize and rebase green PR #515 onto the current main using the supported no-mistakes pipeline, rerun review, tests, documentation, lint, push, PR, and CI handling, and merge PR 515 only after it is green and mergeable. Preserve all corrected PR 514 scope and original changes, do not merge or close PR 514 until PR 515 is confirmed merged, then verify PR 515 contains all original PR 514 changes before closing PR 514 as superseded through the guarded project workflow. Do not use raw git push/merge/force operations or a competing validation run.

What Changed

  • Hardened Electron window readiness across full-document navigations, early renderer registration, fallback controls, and light title-bar overlay synchronization.
  • Improved service-worker startup/offline handling by avoiding cached failures, reusing valid shells for navigation errors, and returning valid offline responses.
  • Added regression coverage and test wiring for service-worker behavior, readiness navigation semantics, IPC sender validation, and related documentation.

Risk Assessment

⚠️ Medium: The change spans Electron readiness, IPC validation, and service-worker fallback boundaries, but review found no concrete source defect or intent contradiction.

Testing

Focused automated tests, real macOS Electron control/fullscreen behavior, browser/LAN Playwright checks, and reviewer-visible screenshots all succeeded. Generated build/dependency/test outputs were removed from the worktree. Native Windows/Linux runtime behavior was not rerun on this macOS host.

Evidence: macOS Electron runtime probe

SUMMARY | 14/14 checks passed PASS | minimize/maximize IPC round-trip PASS | fullscreen enter/exit

INFO | environment | platform=darwin electron=43.4.1
PASS | mode-resolution: real environment decision matches contract | resolved=html-fallback (platform=darwin, electronMajor=43, overlayApiPresent=false)
PASS | mode-resolution: missing overlay API fails closed to html-fallback | overlayApiPresent=false -> html-fallback
PASS | mode-resolution: pre-33 Electron fails closed to html-fallback | electron 32.x -> html-fallback
PASS | mode-resolution: unknown platform fails closed to html-fallback | platform=sunos -> html-fallback
PASS | fallback-options: html-fallback builds without titleBarOverlay | titleBarOverlay present=false
PASS | fallback-options: titleBarStyle stays hidden/hiddenInset in fallback | titleBarStyle=hiddenInset
PASS | window-creation: main window created with resolved mode | mode=html-fallback
PASS | overlay-config: real macOS BrowserWindow receives hiddenInset and centered traffic lights | titleBarStyle=hiddenInset trafficLightPosition={"x":16,"y":14}
PASS | window-action: unsupported verbs are rejected | action='explode' rejected
PASS | window-action: minimize via IPC verb works | isMinimized()=true after minimize
PASS | window-action: toggle-maximize via IPC verb maximizes | isMaximized()=true
PASS | window-action: toggle-maximize restores | isMaximized()=false after second toggle
PASS | fullscreen: enters native fullscreen | isFullScreen()=true
PASS | fullscreen: exits native fullscreen cleanly | isFullScreen()=false
SUMMARY | 14/14 checks passed
Evidence: Live Electron renderer readiness observation

{"url":"http://localhost:3001/setup/","readySurface":true,"fallbackControls":true,"titleBarMode":"html-fallback","titleBarEpoch":2}

{
  "url": "http://localhost:3001/setup/",
  "title": "Flo",
  "readySurface": true,
  "fallbackControls": true,
  "status": {
    "server": "running",
    "kdsServer": "running",
    "serverApp": "running",
    "memory": {
      "heapUsed": 23,
      "heapTotal": 36,
      "rss": 196
    },
    "uptime": 2.461951666,
    "port": 3001,
    "titleBarMode": "html-fallback",
    "titleBarEpoch": 2,
    "titleBarDocumentNonce": "89345bbc-df8e-4901-9701-e7829033d5e8"
  },
  "bodyText": "Welcome to FloCafe\n\nCreate the owner account and choose the restaurant setup.\n\nChoose Your Language\n\nPick the language for this setup flow before choosing the c"
}
  • Evidence: Browser POS surface with Electron-only chrome absent (local file: ~/.no-mistakes/evidence/01M0TW5PHCG093X5Y6GYNMJCRH/browser-pos-titlebar-boundary.png)
  • Evidence: Desktop fallback controls visual evidence (local file: ~/.no-mistakes/evidence/01M0TW5PHCG093X5Y6GYNMJCRH/flocafe-runtime-ready.png)
  • Outcome: 🔧 1 issue found → auto-fixed ✅ across 2 runs (24m21s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed ✅
  • 🚨 main/index.ts:464 - The listener treats its first callback argument as navigation details, but Electron 43.4.1 emits did-start-navigation with positional arguments (event, url, isSameDocument, isMainFrame, ...) (runtime source). Therefore isFullDocumentMainFrameNavigation(details) receives the event object, returns false for every navigation, and never resets readiness on reloads. Bind the actual positional arguments or normalize the payload before calling the helper.

🔧 Fix: Normalize Electron navigation arguments before resetting readiness
✅ Re-checked - no issues remain.

🔧 **Test** - 1 issue found → auto-fixed ✅
  • ⚠️ main/window-readiness.ts:60 - One cold Electron launch logged the 10-second renderer readiness fail-safe for epoch 2. A subsequent instrumented launch mounted controls successfully and reload invalidation passed, so this appears transient but should be repeated on a clean first-run environment before claiming cold-start readiness is fully deterministic.
  • npm ci --ignore-scripts
  • npm run test:window-readiness
  • npm run test:service-worker
  • npm run test:kds-window-hardening
  • npm run test:titlebar-window-options
  • npm run test:electron-api-contract
  • npm run build
  • npm run build:frontend
  • npx electron tests/platform-titlebar-runtime-probe.cjs
  • Live Electron launch with CDP inspection of setup UI, readiness controls, epoch/nonce state, and page.reload() invalidation
  • screencapture desktop evidence capture

🔧 Fix: Restored locked dependencies; readiness test now passes
✅ Re-checked - no issues remain.

  • npm run test:window-readiness
  • npm run test:titlebar-window-options
  • npm run test:electron-api-contract
  • npm run test:service-worker
  • npm run test:kds-window-hardening
  • npm run build
  • ./node_modules/.bin/electron tests/platform-titlebar-runtime-probe.cjs --fullscreen-check
  • npm run build:frontend
  • npm run test:e2e -- e2e/title-bar-platform.spec.ts
  • Inline Playwright authenticated POS capture and Electron-only DOM boundary check
  • screencapture -x -T 1 against the live Electron probe
  • Final clean-worktree and transient-output verification
✅ **Document** - passed

✅ No issues found.

🔧 **Lint** - 1 issue found → auto-fixed ✅
  • ⚠️ main/ipc.ts:92 - Focused ESLint passes with 0 errors, but main/ipc.ts retains 15 no-explicit-any warnings; this matches the base commit and needs broader IPC typing cleanup.

🔧 Fix: Remove IPC any lint warnings
✅ Re-checked - no issues remain.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR hardens Electron renderer-readiness tracking and service-worker failure handling while keeping the native title bar aligned with the renderer’s light-only palette.

  • Resets readiness only for full-document main-frame navigations and binds readiness to the current frame, epoch, and document nonce.
  • Ensures handled service-worker fetch failures resolve to valid responses, avoids caching server errors, and invalidates the previous cache generation.
  • Pins title-bar overlay colors to the light palette and updates focused tests and platform documentation.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains in the eligible follow-up review scope.

No blocking failure remains.

Important Files Changed

Filename Overview
main/window-readiness.ts Adds full-document main-frame navigation classification while retaining epoch, nonce, stale-frame, and fail-safe protections.
main/ipc.ts Adds narrowly scoped early document registration with main-window, current-frame, origin, epoch, and nonce validation.
main/index.ts Moves readiness resets to qualified navigation events, wires main-window lookup into IPC registration, and pins overlay creation to the light palette.
frontend/public/sw.js Makes network and cache failure paths return valid responses, avoids caching failed startup responses, and advances the cache generation.
tests/window-readiness.test.ts Extends regression coverage for navigation classification, stale readiness reports, reload invalidation, and fail-safe behavior.
tests/service-worker.test.cjs Adds behavioral coverage for failed subresources, offline navigation, startup errors, cache cleanup, and API bypass behavior.

Sequence Diagram

sequenceDiagram
    participant Main as Electron main
    participant Nav as WebContents navigation
    participant Preload as Current preload
    participant Renderer as Renderer UI

    Main->>Main: beginRendererDocument()
    Nav->>Main: did-start-navigation
    alt full-document main-frame navigation
        Main->>Main: advance epoch and clear nonce/readiness
    else same-document or subframe navigation
        Main->>Main: preserve current readiness
    end
    Preload->>Main: window-document(documentNonce)
    Main->>Main: validate window, frame, origin, and nonce
    Renderer->>Main: window-ready(epoch, documentNonce)
    Main->>Main: validate current frame, epoch, and nonce
    Main->>Renderer: show window
Loading

Reviews (2): Last reviewed commit: "no-mistakes(lint): Remove IPC any lint w..." | Re-trigger Greptile

@khaira777
khaira777 force-pushed the fm/flocafe-514-window-readiness-review-fix branch from a7cf5fa to 5e370ce Compare August 24, 2026 22:40
@khaira777 khaira777 changed the title fix: harden desktop readiness and service-worker startup handling fix(main): harden window readiness and offline startup handling Aug 24, 2026
@khaira777
khaira777 merged commit cf9af85 into main Aug 24, 2026
14 checks passed
@khaira777
khaira777 deleted the fm/flocafe-514-window-readiness-review-fix branch August 24, 2026 22:49
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