Skip to content

[DX-789] Implement pubsub message annotations#148

Draft
sacOO7 wants to merge 3 commits intofix/pubsub-subscribe-history-formattingfrom
feature/pubsub-message-annotations
Draft

[DX-789] Implement pubsub message annotations#148
sacOO7 wants to merge 3 commits intofix/pubsub-subscribe-history-formattingfrom
feature/pubsub-message-annotations

Conversation

@sacOO7
Copy link
Contributor

@sacOO7 sacOO7 commented Mar 5, 2026

@vercel
Copy link

vercel bot commented Mar 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cli-web-cli Ready Ready Preview, Comment Mar 6, 2026 9:42am

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 93c2c3fc-6bdb-4e52-a5b2-462ead7bcb7e

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

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/pubsub-message-annotations

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 and usage tips.

- Updated CLAUDE.md to not truncate external markdown documentation

# Conflicts:
#	.claude/CLAUDE.md
@sacOO7 sacOO7 force-pushed the feature/pubsub-message-annotations branch from ba412bc to d146303 Compare March 6, 2026 08:41
@sacOO7 sacOO7 changed the base branch from main to fix/pubsub-subscribe-history-formatting March 6, 2026 08:43
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>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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);
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
const channel = client.channels.get(args.channel);
const channel = client.channels.get(args.channel, { modes: ["ANNOTATION_PUBLISH"] });

Copilot uses AI. Check for mistakes.
const client = await this.createAblyRealtimeClient(flags);
if (!client) return;

const channel = client.channels.get(args.channel);
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

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"] }.

Suggested change
const channel = client.channels.get(args.channel);
const channel = client.channels.get(args.channel, {
modes: ["ANNOTATION_PUBLISH"],
});

Copilot uses AI. Check for mistakes.
Comment on lines +122 to +133
// 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 },
);
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.

this.logCliEvent(
flags,
"annotations",
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
"annotations",
"annotations:subscribe",

Copilot uses AI. Check for mistakes.
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