Skip to content

fix(ios): open a tapped alert's pane on the PC that sent it - #4236

Closed
jimbb wants to merge 1 commit into
devswha:mainfrom
jimbb:fix/ios-alert-tap
Closed

jimbb wants to merge 1 commit into
devswha:mainfrom
jimbb:fix/ios-alert-tap

Conversation

@jimbb

@jimbb jimbb commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Change

Implements iOS parity with #3935 so tapping a push notification in the iOS app opens the pane the alert is about on the saved PC that sent it, instead of only bringing the app forward on whatever screen it last showed.

  • app/ios/OvisPushCore/Sources/OvisPushCore/AlertRouting.swift (plus AlertRoutingTests.swift): resolves decrypted alert payloads (pane_id, machine_id, workspace_id, endpoint, server_id) to a saved direct PC or relay PC scope, mirrors Android's PCStore.alertLink / alertTap / appPage / selectionScript rules, and handles iOS's scoped UserDefaults endpoint keys (https://app.ovis.sh/s/<server_id>/).
  • app/ios/App/App/OvisPushPlugin.swift: implements didReceive(response:) (default tap action only), decrypts userInfo["ovis"] with the phone's Keychain keys (so a tap works even if the Notification Service Extension timed out, and nothing unencrypted in userInfo can steer navigation), deduplicates by notification request identifier, and re-binds UNUserNotificationCenter.current().delegate = router on load() so reopen() never leaves the delegate pointing at a deallocated router.
  • app/ios/App/App/HerdrBridgeViewController.swift:
    • openAlert(...): delivers ovis-select-pane (with navigator.serviceWorker fallback for older HTTPS PCs) directly into the open WebView without reloading when the alert is for the PC and app page already shown; otherwise sets PCStore.current / pendingStart and reopens on the alert's URL.
    • reopen(): dispatches ovis-page-leaving (waiting up to 1 s) before tearing down an open PC WebView so in-memory unsent drafts carry over to recovery when switching PCs.
  • app/ios/App/App/SceneDelegate.swift: handles connectionOptions.notificationResponse before creating the initial HerdrBridgeViewController so cold launches from a notification tap open the alert's PC and pane directly.
  • docs/native-app.md and changelog.d/ios-alert-tap-opens-pane.md: updated to reflect iOS alert-tap navigation.

Validation

  • Ran bun run check fast on Linux: workflow syntax, generate:types --check, generate:themes --check, typecheck, build, scripts/changelog-fold.test.ts (12/12), and 19,452/19,454 unit tests passed (the 2 unrelated failures were src/lib/useAddressBar.hook.test.ts on local Bun 1.4.2 and server/lan-https.test.ts).
  • Not run yet (opening as Draft until tested on macOS/iPhone):
    • cd app/ios/OvisPushCore && swift test on macOS
    • Xcode build of App + OvisNotifications
    • Real iPhone tap test (same PC warm, reader page, different PC, and cold start)

@coderabbitai

coderabbitai Bot commented Nov 19, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • 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

@devswha

devswha commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Closing this stale draft PR. The iOS alert-routing parity gap is real, but HerdrBridgeViewController.swift and PCStore have changed substantially on main since this branch was created (including SSH PCs, build-scoped PCStore.appOrigin, and the hosted Home flow), so this branch would need a fresh implementation and macOS/Xcode verification against current main. Feel free to open a fresh PR or issue if you pick this up on a Mac. Thank you for working on it.

@devswha devswha closed this Nov 23, 2026
devswha added a commit that referenced this pull request Nov 27, 2026
## Change

A fresh take on #4236 (closed as stale), rebuilt on current `main` after
its SSH PCs, build-scoped `PCStore.appOrigin`/`shellOrigin`, the hosted
Home flow and the shell served from inside the app. Tapping a pane's
alert in the iPhone app now opens that pane on the saved PC that sent
it, as the Android app has done since #3935.

- **`app/ios/OvisHomeCore/Sources/OvisHomeCore/Alert.swift`** (+
`AlertTests.swift`): the decisions alone, twin of Android's
`PCStore.alertLink` / `alertTap` / `appPage`, with Android's test cases
ported plus the iOS key forms:
- `Alert.link`: the PC saved under the key its endpoint was kept under;
else a relay PC by its relay ID, as the scope on the shell's own origin
(`capacitor://app.ovis.sh/s/<id>/` in a store build that serves the
shell itself, `https://app.ovis.sh/s/<id>/` in one that loads it). A
relay ID never moves an alert from a PC's own address, or from another
relay PC's scope, onto a scope; an endpoint kept under the hosted origin
before the shell moved inside the app (`PCStore.settleShell`) is not the
current pairing's and opens nothing.
- `Alert.handsToPage` / `appPage`: the page on screen takes the pane
when it is a page of the alert's PC and runs the app (not a reader, an
API answer, `/ws` or a file).
- `Alert.selectionScript`: the same `ovis-select-pane` dispatch as
Android (worker message fallback for older pages), answering `true` so a
page that could not run it gets the alert's address instead.
- **`OvisPushPlugin.swift`**: `didReceive` → `tapped`: default action
only; decrypts `userInfo["ovis"]` with the phone's keychain keys
(nothing unencrypted steers navigation, and a tap works where the
extension timed out), maps the alert's endpoint to the PC key it was
stored under, opens each request once (a launching tap can come both
ways).
- **`HerdrBridgeViewController.swift`**: `openAlert` hands the pane to
the PC page on screen (cover lifted, not being replaced), else opens the
alert's PC with `PCStore.open` + `reopen()`, after dispatching
`ovis-page-leaving` on a PC page on screen (waiting at most 1 s) so text
it held in memory alone waits in Recover unsent text. Nothing happens
while a sheet (SSH setup, scanner) is presented: dismissing it from here
would skip its own `model.leave()`. Before the first screen exists it
only makes the PC the one that opens.
- **`SceneDelegate.swift`**: a tap that launched the app
(`connectionOptions.notificationResponse`) is handled after
`settleShell()` and before the first screen, so that screen opens the
alert's PC at its pane.
- **`docs/native-app.md`**,
**`changelog.d/ios-alert-tap-opens-pane.md`**.

Deliberate differences from Android, documented: a relay PC's page
inside the hosted app the person kept as the PC is that relay PC's own,
so its alert selects the pane in place (Android reloads at the scope);
and the sheet rule above. No server, client or contract change:
`server/push.ts` already names `endpoint` / `server_id` for every relay
push.

## Validation

On macOS 27 / Xcode 27.2 (Apple silicon):

- `sh app/ios/check.sh`: OvisHomeCore 107 tests (7 new in `AlertTests`),
OvisSshCore 72 (6 skipped, as on `main`), OvisPushCore 22, ScopePath and
OpeningWatch checks — all pass.
- `xcodebuild` of `App` + `OvisNotifications`: Debug for the iOS
Simulator, and Release for `generic/platform=iOS` with
`CODE_SIGNING_ALLOWED=NO`; both succeed, no new warnings (the 12 left
are in SSH and barcode-scanner files).
- Simulator run (iPhone 17, iOS 27.2) of the real app built from this
branch with `bun run build:web` + `cap sync ios`, against two stub Ovis
PCs on loopback (answering `/api/health?scope=bridge`, logging page
loads, `ovis-select-pane` and `ovis-page-leaving`) and a stub push relay
(`OVIS_PUSH_RELAY` override). The app subscribed through `OvisPush`
(real simulator APNs token, real keychain keys); each alert was the PC's
JSON encrypted for that subscription (RFC 8291 via `web-push`) and
delivered with `xcrun simctl push`, its banner tapped with AXe. 6/6
cases passed:
  0. alert naming no endpoint/relay ID → nothing selected or loaded
1. alert for the PC on screen (app page) → `select-pane` `{pane_id,
machine_id, workspace_id, view: chat}`, no reload
2. alert for the other saved PC → `page-leaving` on the old page, then
the other PC loads at `/?machine=local&ws=w2&pane=w2%3Ap2&view=chat`
3. alert for the PC on screen at `/?read=notes.md` → `page-leaving`,
then its address loads (no select)
  4. same as 2 with the app in the background (behind Settings)
5. app not running → the tap launches it straight onto the alert's PC at
its pane, exactly one page load
- `bun run check fast`: workflow syntax skipped, generated types/themes
fresh, typecheck and build ok; unit tests fail in 18 server/scripts
files with 28 failing tests. The same 28 (plus 4 timing ones) fail on a
clean `main` checkout on this Mac (case-insensitive file names, `/proc`,
sockets, SQLite WAL, SSH), and this PR changes no TypeScript.
- Not run: a real iPhone with live alerts (only a Personal Team on this
Mac; the relay's APNs key is the `sh.ovis.app` team's), a relay PC end
to end (covered by `AlertTests`), and the Integration, Windows and
container CI jobs (left to CI).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Jimmy <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: devswha <[email protected]>
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.

2 participants