Skip to content

feat(sim-search): search Slack live as the person asking, instead of crawling it - #7429

Open
waleedlatif1 wants to merge 4 commits into
stagingfrom
feat/slack-federated-search
Open

feat(sim-search): search Slack live as the person asking, instead of crawling it#7429
waleedlatif1 wants to merge 4 commits into
stagingfrom
feat/slack-federated-search

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Slack is now searched live, at query time, as the person asking, instead of being crawled into a knowledge base. Sim Search calls Slack's Data Access API (assistant.search.context) with that person's own Slack user token, so Slack answers from its own index and enforces its own permissions. Nothing about Slack is stored, embedded, or ACL-materialized.
  • This is how Glean's Slack Real Time Search works, and it is why it beats a crawl here: thread replies and DMs are covered, results are never stale, there is no crawl budget to exceed, and the permission check is Slack's rather than a copy of Slack's that can drift.
  • Slack results render as their own group under the indexed results, not blended into them. Slack ranks with its own relevance, which is not comparable to a vector distance, so interleaving the two would present an ordering that means nothing.
  • A person who has not connected Slack sees nothing extra; the Sources strip is still where they connect it. A connection that stopped working says so, because reconnecting is something they can act on.
  • Failures are absorbed. A Slack outage, a rate limit, or a revoked credential costs the Slack group only, never the knowledge-base results.

Slack app configuration this needs

The scopes live on the workspace's own custom Slack app, the one their Credential Group already authorizes against. Sim's hosted Marketplace app is unchanged and needs no new scopes and no re-review.

On the customer's app:

  • Enable Agents & AI Apps.
  • Add the user scopes search:read.public, search:read.private, search:read.im, search:read.mpim. Slack requires at least search:read.public; the rest widen coverage to the private channels and DMs that person can already read.

Slack's own limits, for the record: the API is available to directory-published and internal apps, which a custom workspace app is; semantic ranking needs Slack AI Search (Business+/Enterprise+) and falls back to keyword search on other plans; guests cannot use it.

Migration

Adding scopes changes the Slack option's scope version, so every already-enrolled Slack member is marked as needing re-authorization and must reconnect once. Until they do, Slack search reports needs_reauth and the UI tells them to reconnect. Their Slack tool credentials are affected by the same re-auth, so this should land with a heads-up rather than silently.

Type of Change

  • New feature

Testing

  • Client: request shape (POST, form body, bearer, message content type, all four conversation kinds, context messages requested), the twenty-result cap, an empty query short-circuiting before any call, normalization joining a hit with the messages around it, dropping a result that cannot be cited or has no text, keeping a result whose timestamp will not parse, and surfacing Slack's own error code.
  • Outcome mapping: searches under the asking person's token, requests only the four search scopes, reports an unconnected person without calling Slack, maps every credential error to the state the UI shows, and absorbs both a Slack failure and an unexpected credential failure.
  • Type-check, lint, check:audits (45 audits), and the full suite (30,438 tests) pass.

Not in this PR

Assistant mode still grounds only in knowledge bases. Wiring these passages into the agent turn reuses searchSlackForViewer unchanged and is the natural follow-up.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Sep 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 3, 2026 5:46am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds live, viewer-scoped Slack search to Sim Search while retaining indexed knowledge results.

  • Adds a session-authorized Slack search route, contract, operation, and application use case.
  • Resolves each viewer’s managed Slack credential and searches Slack’s Data Access API with the required search scopes.
  • Displays Slack results as a separate result group with reconnect and temporary-unavailability states.
  • Adds viewer-aware React Query caching, reconnect invalidation, response normalization, and focused tests.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/lib/api/contracts/knowledge/sim-search.ts Defines and exports the canonical request, response, result, and status schemas and types for live Slack search.
apps/sim/app/api/knowledge/sim-search/slack/route.ts Adds a session-authenticated, workspace-authorized route adapter for federated Slack search.
apps/sim/lib/knowledge/application/sim-search.ts Adds the authorized application use case that searches Slack under the acting viewer’s identity and projects normalized results.
apps/sim/lib/slack-search/credentials.ts Selects the viewer’s eligible managed Slack credential within the authorized workspace.
apps/sim/lib/slack-search/search.ts Resolves managed OAuth tokens, maps credential states, and degrades Slack failures without affecting indexed results.
apps/sim/lib/slack-search/client.ts Implements the bounded Slack Data Access API request and normalizes searchable message context.
apps/sim/hooks/queries/kb/knowledge.ts Adds viewer-keyed, short-lived React Query integration for live Slack results.
apps/sim/app/workspace/[workspaceId]/home/components/knowledge-search-results/slack-search-results.tsx Renders Slack results separately and surfaces actionable credential or availability states.
apps/sim/app/workspace/[workspaceId]/home/components/knowledge-search-results/knowledge-search-results.tsx Composes indexed and Slack result groups under a shared keyboard-navigation container.

Sequence Diagram

sequenceDiagram
  participant U as Viewer
  participant UI as Sim Search UI
  participant API as Slack Search Route
  participant C as Credential Resolver
  participant S as Slack Data Access API
  U->>UI: Submit search query
  UI->>API: POST workspaceId and query
  API->>API: Authenticate and authorize workspace access
  API->>C: Resolve viewer's Slack user token
  alt Connected and authorized
    C-->>API: User access token
    API->>S: assistant.search.context
    S-->>API: Permission-filtered messages
    API-->>UI: ok and normalized results
    UI-->>U: Separate Slack result group
  else Reauthorization required
    C-->>API: Credential needs reauthorization
    API-->>UI: needs_reauth
    UI-->>U: Reconnect Slack prompt
  else Slack or credential unavailable
    API-->>UI: unavailable
    UI-->>U: Slack unavailable notice
  end
Loading

Reviews (4): Last reviewed commit: "fix(sim-search): refresh the Slack searc..." | Re-trigger Greptile

Comment thread apps/sim/lib/api/contracts/knowledge/sim-search.ts Outdated
Comment thread apps/sim/app/api/knowledge/sim-search/slack/route.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 17 files

Re-trigger cubic

Comment thread apps/sim/lib/slack-search/search.ts Outdated
Comment thread apps/sim/lib/slack-search/credentials.ts Outdated
Comment thread apps/sim/hooks/queries/utils/knowledge-keys.ts Outdated
Comment thread apps/sim/lib/slack-search/search.ts Outdated
Comment thread apps/sim/lib/slack-search/client.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 17 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/sim/hooks/queries/kb/knowledge.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 18 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

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