Skip to content

feat(push): add self-hosted Web Push for paired devices - #58400

Draft
Zijian-Wang wants to merge 7 commits into
anomalyco:devfrom
Zijian-Wang:web-push
Draft

Zijian-Wang wants to merge 7 commits into
anomalyco:devfrom
Zijian-Wang:web-push

Conversation

@Zijian-Wang

@Zijian-Wang Zijian-Wang commented Oct 23, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #58428

Stacked on #58399, which fixes notifications on Android. This PR adds Web Push on top of it.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds opt-in Web Push notifications for paired browsers. The local OpenCode server stores a VAPID key and one subscription per browser installation, encrypts each notification, and sends it directly to the browser vendor's push service. There is no OpenCode relay and no new hosted infrastructure.

The app registers a dedicated worker under /push/<server-key>/ and adds a per-server push switch to Settings → Notifications. The existing Agent, Permissions, Questions, and Errors switches choose which events are pushed.

Payloads contain a localized title, the session route, a tag, and the event kind. They omit prompts, source code, session titles, errors, and tool output. Push endpoints are allowlisted, redirects are rejected, and a 404/410 response removes the subscription.

I opened #58428 for design approval and am keeping this as a draft until it gets a decision.

How did you verify your code works?

  • bun run check (34/34 tasks)
  • bun run generate in packages/client (no diff)
  • bun run probe:workerd in packages/server
  • bun test test/push.test.ts in packages/server (5 passed)
  • App unit tests: 19 passed; browser notification state: 4 passed
  • bun run test:service-worker (13 passed, including a stopped-worker push injection)
  • Not verified: live APNs/FCM delivery and physical-device behavior.

Screenshots / recordings

Desktop web app:

Notifications settings with Background push

Mobile portrait (390×844):

Notifications settings on mobile portrait

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Chrome on Android rejects the Notification constructor. Prefer ServiceWorkerRegistration.showNotification when the offline worker is active, add a notification click handler that reopens the matching session, and keep the constructor only as a fallback.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Oct 23, 2026
Let a paired browser receive agent, permission, question, and error notifications while the web app is closed. The local server stores VAPID keys and subscriptions, encrypts payloads, and sends them directly to browser push services. No OpenCode-hosted relay is involved.
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Oct 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

This branch has not been deployed

No deployments
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.

[FEATURE]: Web Push notifications for paired browsers

1 participant