Skip to content

feat(react-native): add registerEvent to the React Native SDK (#128) - #147

Merged
V3RON merged 10 commits into
issue-127-add-registerevent-to-the-kotlin-sdkfrom
issue-128-add-registerevent-to-the-react-native-sd
Oct 2, 2026
Merged

V3RON merged 10 commits into
issue-127-add-registerevent-to-the-kotlin-sdkfrom
issue-128-add-registerevent-to-the-react-native-sd

Conversation

@V3RON

@V3RON V3RON commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

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 like registerTool, through new TurboModule methods registerEvent(json) and unregisterEvent(name) on iOS and Android. In development, postEvent warns about an undeclared name and about a payload that fails a declared Standard Schema; production posts as-is. The playground declares playground_ping.

Acceptance criteria

# Criterion Test Tier
1 registerEvent reaches events.list with description and schema; the disposer removes it event-registration.test.ts (bridge contract); device run for the list unit, device
2 Dev: undeclared name warns, names the event, still posts event-registration.test.ts "warns about an undeclared name" unit
3 Dev: payload failing the declared schema warns event-registration.test.ts "warns when the payload fails" unit
4 Prod: no warnings, payload as-is event-registration.test.ts "posts as-is with no warnings" unit
5 docs/TOOLS.md and writing-tools.md say to declare events docs diff review

E2E 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):

$ appduct events ls
  playground_ping { at: number }
    The Ping button on the Status tab was pressed.
$ appduct events ls --name playground_ping --json   # full payload_schema, at: number
$ appduct_list_events (MCP, this branch)  ->  [{"name":"playground_ping","signature":"playground_ping { at: number }","description":"The Ping button on the Status tab was pressed."}]
  • Listed on iOS and Android; exact-name and --json work; MCP list matches on both.
  • Still listed after background then foreground (iOS: session resumed; Android: suspended then active).
  • Declared ping reached events tail (seq 1). With a temporary local edit posting playground_undeclared (reverted): it reached events tail and appduct_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.md has an entry under Unreleased
  • User-facing docs updated
  • No new import past a module's index.ts; no new direct node:* I/O outside an adapter
  • Simplification checklist applied
  • docs/ARCHITECTURE.md updated if a surface it describes changed

Out of scope

The Android release-noop core (packages/native/android/core-noop) has no registerEvent, so NativeAppductModule will 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

@V3RON V3RON left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment: 0 blockers, 1 should-fix.
Spec: issue #128 and the #95 design comment.
Fix first: the shipped skill's event section is React Native-only but reads as if it applies to Swift and Kotlin apps too.


- `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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 V3RON left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@V3RON
V3RON added this pull request to stack #148 October 2, 2026 09:41
@V3RON
V3RON marked this pull request as ready for review October 2, 2026 09:41
V3RON added 2 commits October 2, 2026 12:27
…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
@V3RON
V3RON merged commit 9b3aa4b into main Oct 2, 2026
8 checks passed
@V3RON
V3RON deleted the issue-128-add-registerevent-to-the-react-native-sd branch October 2, 2026 12:03
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.

Add registerEvent to the React Native SDK

1 participant