feat: add cached referenced_users enrichment for messages and search#72
feat: add cached referenced_users enrichment for messages and search#72cpitt wants to merge 1 commit intostablyai:mainfrom
Conversation
Add a per-workspace user cache with TTL and refresh controls, then wire it into message get/list and search messages/all so outputs include a shared referenced_users map without changing canonical ID fields. Also add --refresh-users flags for message and search commands and update skill/reference docs to document the canonical-ID-plus-reference-map contract.
|
Hey @cpitt , thanks for the PR! Will take a look today and try to get it landed |
|
This is an incredibly useful feature! Resolving raw Slack user IDs to human-readable names is critical for both AI agents and humans reading the CLI output, and this will save a lot of unnecessary API round-trips. Thank you for putting this together! 🚀 I've reviewed the implementation and while the proposed output shape, caching strategy, and ID collection logic are spot on, there are a few operational risks with the current always-on approach. Here is a summarized design review with a proposed Opt-In architecture: The Risks
Proposed Architecture
What to keep: The Let me know what you think of this approach! |
Summary
referenced_usersoutput for message-bearing commandssearch messagesandsearch all, plus add--refresh-usersWhy
Raw Slack user IDs repeat heavily across message and search results, which makes CLI output harder to read and forces downstream consumers to do their own repeated lookups. A shared
referenced_usersmap keeps payload fields canonical and machine-stable while providing enough metadata for human-friendly post-processing.Changes
src/slack/user-cache.tsfor targeted per-workspaceusers.infocaching with TTLreferenced_userstomessage get/listreferenced_userstosearch messages/all--refresh-usersto message and search flowsauthor.user_id, rendered@U...mentions, and reactions only when returned)referenced_usersto users actually represented in the returned payloadValidation
bun run typecheckbun run testCloses #70