Skip to content

Add --stream flag to subscribe for mutable message streaming#141

Open
zknill wants to merge 1 commit intomainfrom
zak/mutable-messages-streaming
Open

Add --stream flag to subscribe for mutable message streaming#141
zknill wants to merge 1 commit intomainfrom
zak/mutable-messages-streaming

Conversation

@zknill
Copy link
Contributor

@zknill zknill commented Feb 27, 2026

Upgrade ably SDK from 2.14.0 to 2.18.0 to support mutable messages. Add a --stream flag to channels subscribe that concatenates message.append data for the same serial, streaming tokens in-place on TTY terminals. In JSON mode, action and serial fields are included in the output when --stream is enabled.

Update the publish command's publisher callback signature to accept the new PublishResult return type from the upgraded SDK.

Summary by CodeRabbit

  • Dependencies

    • Updated Ably library to version 2.18.0.
  • New Features

    • Added --stream flag to channel subscription command enabling inline accumulation and display of messages grouped by serial number.
  • Tests

    • Added test coverage for stream mode functionality including message handling, output formatting, and serial tracking behavior.

Upgrade ably SDK from 2.14.0 to 2.18.0 to support mutable messages.
Add a --stream flag to `channels subscribe` that concatenates
message.append data for the same serial, streaming tokens in-place
on TTY terminals. In JSON mode, action and serial fields are included
in the output when --stream is enabled.

Update the publish command's publisher callback signature to accept
the new PublishResult return type from the upgraded SDK.
@cursor
Copy link

cursor bot commented Feb 27, 2026

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on March 4.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@vercel
Copy link

vercel bot commented Feb 27, 2026

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

Project Deployment Actions Updated (UTC)
cli-web-cli Building Building Preview, Comment Feb 27, 2026 3:59pm

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 040e7df and 122578d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • package.json
  • src/commands/channels/publish.ts
  • src/commands/channels/subscribe.ts
  • test/unit/commands/channels/subscribe.test.ts

Walkthrough

The PR updates the Ably dependency from 2.14.0 to 2.18.0, widens the publisher callback type to optionally return a PublishResult, and introduces a new stream-based output mode to the subscribe command that concatenates inline message data per serial with corresponding test coverage.

Changes

Cohort / File(s) Summary
Dependency Update
package.json
Ably library updated from ^2.14.0 to ^2.18.0.
Publisher Callback Type
src/commands/channels/publish.ts
Publisher callback signature widened to accept Promise<void | Ably.PublishResult> instead of Promise<void>, allowing optional result returns.
Stream Mode Feature
src/commands/channels/subscribe.ts
Adds --stream flag and stream handling with state fields (streamCurrentSerial, streamAppendCount), new methods (handleStreamMessage, finalizeStream), and modified message routing for inline token streaming and accumulation per serial.
Stream Mode Tests
test/unit/commands/channels/subscribe.test.ts
Comprehensive test suite validating stream mode behavior: message.create display, successive message.append accumulation, JSON output inclusion of action/serial, serial reset logic, and non-serial message display.

Sequence Diagram

sequenceDiagram
    participant User as User/CLI
    participant Subscribe as subscribe.ts
    participant Handler as handleStreamMessage
    participant Output as Stdout/TTY

    User->>Subscribe: channels:subscribe --stream
    Subscribe->>Subscribe: Initialize streamCurrentSerial=null, streamAppendCount=0
    
    loop For each received message
        Subscribe->>Handler: Process message via handleStreamMessage
        
        alt Message is create/append action
            Handler->>Handler: Check if serial matches streamCurrentSerial
            alt Serial changed or first message
                Handler->>Output: Finalize previous stream (if any) with count
                Handler->>Handler: Reset streamCurrentSerial, streamAppendCount=0
            end
            Handler->>Handler: Increment streamAppendCount
            Handler->>Output: Stream/delta output in-place (TTY mode)
        else Other action types
            Handler->>Output: Display message with standard structured log
        end
    end
    
    Subscribe->>Handler: finalizeStream() at loop end
    Handler->>Output: Emit final count summary
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A streaming burrow of data flows free,
Serials aligned, appends agree,
Messages nest in their proper place,
TTY rewrite—a swift update's grace.
Ably hops forward, version anew—
Dependencies dance, tests debut!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add --stream flag to subscribe for mutable message streaming' accurately and concisely describes the main change: adding a streaming feature to the subscribe command with support for mutable messages.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch zak/mutable-messages-streaming

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.

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.

1 participant