[DX-789] Implement pubsub message annotations#148
[DX-789] Implement pubsub message annotations#148sacOO7 wants to merge 3 commits intofix/pubsub-subscribe-history-formattingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
1ac56f2 to
ba412bc
Compare
- Updated CLAUDE.md to not truncate external markdown documentation # Conflicts: # .claude/CLAUDE.md
ba412bc to
d146303
Compare
…pect to CLAUDE.md
ably channels annotations publish <channelName> <msgSerial> <annotationType> ably channels annotations delete <channelName> <msgSerial> <annotationType> ably channels annotations get <channelName> <msgSerial> ably channels annotations subscribe <channelName>
There was a problem hiding this comment.
Pull request overview
Adds Ably Channel Message Annotations support to the CLI (DX-789) by introducing new channels annotations subcommands plus supporting validation, mocks, and tests.
Changes:
- Introduces new commands:
channels annotations publish|delete|get|subscribe. - Adds shared annotation-type parsing/validation utilities.
- Extends test mocks and adds unit + E2E coverage for the new commands.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/commands/channels/annotations.ts |
Adds channels:annotations topic command entry point. |
src/commands/channels/annotations/publish.ts |
Implements publishing annotations with param validation and JSON/human output. |
src/commands/channels/annotations/delete.ts |
Implements deleting annotations with param validation and JSON/human output. |
src/commands/channels/annotations/get.ts |
Implements fetching annotations for a message via REST. |
src/commands/channels/annotations/subscribe.ts |
Implements long-running subscription to annotation events with --duration support. |
src/utils/annotation-validation.ts |
Centralizes annotation type parsing + required-flag validation. |
test/helpers/mock-ably-realtime.ts |
Adds annotations support to realtime channel mock. |
test/helpers/mock-ably-rest.ts |
Adds annotations support to REST channel mock. |
test/unit/commands/channels/annotations/*.test.ts |
Adds unit coverage for validation + new commands. |
test/e2e/channels/channel-annotations-e2e.test.ts |
Adds E2E coverage for publish/get/delete/subscribe flows. |
ANNOTATIONS_IMPL.md |
Documents the implementation plan and SDK behavior notes. |
.claude/CLAUDE.md |
Minor formatting + adds guidance about not truncating fetched markdown docs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const client = await this.createAblyRealtimeClient(flags); | ||
| if (!client) return; | ||
|
|
||
| const channel = client.channels.get(args.channel); |
There was a problem hiding this comment.
channels.get() is called without setting the Ably channel mode required for annotation publishing. The Ably SDK expects ANNOTATION_PUBLISH mode for annotation publish/delete; without it, channel.annotations.publish() can fail at runtime. Request the channel with { modes: ["ANNOTATION_PUBLISH"] } (and preserve/merge any other modes if needed).
| const channel = client.channels.get(args.channel); | |
| const channel = client.channels.get(args.channel, { modes: ["ANNOTATION_PUBLISH"] }); |
| const client = await this.createAblyRealtimeClient(flags); | ||
| if (!client) return; | ||
|
|
||
| const channel = client.channels.get(args.channel); |
There was a problem hiding this comment.
channels.get() is called without setting the Ably channel mode required for annotation publishing. The Ably SDK expects ANNOTATION_PUBLISH mode for annotation publish/delete; without it, channel.annotations.delete() can fail at runtime. Request the channel with { modes: ["ANNOTATION_PUBLISH"] }.
| const channel = client.channels.get(args.channel); | |
| const channel = client.channels.get(args.channel, { | |
| modes: ["ANNOTATION_PUBLISH"], | |
| }); |
| // 6. Wait until interrupted or timeout | ||
| const exitReason = await waitUntilInterruptedOrTimeout(flags.duration); | ||
|
|
||
| // 7. Auto-unsubscribe on cleanup | ||
| channel.annotations.unsubscribe(); | ||
| this.logCliEvent( | ||
| flags, | ||
| "annotations:subscribe", | ||
| "cleanup", | ||
| "Unsubscribed from annotations", | ||
| { exitReason }, | ||
| ); |
There was a problem hiding this comment.
Cleanup after the --duration timeout won’t run in non-test mode: waitUntilInterruptedOrTimeout() calls process.exit(0) on timeout (src/utils/long-running.ts:42-48), so execution never reaches channel.annotations.unsubscribe() / logCliEvent() below. To ensure unsubscribe/logging happens, avoid relying on waitUntilInterruptedOrTimeout()’s timeout exit (e.g., implement the duration timer in this command and call this.exit() after cleanup, or change the helper to always resolve and let callers decide when to exit).
|
|
||
| this.logCliEvent( | ||
| flags, | ||
| "annotations", |
There was a problem hiding this comment.
logCliEvent uses two different event namespaces in the same command ("annotations" vs "annotations:subscribe"). This makes downstream log filtering/analytics harder and inconsistent with other commands. Use a single consistent namespace (typically the command id, e.g. "annotations:subscribe") for all events emitted from this command.
| "annotations", | |
| "annotations:subscribe", |
Uh oh!
There was an error while loading. Please reload this page.