fix(slack): unfurl org pages for the connected workspace, and finish unfurls

Merged
SA
2mo ago
+49-53

Problem

Harshith's link to an org-visible page (pr-7773-…-dojhim) didn't unfurl in #general, and he didn't see a connect-account prompt either.

  • He has no Slack identity linked in prod, so the page returned needs_user and we tried the user_auth_required prompt.
  • route.ts fired processLinkShared (and entity details / app home) without awaiting it or using after(). Vercel froze the function after the 200. In prod logs every chat.unfurl failure (cannot_auth_user, cannot_prompt) is attached to unrelated requests (/api/auth/oauth2/token, Linear webhook) 12–47 min after the link_shared event.

Changes

  • route.ts: link_shared, entity_details_requested and app_home_opened handlers run inside after().
  • previewAccess: everyone and org pages are readable for the Slack workspace connected to the page's org, like tasks. just_me still needs the linked creator. Visibilities are matched by name so a future one falls through to the reader check.

Validation

  • bun test for packages/trpc/src/router/page and apps/api/src/app/api/integrations/slack: pass.
  • tsc --noEmit on apps/api and packages/trpc, biome: clean.
  • Not verified in Slack yet: route tests stop before the after() calls. Plan: re-post Harshith's link in #general after deploy and confirm it unfurls.

Summary by cubic

Fixes Slack unfurls for org-visible pages and ensures Slack event handlers finish after the response is sent.

  • Org and public pages now unfurl for the connected Slack workspace, like tasks; just_me pages still require their creator to have linked Slack.
  • The link_shared, entity_details_requested, and app_home_opened handlers now run inside after() so Vercel doesn't freeze them after the 200.