Repository navigation
feat(push): add self-hosted Web Push for paired devices - #58400
Draft
Zijian-Wang wants to merge 7 commits into
Draft
Zijian-Wang wants to merge 7 commits into
Zijian-Wang wants to merge 7 commits into
Conversation
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.
3 of 6 tasks
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.
1 task done
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
This branch has not been deployed
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.
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
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 generateinpackages/client(no diff)bun run probe:workerdinpackages/serverbun test test/push.test.tsinpackages/server(5 passed)bun run test:service-worker(13 passed, including a stopped-worker push injection)Screenshots / recordings
Desktop web app:
Mobile portrait (390×844):
Checklist