Skip to content

Fix: Rename channels presence get-all to get#188

Open
sacOO7 wants to merge 2 commits intomainfrom
fix/channels-presence
Open

Fix: Rename channels presence get-all to get#188
sacOO7 wants to merge 2 commits intomainfrom
fix/channels-presence

Conversation

@sacOO7
Copy link
Contributor

@sacOO7 sacOO7 commented Mar 24, 2026

  • Renamed channels presence get-all to channels presence get
  • Removed presence update since exact same behaviour can be achieved using presence enter twice ( added description for the same )
  • Publishing presence on behalf for given clientId also gives exact same output ( new connectionId with same clientId )

Summary by CodeRabbit

  • Documentation

    • Updated presence command: ably channels presence get-all renamed to ably channels presence get.
  • Command Updates

    • The channels presence update command now requires the --client-id flag.
    • Added warning messages when wildcard client IDs affect presence operations.
    • Improved data handling in presence update workflows.

@vercel
Copy link

vercel bot commented Mar 24, 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 5:18pm

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

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: 2f196a09-7067-4f70-a742-83f7c03555ad

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

Walkthrough

This pull request renames the channels presence get-all command to channels presence get across implementation and tests, and refactors the channels presence update command to require a --client-id flag, make the --data parameter optional, and add a warning message about client ID behavior.

Changes

Cohort / File(s) Summary
Command rename (get-all → get)
README.md, src/commands/channels/presence/get.ts, test/unit/commands/channels/presence/get.test.ts
Updated command references from channels presence get-all to channels presence get. Renamed exported class from ChannelsPresenceGetAll to ChannelsPresenceGet. Updated all test cases and error identifiers to use the new command name.
Update command refactoring
src/commands/channels/presence/update.ts, test/unit/commands/channels/presence/update.test.ts
Made --client-id a required locally-defined flag (removed shared flag usage). Made --data parameter optional, defaulting to empty JSON object. Added warning message when clientId causes new connectionId entry. Changed presence entry logic to apply data only during update call. Updated all tests to include --client-id test-client flag.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A presence renamed, from many to one,
Get-all becomes get—simplification's done!
Update takes flags now, with ClientId required,
Data flows gentler, as warnings transpired. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: renaming the channels presence command from get-all to get, which is reflected across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/channels-presence

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
test/unit/commands/channels/presence/update.test.ts (2)

132-139: ⚠️ Potential issue | 🔴 Critical

Test will fail: holding status is now at lines[2], not lines[1].

Same issue as above—with the new warning line, the holding status has shifted to index 2.

Proposed fix
       const lines = stdout.trim().split("\n").filter(Boolean);
-      expect(lines.length).toBeGreaterThanOrEqual(2);
+      expect(lines.length).toBeGreaterThanOrEqual(3);
 
-      const status = JSON.parse(lines[1]);
+      // lines[0] = warning, lines[1] = result, lines[2] = holding
+      const status = JSON.parse(lines[2]);
       expect(status.type).toBe("status");
       expect(status.status).toBe("holding");
       expect(status.message).toContain("Holding presence");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/unit/commands/channels/presence/update.test.ts` around lines 132 - 139,
The test assumes the "holding" status is at lines[1] but a new warning line
pushed it to lines[2]; update the assertion in the test (in
test/unit/commands/channels/presence/update.test.ts) to parse and assert against
lines[2] (or more robustly locate the JSON object whose type is "status" and
status is "holding" instead of assuming a fixed index) by changing the JSON
parse/expect reference from lines[1] to lines[2] (or implement a find over lines
to pick the correct status object) so the test checks the actual holding status
line.

105-116: ⚠️ Potential issue | 🔴 Critical

Test will fail: JSON output indexes are off by one due to new warning line.

The implementation at update.ts:62 now emits a warning status as the first JSON line when --json is used. This means:

  • lines[0] = warning status (type: "status", status: "warning")
  • lines[1] = result (type: "result")
  • lines[2] = holding status (type: "status", status: "holding")

The test expects lines[0] to be the result, which will fail.

Proposed fix
       const lines = stdout.trim().split("\n").filter(Boolean);
-      expect(lines.length).toBeGreaterThanOrEqual(1);
+      expect(lines.length).toBeGreaterThanOrEqual(2);
 
-      const result = JSON.parse(lines[0]);
+      // lines[0] is the warning status, lines[1] is the result
+      const warning = JSON.parse(lines[0]);
+      expect(warning.type).toBe("status");
+      expect(warning.status).toBe("warning");
+
+      const result = JSON.parse(lines[1]);
       expect(result.type).toBe("result");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/unit/commands/channels/presence/update.test.ts` around lines 105 - 116,
The test assumes the first JSON line is the result but update.ts now emits a
warning as the first JSON line (see update.ts:62), so change the assertion to
locate the JSON object with type === "result" instead of using lines[0]; parse
the JSON lines array (variable lines) and pick the entry where parsed.type ===
"result" (or filter for type "result" and take the first match) and run the
existing presenceMessage assertions against that object.
🧹 Nitpick comments (1)
src/commands/channels/presence/update.ts (1)

34-37: Flag description differs from the shared clientIdFlag convention.

The local definition uses a shorter description than the shared clientIdFlag in src/flags.ts, which includes context about the "none" option and token authentication. If this simplification is intentional for this command, consider documenting the rationale. Otherwise, align with the shared flag's description for consistency.

Additionally, the description ends with a period while most flag descriptions in the codebase do not.

Suggested description alignment
     "client-id": Flags.string({
-      description: "ClientId of a channel presence member.",
+      description:
+        'Client ID for the presence member. Use "none" to explicitly set no client ID',
       required: true,
     }),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/commands/channels/presence/update.ts` around lines 34 - 37, The
"client-id" flag in update.ts diverges from the shared clientIdFlag convention:
update the "client-id" Flags.string description to match the shared clientIdFlag
wording (include the "none" option and token authentication context) and remove
the trailing period to match codebase style so the local flag description is
consistent with clientIdFlag used elsewhere.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@README.md`:
- Line 1945: The fenced code block in the README under the presence-get usage
(the block showing the "USAGE $ ably channels presence get CHANNEL ..." example)
is unlabeled and triggers markdownlint MD040; update the opening fence from ```
to ```text (i.e., add the language label "text" to the opening triple backticks
for the presence-get example) so the block is explicitly labeled while leaving
the content and closing fence unchanged.

---

Outside diff comments:
In `@test/unit/commands/channels/presence/update.test.ts`:
- Around line 132-139: The test assumes the "holding" status is at lines[1] but
a new warning line pushed it to lines[2]; update the assertion in the test (in
test/unit/commands/channels/presence/update.test.ts) to parse and assert against
lines[2] (or more robustly locate the JSON object whose type is "status" and
status is "holding" instead of assuming a fixed index) by changing the JSON
parse/expect reference from lines[1] to lines[2] (or implement a find over lines
to pick the correct status object) so the test checks the actual holding status
line.
- Around line 105-116: The test assumes the first JSON line is the result but
update.ts now emits a warning as the first JSON line (see update.ts:62), so
change the assertion to locate the JSON object with type === "result" instead of
using lines[0]; parse the JSON lines array (variable lines) and pick the entry
where parsed.type === "result" (or filter for type "result" and take the first
match) and run the existing presenceMessage assertions against that object.

---

Nitpick comments:
In `@src/commands/channels/presence/update.ts`:
- Around line 34-37: The "client-id" flag in update.ts diverges from the shared
clientIdFlag convention: update the "client-id" Flags.string description to
match the shared clientIdFlag wording (include the "none" option and token
authentication context) and remove the trailing period to match codebase style
so the local flag description is consistent with clientIdFlag used elsewhere.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 927f8ad1-cac4-4c5b-9a7d-17367172f833

📥 Commits

Reviewing files that changed from the base of the PR and between c2c1d30 and f740053.

📒 Files selected for processing (5)
  • README.md
  • src/commands/channels/presence/get.ts
  • src/commands/channels/presence/update.ts
  • test/unit/commands/channels/presence/get.test.ts
  • test/unit/commands/channels/presence/update.test.ts

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

Renames the Channels Presence command from get-all to get, and adjusts docs/tests accordingly; also updates channels presence update to emit a warning and require a client ID.

Changes:

  • Rename channels presence get-all command/test/docs to channels presence get.
  • Update channels presence update to require --client-id, emit a warning, and adjust how --data is parsed/used.
  • Refresh README command references and “See code” links for the renamed command.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/unit/commands/channels/presence/update.test.ts Updates tests to pass --client-id for the update command.
test/unit/commands/channels/presence/get.test.ts Updates tests to use the new channels:presence:get command ID.
src/commands/channels/presence/update.ts Adds a warning, changes --client-id/--data flag handling, and adjusts presence enter/update behavior.
src/commands/channels/presence/get.ts Renames the command class/telemetry identifiers and updates examples to get.
README.md Renames documentation references from get-all to get and updates the source link.

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

- Removed channels presence update command
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