Skip to content

Add channels:inspect command to open dashboard#136

Merged
zknill merged 3 commits intomainfrom
zak/channel-inspect-command
Feb 24, 2026
Merged

Add channels:inspect command to open dashboard#136
zknill merged 3 commits intomainfrom
zak/channel-inspect-command

Conversation

@zknill
Copy link
Contributor

@zknill zknill commented Feb 20, 2026

Opens the Ably dashboard channel page in the browser for a given channel name. Constructs the URL from the configured account ID and app ID, with URL-encoding for special characters in channel names. Supports --app flag to override the current app, web CLI mode (prints URL instead of opening browser), and validates that both account and app are configured before proceeding.

This is change obviously falls short of a full channel inspector experience in the CLI, but at least the functionality is exposed to cli users, and provides a quick jump to the dashboard inspectors.

Summary by CodeRabbit

New Features

  • Introduced a new channels:inspect CLI command for quickly accessing and reviewing channel details directly within the Ably dashboard. Supports optional app selection via the --app flag, which defaults to your current app selection. Automatically handles special characters in channel names.

Note

Low Risk
Primarily adds a new command and a small behavior change in openUrl for web-CLI mode; minimal impact beyond link-opening flows.

Overview
Adds a new channels:inspect command that opens the Ably dashboard channel page for a given channel, using the configured account/app (with --app override) and URL-encoding the channel name.

Introduces a hidden global --dashboard-host/ABLY_DASHBOARD_HOST override for constructing dashboard links, and updates openUrl so web CLI mode prints Visit <url> instead of attempting to open a browser. Includes unit tests covering URL construction, overrides, and missing account/app errors.

Written by Cursor Bugbot for commit f932b47. This will update automatically on new commits. Configure here.

@vercel
Copy link

vercel bot commented Feb 20, 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 Feb 23, 2026 4:37pm

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Feb 20, 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.

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

A new CLI command ChannelsInspect is introduced that enables users to inspect Ably channels by opening their dashboard. The command accepts a required channel name argument and optional --app flag, validates account and app configurations, constructs a dashboard URL, and opens it in a browser or displays it for web CLI mode with appropriate error handling.

Changes

Cohort / File(s) Summary
ChannelsInspect Command Implementation
src/commands/channels/inspect.ts
New command class extending AblyBaseCommand with channel name argument, --app flag support, URL construction for dashboard access, and browser/display handling with account and app validation.
Test Suite
test/unit/commands/channels/inspect.test.ts
Comprehensive test coverage including normal CLI mode URL opening, special character encoding, account/app validation errors, --app flag priority, web CLI mode display behavior, and help text verification.

Sequence Diagram

sequenceDiagram
    participant User as User/CLI
    participant Cmd as ChannelsInspect
    participant Config as Config Manager
    participant Browser as Browser/Dashboard
    
    User->>Cmd: channels:inspect [channel-name] --app [app-id]
    Cmd->>Config: Get current account
    alt Account missing
        Cmd-->>User: Error: No account configured
    else Account exists
        Cmd->>Config: Get app (from --app flag or current)
        alt App missing
            Cmd-->>User: Error: No app selected
        else App exists
            Cmd->>Cmd: Build dashboard URL<br/>(account, app, channel)
            alt Web CLI mode
                Cmd-->>User: Display: Visit [URL]
            else Normal mode
                Cmd->>Browser: Open URL
                Browser-->>User: Dashboard opened
            end
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A channel to inspect, so shiny and new,
Dashboard awaits with its URL,
With flags and arguments, validation so keen,
The finest CLI command you've seen! ✨
Open the browser, or web mode will show,
Where channels and data in splendor all glow!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add channels:inspect command to open dashboard' directly and clearly summarizes the main change: adding a new CLI command that opens the Ably dashboard for channels inspection.
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
  • Post copyable unit tests in a comment
  • Commit unit tests in branch zak/channel-inspect-command

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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.

Opens the Ably dashboard channel page in the browser for a given
channel name. Constructs the URL from the configured account ID
and app ID, with URL-encoding for special characters in channel
names. Supports --app flag to override the current app, web CLI
mode (prints URL instead of opening browser), and validates that
both account and app are configured before proceeding.

This is change obviously falls short of a full channel inspector
experience in the CLI, but at least the functionality is exposed to cli
users, and provides a quick jump to the dashboard inspectors.
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

🧹 Nitpick comments (1)
test/unit/commands/channels/inspect.test.ts (1)

23-53: Mock openUrl to avoid triggering real browser-open syscalls and decouple assertions from openUrl's output format.

The tests in this file execute the command in-process via runCommand(), which calls the real openUrl() utility. This causes actual browser-launch syscalls to fire in CI and couples the test assertions to openUrl's internal print format — if that format ever changes, these tests fail even though the command logic is correct.

Instead, mock openUrl and assert it was called with the expected URL:

♻️ Suggested refactor
+import { vi } from "vitest";
+
+vi.mock("../../../src/utils/open-url.js", () => ({
+  default: vi.fn().mockResolvedValue(undefined),
+}));
+
+import openUrl from "../../../src/utils/open-url.js";
 
   it("should open browser with correct dashboard URL", async () => {
     const mockConfig = getMockConfigManager();
     const accountId = mockConfig.getCurrentAccount()!.accountId!;
     const appId = mockConfig.getCurrentAppId()!;
 
-    const { stdout } = await runCommand(
+    await runCommand(
       ["channels:inspect", "my-channel"],
       import.meta.url,
     );
 
-    expect(stdout).toContain("Opening");
-    expect(stdout).toContain("in your browser");
-    expect(stdout).toContain(
-      `https://ably.com/accounts/${accountId}/apps/${appId}/channels/my-channel`,
-    );
+    expect(openUrl).toHaveBeenCalledWith(
+      `https://ably.com/accounts/${accountId}/apps/${appId}/channels/my-channel`,
+      expect.anything(),
+    );
   });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/unit/commands/channels/inspect.test.ts` around lines 23 - 53, The tests
currently call runCommand(...) which triggers the real openUrl() and causes
browser syscalls and brittle output assertions; update the tests in
inspect.test.ts to mock/stub the openUrl function (the openUrl export used by
the channels:inspect command) before calling runCommand, assert openUrl was
invoked once with the exact dashboard URL (including percent-encoding for
"my-channel/foo#bar"), and remove or replace assertions that check for
"Opening"/"in your browser" or rely on openUrl's stdout format; ensure you
reference the openUrl symbol when creating the mock and keep other uses of
runCommand the same.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/commands/channels/inspect.ts`:
- Line 46: Replace the hardcoded dashboard base in the URL construction with a
configurable dashboardHost sourced from a new global flag or environment
variable; specifically, add a `dashboard-host` global flag to
AblyBaseCommand.globalFlags (or read process.env.ABLY_DASHBOARD_URL as a
fallback), then build the URL using that dashboardHost when forming the const
url that currently uses `https://ably.com` (keeping the rest: accountId, appId,
and encodeURIComponent(args.channel)); ensure the code uses
flags["dashboard-host"] || process.env.ABLY_DASHBOARD_URL || 'https://ably.com'
as the final host so staging/enterprise overrides work.

---

Nitpick comments:
In `@test/unit/commands/channels/inspect.test.ts`:
- Around line 23-53: The tests currently call runCommand(...) which triggers the
real openUrl() and causes browser syscalls and brittle output assertions; update
the tests in inspect.test.ts to mock/stub the openUrl function (the openUrl
export used by the channels:inspect command) before calling runCommand, assert
openUrl was invoked once with the exact dashboard URL (including
percent-encoding for "my-channel/foo#bar"), and remove or replace assertions
that check for "Opening"/"in your browser" or rely on openUrl's stdout format;
ensure you reference the openUrl symbol when creating the mock and keep other
uses of runCommand the same.

);
}

const url = `https://ably.com/accounts/${accountId}/apps/${appId}/channels/${encodeURIComponent(args.channel)}`;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Search for controlHost usage and other dashboard URL patterns
rg -n "ably\.com|dashboardHost|controlHost" src/commands/ --type ts -A 2 -B 2 | head -100

Repository: ably/ably-cli

Length of output: 3771


🏁 Script executed:

# Check the base command and config for any dashboard host configuration
fd -e ts -e js src/ | xargs grep -l "dashboardHost\|dashboard.*url" 2>/dev/null | head -20

Repository: ably/ably-cli

Length of output: 378


🏁 Script executed:

# Look at the base-command.ts to see what host configs are exposed
cat src/base-command.ts | head -150

Repository: ably/ably-cli

Length of output: 5269


🏁 Script executed:

# Check if there are other commands that construct URLs to ably.com
rg "https://ably\.com" src/commands/ --type ts -B 5 -A 2

Repository: ably/ably-cli

Length of output: 2654


Hardcoded dashboard base URL violates the "no hardcoded endpoint URLs" guideline.

Line 46 hardcodes https://ably.com as the dashboard base. This breaks for staging/enterprise environments and is not configurable. A dashboardHost flag or env-override (e.g., ABLY_DASHBOARD_URL) should supply the base, consistent with how control-host is used elsewhere in the codebase.

♻️ Suggested refactor
-    const url = `https://ably.com/accounts/${accountId}/apps/${appId}/channels/${encodeURIComponent(args.channel)}`;
+    const dashboardHost = flags["dashboard-host"] ?? process.env.ABLY_DASHBOARD_URL ?? "https://ably.com";
+    const url = `${dashboardHost}/accounts/${accountId}/apps/${appId}/channels/${encodeURIComponent(args.channel)}`;

Alternatively, add a dashboard-host global flag to AblyBaseCommand.globalFlags (similar to control-host) and use flags["dashboard-host"] here.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/commands/channels/inspect.ts` at line 46, Replace the hardcoded dashboard
base in the URL construction with a configurable dashboardHost sourced from a
new global flag or environment variable; specifically, add a `dashboard-host`
global flag to AblyBaseCommand.globalFlags (or read
process.env.ABLY_DASHBOARD_URL as a fallback), then build the URL using that
dashboardHost when forming the const url that currently uses `https://ably.com`
(keeping the rest: accountId, appId, and encodeURIComponent(args.channel));
ensure the code uses flags["dashboard-host"] || process.env.ABLY_DASHBOARD_URL
|| 'https://ably.com' as the final host so staging/enterprise overrides work.

@zknill zknill requested a review from AndyTWF February 20, 2026 15:26

const url = `https://ably.com/accounts/${accountId}/apps/${appId}/channels/${encodeURIComponent(args.channel)}`;

if (this.isWebCliMode) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than if here, should we add the condition to openUrl?

);
}

const url = `https://ably.com/accounts/${accountId}/apps/${appId}/channels/${encodeURIComponent(args.channel)}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto coderabbit, this needs to work on the staging sites so should be configurable. It'll also need to be added to the terminal server, because that's where the web CLI will be running

…penUrl

Add a --dashboard-host global flag (env: ABLY_DASHBOARD_HOST) so the
channels:inspect command can target staging or enterprise dashboard
environments instead of the hardcoded https://ably.com.

Move the web CLI mode check ("Visit <url>" instead of opening a
browser) from individual commands into the openUrl utility so all
callers get consistent behavior without duplicating the logic.
@zknill zknill requested a review from AndyTWF February 23, 2026 16:05
When the --dashboard-host flag or ABLY_DASHBOARD_HOST env var is
provided without a URL scheme, automatically prepend https:// so
that the constructed dashboard URL is valid.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

this.error(
`No app selected. Please select an app first with ${chalk.cyan('"ably apps switch"')} or specify one with ${chalk.cyan("--app")}.`,
);
}
Copy link

Choose a reason for hiding this comment

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

Web CLI mode may lack account config

Medium Severity

In web CLI mode, channels:inspect still requires this.configManager.getCurrentAccount() and getCurrentAppId() to be configured, and errors out if they aren’t. Since web CLI mode typically relies on environment-provided context rather than local config, this can make the new command unusable in the intended environment even though openUrl supports web CLI output.

Fix in Cursor Fix in Web

@zknill zknill merged commit 00a97fd into main Feb 24, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants