Skip to content

v9.10.0-beta.1

@isekovanic isekovanic tagged this 14 Oct 09:19
## 🎯 Goal

Deprecate the standalone `@stream-io/chat-react-native-ai` package and
ship the AI components from the SDK itself, the same way React did in
GetStream/stream-chat-react#3314.

This is a direct port of [this part of the AI components
repo](https://github.com/GetStream/ai-components-js/tree/main/packages/react-native-sdk),
with some minor tweaks and fixes.

Apps import them from a separate entry point:

- `stream-chat-react-native/ai-components`
- `stream-chat-expo/ai-components`

Apps that don't import it are unaffected: no extra JS in their bundle
(+61 bytes, one empty native-handler slot) and no new required
dependencies.

## 🛠 Implementation details

**Port.** Markdown, syntax highlighting, charts, the AI composer and
dictation are ported 1:1. The only deliberate changes are:

- `ShimmeringView` is removed; the typing indicator uses the SDK's
native shimmer, laid over the text.
- If the dictation module isn't compiled in, the mic button hides itself
instead of crashing.
- `react-syntax-highlighter` moves to v16, for the Prism CVE.
- The native code is registered by the two wrappers instead of a
separate package.

**Isolation.** `validate-entry-isolation` (part of `yarn lint`) fails if
the main entry points ever reach the AI code or its dependencies. It
also fails if the AI entry reaches the chat SDK, so AI-only apps don't
bundle chat. Both directions are confirmed with real Metro bundles.

**Dependencies.** The JS-only libraries (zod, the highlighter,
simple-markdown, state-store) are regular dependencies. Skia and
victory-native are optional peers, needed only by apps that use the AI
components.

**Native.**

- **PerfText:** an Android Fabric text view with a C++ shadow node,
built through a custom CMakeLists in each wrapper.
- **AIDictation:** a TurboModule for both platforms.
- **iOS dictation is opt-in:** enable it with
`$StreamChatEnableDictation = true` in the Podfile, or with the new
`stream-chat-expo` config plugin. Referencing the Speech framework makes
App Store Connect require a speech-recognition purpose string from every
app, so it isn't compiled in by default.
- **Android:** the library never declares `RECORD_AUDIO`.

**Fixes on top of the port**, mostly bugs inherited from upstream:

- A final dictation result arriving after recording stops is now applied
to the input.
- Android no longer cuts users off mid-sentence when the recognizer
sends no live results.
- The iOS first press no longer races the permission prompts.
- Per-method lodash imports (-45.6 KB min) and direct
`react-syntax-highlighter` imports (-369 KB min), both in AI bundles
only.
- The native shimmer now links on RN 0.76 iOS (`StreamShimmerViewCls`),
an existing v9 issue.

**Samples.** SampleApp gets an "AI Assistant" screen. The Expo ChatGPT
sample from `ai-components-js` is ported as `examples/ExpoChatGPTSample`
(Expo 57).

**Migration.** See `package/src/ai-components/README.md`: the new import
path, the Podfile flag and plugin rename, the Babel plugin `zod` needs,
and the removed exports.

## 🧪 Testing

## 🎨 UI Changes

---------

Co-authored-by: Anton Arnautov <arnautov.anton@gmail.com>
Assets 2
Loading