Do not suppress iOS encrypted push on stale focus#44
Merged
Just-Insane merged 1 commit intoJun 13, 2026
Conversation
|
Deploying with
|
| Status | Preview URL | Commit | Alias | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! | https://pr-44-sable.justin-tech.workers.dev | 7b80727 | pr-44 |
Sat, 13 Jun 2026 15:47:43 GMT |
There was a problem hiding this comment.
Pull request overview
This PR adjusts service-worker handling for encrypted “minimal” push payloads to avoid suppressing OS notifications based on potentially stale WindowClient.focused state (notably on iOS standalone PWAs).
Changes:
- Introduces a small helper (
getEncryptedMinimalPushFocusDecision) and corresponding unit test. - Updates encrypted minimal-push handling to stop early-suppressing notifications purely due to focused clients, and adds a new telemetry event (
stale_focus_ignored) to track the scenario.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/sw/pushRouting.ts |
Adds a helper/type to decide how to treat focused clients for encrypted minimal push suppression. |
src/sw/pushRouting.test.ts |
Adds a unit test for the new helper. |
src/sw.ts |
Changes encrypted minimal push behavior and adds telemetry event stale_focus_ignored. |
Comment on lines
897
to
909
| const focusedClientCount = focusedWindowClientCount(windowClients); | ||
| const browserVisibleClientCount = visibleWindowClientCount(windowClients); | ||
| if (focusedClientCount > 0) { | ||
| await recordPushTelemetry('confirmed_visible', { | ||
| if (getEncryptedMinimalPushFocusDecision(focusedClientCount) === 'ignore_stale_focus') { | ||
| // iOS standalone PWAs can report a bfcached/background page as focused. | ||
| // A push event is our only reliable wake-up path in that state, so do not | ||
| // let stale WindowClient focus suppress the OS notification. | ||
| await recordPushTelemetry('stale_focus_ignored', { | ||
| payload_type: 'minimal', | ||
| focused_client_count: focusedClientCount, | ||
| browser_visible_client_count: browserVisibleClientCount, | ||
| visibility_state: result?.visibilityState ?? 'unknown', | ||
| }); | ||
| await recordPushTelemetry('suppressed_visible', { | ||
| payload_type: 'minimal', | ||
| focused_client_count: focusedClientCount, | ||
| browser_visible_client_count: browserVisibleClientCount, | ||
| visibility_state: result?.visibilityState ?? 'unknown', | ||
| }); | ||
| return; | ||
| } |
Comment on lines
+38
to
+44
| export type EncryptedMinimalPushFocusDecision = 'ignore_stale_focus' | 'no_focused_client'; | ||
|
|
||
| export function getEncryptedMinimalPushFocusDecision( | ||
| focusedClientCount: number | ||
| ): EncryptedMinimalPushFocusDecision { | ||
| return focusedClientCount > 0 ? 'ignore_stale_focus' : 'no_focused_client'; | ||
| } |
Comment on lines
+46
to
+49
| it('ignores focused clients for encrypted minimal push suppression', () => { | ||
| expect(getEncryptedMinimalPushFocusDecision(0)).toBe('no_focused_client'); | ||
| expect(getEncryptedMinimalPushFocusDecision(1)).toBe('ignore_stale_focus'); | ||
| }); |
11 tasks
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.
Description
Fixes #
Type of change
Checklist:
AI disclosure: