Skip to content

perf(channels): refresh_cache merges fresh counts instead of re-listing all channels#10

Merged
AlexanderMakarov merged 1 commit into
masterfrom
fix/channels-refresh-counts-only
Jul 6, 2026
Merged

perf(channels): refresh_cache merges fresh counts instead of re-listing all channels#10
AlexanderMakarov merged 1 commit into
masterfrom
fix/channels-refresh-counts-only

Conversation

@AlexanderMakarov

Copy link
Copy Markdown
Collaborator

Summary

channels_list with refresh_cache=true used to force a synchronous re-list of every channel (conversations.list pagination under Tier-2 rate limiting) — ~55s for a ~1,800-channel workspace, and minutes when Slack throttles. Callers like the sde-automation Slack-unread page only need fresh unread counters, which a single client.counts edge call already provides.

RefreshChannelCounts merges HasUnreads/LastRead/MentionCount from client.counts into the in-memory channels snapshot without touching the cache file, so the TTL clock keeps running and the existing stale-while-revalidate machinery still re-lists the full channel set in the background once the cache expires. When counts are unavailable (no edge client), the handler falls back to the old full synchronous refresh.

Testing

  • Unit tests for the counts merge (immutability included), the ErrCountsUnavailable fallback signal, and cache-TTL expiry detection (pkg/provider/api_counts_refresh_test.go).
  • Verified live against a real workspace: channels_list refresh_cache=true dropped from ~55s to 0.2s; server log confirms the counts path ran with no fallback and no full re-list.

https://claude.ai/code/session_01JA39im4Ha2g7t4qdLg5Adt

…ng all channels

channels_list with refresh_cache=true used to force a synchronous
re-list of every channel (conversations.list pagination under Tier-2
rate limiting) — ~55s for a ~1,800-channel workspace, and minutes when
Slack throttles. Callers like the sde-automation Slack-unread page only
need fresh unread counters, which a single client.counts edge call
already provides.

RefreshChannelCounts merges HasUnreads/LastRead/MentionCount from
client.counts into the in-memory channels snapshot without touching the
cache file, so the TTL clock keeps running and the existing
stale-while-revalidate machinery still re-lists the full channel set in
the background once the cache expires. When counts are unavailable
(no edge client), the handler falls back to the old full synchronous
refresh.

Claude-Session: https://claude.ai/code/session_01JA39im4Ha2g7t4qdLg5Adt
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@AlexanderMakarov, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f9d3140b-8dc2-46fd-8371-077d60c0e35d

📥 Commits

Reviewing files that changed from the base of the PR and between 199fe3f and ba9b8fd.

📒 Files selected for processing (4)
  • pkg/handler/channels.go
  • pkg/provider/api.go
  • pkg/provider/api_counts_refresh_test.go
  • pkg/server/server.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/channels-refresh-counts-only

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.

@AlexanderMakarov AlexanderMakarov merged commit 0e1e28b into master Jul 6, 2026
7 checks passed
@AlexanderMakarov AlexanderMakarov deleted the fix/channels-refresh-counts-only branch July 6, 2026 13:48
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