Skip to content

feat: persist handle/email → Slack user-id resolution cache - #162

Open
arnaud-gp wants to merge 1 commit into
stablyai:mainfrom
arnaud-gp:feat/user-id-resolution-cache
Open

arnaud-gp wants to merge 1 commit into
stablyai:mainfrom
arnaud-gp:feat/user-id-resolution-cache

Conversation

@arnaud-gp

Copy link
Copy Markdown

Problem

resolveUserId() always hit Slack: users.lookupByEmail for emails, then a full users.list scan for handles. Browser xoxc tokens cannot call users.lookupByEmail (not_allowed_token_type), so every email lookup burned a failed request and then paginated the directory. In a workspace of this size that scan is multiple users.list pages, on every user get, user dm-open, channel invite, and search --user.

The existing users-cache-*.json file only stored id → profile for --resolve-users output annotation. It was never consulted in the reverse direction.

What Changed

  • The per-workspace user cache now also stores handle/email → user-id aliases (24h TTL), written through from users.list pages and users.info results.
  • resolveUserId() reads that index before calling Slack.
  • Browser auth skips users.lookupByEmail.
  • agent-slack user cache warm and user list --refresh prime the whole directory once.
  • user get --refresh-users bypasses TTL so renames/deactivations are recoverable.
  • README documents cache path, TTL, warm, and invalidation.

Verification

  • bun test — 406 pass, 0 fail. New coverage: cache hit, miss with write-through, TTL expiry, browser-auth email short-circuit, user cache warm, and --refresh-users bypass.
  • bun run typecheck — clean.

Risks

  • Cache writes remain best-effort. A failed write still falls back to users.list.
  • Stale handles until TTL or --refresh-users. Same 24h window as the existing profile cache.

Made with Cursor

Avoid repeating users.list pagination on every lookup, skip lookupByEmail for browser tokens, and add user cache warm.

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