Skip to content

feat(app): receive Android push through FCM in a module of its own - #1744

Merged
devswha merged 1 commit into
mainfrom
feat/android-fcm-push
Oct 23, 2026
Merged

devswha merged 1 commit into
mainfrom
feat/android-fcm-push

Conversation

@devswha

@devswha devswha commented Oct 23, 2026

Copy link
Copy Markdown
Owner

The Android half of the phone app's push: the PC's alerts reach an Android phone through Firebase Cloud Messaging and are decrypted on the phone. The relay side is a commit on #1695 (feat/push-relay), so that PR grows instead of a second one touching push-relay/.

Shape: a module of its own

This PR must not touch any file #1697 changes (app/android/app/build.gradle, AndroidManifest.xml, MainActivity.java, app/package.json, …). The owner chose a self-contained library module, app/android/ovis-push:

  • settings.gradle includes the module and adds it to :app, from plugins.withId('com.android.application').
  • The module's manifest merges in the messaging service, POST_NOTIFICATIONS and a startup provider.
  • OvisPushInitializer (the provider) registers the plugin with the app's BridgeActivity from onActivityCreated. That callback runs inside Activity.onCreate, before BridgeActivity builds its bridge.
  • Once fix(app): free the old iOS web view, dark Android bars, error reasons and review follow-ups #1697 is merged, the dependency and the registration can move into app/build.gradle and MainActivity, and the two hooks go away.

What it does

  • OvisPush plugin (subscribe({ applicationServerKey }), getSubscription(), unsubscribe()), called from the PC page:
    • asks for notifications on Android 13+;
    • gets the FCM token and registers it with the relay as {service:"fcm", token, vapid_key}, once per PC;
    • answers like a browser's PushSubscriptionJSON: {endpoint, expirationTime, keys:{p256dh, auth}};
    • makes a new endpoint when the FCM token or the PC's key changes.
    • Error codes: unavailable, permission, no_pc, invalid_key, failed.
  • OvisMessagingService:
    • receives the relay's data-only message;
    • decrypts its ovis field (RFC 8291 / RFC 8188 aes128gcm, WebPushDecrypt) with the phone's P-256 keys (PushKeys, kept in app-private preferences by PushStore);
    • shows the PC's title and body per tag, as public/sw.js does, or "herdr needs you" when it cannot decrypt.
  • No Google contact until a PC subscribes: firebase_messaging_auto_init_enabled=false.
  • Firebase config without the google-services plugin: ovis-push/build.gradle reads app/android/app/google-services.json (gitignored) or $OVIS_GOOGLE_SERVICES, and generates the resources Firebase's own startup reads.
    • Without the file the app builds and runs with push unavailable.
    • google-services.example.json is a placeholder with fake values.
  • The client side (src/lib/push.ts calling the plugin) is a later, separate change.

Verification

  • ./gradlew :ovis-push:testDebugUnitTest: 4 pass.
    • The RFC 8291 appendix A message decrypts to its plaintext.
    • A changed ciphertext is refused.
    • Other keys are refused.
    • Generated key halves agree.
  • :ovis-push:lintDebug: 0 errors, 2 deliberate warnings.
    • commit() on first key generation, so keys persist before the public half is handed out.
    • No onNewToken: endpoints re-register lazily at the next subscribe.
  • Android 16 Play emulator, against an isolated QA server:
    • Without google-services.json: OvisPush is registered (Capacitor.PluginHeaders). subscribe answers no_pc on the connect screen and unavailable on the PC page; getSubscription returns null.
    • With the placeholder config: Android's "Allow Ovis to send you notifications?" dialog appears. After Allow, POST_NOTIFICATIONS is granted and Firebase's token request fails on the fake API key, as it should. A bad applicationServerKey answers invalid_key, and the PC's real key from GET /api/push gets to Firebase.
  • Real FCM delivery needs the owner's Firebase project; see below.
  • bun run check fast: pass.
  • Gate review: round 1 rejected readAllBytes() (needs API 33; minSdk is 26). It was replaced, and the re-review approved.

What the owner sets up (ovis-push/README.md)

  1. A Firebase project, with an Android app sh.ovis.app in it.
  2. Download google-services.json into app/android/app/. It is never committed.
  3. A service-account JSON key, which goes only into the relay: wrangler secret put FCM_SERVICE_ACCOUNT.
  4. Before this ships in a Play build, update the data safety form and the privacy policy: the FCM token goes to the relay.

No overlap

New files plus app/android/settings.gradle, app/android/.gitignore and a changelog fragment. Nothing here is in #1697, #1695, #1736 or #1737.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 5 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 9357629 and 8d69b99.

📒 Files selected for processing: 17
  • app/android/.gitignore
  • app/android/ovis-push/README.md
  • app/android/ovis-push/build.gradle
  • app/android/ovis-push/google-services.example.json
  • app/android/ovis-push/src/main/AndroidManifest.xml
  • app/android/ovis-push/src/main/java/sh/ovis/push/OvisMessagingService.java
  • app/android/ovis-push/src/main/java/sh/ovis/push/OvisPushInitializer.java
  • app/android/ovis-push/src/main/java/sh/ovis/push/OvisPushPlugin.java
  • app/android/ovis-push/src/main/java/sh/ovis/push/PushKeys.java
  • app/android/ovis-push/src/main/java/sh/ovis/push/PushStore.java
  • app/android/ovis-push/src/main/java/sh/ovis/push/WebPushDecrypt.java
  • app/android/ovis-push/src/main/res/drawable/ic_stat_ovis.xml
  • app/android/ovis-push/src/main/res/values-ko/strings.xml
  • app/android/ovis-push/src/main/res/values/strings.xml
  • app/android/ovis-push/src/test/java/sh/ovis/push/WebPushDecryptTest.java
  • app/android/settings.gradle
  • changelog.d/android-fcm-push.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 23, 2026

Copy link
Copy Markdown
Owner Author

Merge-pass gate review of head 8d69b99 (a gate reviewer on a different model than the author's): APPROVE. The PR is in the merge queue and will merge once its checks are green and main is confirmed.

Verified:

Notes for a follow-up. None of these blocks the merge:

  • Backup: the push private key and auth secret are kept in plain private SharedPreferences, which Android backs up. Once fix(app): free the old iOS web view, dark Android bars, error reasons and review follow-ups #1697's data_extraction_rules.xml lands, add these prefs to the exclusions, or move them to the Keystore or EncryptedSharedPreferences.
  • Key sharing: one key pair is shared by every PC the phone subscribes for.
  • Unsubscribe: unsubscribe() only clears local state. It does not delete the relay endpoint, which expires only after the relay's 60-day unused TTL.
  • Not verified here: an Android compile of the module (it stopped earlier, on a missing generated cordova.variables.gradle), real FCM delivery, and the notification permission prompt. These need a device or emulator run.

@devswha

devswha commented Oct 23, 2026

Copy link
Copy Markdown
Owner Author

Answers to the merge pass's follow-up notes on 8d69b99. There is no code change: each is covered elsewhere or deliberate.

  • Backup of the push keys: fix(app): free the old iOS web view, dark Android bars, error reasons and review follow-ups #1697 already covers this once it lands, with nothing extra needed here.
    • Its manifest sets android:allowBackup="false".
    • Its data_extraction_rules.xml excludes the whole sharedpref domain (path=".") from both cloud backup and device transfer, so the ovis_push preferences file is excluded too.
    • Moving the keys into the Keystore remains a possible hardening step later.
  • One key pair for every PC: deliberate. Each PC still gets its own endpoint, pinned to that PC's VAPID key at registration (feat(push-relay): add the phone app's APNs push relay Worker #1695), so one PC cannot push through another's endpoint. Only the phone holds the private key.
  • unsubscribe() only clears local state: right. The relay has no delete route yet; an unused endpoint expires after the relay's 60-day TTL, and the PC drops a subscription the client unsubscribes. A relay delete route plus a call from unsubscribe() belongs with the client step (src/lib/push.ts), not this PR.
  • Not verified in your run: I did run these on the Android 16 Play emulator for this PR (details in the description):
    • ./gradlew :ovis-push:testDebugUnitTest :ovis-push:lintDebug assembleDebug passed: 4 tests, lint 0 errors.
    • The notification permission prompt appeared, and POST_NOTIFICATIONS was granted=true after Allow.
    • With the placeholder config, Firebase's token call fails on the fake API key, as it should.
    • The compile stop you saw (cordova.variables.gradle missing) is generated by bunx cap sync android; run that after bun run build:web and before Gradle, as docs/native-app.md says.
    • Real FCM delivery still needs the owner's Firebase project.

@devswha

devswha commented Oct 23, 2026

Copy link
Copy Markdown
Owner Author

Merge pass: reviewed in place of a CodeRabbit review, which was rate-limited. A gate reviewer on a different model than the author's checked:

@devswha
devswha merged commit bac0e46 into main Oct 23, 2026
9 checks passed
@devswha
devswha deleted the feat/android-fcm-push branch October 23, 2026 09:32
devswha added a commit that referenced this pull request Oct 24, 2026
…checks (#1816)

## What

The FCM route this was meant to add is already on main: it landed with
the relay in #1695 (commit `1089a2b41`, "send to Android phones through
Firebase Cloud Messaging"). It has `{ "service": "fcm", "token",
"vapid_key" }` registration, FCM HTTP v1 data messages, VAPID pinning,
the same rate limits, and gone handling scoped per service. #1744's
Android module already registers that way. This PR audits the route
against the APNs contract and closes what the audit found:

1. **An FCM token that FCM calls invalid is gone, as an APNs
`BadDeviceToken` already is.** Before, FCM's `INVALID_ARGUMENT` for a
token that is not one answered `502` and kept the endpoint. The PC kept
pushing to it until the 60-day expiry, while the same case on APNs
answered `410` (unsubscribe). Now it deletes the token's FCM endpoints
and answers `410`. The rule is below.
2. **FCM endpoints are tested under the same limits.** A new test pins
the per-endpoint limit (60) and the per-phone limit across a token's
endpoints (120), applied before FCM is called. Moving the FCM branch
above the limits fails it (mutation-checked).
3. **`push-relay/test-push.ts fcm <token>`** sends one real push through
FCM after a deploy, as it already did for APNs. The tests use a fake
Google, so only a real call shows that the relay's sign-in with
`FCM_SERVICE_ACCOUNT` and its message reach FCM. A made-up token checks
the sign-in without a phone: the relay answers `410` only once Google
took its sign-in and FCM called the token invalid.
4. **The relay's tests run in Fast checks.** The unit glob in
`scripts/ci-tests.ts` now includes `push-relay`, and
`.github/workflows/push-relay.yml` is removed. Fast checks runs on every
PR with no path filter, so a relay-only PR still runs them, and they now
sit behind a required check.
5. **Docs**: `docs/native-app.md` said Android (FCM) would get its route
"later". It now says what is built and what Android push still waits
for: step 4's native subscribe, the Firebase project and the deploy.
`push-relay/README.md` gains the invalid-token rule, the Firebase
prerequisite, the FCM real-push check and the CI move. The changelog
fragment is under Maintenance.

## Why FCM HTTP v1, as a data-only message

- HTTP v1 (`projects/<id>/messages:send` with an OAuth access token from
the service account) is the send API Google documents. The legacy
server-key APIs are deprecated.
- **Data only, no `notification` part.** Android hands a data message to
the app's `FirebaseMessagingService` (`ovis-push`), which decrypts it
and shows the PC's title and body. A `notification` part would be shown
by the system with text the relay wrote, and the relay cannot read the
alert.
- **`data.ovis` holds the ciphertext in standard base64**, the same
field and encoding as the APNs payload's `ovis`, so both apps decode
alike. `ovis` is not a reserved key: FCM reserves `from`,
`message_type`, and `google`/`gcm` prefixes.
- **Size**: FCM's 4096-byte limit counts data keys and values. The relay
already refuses a push whose APNs wrapper passes 4096 bytes, so `ovis`
plus the ciphertext always fits.
- **Headers**: `Urgency: high` becomes `android.priority: HIGH`
(anything else, `NORMAL`). `TTL` becomes `android.ttl` as `"<n>s"`,
capped at 28 days, which is FCM's 4-week maximum; `0s` means now or
never. `Topic` becomes `android.collapse_key`.
- Still end-to-end encrypted: the relay forwards the RFC 8291
`aes128gcm` body untouched and holds no key that could read it.

## The invalid-token rule

[FCM's error
codes](https://firebase.google.com/docs/cloud-messaging/error-codes) say
`INVALID_ARGUMENT` comes with "an extension of type
`google.rpc.BadRequest` ... to specify which field was invalid".
[Example 2 on the send
page](https://firebase.google.com/docs/cloud-messaging/send-message) (an
invalid registration token) carries only the `FcmError` detail. The
[token management
guide](https://firebase.google.com/docs/cloud-messaging/manage-tokens)
says: "If you are certain that the message payload is valid and you
receive either of these responses [`UNREGISTERED`, `INVALID_ARGUMENT`]
... it is safe to delete your record of this registration".

The relay's message has a fixed shape, and every parameter a PC controls
(TTL, Topic, Urgency, body size) is validated before sending. So:

- `INVALID_ARGUMENT` naming no field, or only `message.token`: the
token's FCM endpoints are deleted, and the answer is `410`.
- `INVALID_ARGUMENT` naming any other field, or a bare `BadRequest`: the
relay's message was at fault. The answer is `502` and the endpoint
stays.
- The delete stays `service = 'fcm'`, so a leaked APNs token registered
as an FCM one cannot wipe the phone's iOS endpoints (tested).
`UNREGISTERED` and `SENDER_ID_MISMATCH` are unchanged.

Changes to existing tests (still 27 of them, plus 1 new = 28):

- In "a refused access token is fetched again once; other FCM or sign-in
failures keep the endpoint", the bare `INVALID_ARGUMENT` case that
expected `502` is what this PR now treats as gone. It moved to the gone
test, and three `INVALID_ARGUMENT` answers that name a field of the
message take its place, still `502` and kept.
- The expired-access-token fixture now uses FCM's `UNAUTHENTICATED`
answer instead of `THIRD_PARTY_AUTH_ERROR`, which is about APNs and web
push credentials. Behaviour for any 401 is unchanged: fetch a new access
token once.

## Left as it is, on purpose

- No deploy, no Cloudflare resources, no secrets.
- Nothing in `app/`, `server/` or `shared/`.
- The 32-endpoint cap and the per-phone limit still count per token
string across services. A token string belongs to one service in
practice, and a per-service cap would not stop a leaked-token eviction
(one can register 32 of the same service).
- A `429` from FCM or APNs is passed on without `Retry-After`, as
before.

## CI and open PRs

No open PR touches `scripts/ci-tests.ts`,
`.github/workflows/push-relay.yml` or `ci.yml`. #1652 changes
`docs/development.md` in another hunk (line 145; this one is at line
756). #1542, which #1695 waited for before folding the workflow in, is
merged. #1813 touches `server/` only.

## Verification

- `bun test ./push-relay`: 28 pass, 0 fail.
- Mutation checks, each restored afterwards. Treating `INVALID_ARGUMENT`
as never gone fails the gone test. Ignoring the named fields fails the
keep test. Sending to FCM before the rate limits fails the new limits
test.
- `test-push.ts` through its CLI, against the real `worker.ts` served on
loopback with in-memory SQLite and a fake Google/FCM that gives
Firebase's documented invalid-token answer:
- With no arguments, `fcm` without a token, or an unknown APNs
environment, it prints the usage and exits 2.
- An APNs sandbox token gets `201` through `api.sandbox.push.apple.com`.
  - An FCM token gets `201` after one Google sign-in.
- A made-up FCM token gets `410` with the sign-in note, its endpoint is
deleted, and the cached access token is reused.
- `bun run check fast`: all steps ok on the final tree (typecheck,
build, unit tests 6365 pass / 0 fail in 452 files, now including
`push-relay/worker.test.ts`), exit 0.
- Gate review by a code-review agent: APPROVE, no blocking issues. It
reran the relay and changelog suites (40 pass), reproduced the
`test-push.ts` smoke run against the real Worker, and ran 13 error-path
probes of its own on the FCM handling.

## Review

This changes the relay's HTTP answer for one FCM error (`502` to `410`)
and removes a workflow, so it waits for a real review.
devswha added a commit that referenced this pull request Oct 24, 2026
## What

Phase 1 steps 4 and 5 of
[docs/native-app.md](docs/native-app.md#push-in-the-app): the phone app
gets the PC's alerts as push notifications.

- **Client** (`src/lib/push.ts`, `src/lib/notifications.ts`,
`src/lib/nativeApp.ts`): the app's web view has no service worker,
`PushManager` or `Notification`. When the app announces its `OvisPush`
plugin (Capacitor's plugin headers), the client reads and asks for the
notification permission through it, and subscribes through it instead of
`pushManager.subscribe`. The plugin answers with `{ endpoint,
expirationTime, keys }`, shaped like a browser's `PushSubscriptionJSON`.
That object goes to `POST /api/push/subscribe` unchanged, so
**`server/push.ts` and the HTTP contract do not change**. A
`subscription_gone` answer has the app forget its kept relay endpoint
and register a new one. An app built before the plugin gets no call at
all, because on iOS a call to a missing plugin never settles.
- **iOS plugin** (`app/ios/App/App/OvisPushPlugin.swift`): the same
calls as the Android plugin from #1744:
- `checkPermissions` and `requestPermissions` answer `{ notifications
}`.
- `subscribe({ applicationServerKey })` gets the APNs token and
registers with `POST {relay}/v1/register` (`{ token, environment,
vapid_key }`) once per PC.
  - `getSubscription` and `unsubscribe` complete the set.

The endpoint is kept per PC with the token, key and environment it was
made for. The relay address is the `OVIS_PUSH_RELAY` build setting
(`https://push.ovis.sh`). The plugin also presents a push that arrives
while the app is open, such as the confirmation push.
- **Keys**: one P-256 key pair and auth secret per phone, made by the
app. They live in a keychain group shared with the extension
(`$(AppIdentifierPrefix)sh.ovis.app.push`), stored
`AfterFirstUnlockThisDeviceOnly` so a push to a locked phone still
decrypts.
- **Notification Service Extension** (`OvisNotifications`,
`sh.ovis.app.notifications`): decrypts the relay's `ovis` field (RFC
8291 / RFC 8188 `aes128gcm`) and shows the PC's title and body, with one
alert per pane tag as `public/sw.js` and Android do. An alert it cannot
decrypt shows "herdr needs you" (Korean on a Korean phone, same strings
as Android).
- **`app/ios/OvisPushCore`**: a local Swift package with the decryption
and keychain code, used by both targets. `swift test` checks the RFC
8291 appendix A vector and the refusal cases, mirroring
`WebPushDecryptTest.java`.
- **Android** (`OvisPushPlugin.java`):
`checkPermissions`/`requestPermissions` now answer whether notifications
are on before Android 13. Without that, Capacitor answers `prompt`
there, and asking would fail. The module README's "later change" note
now points at this one.
- One new hint string, "Allow notifications for Ovis in the phone's
Settings, then try again.", in en/ko/ja/zh, shown in the app instead of
the browser-settings hint when the phone refused notifications. No other
UI changes: the existing Alerts item and Test notification row drive it.
- Docs: `docs/native-app.md` (status, steps 4/5, a new "Push in the app"
section), the `app/android/ovis-push` README, and a changelog fragment.
The Android fragment loses its "client starts using it later" sentence.

## Verification

- `bun run check fast` on the branch rebased onto current main: all
steps ok (6377 unit tests pass, the push relay's included).
- `src/lib/push.test.ts`: 7 new tests for the app route (permission
mapping, subscribe with the PC's key, reuse, retired endpoint, removal,
test push, an app without the plugin).
- Android: `./gradlew :ovis-push:compileDebugJavaWithJavac
:ovis-push:testDebugUnitTest` passes.
- **Manual QA, client against a real server.** The real client ran in
Chromium with no service worker, `Notification` or `PushManager` (as in
the app's web view) and a stand-in `OvisPush` plugin. The server was a
real Ovis server on the isolated herdr test session, and the relay was
`server/push.fake.ts`, which decrypts with the keys the plugin handed
over. All 6 rows passed:
1. Before asking, the Alerts item says "On in the app", and only
`checkPermissions` is called.
2. Tapping Alerts runs `requestPermissions`, then `subscribe` with the
PC's VAPID key. The PC stores the app's `{endpoint, keys}`, the
confirmation push decrypts to "Alerts are on for this device" with a
valid VAPID signature, and the item says "On, pushed to this device".
3. A reload re-registers without prompting, and the PC still has one
subscription.
  4. Send test reaches the relay.
5. Turning Alerts off empties `push-subscriptions.json` and the plugin
forgets the endpoint.
6. With permission denied, the app hint shows and Send test is disabled.
- **iOS, on the test MacBook Air** (Xcode 27, iOS 27 simulator, fresh
clone in `/tmp` checked out at this PR's head `117b6e6a0`, removed
afterwards):
  - `swift test` in `app/ios/OvisPushCore`: 4 tests pass.
- Simulator Debug build succeeds with no warning from this change's
sources, and `App.app/PlugIns/OvisNotifications.appex` is embedded
(`sh.ovis.app.notifications`, `com.apple.usernotifications.service`).
- The generated entitlements show `aps-environment` on the app and the
shared keychain group on both targets.
  - `bun run sync` (cap sync) leaves `project.pbxproj` byte-identical.
- **iOS plugin through real `Capacitor.nativePromise` calls in the
simulator**, against a fake relay on loopback:
  - Permissions answer `granted`.
  - A bad key is rejected with `invalid_key`.
- APNs gave a real sandbox token, and the relay got lowercase hex,
`environment: "sandbox"` and the VAPID key.
- `subscribe` returned the relay's endpoint with a 65-byte `p256dh` and
a 16-byte `auth`.
- `getSubscription` and `unsubscribe` work, a repeat `subscribe` reuses
the endpoint, and the keys stay the same across relaunches.
  - `simctl push` showed the foreground banner.
- **`NotificationService`, in-process.** `simctl push` does not start a
Notification Service Extension, so a scratch build compiled the
unchanged `NotificationService.swift` into the app. It then called
`didReceive` on a request of the relay's shape, encrypted by `web-push`
for the keys `subscribe` returned. All four cases came out as expected:
- A good payload shows the PC's title and body, with `threadIdentifier`
set to the tag.
  - A garbage `ovis` shows "Ovis" / "herdr needs you".
- The same garbage under `-AppleLanguages (ko)` shows "herdr가 확인을 기다리고
있습니다".
  - An already delivered notification with the same tag is removed.

## Not verified / follow-ups

- A real push through APNs on a physical iPhone: the relay is not
deployed yet (no secrets, no deploy in this PR). `simctl push` does not
run Notification Service Extensions, so the extension running as its own
process (and reading the shared keychain item from there, including
while the phone is locked) still needs a device.
- Device signing: a team needs Push Notifications and the keychain group
on `sh.ovis.app` and `sh.ovis.app.notifications`; automatic signing
should add them.
- Tapping an alert opens the app but not the pane yet; a browser's opens
the pane.
- App Store privacy answers (step 6) should mention that the APNs token
goes to the relay.

## Review notes

Touches the push subscription and notification-permission flow on the
client. No server, HTTP/WS or protocol change. Avoids `server/index.ts`,
`shared/protocol.ts` and the files of open PRs.
devswha added a commit that referenced this pull request Oct 24, 2026
…the privacy policy (#1843)

Play Alpha 1.0 (1) was built on 2026-10-20, before `ovis-push` existed
(#1744), and its bundle carries no FCM config (no `google_app_id` in
`base/resources.pb`, no `OvisMessagingService` in the manifest). iOS
build 2 (in App Review) has no push either; native push comes with build
3, so `app/store/ios.md` is unchanged. A new Android bundle, 1.0 (2),
was built with `OVIS_GOOGLE_SERVICES` and signed with the upload key; it
is not uploaded (the owner uploads it).

**Changes**
- `app/android/app/build.gradle`: `versionCode 2` (`versionName` stays
`1.0`).
- `ovis-site/privacy/` and `ovis-site/ko/privacy/`: an Alerts section.
Once alerts are on, the app registers its APNs or FCM push token with
`push.ovis.sh`, which keeps it until Apple or Google calls it gone or it
goes unused for 60 days; alerts are end-to-end encrypted; the relay
keeps no logs or IP addresses. The summary no longer says the app sends
us nothing.
- `app/store/android.md`: 1.0 (2) is the push build; data safety lists
the push relay as a third route and the FCM token under Device or other
IDs; release name and notes for 1.0 (2).

**Checked**
- `unzip` of the new bundle: `google_app_id` present,
`OvisMessagingService` in the manifest, merged manifest
`versionCode="2"`; `keytool -printcert` matches the upload key's
SHA-256.
- Relay without a phone: `bun push-relay/test-push.ts fcm <made-up
token>` gives register 201, push 410 (FCM sign-in works).
- Every claim in the Alerts section checked against `push-relay/` and
`src/lib/push.ts` by a code-review agent (omo-native-code-reviewer),
three rounds, final verdict APPROVE.
- `bun run check fast` passes.

No code changes in `server/`, `src/` or `shared/`.

---------

Co-authored-by: mp <mp@local>
devswha added a commit that referenced this pull request Oct 25, 2026
## What

Mute one noisy agent's alerts from its row menu in the Agents list (the
⋯, a right-click or the context-menu key): **Mute alerts** / **Unmute
alerts**. A muted pane raises no alert on any channel, on any browser or
device of the server, while its status is still drawn and tracked:

- **Push, browser and phone app.** `server/push.ts` reads the shared
list when an alert is scheduled, again right before a delayed one goes
out (also after its title lookup), and when a pane ends. A mute change
calls off waiting alerts for good, so an unmute does not bring back an
old finish. The phone app (#1744, #1816, #1817) subscribes through its
`OvisPush` plugin and posts its relay endpoint to the same `POST
/api/push/subscribe`, so it is one more subscription on the same list
and is muted the same way: the push service treats every endpoint alike,
and a test pins a relay-shaped subscription held back next to a browser
one.
- **In the page:** the in-app droplet, the chime and the tab
notification (`src/lib/useAlerts.ts`). A chime that waits its turn among
open tabs checks the mute again right before it plays, and a chime
already scheduled behind another one (`src/lib/alertSound.ts`) is
silenced when the pane is muted before its notes start, unless another
pane it also tells is still unmuted; a caller is confirmed only when the
chime sounded and its pane is still unmuted.
- **Shared like the pins:** a new optional `muted_panes` in
`/api/preferences` (keys are `paneStorageId`, so a pane id reused on
another PC is not muted; validated, deduplicated, at most 500). A
missing list in a change leaves it, an empty one clears it. An older
server that keeps no list gets none sent and offers no mute. Two
browsers muting different panes at once both keep their mute (merged
pane by pane), and a refused change gives way to a newer list as the
pins do.
- A muted row shows a crossed bell. A watching device sees the item
disabled.

Refs #1052. This revives a local branch from before the i18n, `App.tsx`
and shared-type splits; it is rebased onto current main with the strings
in `src/lib/i18n/sidebar.*` and the page checks in `useAlerts.ts`.

Design: follows the per-conversation mute of chat apps (Slack's "Mute
channel", Discord's "Mute channel"): one switch in the item's own menu,
a quiet icon on the row, state shared across devices. Coding-agent apps
(Codex, Claude) have no per-session mute, so there is nothing closer to
follow. DESIGN.md has the entry.

## Why

One agent that finishes or asks often (a watcher, a looping job) drowns
out the others. The only way to quiet it was to turn alerts off for
every pane or on one device at a time.

## Storage

The list is kept in a document of its own, `muted-panes.json` (`{
"muted_panes": [...] }`) in the state directory, written by
`PreferenceStore` (`server/preferences.ts`). `preferences.json` keeps
exactly the shape every release reads and writes. A release from before
this one rewrites `preferences.json` whole on its next save; keeping the
list there would let a rollback or downgrade erase every mute. In its
own document it is an addition an older writer cannot erase, so under
the stored-format rules of #1824 it is not a structural change:

- an older release never opens `muted-panes.json`, and its saves leave
it alone; after it, this release reads the older save and the mutes
together, with no write of its own (tested);
- a missing `muted-panes.json` reads as nothing muted; a damaged one
mutes nothing, is never read as an empty list to write over, and is kept
as `muted-panes.json.bad` by the next mute (tested);
- a save writes `preferences.json` first, then `muted-panes.json`. If
the second write fails, the previous `preferences.json` is put back
before the 500, so both files are byte-for-byte as they were (tested);
- **accepted window:** two files cannot be swapped as one. If putting
`preferences.json` back fails too, or the process ends between the two
renames, `preferences.json` keeps the refused change and a restart reads
it, although memory and the client were told the save failed. Nothing is
lost; at worst a refused settings or pins change comes back after a
restart. Closing this would take a journal or one combined document,
which is more machinery than a settings store warrants;
- the HTTP/WS contract still carries the list as `muted_panes` in the
`/api/preferences` document and the `preferences` event.

## Contract change — needs a real review

This adds a field to the `/api/preferences` HTTP contract and the
`preferences` event on the machines event stream, and changes when
web/native push is sent. Per AGENTS.md it should wait for a real review,
not only CodeRabbit.

## How it was verified

- `bun run check fast`: typecheck, build and unit tests pass.
- Unit tests: `server/push.test.ts` (mute cancels a delayed push;
mute+unmute during the title lookup sends nothing; list re-read before
send; all four paths suppress only the keyed pane; the phone app's relay
subscription is muted next to a browser's), `server/preferences.test.ts`
(malformed and oversized lists, older documents, an older release's
whole rewrite of `preferences.json` after a mute, a damaged
`muted-panes.json`), `src/lib/alertSound.test.ts` (a question queued
behind a finish, muted before its notes start, never sounds and gives
its place back; a question chime two panes share keeps sounding for the
unmuted one and is confirmed only to it),
`src/lib/preferencesSync(.hook).test.ts` (older server, refused change,
concurrent mutes from two browsers), `src/lib/notifications.test.ts`.
- `server/api.contract.test.ts`: the HTTP and event-stream round trip,
two tabs' revisions, and a watching device's PUT answered 403.
- `scripts/pane-mute-demo-regression.ts` (enrolled in `ci-browser.sh`):
the unmodified app over the demo transport with the real
`PreferenceStore`, two tabs as two browsers, at 390 and 1440 wide, light
and dark, Korean at 390: the menu item, its pressed and focus states,
the crossed bell, the alerts held back, an older server and a watching
device.
- Reviewed by a code-review agent and by Codex (no HIGH findings).
Fixed: concurrent mutes from two browsers now merge pane by pane (with a
test that fails without it), and a chime waiting its turn among tabs
re-checks the mute. Known and left as is: two saves of the mute list
landing at the same instant end with the last one, as the pins do; the
menu item says Mute/Unmute and carries a checked state, as designed in
DESIGN.md.

---------

Co-authored-by: mp <mp@local>
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