Skip to content

Fix : channels and rooms subcommands : list and occupancy#191

Open
sacOO7 wants to merge 2 commits intomainfrom
fix/list-and-occupancy-subcommands
Open

Fix : channels and rooms subcommands : list and occupancy#191
sacOO7 wants to merge 2 commits intomainfrom
fix/list-and-occupancy-subcommands

Conversation

@sacOO7
Copy link
Contributor

@sacOO7 sacOO7 commented Mar 25, 2026

  1. channels list / rooms list -> now only returns names of channels and rooms without occupancy. Avoids retrieving occupancy for every listed channel. We already have separate subcommands channels occupancy get and rooms occupancy get to retrieve occupancy.
  2. channels occupancy/ rooms occupancy -> refactored to show all fields for json/non-json flags

@vercel
Copy link

vercel bot commented Mar 25, 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 25, 2026 4:39pm

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Mar 25, 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: f689751d-d715-42e5-a202-ebbee4f217f6

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
  • Commit unit tests in branch fix/list-and-occupancy-subcommands

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.

@sacOO7 sacOO7 changed the title Fix : channels and rooms subcommands Fix : channels and rooms subcommands : list and occupancy Mar 25, 2026
@sacOO7 sacOO7 requested a review from Copilot March 25, 2026 09:43
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

This PR updates the channels and rooms listing + occupancy subcommands to avoid expensive occupancy lookups during listing, and to standardize occupancy output (both human-readable and JSON) across commands.

Changes:

  • channels list / rooms list now return only channel/room identifiers (no occupancy), avoiding per-item occupancy retrieval.
  • channels occupancy / rooms occupancy JSON output is refactored to consistently nest results/events under a top-level occupancy field.
  • Unit tests and README command docs are updated to reflect the new output shapes and behavior.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/unit/commands/rooms/occupancy/subscribe.test.ts Updates subscribe tests to use Realtime occupancy events and validate occupancy-nested JSON envelopes.
test/unit/commands/rooms/occupancy/get.test.ts Updates get tests to use REST /channels/:id?occupancy=metrics and validate all metrics + occupancy nesting.
test/unit/commands/rooms/list.test.ts Removes occupancy assertions; updates JSON expectations to room-name-only objects and includes total/timestamp/hasMore.
test/unit/commands/rooms/features.test.ts Aligns feature tests with REST/realtime mocks and new subscribe/get behaviors.
test/unit/commands/channels/occupancy/subscribe.test.ts Updates event assertions to expect occupancy.channelName rather than a top-level channel.
test/unit/commands/channels/occupancy/get.test.ts Updates JSON shape assertions to occupancy.channelName + metrics; ensures all 6 metrics appear in text output.
test/unit/commands/channels/list.test.ts Removes occupancy-from-list assertions; updates JSON expectations to channelId-only items and paging metadata.
src/commands/rooms/occupancy/subscribe.ts Refactors room occupancy subscribe to use Realtime [meta]occupancy on ${room}::$chat and nest JSON under occupancy.
src/commands/rooms/occupancy/get.ts Refactors room occupancy get to use REST channel details + occupancy metrics and nest JSON under occupancy.
src/commands/rooms/list.ts Removes occupancy printing and returns only room names (and paging metadata) in both text and JSON output.
src/commands/channels/occupancy/subscribe.ts Nests JSON events under occupancy and prints structured metrics fields in text output.
src/commands/channels/occupancy/get.ts Nests JSON results under occupancy and prints all 6 metrics in text output.
src/commands/channels/list.ts Removes occupancy printing and returns only channel IDs (and paging metadata) in both text and JSON output.
README.md Updates generated command docs/examples to reflect flag changes and updated descriptions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

1. list -> now only returns names of channels and rooms without occupancy
2. occupancy -> refactored to show all fields for json/non-json flags
- Refactored channels list and rooms list commands to return plain names
@sacOO7 sacOO7 force-pushed the fix/list-and-occupancy-subcommands branch from 21a8155 to 3b1dffc Compare March 25, 2026 16:10
@sacOO7 sacOO7 marked this pull request as ready for review March 25, 2026 16:30
@claude-code-ably-assistant
Copy link

Walkthrough

This PR refactors the channels list and rooms list commands to return only names (removing the previously bundled occupancy data), and improves the channels occupancy and rooms occupancy subcommands to show all available metrics fields. It also fixes the JSON output structure to follow the domain-nesting convention, and rewires rooms occupancy to use the REST API directly rather than the Chat SDK.

Changes

Area Files Summary
Commands src/commands/channels/list.ts, src/commands/rooms/list.ts Stripped occupancy data from list output; now returns plain channel/room names only
Commands src/commands/channels/occupancy/get.ts, src/commands/channels/occupancy/subscribe.ts Added missing objectPublishers/objectSubscribers fields; fixed JSON nesting under occupancy key; improved human-readable output format
Commands src/commands/rooms/occupancy/get.ts, src/commands/rooms/occupancy/subscribe.ts Rewired from Chat SDK to REST/Realtime APIs; added all 8 metrics; fixed JSON nesting under occupancy key
Commands src/commands/spaces/occupancy/get.ts, src/commands/spaces/occupancy/subscribe.ts Added objectPublishers/objectSubscribers to metrics output
Tests test/unit/commands/channels/list.test.ts, test/unit/commands/rooms/list.test.ts Updated to match new plain-name list output
Tests test/unit/commands/channels/occupancy/get.test.ts, test/unit/commands/channels/occupancy/subscribe.test.ts Updated assertions for new field set and JSON structure
Tests test/unit/commands/rooms/occupancy/get.test.ts, test/unit/commands/rooms/occupancy/subscribe.test.ts Replaced Chat SDK mocks with REST/Realtime mocks; rewrote tests for new API
Tests test/unit/commands/rooms/features.test.ts, test/unit/commands/spaces/occupancy/get.test.ts Updated mock data and assertions for new objectPublishers/objectSubscribers fields
Tests test/e2e/channels/channel-occupancy-e2e.test.ts Minor assertion update
Docs README.md Regenerated — reflects removed --client-id from rooms occupancy get, updated descriptions

Review Notes

  • Breaking change — channels list and rooms list JSON output: The --json output for both commands no longer includes occupancy metrics. Previously the channels array contained { channelId, metrics } objects; now it contains plain strings. Any scripts or tooling consuming this output will need updating.
  • Breaking change — rooms occupancy get JSON shape: The JSON envelope previously had top-level room and metrics keys; it now nests everything under an occupancy key (occupancy.roomName, occupancy.metrics). Same for channels occupancy get which moved from { channel, metrics } to { occupancy: { channelName, metrics } }.
  • rooms occupancy SDK change: The rooms occupancy get and rooms occupancy subscribe commands now bypass the Chat SDK and use the Pub/Sub REST API and Realtime channel directly (via [meta]occupancy channel subscription). This is intentional to access the full 8-field metrics set — but reviewers should confirm the channel naming convention (roomId::$chat) and [meta]occupancy event name are correct per the Ably Chat spec.
  • --client-id removed from rooms occupancy get: The flag was dropped from this command (visible in README diff). Verify this is intentional given the command no longer creates a Realtime client.
  • Unconditional zero-display: The occupancy commands now always print all 8 metric fields even when zero, removing the previous conditional rendering for presence/object fields. This is a minor UX change to ensure consistent output.

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