Fix PWA energy kills with visibility-aware background pausing#36
Merged
Conversation
Safari terminates PWAs that consume significant energy in the background. This adds visibility-aware pausing for SSE, health polling, WS reconnects, release manager polling, and CSS animations. Also adds an energy metrics tracker that persists to localStorage and beacons to the backend for post-mortem diagnostics. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Require agents to run type checking, web finalization, e2e tests, and unit tests before marking any task as done. Added to both CLAUDE.md and AGENTS.md to cover Claude Code and Codex agents. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
document.hiddencheck — prevents reconnect loops from firing in the backgroundhtml[data-hidden]attribute — stops GPU-compositedwill-change: transformanimation from consuming energyweb/src/lib/energy-metrics.ts) that records SSE events, reconnects, HTTP requests, health poll fires/skips, visibility transitions, and hidden duration. Persists tolocalStorageevery 30s and beacons to/api/v1/energy-reporton visibility change to hidden — survives Safari's forced reload for post-mortem diagnostics/api/v1/energy-reportendpoint that logs beacon payloads for server-side inspectionCLAUDE.mdandAGENTS.md— agents must now run type checking, web finalization, e2e tests, and unit tests before marking any task as doneContext
Safari's energy watchdog kills PWAs that consume "significant energy" while backgrounded. The app had several sources of continuous background activity: an always-open SSE connection, 8s health poll timer, WebSocket reconnect loops, and infinite CSS animations with
will-change: transform.Test plan
npm run finalize:webpasses (TypeScript check + production build)e2e/energy-visibility.spec.ts)data-hiddenattribute toggles correctly via Playwright🤖 Generated with Claude Code