Skip to content

fix(unreads): fall back when client.counts is team_is_restricted - #161

Open
arnaud-gp wants to merge 1 commit into
stablyai:mainfrom
arnaud-gp:fix/unreads-grid-counts-fallback
Open

arnaud-gp wants to merge 1 commit into
stablyai:mainfrom
arnaud-gp:fix/unreads-grid-counts-fallback

Conversation

@arnaud-gp

Copy link
Copy Markdown

Problem

On some Enterprise Grids client.counts is blocked org-wide with team_is_restricted. That is not a token-host mismatch: the same error is returned on both the org shell and the workspace host, with or without org_wide_aware. agent-slack unreads (and channel list --via-counts) then exit 1 even though client.dms, users.conversations, conversations.info, and conversations.history still work.

What Changed

  • Keep client.counts as the primary unreads path. Fall back only on team_is_restricted.
  • DM / MPIM fallback: client.dms with count 50 (most recently active conversations), then conversations.info (last_read) compared to the latest message ts. Call volume is 1 + ≤50 info calls and does not sweep the full IM list.
  • Channel fallback: users.conversations (public/private, max 50, newest updated first when present), then conversations.info plus conversations.history.
  • channel list --via-counts uses the same trigger and falls back to users.conversations.
  • later list uses the same trigger on saved.list and falls back to search.messages with is:saved.
  • README documents the fallback and the DM call bound.

Verification

  • bun test — 412 pass, 0 fail. New test/unreads.test.ts covers the team_is_restricted trigger, the counts-only DM bound, and the primary client.counts path. Channel and Later fallbacks are covered in their existing test files.
  • bun run typecheck — clean.

Risks

  • Fallback unreads omit thread-unread counts (those only come from client.counts).
  • Channel scan is capped at 50 joined conversations, so a quieter unread channel outside that window can be missed.
  • Later fallback via is:saved cannot distinguish archived/completed states; those filters return empty items with a total count only.

Made with Cursor

Enterprise Grids that block client.counts can still serve unreads via a
bounded client.dms + users.conversations path, with the same trigger for
channel list --via-counts and later list.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-authored-by: Cursor <cursoragent@cursor.com>
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