GeezerVison is showing github.com — feat(core): add push notifications for the mobile apps by Tarquinen · Pull Request #66130 · anomalyco/opencode
Conversation
Tarquinen
commented
Nov 24, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Issue for this PR
No issue; this is a new feature.
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
Adds push notifications for the mobile apps to the server.
A phone registers with the server, and the server notifies it when a session:
- finishes or fails
- asks a question
- asks for permission
Also:
- Notification text is end-to-end encrypted, so the relay that delivers it can't read it.
- Each phone picks a level: everything, only when a session needs you, or nothing. A session can override that with its own bell, for one phone or for all of them.
- Notifications can be paused for the whole server or for one phone.
- Phones can be listed and removed.
- A notification is removed from the phone when it goes stale: the question or permission was answered elsewhere, a finished session got a new message or was opened on another client, or the session was deleted. A view reported within 5 seconds of the turn ending is ignored, since a client with the session already open reports it whether or not anyone is looking.
There is no feature flag: push is on for everyone, and does nothing until a phone registers. The routes are under /api/experimental/push, so the API can still change.
Phones are only reached through the two OpenCode notification relays (production and dev); a callback URL anywhere else is rejected.
How did you verify your code works?
Typecheck and the new tests pass. A real Android phone running anomalyco/opencode-android#297 received and cleared notifications from a server on this branch.
Screenshots / recordings
No UI change.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Added by the opencode bot (AI-generated).
Public API: adds experimental /api/experimental/push routes, client operations, Push schema types and the experimental.push.updated event (backwards compatible)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add /api/experimental/push with GET (phones and settings) and PUT/DELETE
device/<id>, which keeps one KV record per phone, checks the relay callback URL
against the allowed relays and answers with the server's P-256 key for the
phone. /api/info gains capabilities.push while the flag is on, and a push
config setting adds relays beyond the production one.
Verified: bun typecheck in schema, protocol, core, server; core
test/push-list.test.ts and server test/push-routes.test.ts pass.
Phones can be paused (PATCH device/<id>), each phone can set its own bell for a
session, a session can have a shared bell, and everything can be paused until a
time (settings). Bells and pauses survive re-registration, expire at their
until, and bells are dropped when their session is deleted. Every change
publishes push.updated so clients refetch.
Verified: bun typecheck in core, server, protocol, client; core
test/push-list.test.ts (8 pass), server test/push-routes.test.ts (3 pass),
protocol bun test.
PushSender picks each phone's level (everything paused, phone paused, the
phone's session bell, the shared bell, the phone's default), builds the
v1 message, shortens the body so it fits the relay's box limit, seals it with
AES-256-GCM under the phone's shared key and posts {box} to its callback URL
with a 10 s timeout and no redirects. 404/410 remove the phone, 5xx and network
errors retry twice, anything else moves on. Sending runs in the background.
Verified: core bun typecheck; test/push-sender.test.ts reproduces the Android
app's known box and covers gone, failing and filtered phones against a fake
relay; test/push-list.test.ts still passes.
The push watcher subscribes to session.execution.succeeded, failed and
interrupted (inactivity only) server-wide and sends 'Finished', 'Failed'
or 'Stopped' for sessions without a parent. PushOptions becomes a small
global service so the watcher and the server handlers share it.
Verified: bun typecheck (core, server); core push-list, push-sender and
push-watcher tests (13 pass); server push-routes tests (3 pass).
…ssion
The push watcher also subscribes to form.created (question forms only)
and permission.asked server-wide, including from subagents. The
notification carries the top-level session's ID and title, the first
question's text or 'Needs permission: <action>', and counts as 'needs
you', so it passes the attention level.
Verified: bun typecheck (core); push-watcher tests (2 pass).
The sender now removes a phone on 404/410 only if the stored callback URL is
still the one it posted to, checked under the list's lock, so a phone that
re-registered meanwhile keeps its new registration and bells. Registering over
an expired entry starts afresh instead of reviving its pause, bells and key.
Callback URLs must be exactly canonical (no empty query, fragment, userinfo or
dot segments). A failure while dropping a deleted session's bells is logged
instead of ending the subscription.
Verified: bun run script/test.ts test/push-list.test.ts (10 pass).
The sender shortens the body and then the title by their encoded JSON size, so
multi-byte and escaped text keep as much as fits and long titles no longer
overflow the relay's box limit. Phones on a relay no longer in config get no
posts. Each phone's send runs on its own, logging any defect instead of
cancelling the others. The response body is drained, and HTTP client tracing is
off for these requests so callback URLs never reach span attributes.
Verified: bun run script/test.ts test/push-sender.test.ts (4 pass, incl. 404
removal, 429 dropped, redirect manual, removed relay skipped).
session.execution.succeeded fires for any busy period, including session moves,
revert clears and manual compactions; the watcher now sends Finished only when a
model step started in that period. Drops the inactivity Stopped notification,
since nothing emits that reason. The watcher reads the flag only when a phone is
registered, treats an empty title as missing, and logs handler defects instead
of ending its subscriptions.
Verified: push-watcher tests (2 pass); against a local server, a prompt sent one
Finished push and revert clear, compact and move sent none.
Config relays that aren't https URLs or repeat the default are left out of the
allowed list and capabilities.push.relays. Also builds the info capabilities
once and adds push to the client's expected experimental groups.
Verified: bun test in packages/client (269 pass), server push-routes (3 pass).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found nothing that should block this. I ran the new core, server and client tests (all pass) and a tsc -b build of packages/server (no errors), and read through the list, sender and watcher. I couldn't check delivery end to end because that needs the relay and a phone.
The push state is wired sensibly: Bus and Session are global nodes, so the global watcher sees every session's events. Notifications from subagents go under the top-level session, so its bell applies. Callback URLs are limited to the two relays. Errors in the watcher, sender and the cleanup on session deletion are logged and swallowed, so they can't take the server down. The tests use TestClock and a stubbed fetch, with no real network calls or sleeps.
Public API (all additions, backwards compatible):
- New HTTP routes under
/api/experimental/push:
GET /
PUT, PATCH and DELETE on /device/:deviceID
PUT and DELETE on /device/:deviceID/session/:sessionID
PUT and DELETE on /session/:sessionID
PUT /settings
- Matching operations in the OpenAPI spec (
experimental.push.*), the TS client (experimental.push.*) and the Rust and Luau clients.
- A new
PushDeviceNotFoundError (404).
- New
Push.* schema types.
- A new ephemeral
experimental.push.updated event, added to the event manifest and to the event-subscribe filter.
No existing route, type or event changes.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…ew of the session"
This reverts commit 85d5198.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing new to raise. The push code is identical to what I reviewed last time: the change to clearing a finished notification on view is added and then reverted, and the rest is a merge of dev. The one remaining change, attaching the catch before close() in packages/sdk/test/promise.test.ts, is a sound fix for a rejection that could otherwise go unhandled. The SDK promise tests (3) and the core push tests (22) pass. The public API is unchanged from my last review.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|