Skip to content

feat(system): replace the notify plugin with the server's push notifications - #337

Merged
Tarquinen merged 17 commits into
devfrom
push-core-notifications
Nov 29, 2026
Merged

Tarquinen merged 17 commits into
devfrom
push-core-notifications

Conversation

@Tarquinen

@Tarquinen Tarquinen commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

The OpenCode server now sends push messages itself, but the app only understood the old notify plugin's payload, so none of them showed.

Now the phone registers with the server's push API and shows each message as a notification you can act on. The old system is removed: the notify plugin and its setup, the callback sent with each prompt, and Always Notify.

Permission requests: two commands, a long pipeline, eight commands, a file edit

Questions: three options, eight options, a long question, several questions

Finished, failed, and four notifications grouped by project, closed and open

A typed answer, the group in dark mode, and the lock screen

  • Permission: the commands or paths in a code block, with Deny, Always Allow and Allow. Allowing asks for an unlock on the lock screen. A request too long to show in full only offers Open.
  • Question: up to three options as rows that answer on tap, plus Reply for a typed answer. Long questions, several questions at once and multi-selects only offer Open.
  • Finished and Failed: the end of the answer or the error, with Reply to send the next prompt.
  • Notifications are grouped by project and removed when the server says they were handled elsewhere. If that message is lost, opening the app removes the ones for sessions you've read or archived and requests already answered.
  • Tapping one opens its session, closing Settings or the drawer if they're in the way.

Settings › Notifications, before and after:

Settings › Notifications: before, and after in light and dark

Off, the Notify About menu, and blocked in Android settings

  • Notifications turns this phone's notifications from this server on or off. Off removes the phone from the server. Removing the server from the app does too, and clears its notifications. The first turn-on shows Android's permission prompt.
  • Notify About is Everything, or Only When It Needs Me (permissions and questions).
  • Android's permission prompt appears once, after the first message someone sends (every user sends one, once per install). Allowing registers the phone; nothing else needs setting up.
  • How each kind arrives is fixed: permissions, questions and failures pop up with a sound, and a finished session only makes a sound.
  • The page only controls this phone. A server older than 2.4.2 shows the switch disabled with “This server doesn’t support notifications. Update OpenCode on your computer.”

Worth a look:

  • This commits firebase.xml (the values google-services.json would generate), which FCM needs. They ship in the APK anyway, but the key should be restricted in the Firebase console.
  • Registration no longer needs an HTTPS address, since it uses the same connection as everything else. The old pairing call refused plain HTTP.
  • A server older than 2.4.2 no longer notifies this app, even with the notify plugin installed.
  • The app no longer keeps its own count for the icon badge, and the “Badge on the App Icon” What’s New entry is removed. The launcher's badge is now just the notifications that are showing; the saved count was computed but never shown.
  • The What’s New entries for Always Notify, the notify plugin setup and encrypted notification previews are removed with the features.

Verified with scripts/check.sh and on API 36 emulators against a server run from OpenCode dev, with real pushes through the relay and FCM: permissions, questions, replies, clears, grouping, the lock screen and a killed app. Also checked: stale notifications removed on reopening after lost clears, a tap with Settings open, and removing a server with a notification showing. The settings page was checked on, off, at each level, with Android's permission never asked and denied, after removing a server, and against a 2.4.1 server.

OpenCode now sends push messages itself (specs/v2/push.md in the opencode
repo): permission requests, questions, finished and failed turns, and clears.
The phone registers with PUT /api/experimental/push/device/<ref> instead of
pairing through the notify plugin, and shows each message as its own
notification:

- Permission: the commands or paths in a code block with Deny, Always Allow
  and Allow. A request that was cut only offers Open.
- Question: up to three option rows that answer on tap, plus Reply for a typed
  answer. Long questions, several questions and multi-selects only offer Open.
- Finished and failed: the end of the answer or the error, with Reply.
- Clears remove a notification, ordered by time as the spec asks.

Replaces OpenCodeClient.pairNotificationPreview with registerPushDevice and
drops the "previews need HTTPS" error. Boxes in the old payload format still
go through the old path.

Verified: scripts/check.sh on the Android VM (assemble, lint, unit tests),
translations.py all.
The debug-only lab-server-url extra saved the server with an empty password, so a
test server with a password answered 401. lab-server-password sets it.

Verified: a debug build launched with both extras connected to a password-protected
server on the emulator.
- A question answered by typing into the notification stayed in the shade:
  Android refuses an app's cancel of a notification that was replied to
  inline. It is now posted again with a short timeout, and later clears leave
  it alone while it goes.
- The launcher's badge count was the unread count times the number of
  notifications, because each one carried the whole count. Each push
  notification now counts as one.
- A finished turn shows the end of the answer as plain text (Markdown marks
  dropped), cut to the lines that fit, instead of the first lines of the last
  500 characters.
- A long question's collapsed line is its last line, which is the one that
  asks.
- "Wants to run a command" instead of "Wants to run 1 command".

Verified on the Android VM emulator (API 36) against an OpenCode dev server:
typed answer removes the question and the Finished notification replaces it;
scripts/check.sh :feature:system; translations.py all.
… is now

The parity doc still described the relay work FCM needed; the relay has it,
and OpenCode sends the pushes itself.

Verified: scripts/check.sh :feature:system on the Android VM.
…ation

PushNotificationTests reads messages in the server's format and checks what
each becomes: the permission's commands and buttons, question rows, the end of
a finished answer, failure text, unknown messages, and the ledger's ordering
of messages and clears.

firebase.xml holds the Firebase app's four string resources, which FCM needs
to give the app a token. Without it no push can arrive.

Verified: scripts/check.sh :feature:system on the Android VM (14 new tests pass).
…ixes

A permission request the server cut down to its ids has no action. It was
shown as a generic notification; it is now a permission notification that
only offers Open. A clear with a version this app doesn't know does nothing.
Typed replies ask for the phone to be unlocked, as Allow does.

Also drops an unused parameter, updates two comments and the parity rows
that still described the notify plugin's pairing call.

Verified: scripts/check.sh :server :feature:system on the VM (PushNotificationTests 14 passed).
The icon was orange, green or red by kind. It now has the system's own
colour, as the app's other notifications do.

Verified: scripts/check.sh :feature:system on the VM.
A long command, or many of them, was cut at four lines while Allow and
Always Allow stayed, so the part being approved could be hidden. The code
block now shows up to eight lines, and a request that doesn't fit in them
only offers Open, like one the server had to cut. Whether it fits is
estimated from the screen width and font size, erring towards Open.

Shell commands start with "$ " so a wrapped command reads as one.

Verified: scripts/check.sh :feature:system on the VM (PushNotificationTests
15 passed); on an API 36 emulator a 300-character pipeline, eight chained
commands and a heredoc script each showed Open only, and two short commands
kept Deny, Always Allow and Allow.
…fications

The line listed every saved pattern under the commands and ran to two
clipped lines for a request with several commands. A permission
notification is now the commands and the buttons; the patterns Always
Allow would save are no longer read from the message.

Verified: scripts/check.sh :feature:system on the VM (PushNotificationTests
15 passed); a two-command request on an API 36 emulator shows the commands
and Deny, Always Allow, Allow with nothing between.
A permission for a file such as README.md got a system "Open link" chip,
because the name looks like a web address.

Verified: scripts/check.sh :feature:system on the VM; an edit request for
README.md on an API 36 emulator shows only Deny, Always Allow and Allow.
Push notifications no longer post silently for an In-App Notices mode:
PushNotifications drops the silent flag, since presentation() is now only
None (the visible session) or Banner. docs/parity/system.md keeps this
branch's push rows and takes dev's wording that In-App Notices is not in
the app.

Verified: scripts/check.sh (all modules) on the Android VM.
The app still carried the old notification system next to the new one: the
notify plugin check and its setup prompt, the callback address sent with
every prompt and share, Always Notify, and the old payload format.

Now there is one path. The phone registers with the server's push API when
it connects, and Settings > Notifications controls only this phone:

- Notifications: on or off for this server. Off deletes the device on the
  server, and so does removing the server from the app.
- Notify About: Everything, or Only When It Needs Me.
- Sound and banners: rows that open Android's settings for each channel.
- A server without the push API shows the switch disabled.

Removed: OpenCodeClient.notifyPluginStatus and setAlwaysNotify,
PromptContext.notificationCallbackURL, the callback in ShareCredentials,
the Always Notify card, the old payload path in SessionPushNotifications,
NotificationContent and NotificationCrypto, and the What's New entries for
Always Notify, notify plugin setup and encrypted notification previews.
A server older than 2.4.2 no longer notifies this app.

Verified: scripts/check.sh (all modules) on the VM. On an API 36 emulator
against a server run from OpenCode dev: registration on connect, each
level, off and on, Android's permission never asked and denied, a real
push through the relay and FCM, removing a server (its device is deleted),
and a 2.4.1 server (switch disabled).
@Tarquinen Tarquinen changed the title feat(system): show the server's push messages as notifications feat(system): replace the notify plugin with the server's push notifications Nov 28, 2026
The line under the three rows ("Opens Android settings, where each kind can
pop up, make a sound or be turned off.") read oddly and the rows explain
themselves, so it is removed along with its string and translations.

Verified: scripts/check.sh :feature:settings on the VM, and the page on an
API 36 emulator in light and dark.
The page listed Needs You, Finished and Failed with a way into each
channel's Android settings. The app decides how each kind arrives instead
(permissions, questions and failures pop up with a sound; a finished
session only makes a sound), so the rows, the code that read the channels'
importance and their strings are removed.

Verified: scripts/check.sh (all modules) on the VM, and the page on an API
36 emulator in light and dark.
Android's notification prompt only appeared from the switch in Settings or
a first voice call, so most people would never be asked and never get a
notification.

Now an accepted send shows the prompt while Android has never asked. That
happens once per install: a refusal is remembered and the Settings page
then points at Android's settings. Allowing registers the phone.

Verified: scripts/check.sh (all modules) on the VM. On an API 36 emulator
with a fresh install: the first send shows the prompt, Allow registers the
device on the server, and after Don't allow a second send does not ask.
…ttings

- Opening the app removes this server's notifications for sessions that are
  read or archived and for requests already answered. The server's clear push
  normally does this, but it can be lost.
- Tapping a notification closes Settings and the drawer so the session shows.
- Removing a server from the app removes its notifications; a tap on one did
  nothing before.
- Notifications no longer carry CATEGORY_MESSAGE, which is for messages between
  people and can pass Do Not Disturb.

Verified with scripts/check.sh and on an API 36 emulator: stale notifications
removed on reopening after lost clears (unread ones kept), a tap with Settings
open, removing a server with a notification showing, and no category in
dumpsys notification.
Cleanup after review of the push rebuild.

- The app no longer keeps its own launcher count. AppIconBadge, AppBadgeLedger,
  Home's badge publishing, the ledger block in the push handler and the
  "Badge on the App Icon" What's New entry are gone: every push already counted
  as one, so the saved count was computed and never shown. The launcher badge
  is the notifications that are showing.
- Removed members nothing called: SessionNotifications.onOpen,
  pendingDestination, includeBadges, PushTokenProvider.inert; the
  NotificationPresentation enum is now isOnScreen(sessionID).
- A device id is no longer made up on read: the stale sweep, turning
  notifications off and removing a server use savedRef, and no DELETE is sent
  to a server this phone never registered with.
- A notification choice is saved only after the server accepts it, instead of
  saved first and rolled back.
- The three push requests are OpenCodeClient values with live and test
  implementations, like every other request.
- Every removal goes through PushNotifications.cancel, so a notification that
  was answered inline is removed the same way everywhere.
- HomeNotificationsFeature loads the settings in one helper.
- Stale comments, a test name and the parity rows updated.

Verified: vm.sh check (build, lint, unit tests) passes. On the emulator against
the push rig: Finished and question pushes arrive and group; answering a
question from the notification removes it; opening a session clears its
notification; the Notifications switch deletes and re-registers the device;
offline the switch stays on with "Couldn't change notifications. Try again.";
with the device deleted on the server, reopening the app removes a viewed
session's notification and keeps an unread one.
@Tarquinen
Tarquinen merged commit 1f07515 into dev Nov 29, 2026
2 checks passed
@Tarquinen
Tarquinen deleted the push-core-notifications branch November 29, 2026 23:23
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