Skip to content

feat(channel list): add --via-counts flag for Enterprise Grid#109

Open
cawilliamson wants to merge 1 commit into
stablyai:mainfrom
cawilliamson:feat/channel-list-enterprise
Open

feat(channel list): add --via-counts flag for Enterprise Grid#109
cawilliamson wants to merge 1 commit into
stablyai:mainfrom
cawilliamson:feat/channel-list-enterprise

Conversation

@cawilliamson

Copy link
Copy Markdown

What

channel list --via-counts — lists the current user's joined conversations (channels, MPIMs, DMs) with names on Enterprise Grid workspaces, where browser/session tokens can't use users.conversations/conversations.list (Slack returns enterprise_is_restricted).

Why

On Enterprise Grid, Slack restricts org-wide conversation enumeration (conversations.list, users.conversations) for browser/session (xoxc/xoxd) tokens — this is intentional on Slack's side and not something a CLI can route around. The web client builds its sidebar from client.counts, which is still permitted and returns every conversation the user has joined (split across channels/mpims/ims, ids only). This PR exposes that same path behind an explicit flag so Grid users can list their joined conversations from the CLI without an admin-approved app token.

--all (full workspace enumeration) remains inherently unavailable via browser tokens on Grid — only an app token (xoxp) with conversations:read can do that. --via-counts is therefore incompatible with --all and --user (client.counts is current-user, joined-only, and has no server-side pagination; --limit slices locally, --cursor is ignored).

How

  • listConversationsViaCounts (src/slack/channels.ts): calls client.counts, collects ids from channels/mpims/ims, enriches each via conversations.info (parallelised with Promise.all), and returns the same ConversationsPage shape as the other list helpers. Keeps { id } if conversations.info fails for a given conversation.
  • channel list (src/cli/channel-command.ts) gains --via-counts; mutually exclusive with --all/--user.

Testing

  • bun run typecheck — clean
  • bun run lint — no new warnings/errors (10 pre-existing warnings unchanged)
  • bun run format:check — clean
  • bun test — 242 pass, 0 fail (3 new tests for listConversationsViaCounts: enumeration + enrichment, info-failure fallback, limit slicing / id-less entries)

Example

$ agent-slack channel list --via-counts
{
  "channels": [
    { "id": "C…", "name": "general", "is_channel": true, … },
    { "id": "G…", "name": "group-dm-name", "is_mpim": true, … },
    { "id": "D…", "name": "alice", "is_im": true, … }
  ]
}

On Enterprise Grid, users.conversations and conversations.list return
enterprise_is_restricted for browser/session tokens, so `channel list`
(and `channel list --all`) can't enumerate conversations without an
admin-approved app token.

Add `channel list --via-counts`, which enumerates the current user's
joined conversations via client.counts (the slack web client's sidebar
method, still permitted on Grid) + conversations.info per id for names.
Output matches the existing channel-record shape from the other list
helpers.

- listConversationsViaCounts: client.counts -> ids across channels/mpims/ims
  -> conversations.info per id (parallel), keep {id} on info failure
- --via-counts is incompatible with --all and --user (client.counts is
  current-user, joined-only, no server-side pagination; --limit slices
  locally, --cursor is ignored)
- tests for enumeration, info-failure fallback, limit slicing, id-less
  entries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant