You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Build the browser push enrollment flow and notification preferences settings #1722
Browsers require notification permission to be requested from a user gesture. iOS/iPadOS additionally requires the web app to be installed on the Home Screen before Web Push enrollment is available. Users also need category, badge, and quiet-hour controls before push is enabled.
Requirements
Add a typed notification API client.
Add a hook that reports service-worker, Push API, permission, installation, and subscription state.
Convert the VAPID URL-safe public key correctly for PushManager.subscribe.
Request permission only from an explicit Enable button.
Register the subscription with the authenticated backend.
Support disabling push by revoking the backend subscription and unsubscribing locally.
Add notification preferences to Settings with category toggles, badge preference, timezone, and quiet hours.
Explain the iOS Home Screen requirement when applicable.
Surface missing VAPID configuration without showing a broken Enable button.
Reconcile an existing browser subscription after login or account changes.
Acceptance Criteria
No permission prompt appears on initial page load.
Enabling notifications from a user click creates one backend subscription.
Repeated enablement is idempotent.
Disabling removes both the browser and backend subscription.
Denied permission produces instructions instead of retry loops.
Settings persist after reload.
iOS Safari outside standalone mode tells the user to add ProPR to the Home Screen.
Separate the API client, browser capability hook, and settings presentation. This makes permission logic testable without rendering the full Settings page. Automatic permission requests were rejected because browsers block them, they create a poor trust experience, and iOS requires a direct user gesture. Preference saves are explicit to avoid silent network writes while toggling several controls.
File: propr-ui/src/api/notificationsApi.ts (new file)
Why this file: It gives the UI a typed boundary for notification configuration, preferences, subscriptions, Inbox state, and receipts.
File: propr-ui/src/hooks/usePushNotifications.ts (new file)
Why this file: Browser capability and permission transitions are asynchronous and platform-specific. A hook keeps these concerns out of the settings component.
import{useCallback,useEffect,useState}from'react';import{getNotificationConfig,registerPushSubscription,revokePushSubscription,}from'../api/notificationsApi';constdecodeVapidKey=(value: string): Uint8Array=>{constpadded=value+'='.repeat((4-value.length%4)%4);constbinary=atob(padded.replace(/-/g,'+').replace(/_/g,'/'));returnUint8Array.from(binary,character=>character.charCodeAt(0));};constisStandalone=(): boolean=>window.matchMedia('(display-mode: standalone)').matches||Boolean((navigatorasNavigator&{standalone?: boolean}).standalone);exportfunctionusePushNotifications(){constsupported='serviceWorker'innavigator&&'PushManager'inwindow&&'Notification'inwindow;const[configured,setConfigured]=useState(false);const[permission,setPermission]=useState<NotificationPermission>(supported ? Notification.permission : 'denied');const[subscribed,setSubscribed]=useState(false);const[busy,setBusy]=useState(true);const[error,setError]=useState<string|null>(null);constcurrentSubscription=useCallback(async()=>{if(!supported)returnnull;constregistration=awaitnavigator.serviceWorker.ready;returnregistration.pushManager.getSubscription();},[supported]);useEffect(()=>{if(!supported){setBusy(false);return;}Promise.all([getNotificationConfig(),currentSubscription()]).then(([config,subscription])=>{setConfigured(config.configured);setSubscribed(Boolean(subscription));}).catch(reason=>setError((reasonasError).message)).finally(()=>setBusy(false));},[currentSubscription,supported]);constenable=useCallback(async()=>{setBusy(true);setError(null);try{constconfig=awaitgetNotificationConfig();if(!config.configured||!config.vapidPublicKey)thrownewError('Web Push is not configured on this ProPR server');constnextPermission=awaitNotification.requestPermission();setPermission(nextPermission);if(nextPermission!=='granted')thrownewError('Notification permission was not granted');constregistration=awaitnavigator.serviceWorker.ready;constsubscription=awaitregistration.pushManager.subscribe({userVisibleOnly: true,applicationServerKey: decodeVapidKey(config.vapidPublicKey),});awaitregisterPushSubscription(subscription.toJSON()asParameters<typeofregisterPushSubscription>[0]);setSubscribed(true);}catch(reason){setError((reasonasError).message);}finally{setBusy(false);}},[]);constdisable=useCallback(async()=>{setBusy(true);setError(null);try{constsubscription=awaitcurrentSubscription();if(subscription){// Revoke server delivery before deleting the browser endpoint so a// transient unsubscribe failure cannot leave a still-active backend row.awaitrevokePushSubscription(subscription.endpoint);awaitsubscription.unsubscribe();}setSubscribed(false);}catch(reason){setError((reasonasError).message);}finally{setBusy(false);}},[currentSubscription]);return{
supported,
configured,
permission,
subscribed,
busy,
error,standalone: isStandalone(),
enable,
disable,};}
File: propr-ui/src/pages/SettingsPage/NotificationPreferencesSection.tsx (new file)
Why this file: This component makes push enrollment and delivery policy visible in the existing Settings workflow.
importReact,{useEffect,useState}from'react';importtype{NotificationCategory,NotificationPreferences}from'@propr/shared';import{getNotificationPreferences,updateNotificationPreferences}from'../../api/notificationsApi';import{usePushNotifications}from'../../hooks/usePushNotifications';constlabels: Record<NotificationCategory,string>={plans: 'Plans ready for review',tasks: 'Task progress and failures',pull_requests: 'Pull requests needing attention',indexing: 'Repository indexing failures',system: 'System failures',};exportfunctionNotificationPreferencesSection(){constpush=usePushNotifications();const[preferences,setPreferences]=useState<NotificationPreferences|null>(null);const[saving,setSaving]=useState(false);const[message,setMessage]=useState<string|null>(null);useEffect(()=>{voidgetNotificationPreferences().then(setPreferences).catch(error=>setMessage(error.message));},[]);if(!preferences)return<sectionclassName='rounded-lg border p-4'>Loading notification preferences…</section>;constsave=async()=>{setSaving(true);setMessage(null);try{constupdated=awaitupdateNotificationPreferences({ ...preferences,pushEnabled: push.subscribed});setPreferences(updated);setMessage('Notification preferences saved.');}catch(error){setMessage((errorasError).message);}finally{setSaving(false);}};return(<sectionclassName='rounded-lg border border-slate-200 bg-white p-4 space-y-4'><div><h2className='font-semibold text-slate-900'>Notifications</h2><pclassName='text-sm text-slate-600'>Choose what appears in the Inbox and on this device.</p></div>{!push.supported&&<pclassName='text-sm text-amber-700'>This browser does not expose the Web Push API.</p>}{push.supported&&!push.standalone&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&(<pclassName='text-sm text-amber-700'>On iPhone or iPad, add ProPR to the Home Screen, open the installed app, then enable notifications here.</p>)}{push.supported&&!push.configured&&<pclassName='text-sm text-amber-700'>The server administrator has not configured VAPID keys.</p>}{push.error&&<pclassName='text-sm text-red-600'>{push.error}</p>}<buttontype='button'disabled={push.busy||!push.supported||!push.configured}onClick={push.subscribed ? push.disable : push.enable}className='rounded-md bg-teal-700 px-3 py-2 text-sm text-white disabled:opacity-50'>{push.busy ? 'Updating…' : push.subscribed ? 'Disable push on this device' : 'Enable push on this device'}</button><divclassName='grid gap-2'>{(Object.keys(labels)asNotificationCategory[]).map(category=>(<labelkey={category}className='flex items-center gap-2 text-sm'><inputtype='checkbox'checked={preferences.categories[category]}onChange={event=>setPreferences(current=>current&&({
...current,categories: { ...current.categories,[category]: event.target.checked},}))}/>{labels[category]}</label>))}</div><labelclassName='flex items-center gap-2 text-sm'><inputtype='checkbox'checked={preferences.badgeEnabled}onChange={event=>setPreferences({ ...preferences,badgeEnabled: event.target.checked})}/>
Show unread count on the installed app icon
</label><divclassName='grid grid-cols-1 sm:grid-cols-3 gap-3'><labelclassName='text-sm'>Quiet from<inputtype='time'value={preferences.quietHoursStart??''}onChange={event=>setPreferences({ ...preferences,quietHoursStart: event.target.value||null})}className='block w-full rounded border p-2'/></label><labelclassName='text-sm'>Quiet until<inputtype='time'value={preferences.quietHoursEnd??''}onChange={event=>setPreferences({ ...preferences,quietHoursEnd: event.target.value||null})}className='block w-full rounded border p-2'/></label><labelclassName='text-sm'>Timezone<inputvalue={preferences.timezone}onChange={event=>setPreferences({ ...preferences,timezone: event.target.value})}className='block w-full rounded border p-2'/></label></div><buttontype='button'onClick={save}disabled={saving}className='rounded-md border px-3 py-2 text-sm disabled:opacity-50'>{saving ? 'Saving…' : 'Save notification preferences'}</button>{message&&<pclassName='text-sm text-slate-600'>{message}</p>}</section>);}
File: propr-ui/src/pages/SettingsPage/index.tsx
Why this file: The section belongs in the existing settings surface rather than a disconnected PWA-only page.
Activity
propr-dev commentedon Aug 2, 2026
Suggested Implementation:
Implementation Approach
Separate the API client, browser capability hook, and settings presentation. This makes permission logic testable without rendering the full Settings page. Automatic permission requests were rejected because browsers block them, they create a poor trust experience, and iOS requires a direct user gesture. Preference saves are explicit to avoid silent network writes while toggling several controls.
File:
propr-ui/src/api/notificationsApi.ts(new file)Why this file: It gives the UI a typed boundary for notification configuration, preferences, subscriptions, Inbox state, and receipts.
File:
propr-ui/src/hooks/usePushNotifications.ts(new file)Why this file: Browser capability and permission transitions are asynchronous and platform-specific. A hook keeps these concerns out of the settings component.
File:
propr-ui/src/pages/SettingsPage/NotificationPreferencesSection.tsx(new file)Why this file: This component makes push enrollment and delivery policy visible in the existing Settings workflow.
File:
propr-ui/src/pages/SettingsPage/index.tsxWhy this file: The section belongs in the existing settings surface rather than a disconnected PWA-only page.
propr-dev commentedon Aug 24, 2026
🤖 AI processing has started for this issue using codex agent with gpt-5.6-sol model.
I'll analyze the problem and work on a solution. This may take a few minutes.
Processing Details:
codexgpt-5.6-sol1722/gpt-5.6-sol-build-the-browser-push-en-20260824-1134-ztd1716-epic-failed-to-3m8issue-1722-20260824-1134-gpt-5.6-sol-ztd🔍 Track Task Execution
fix(ai): Resolve issue #1722 - Build the browser push enrollment flow…
[1722 by GPT-5.6 Sol] Build the browser push enrollment flow and noti…
[Epic] PWA & Web push (#1731)