Skip to content

fix(client): harden PWA push resume and SW session recovery#116

Merged
Just-Insane merged 9 commits into
integrationfrom
codex/fix-pwa-push-resume-recovery
Jun 17, 2026
Merged

fix(client): harden PWA push resume and SW session recovery#116
Just-Insane merged 9 commits into
integrationfrom
codex/fix-pwa-push-resume-recovery

Conversation

@Just-Insane

@Just-Insane Just-Insane commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Description

Fix background push and resumed-PWA notification regressions by keeping web push durably registered and letting the service worker decide notification ownership at delivery time.

This replaces the fragile visibility-driven pusher lifecycle with a live foreground probe:

  • the service worker pings controlled clients when a push arrives
  • OS notifications are suppressed only when a page responds quickly and proves it is actively foregrounded
  • if the page is suspended, stale, missing permission, or otherwise unreachable, notification delivery falls back safely instead of silently disappearing
  • invite notifications stay push-owned only when web push is actually ready, preserving foreground invite fallback when registration or permission is missing

This PR also keeps the service-worker/session recovery work from this branch:

  • reconcile web-push registration on startup for already-enabled users whose pusher was deleted by the old visibility logic
  • preserve resumed-PWA media fetches by keeping overlapping live-session waiters independent instead of letting one timeout cancel the rest
  • retry authenticated media fetches against a live session when resumed tabs temporarily answer with stale persisted auth

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

@github-code-quality

github-code-quality Bot commented Jun 16, 2026

Copy link
Copy Markdown

Code Coverage Overview

Languages: JavaScript

JavaScript / code-coverage/vitest

The overall coverage in the branch remains at 22%, unchanged from the branch.

Show a code coverage summary of the most impacted files.
File 892f35c 99e9968 +/-
src/app/state/p...Subscription.ts 40% 0% -40%
src/app/feature...tifications.tsx 69% 73% +4%
src/app/hooks/u...ppVisibility.ts 75% 80% +5%
src/app/pages/c...ationRouting.ts 0% 100% +100%

Updated June 17, 2026 01:09 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5582243e3a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sw.ts Outdated
@Just-Insane Just-Insane force-pushed the codex/fix-pwa-push-resume-recovery branch from 5582243 to 1bfdc28 Compare June 16, 2026 23:49

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1bfdc28089

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/app/hooks/useAppVisibility.ts
Comment thread src/app/pages/client/ClientNonUIFeatures.tsx Outdated
Comment thread src/app/pages/client/ClientNonUIFeatures.tsx Outdated
Comment thread src/app/pages/client/ClientNonUIFeatures.tsx Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1707ea5ea4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/app/pages/client/ClientNonUIFeatures.tsx Outdated
Comment thread src/sw.ts Outdated
Comment thread src/app/pages/client/ClientNonUIFeatures.tsx Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 30da22699f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sw.ts Outdated
Comment thread src/app/hooks/useAppVisibility.ts Outdated
Comment thread src/app/pages/client/ClientNonUIFeatures.tsx Outdated
Comment thread src/sw/pushRouting.ts Outdated
Comment thread src/app/pages/client/notificationRouting.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c4a564f326

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sw.ts Outdated
Comment thread src/app/pages/client/notificationRouting.ts Outdated
@Just-Insane Just-Insane merged commit 303c3f4 into integration Jun 17, 2026
13 of 14 checks passed
@Just-Insane Just-Insane deleted the codex/fix-pwa-push-resume-recovery branch June 17, 2026 01:09

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 99e996840e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +531 to +536
if (
shouldDeferMessageNotificationToPush(
usePushNotifications,
document.visibilityState,
document.hasFocus()
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Gate message deferral on usable push

When usePushNotifications is true but web push is not actually usable (for example the browser subscription is missing, Notification.permission is default/denied, or the startup reconciliation skipped), this return runs for hidden or merely unfocused message events and exits before the fallback OS notification, audio, and visible-page banner paths below. Since the service worker cannot deliver a push in those states, users with a stale/default push setting can get silent background messages; mirror the invite path by checking a pushReady condition before deferring.

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

Status Preview URL Commit Alias Updated (UTC)
✅ Deployment successful! https://pr-116-charm.justin-tech.workers.dev 99e9968 pr-116 Wed, 17 Jun 2026 01:09:52 GMT

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