Skip to content

Migrates Chat to the new @ably/pubsub-* packages - #734

Merged
ttypic merged 3 commits into
mainfrom
integration/v2
Oct 30, 2026
Merged

ttypic merged 3 commits into
mainfrom
integration/v2

Conversation

@ttypic

@ttypic ttypic commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Context

Based on PDR-091: a new major release (2.0.0) to support the new @ably/pubsub-* 3.0.0 packages.

Description

  • Pub/Sub v3: the ably peer dependency is replaced by @ably/pubsub-core. Apps install either @ably/pubsub-server or @ably/pubsub-device (optional peers) to create the client they pass to Chat. The demo and README use @ably/pubsub-device.
  • createChatClient factory: ChatClient is now an interface. new ChatClient(...) is replaced by createChatClient(realtime, clientOptions?).
  • Node.js 22+: Node 20 is EOL, so engines and CI now require Node.js 22 or newer.

All three changes break existing code. UPGRADING.md covers the migration.

@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 112 files, which is 12 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.

Run configuration
Commits

Reviewing files that changed from the base of the PR and between d20e241 and 8d6c6fb.

Files ignored due to path filters: 2
  • demo/package-lock.json is excluded by !**/package-lock.json
  • package-lock.json is excluded by !**/package-lock.json
Files selected for processing: 112
  • .github/workflows/dev.yml
  • .github/workflows/docs.yml
  • .github/workflows/publish.cdn.yml
  • .github/workflows/release.yml
  • CLAUDE.md
  • README.md
  • UPGRADING.md
  • __mocks__/@ably/pubsub-device/index.ts
  • demo/package.json
  • demo/src/components/ChatBoxComponent/ChatBoxComponent.tsx
  • demo/src/main.tsx
  • eslint.config.js
  • package.json
  • scripts/cdn_deploy.js
  • src/core/channel-manager.ts
  • src/core/chat-api.ts
  • src/core/chat-client.ts
  • src/core/client-id.ts
  • src/core/connection.ts
  • src/core/discontinuity.ts
  • src/core/errors.ts
  • src/core/index.ts
  • src/core/logger.ts
  • src/core/message-parser.ts
  • src/core/message-reactions.ts
  • src/core/message.ts
  • src/core/messages.ts
  • src/core/occupancy-parser.ts
  • src/core/occupancy.ts
  • src/core/presence.ts
  • src/core/realtime-extensions.ts
  • src/core/realtime.ts
  • src/core/room-lifecycle-manager.ts
  • src/core/room-options.ts
  • src/core/room-reaction-parser.ts
  • src/core/room-reactions.ts
  • src/core/room-status.ts
  • src/core/room.ts
  • src/core/rooms.ts
  • src/core/serial.ts
  • src/core/typing.ts
  • src/core/utils/event-emitter.ts
  • src/core/version.ts
  • src/core/vite.cdn.config.ts
  • src/core/vite.config.ts
  • src/react/helper/room-reference-manager.ts
  • src/react/hooks/internal/use-chat-client-context.ts
  • src/react/hooks/internal/use-room-context.ts
  • src/react/hooks/internal/use-room-reference-manager.ts
  • src/react/hooks/internal/use-room-status.ts
  • src/react/hooks/use-chat-client.ts
  • src/react/hooks/use-chat-connection.ts
  • src/react/hooks/use-messages.ts
  • src/react/hooks/use-occupancy.ts
  • src/react/hooks/use-presence-listener.ts
  • src/react/hooks/use-presence.ts
  • src/react/hooks/use-room-reactions.ts
  • src/react/hooks/use-room.ts
  • src/react/hooks/use-typing.ts
  • src/react/providers/chat-client-provider.tsx
  • src/react/providers/chat-room-provider.tsx
  • src/react/types/chat-status-response.ts
  • src/react/vite.config.ts
  • src/vite.config.ts
  • test/core/channel-manager.test.ts
  • test/core/chat-api.test.ts
  • test/core/chat-client.integration.test.ts
  • test/core/chat-client.test.ts
  • test/core/client-id.test.ts
  • test/core/connection.test.ts
  • test/core/message-parser.test.ts
  • test/core/messages-reactions.test.ts
  • test/core/messages.test.ts
  • test/core/occupancy-parser.test.ts
  • test/core/occupancy.test.ts
  • test/core/presence.integration.test.ts
  • test/core/presence.test.ts
  • test/core/realtime-extensions.test.ts
  • test/core/realtime-subscriptions.test.ts
  • test/core/realtime.test.ts
  • test/core/room-lifecycle-manager.test.ts
  • test/core/room-reaction-parser.test.ts
  • test/core/room-reactions.test.ts
  • test/core/room-status.test.ts
  • test/core/room.test.ts
  • test/core/rooms.integration.test.ts
  • test/core/rooms.test.ts
  • test/core/typing.integration.test.ts
  • test/core/typing.test.ts
  • test/helper/channel.ts
  • test/helper/chat.ts
  • test/helper/expectations.ts
  • test/helper/realtime-client.ts
  • test/helper/room.ts
  • test/react/helper/room-reference-manager.test.ts
  • test/react/hooks/internal/use-chat-client-context.test.tsx
  • test/react/hooks/internal/use-eventual-room.test.tsx
  • test/react/hooks/internal/use-room-reference-manager.test.tsx
  • test/react/hooks/internal/use-room-status.test.tsx
  • test/react/hooks/use-chat-client.test.tsx
  • test/react/hooks/use-chat-connection.test.tsx
  • test/react/hooks/use-messages.test.tsx
  • test/react/hooks/use-occupancy.test.tsx
  • test/react/hooks/use-presence-listener.test.tsx
  • test/react/hooks/use-presence.test.tsx
  • test/react/hooks/use-room-reactions.test.tsx
  • test/react/hooks/use-room.test.tsx
  • test/react/hooks/use-typing.integration.test.tsx
  • test/react/hooks/use-typing.test.tsx
  • test/react/providers/chat-client-provider.test.tsx
  • test/react/providers/chat-room-provider.test.tsx
  • typedoc.json

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 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

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 95.24% (🎯 95%) 4029 / 4230
🔵 Statements 95.24% (🎯 95%) 4029 / 4230
🔵 Functions 99% (🎯 98%) 298 / 301
🔵 Branches 97.02% (🎯 97%) 980 / 1010
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/core/channel-manager.ts 100% 92.85% 100% 100%
src/core/chat-api.ts 100% 100% 95.65% 100%
src/core/chat-client.ts 100% 92.85% 100% 100%
src/core/client-id.ts 100% 100% 100% 100%
src/core/connection.ts 94.84% 95.65% 100% 94.84% 333-337
src/core/discontinuity.ts 0% 0% 0% 0%
src/core/errors.ts 100% 100% 100% 100%
src/core/logger.ts 73.95% 95.83% 90.9% 73.95% 115-140
src/core/message-parser.ts 100% 100% 100% 100%
src/core/message-reactions.ts 96.44% 96.22% 100% 96.44% 483-488
src/core/message.ts 85.71% 95.23% 100% 85.71% 285-300
src/core/messages.ts 89.37% 91.48% 100% 89.37% 744-750, 789-798, 814-822, 968
src/core/occupancy-parser.ts 100% 100% 100% 100%
src/core/occupancy.ts 100% 100% 100% 100%
src/core/presence.ts 98.21% 100% 100% 98.21% 426-428
src/core/realtime-extensions.ts 100% 100% 100% 100%
src/core/realtime.ts 100% 100% 100% 100%
src/core/room-lifecycle-manager.ts 98.19% 97.22% 100% 98.19% 253-257
src/core/room-options.ts 100% 100% 100% 100%
src/core/room-reaction-parser.ts 100% 100% 100% 100%
src/core/room-reactions.ts 92.3% 92.3% 100% 92.3% 221-226
src/core/room-status.ts 100% 100% 100% 100%
src/core/room.ts 100% 100% 100% 100%
src/core/rooms.ts 100% 100% 100% 100%
src/core/serial.ts 100% 100% 100% 100%
src/core/typing.ts 90.87% 93.44% 95.23% 90.87% 374-379, 430-435, 511-515, 571-575, 691-694, 702-703
src/core/version.ts 100% 100% 100% 100%
src/core/vite.cdn.config.ts 0% 100% 100% 0% 2-18
src/core/utils/event-emitter.ts 100% 100% 100% 100%
src/react/helper/room-reference-manager.ts 89.27% 94.23% 100% 89.27% 31-41, 173-178, 227-230, 244-248
src/react/hooks/use-chat-client.ts 100% 100% 100% 100%
src/react/hooks/use-chat-connection.ts 100% 100% 100% 100%
src/react/hooks/use-messages.ts 93.82% 94.59% 100% 93.82% 542-544, 616-617, 624-629
src/react/hooks/use-occupancy.ts 100% 100% 100% 100%
src/react/hooks/use-presence-listener.ts 89% 90.24% 100% 89% 178-181, 198-201, 224-233, 237-239, 260
src/react/hooks/use-presence.ts 99.43% 100% 100% 99.43% 440
src/react/hooks/use-room-reactions.ts 100% 100% 100% 100%
src/react/hooks/use-room.ts 100% 100% 100% 100%
src/react/hooks/use-typing.ts 99% 96.29% 100% 99% 225
src/react/hooks/internal/use-chat-client-context.ts 100% 100% 100% 100%
src/react/hooks/internal/use-room-context.ts 100% 100% 100% 100%
src/react/hooks/internal/use-room-reference-manager.ts 100% 100% 100% 100%
src/react/hooks/internal/use-room-status.ts 100% 100% 100% 100%
src/react/providers/chat-client-provider.tsx 100% 100% 100% 100%
src/react/providers/chat-room-provider.tsx 100% 100% 100% 100%
src/react/types/chat-status-response.ts 0% 0% 0% 0%
Generated in workflow #3215 for commit 8d6c6fb by the Vitest Coverage Report Action

Ably Pub/Sub v3 splits the `ably` package into a shared core plus two
side-declaring wrappers. Point the SDK and the demo at the halves that
match how each of them runs.

The SDK depends on `@ably/pubsub-core@^3.0.0`. Core is the right half
for a library: it declares no side, leaving that to the client the
caller passes in. `@ably/pubsub-server` and `@ably/pubsub-device`
^3.0.0 are optional peer dependencies, one of which the application
installs to create that client.

The demo depends on `@ably/pubsub-device` and builds its client with
`createClient()`, so browser traffic is attributed to a device. The
README quickstarts move the same way.

Adapt to the breaking changes in v3:

- Ably.Realtime is gone; use the PubSubRealtimeClient interface for
  types. The v3 renames (`Rest*` to `Http*`) and removals
  (`environment`, `restHost`, `realtimeHost`, the callback overloads)
  are all things chat never used.
- pubsub-core only ships ErrorInfo, EventEmitter and PartialErrorInfo
  at runtime, so the chat EventEmitter now builds directly on the
  exported, typed Ably.EventEmitter, narrowing emit, on and off to its
  EventsMap.
- PresenceMessage gains a required memberKey, implemented as a getter.
  Our spread into PresenceMember would drop it, so omit it from the
  PresenceMember type to keep the public API unchanged.
- RealtimeChannel.publish gains a deprecated callback overload declared
  last, which vi.spyOn infers; tests now spy via a PublishableChannel
  type pinned to the promise overload.

Tests build clients with `createClient` from `@ably/pubsub-device`, and
the mock client moves to `__mocks__/@ably/pubsub-device`, so mocked
suites and the shared client helper construct it through the same
module.

ESLint drops import/named and import/namespace for TS (they can't
follow the nested `export *` chains in the new typings) and allows
spreading Message and PresenceMessage, which are now declared as
classes.

The UMD global for the external is now declared explicitly as `Ably`
instead of left to rollup to guess from the package name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Make ChatClient an interface exposing only the public surface, and
create clients via a new createChatClient(realtime, clientOptions?)
factory. The implementation moves to an internal DefaultChatClient
class, which keeps the internal logger and agent methods used by the
React bindings, matching the Rooms/DefaultRooms pattern.

This is a breaking change: `new ChatClient(...)` no longer works.
UPGRADING.md, the README, the demo and doc examples are updated, and
unit tests cover the factory.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@maratal maratal left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

Node.js 20 is end of life, so raise the minimum to 22, the oldest
supported LTS release line. Update engines, drop 20 from the CI test
matrix, move the remaining workflows from 20 to 22, and note the change
in the README and the 2.0.0 upgrade guide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ttypic
ttypic merged commit e9c3eaf into main Oct 30, 2026
12 checks passed
@ttypic
ttypic deleted the integration/v2 branch October 30, 2026 15:27
@ttypic ttypic mentioned this pull request Oct 30, 2026

This branch was successfully deployed

1 active deployment
staging/pull/734/typedoc — 8d6c6fb7 Deployed Oct 30, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants