feat(react-native): add registerEvent to the React Native SDK (#128) - #147
Conversation
…128) 11 failing -> 0 failing (JS layer; native bridges follow)
…he-kotlin-sdk' into issue-128-add-registerevent-to-the-react-native-sd
|
|
||
| - `payloadSchema` takes the same forms as `inputSchema`; a raw JSON Schema is listed but never | ||
| checked. `name` can be any string, dotted names included. | ||
| - Declaring is advisory: an undeclared `postEvent` still arrives. In dev, `postEvent` warns about |
There was a problem hiding this comment.
should-fix. This section reads as applying to every app, but it only covers React Native. The tool section above gives Swift and Kotlin examples too. An agent working on a native app gets told to "declare every event the app posts", sees only a TS registerEvent({...}) call, and is told postEvent warns in dev, which Swift and Kotlin deliberately don't do (see the design's "Dev warnings are React Native only"). Concretely: in a Kotlin app the agent writes registerEvent({ name, ... }), or expects a dev warning it will never get. Fix: add the one-line Swift (Appduct.shared.registerEvent(name:description:payloadSchema:)) and Kotlin (Appduct.registerEvent(name, description, payloadSchema)) calls, and say the dev warnings are React Native only. docs/TOOLS.md L189 has the same unqualified dev-warning claim.
V3RON
left a comment
There was a problem hiding this comment.
Approve (posted as a comment because GitHub blocks approving your own PR), 0 findings. Round 1's should-fix is resolved: TOOLS.md and writing-tools.md now show Swift and Kotlin, and the snippets match the real APIs in packages/native (Appduct.shared.registerEvent and Appduct.registerEvent, each with remove()). Dev warnings are now described as React Native only.
Spec: issue #128 and the PR's criteria table.
Before marking ready: the E2E notes and the Out of scope note in the PR body are out of date. The event is now declared on the Tools tab, and core-noop already has registerEvent.
…he-kotlin-sdk' into issue-128-add-registerevent-to-the-react-native-sd
…he-kotlin-sdk' into issue-128-add-registerevent-to-the-react-native-sd
…he-kotlin-sdk' into issue-128-add-registerevent-to-the-react-native-sd
…he-kotlin-sdk' into issue-128-add-registerevent-to-the-react-native-sd
Closes #128
Stacked on #146 (base: the Kotlin branch), top of #143 <- #144 <- #145 <- #146.
What changed
registerEvent({ name, description, payloadSchema? })in@appduct/react-native, returning a disposer likeregisterTool, through new TurboModule methodsregisterEvent(json)andunregisterEvent(name)on iOS and Android. In development,postEventwarns about an undeclared name and about a payload that fails a declared Standard Schema; production posts as-is. The playground declaresplayground_ping.Acceptance criteria
registerEventreachesevents.listwith description and schema; the disposer removes itevent-registration.test.ts(bridge contract); device run for the listevent-registration.test.ts"warns about an undeclared name"event-registration.test.ts"warns when the payload fails"event-registration.test.ts"posts as-is with no warnings"docs/TOOLS.mdandwriting-tools.mdsay to declare eventsE2E evidence
Target: iOS simulator (iPhone 17 Pro, iOS 26.4) and Android emulator (Pixel_8_API_35, Android 15), Expo playground, commit 345eb0f. Branch's own daemon, APPDUCT_STATE_DIR=/tmp/ad128, wssPort 0.
Smoke: SMOKE_OK on both; throwing_tool returns tool_execution_error.
Feature (the Status tab must be opened once: the event is declared in that screen's effect):
events tail(seq 1). With a temporary local edit postingplayground_undeclared(reverted): it reachedevents tailandappduct_events(seq 2), and Metro logged: WARN [Appduct] postEvent("playground_undeclared"): this event is not declared, so agents cannot list it. Declare it with registerEvent({ name, description, payloadSchema }). Undeclared check run on iOS only (shared JS path).Checklist
CHANGELOG.mdhas an entry underUnreleasedindex.ts; no new directnode:*I/O outside an adapterdocs/ARCHITECTURE.mdupdated if a surface it describes changedOut of scope
The Android release-noop core (
packages/native/android/core-noop) has noregisterEvent, soNativeAppductModulewill not compile there until #127 adds it; left alone per the stack rules.Status
Implement: done (5/5 green) Review: round 2, approve E2E: pass (iOS + Android, Expo playground) Ready: yes