Skip to content

Do not suppress iOS encrypted push on stale focus#44

Merged
Just-Insane merged 1 commit into
integrationfrom
codex/fix-ios-background-push-suppression
Jun 13, 2026
Merged

Do not suppress iOS encrypted push on stale focus#44
Just-Insane merged 1 commit into
integrationfrom
codex/fix-ios-background-push-suppression

Conversation

@Just-Insane

Copy link
Copy Markdown
Collaborator

Description

Fixes #

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

AI disclosure:

  • Partially AI assisted (clarify which code was AI assisted and briefly explain what it does).
  • Fully AI generated (explain what all the generated code does in moderate detail).

Copilot AI review requested due to automatic review settings June 13, 2026 15:45
@Just-Insane Just-Insane merged commit dca8bba into integration Jun 13, 2026
10 of 11 checks passed
@github-actions

Copy link
Copy Markdown

⚠️ Missing changeset

This pull request does not include a changeset. Please add one before requesting review so the change is properly documented and included in the release notes.

How to add a changeset:

  1. Run pnpm run document-change (interactive) and commit the generated file, or
  2. Manually create .changeset/<descriptive-name>.md:
---
default: patch
---

Short user-facing summary of the change.

Replace patch with major, minor, patch, docs, or note as appropriate.

📖 Read more in CONTRIBUTING.md.

If this PR is internal/maintenance with no user-facing impact, a maintainer can add the internal label to skip this check.

@Just-Insane Just-Insane deleted the codex/fix-ios-background-push-suppression branch June 13, 2026 15:46
@github-actions

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread src/sw.ts
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 thread src/sw/pushRouting.ts
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');
});
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.

2 participants