Repository navigation
feat(mobile): fire the page's haptics over the bridge notify (OTA phase C, C7.10 E) - #21864
Conversation
`native.haptics.trigger` joins the envelope's notify union with a `kind` of exactly the five `src/platform/haptics.ts` has, and the single token `haptics` joins `BRIDGE_NOTIFY_GRANTS` and `MOBILE_WEB_SHELL_GRANTS`. A notify rather than a verb because nothing is owed back: a reply would spend a slot in the same 64-deep in-flight window a forwarded request does, and there are 90 call sites in this app, some of them one per row of a scrolling list (rulings-ota-c7.md ruling 30). The arm's fields live in their own module because `bridge-envelope.ts` is at its line cap, as `bridge-event-envelope-bytes.ts` already is; the version literal stays in the envelope, so the fields are spread in beside it rather than reading it back through an import cycle. The shell's half rides `onHaptic` on `BridgeHostOptions`, as every other device-local notify does: the host is the protocol's side of the bridge and a static import of the app's haptics would put `react-native` and `expo-haptics` in its graph, which breaks every test that loads it. `page-haptics.ts` is the one mapping — `haptics.ts`'s own functions, its `Platform.OS` split and its Android `HapticFeedbackConstants` untouched. The dispatch branch rides along with the union rather than waiting for the page side: `Record<BridgeNotifyName, …>` and the `notify` fall-through are total over that union, so the shell does not compile without it. That is the totality working, and `bridge-notify-grants.test.ts` shows it as the TS2741 a missing row is. Red first: the envelope cases per kind, the ungranted refusal, the grant-list pin and the missing-row type error all failed against the tree before this. Control on the dispatch: neutering `options.onHaptic` reds 2 of the 29 cases. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…g nothing `haptics.web.ts` stops being five no-ops. Each of the five posts its own kind through the notify seam the entry publishes — the same shape `publishExternalLinkOpener` has, and for the same reason: every caller is a plain function inside a row's press handler that no provider wraps. `notifyHaptics` joins the page client beside the other gated notifies and answers whether the frame left, which nothing reads: a tap that did not buzz is what the page did before this, and a warning per refusal would be one per row of a scrolling list. Measured off the frame the client posted rather than a written copy of its shape, which is what drifts: 77 / 74 / 72 / 70 / 73 bytes for mediumImpact / selection / success / error / edgeBump, the widest under 0.012% of `BRIDGE_MAX_MESSAGE_BYTES`, and a twelve-row scroll 888 bytes across twelve frames. The `web-overrides.json` reason now says what the file does instead of what it declines to do. Red first: the nine web-seam cases failed on `publishHapticsNotifier is not a function`, and the six client cases on `notifyHaptics is not a function`. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…erives the list All five declared page routes carry the `haptics` grant, and the list is a measurement rather than a hand choice: `WorktreeListRow` is in every page closure and calls the seam, so a route without the grant is a page whose taps stop buzzing with nothing on screen to say why. Grants are resolved once from the route the shell opened and held for the session, so the declaration is the only place to fix it. `mobile-web-app-haptics-seam.mjs` is the shared walk, beside the external-link one: it reads the kinds off the tuple that declares them, finds every exported `trigger…` function in a haptics module, and reports the kind each one posts. The posting call is found through the binding `publishHapticsNotifier` assigns rather than a local spelled `post`, because a rename would otherwise turn every posting site into a non-posting one and leave this green on a page with no haptics at all. The census proper holds each route's closure to the `.web.ts` sibling, asserts at least one importer so the grant is not idle, and derives the granted-route list from the closures. The control is the design's: the same walk over the native sibling finds the same five functions and no posting site, so "all five post" is a number rather than an empty scan. Controls run: dropping `haptics` from one route reds 1 of 23; neutering one web post reds 1 of 23. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
One module. Every page closure grew by exactly `bridge-haptics-notify.ts`, and it arrives through `page-route-policy.ts` reading the grant token rather than through the seam, whose import of the kind type is erased; its only dependency is `zod`, which the envelope already put in every closure, so the module total moved by the same one. Local counts per route went 294 → 295, 379 → 380, 435 → 436, 309 → 310, 335 → 336. Pinned structurally rather than as a total, because an absolute closure count is main's to move and a number that drifts for unrelated reasons is one nobody reads. The call sites this replaces, measured over product modules: `triggerError` 43, `triggerSuccess` 24, `triggerSelection` 12, `triggerMediumImpact` 10, `triggerEdgeBump` 1 — 90 across 35 importing modules, which is the design's count plus `page-haptics.ts` itself. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
`bridge-host-init.test.ts` names the grants `init` issues, so the token belongs in that list. `MobileWebShellScreen.test.tsx` now mocks `expo-haptics` for the reason it already mocks the clipboard and both pickers: the screen hands `playPageHaptic` over and reaching the real module pulls in an Expo runtime this test does not have, which failed the whole suite at import. Which expo member each kind reaches stays in `page-haptics.test.ts`. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…pace index The changed-code gate refuses a computed reference into an imported namespace, in both the mapping and its test, and it is right to: `haptics[NAME_BY_KIND[kind]]()` is a call nothing can follow. Each function is a named import instead, which also keeps the second compile-time direction — a row naming something `haptics.ts` does not export is now an import error rather than a `keyof` mismatch. The third direction moves with it, from a namespace read in the test to the census that already reads both files' text: `hapticsImportedNames` names what the shell's mapping takes from the app's haptics, and the census holds that to the five the native file exports. So a haptic added there with no kind of its own still fails, and now it fails where the other two siblings' names are already compared. The test's two `as` assertions become one annotated hoisted type, the shape `MobileWebShellScreen.test.tsx` uses. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
|
Warning Review limit reachedNext included review available in 1 minute. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (32)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (8)
🚧 Files skipped from review as they are similar to previous changes (7)
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe change adds grant-controlled haptics notifications to the mobile web-shell bridge. Web haptics functions send five supported kinds through the bridge. The native shell validates and dispatches each kind to platform-specific haptic functions. All mobile web routes declare the haptics grant. Tests cover protocol validation, grant enforcement, client-host transport, device mappings, route closures, and web/native seam consistency. Priority: ⬇️ Low 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description gives detailed implementation and verification information, but it omits required template sections, including the Linked Issue, Visual Proof or an explicit N/A explanation, checklist confirmations, and the requested structured ELI5, Why, and Testing sections. Resolution Add all required template sections. Include a valid issue reference after “Fixes #”, attach before-and-after visual proof or write “N/A” with a reason, complete the testing checklist, and summarize the change and rationale in the requested sections. ✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
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. Comment |
`GRANT_NAME_PATTERN` accepts `native.haptics.trigger` — it admits `native.<a>.<b>` with lowercase segments, which is why it rejected `native.media.readChunk` and rejects `navigate-back`, not a dotted name as such. So four comments claiming a route declaring the notify's own name would have its bundle refused were false, and they are gone: the grant is a token because the notify table's grants are tokens, a notify not being a verb, and the dotted names in `MOBILE_WEB_SHELL_GRANTS` are spread from the verb table alone. Also folded, with the false claim: `implementedPageRoutes` filters on `grants.every(implementsGrant)`, so a token every page route declares couples the whole set to a shell that carries it — against one without it, no page route is served at all and the phone renders five native screens. Stated in the function's docstring and beside the census's derived list, and pinned: the same declaration under a grant this build does not implement comes back empty, with the token-free route as the control. Removing `BRIDGE_HAPTICS_GRANT` from `MOBILE_WEB_SHELL_GRANTS` reds that case. `%#` consumes no argument, so the web seam's five cases were titled with the whole function body; the kind is the first element now and `%s` names it. One 110-char comment line in `bridge-client-notifications.ts` wrapped to the file's 100; the two still over it there are main's. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the page's haptics stop being no-ops and become a notify the shell plays on the device, with a per-route grant and a census that derives it:
- The wire arm — new
native.haptics.triggernotify inbridge/bridge-haptics-notify.ts, carrying one of a closed five-kind enum; spread into the envelope's notify union so the envelope file stays under its line cap. No version bump; an unknown kind fails the whole frame. - The token —
haptics, a single grant rather than the dotted notify name (GRANT_NAME_PATTERNforbids a dotted grant), added toBRIDGE_NOTIFY_GRANTSandMOBILE_WEB_SHELL_GRANTS. - The page side —
haptics.web.tsgainspublishHapticsNotifier(wired byweb-entry/index.tsxtoclient.notifyHaptics) and each of the five functions posts its own kind; refused or unpublished is a silent no-op. - The shell side — required
onHapticonBridgeHostOptions, dispatched inbridge-host.tsbehind the grant gate, mapped bypage-haptics.tsto the app's existing five functions so thePlatform.OSsplit is written once. - Census and tests —
config/scripts/mobile-web-app-haptics-seam.*walks each route closure, asserts the.webseam is in and the native sibling out, and derives the granted route list from the closures; the native sibling is an explicit non-posting control. Envelope, refusal, dispatch, page-seam, byte-cost and grant-pin cases all read as real assertions. All five routes declarehaptics.
I verified the gating on both halves end to end and found no correctness bug. A page without the grant short-circuits before post, so nothing is ever sent to a shell that would refuse the closed notify, and the shell re-checks the grant before calling onHaptic.
ℹ️ Pre-haptics app builds fall back to native on all five page routes
implementedPageRoutes (mobile/src/mobile-web-shell/page-route-policy.ts) drops any route whose declared grants the shell does not all implement, and the session then falls back to the native screen. This PR adds haptics to all five routes, so an app build older than this shell code renders every web page natively once the host serves the new bundle — a whole-route fallback, not merely silent haptics. This is the documented behaviour ("old app against a new bundle lands on a screen that works"), and it is inherent to the per-route grant model, but it widens the set of routes that require a newer app: /h/[hostId] and agent-history previously needed only navigate+storage.
Technical details
# Older app builds lose the web pages, not just their haptics
## Affected sites
- `mobile/src/mobile-web-shell/page-route-policy.ts` — `implementedPageRoutes` filters on `route.grants.every(implementsGrant)`.
- `mobile/src/mobile-web-shell/mobile-web-shell-session.ts` — `onManifestRead` reads `implementedPageRoutes(manifest.routes)` and stays `NATIVE_ROUTE` when the pathname is not among them.
- `config/scripts/mobile-web-page-routes.mjs` — all five entries now declare `haptics`.
## Why it matters
The page half already degrades on its own: `notifyHaptics` is gated on `hasGrant('haptics')`, so a route that is rendered but not granted haptics is simply quiet. Declaring `haptics` on the route is required to *get* the grant, so there is no per-notify alternative in the current model. The consequence is that an app build predating this shell code can no longer render any of the five page routes once the bundle is served.
## Open questions for the human
- Is a whole-route native fallback for pre-`haptics` app builds the intended rollout, or should the bundle gate/version the page routes to avoid dropping a working web page for that population?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — delta since 091f02b (772c2db): a documentation and test fold with no wire, grant, kind, or byte change.
- Corrected the token rationale — the earlier comments justified the single
hapticstoken with a claim thatGRANT_NAME_PATTERNrefuses a dotted grant. It does not (native.<a>.<b>matches), so the reason was wrong. The comments inbridge-haptics-notify.ts,bridge-notify-grants.ts,bridge-notify-grants.test.ts, andpage-route-policy.tsnow give the real one: the notify table's grants are tokens because a notify is not a verb, and the dotted names inMOBILE_WEB_SHELL_GRANTScome from the verb-table spread. - Pinned the route-availability coupling —
implementedPageRoutesnow documents thatevery(implementsGrant)sends a route native whole when any one of its grants is missing, andpage-route-policy.test.tsadds a case for a route carryinghapticsplus a token-free control. This is the mechanism behind the five-route fallback flagged in the prior review; it is now stated and tested rather than implicit. - Test-title and comment cleanup —
page-haptics.test.tsputs the kind first so%snames the case instead of printing the function body, and a comment inbridge-client-notifications.tsis wrapped.
The only concern from the prior review — pre-haptics builds rendering all five page routes natively — is now documented in the census test, in implementedPageRoutes's docstring, and in the policy test, so it is no longer silent. Nothing here changes behavior.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…page closure (#21908) #21864 (haptics on the page) and #21871 (mermaid on the page) were each green against a main that lacked the other. Together, `haptics.web.ts` reaches `bridge-haptics-notify.ts` inside the session route's closure, so the module pin recorded by #21871 reads 4324 on main, not 4323. Pin the measured count and name the module. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Main at 2d697a4, which carries #21908's re-pin of the session route's module count. One conflict, the pin itself, plus `27a0889dcf`'s relay test arriving unconflicted. Resolved by keeping this branch's `SESSION_ROUTE_MODULES = 4284` and folding #21908's account into the one explanation the docstring already holds. Re-measured on the merged tree with the four postinstall generators run first rather than carried over: 4284 modules, 934 local, with `src/mobile-web-shell/bridge/bridge-haptics-notify.ts` read out of the closure by name rather than inferred from the total. What #21908 adds to the account, and what this branch could not say on its own: C7.10 item E (#21864) and mermaid (#21871) were each green against a main that lacked the other, which is how main came to hold 4323 while measuring 4324. The module reaches this branch's 4284 by that same route and not by anything this branch did. The constant's own comment is now the short form and points at the docstring, so the two explanations read once rather than twice. Nothing under `mobile/` moves in this merge. It changes exactly two files here, the closure test and `src/relay/omp-fresh-launch-environment.test.ts`, so the mobile suite is not re-run; mobile tsc is, and is clean. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

Summary
Phase C, C7.10 PR E (ruling 26: the OTA page loses no capability; ruling 30: haptics ride the notify channel): the page's haptics fire the phone's motor.
haptics.web.tswas five no-ops (the expo web shim's fake click had broken long press, C1.9); it now postsnative.haptics.triggerwithkindone of the five the nativehaptics.tshas, over the bridge's existing fire-and-forgetnotifychannel, under a new grant tokenhapticsinBRIDGE_NOTIFY_GRANTS. The shell's handler is a mapping onto the native file's own functions, so thePlatform.OSsplit and the Android constants exist once. No new frame kind, no reply, no verb table row, noBRIDGE_PROTOCOL_VERSIONchange, no Swift or Kotlin change. Inert on released apps (no release carries the shell). Not inert for the page: the grant is carried by the five page routes whose closure reaches the seam (derived by census, not listed by hand), andpage-route-policy.tsserves a page route only when the shell implements every grant it declares, so a shell without thehapticstoken renders every one of those routes natively; the flip build carries the token (C8 checklist).Why a notify and not a verb (ruling 30): a verb's reply counts against the bridge's 64-request in-flight window, and
triggerSelectionfires per file-explorer row; a notify is 70–77 bytes per kind (0.011% of the frame cap) and a twelve-row scroll is 888 bytes across 12 frames.Shape. The envelope arm's fields live in
bridge/bridge-haptics-notify.ts(the envelope file is at its line cap; the version literal stays in the envelope and the fields are spread beside it, no cycle). The shell's half is a requiredonHapticonBridgeHostOptions, asonExternalLinkis, because a static import of the app's haptics insidebridge-host.tswould putreact-nativein every test that loads it.page-haptics.tsis the one mapping.Tests. Envelope case per kind; an ungranted
hapticsrefused; the grant table's totality over the union (a missing row is a type error); shell dispatch (neuteringonHapticreds 2 of 29 cases); a page test that each of the five web functions posts exactly one notify with its kind; theconfig/scriptscensus that every module in a page route's closure importing the seam resolves to the.web.tsand that the web sibling posts for all five names, with the control that the same walk over the native file returns five non-posting sites (dropping one route's grant or neutering one web post each red one census case); the shell's two grant pins carry the token.Commits:
048a21ee6fcce0f58861cdc8f0598c8b40406fdae9c48e0760origin/main(2524737ef0; no footer)8d0a5921b6091f02b725772c2dbb23GRANT_NAME_PATTERNreason removed from four places; the route-availability coupling pinned inpage-route-policy.test.tswith the token-free route as control; test titles by kind; a comment wrapped)Verification
Round 1 (fresh): approve; findings were comment and test-title fixes, folded as
772c2dbb23. Lead re-gate at that head: tsc 0, ratchet 0, oxlint 0, oxfmt 0, changed-code quality 0, anti-slop 0, bridge + platform + web-shell suites 65 files / 981 passed, seam census 28/28, machine paths 0 (the fold touches 8 files, +75/−20, no wire, grant, kind or byte change).Lead gate on
091f02b725against2524737ef0(verify-gates.sh, artifacts rebuilt): tsc 0, tests-typecheck ratchet 0, oxlint 0, oxfmt 0, changed-code quality 0, react-doctor 0, oxlint-config 0, anti-slop 0, merge-max-lines 0, root oxlint over 31 changed files 0, root oxfmt over 6 files 0, machine paths 0; config/scripts 236 passed + the known owner-loss timing flake (green alone, 21/21); mobile 772 files / 8,649 passed, 0 failed. Lead control:triggerEdgeBumpneutered in the web sibling → the seam census fails exactlyposts every kind the notify admits from the web sibling, and nothing more(1 of 28).Known flakes seen once by the lane and green on re-run:
bridge-terminal-output-backlog,rpc-params-contract-type-only-boundary(5 s timeouts under full-suite load),pr-workflow-parallelism(glob read race).Headroom note:
bridge-envelope.tshas 2 lines ofmax-linesheadroom andconfig/scripts/build-mobile-web-app-bundle.test.mjs10; a merge touching either can red on the cap (split at a module boundary, never a bump).Not in this PR: dictation (PR D), the rich editor (C1/C2), the HTML preview (#21862), Mermaid (PR B).