Skip to content

Add a @slack connector (mention → chip → live context at copy time) #16

Description

@ojowwalker77

Summary

Add a @slack connector so a Slack message / thread / channel can be @-mentioned in the editor, resolved to a chip, and expanded into live context at copy time — the same pattern as the existing @github, @linear, @notion, and @sentry connectors.

Background

Connectors are the scalable unit behind an app chip. The editor and search panel only know how to ask a connector for search results and rendered context; each connector owns its own API details. They're registered in one place and resolved concurrently at copy time by SelfContainedRenderer.

Reference connector: GitHubAppConnector / LinearAppConnector in Sources/ComposerApp/Support/AppConnectors.swift.

Implementation steps

  1. Auth — Slack needs a token, so declare auth as ConnectorAuth.apiToken(label: "Bot/User Token", hint: "xoxb-… / xoxp-…", createURL: "https://api.slack.com/apps") on the connector. The token is entered in Settings and read at runtime from ConnectorSecretStore (~/.local/share/Composer/connector-secrets.json, 0600).
  2. Connector struct — add private struct SlackAppConnector: ComposerAppConnector to AppConnectors.swift: let id = "@slack", the auth above, search(_:context:), and render(selection:).
    • search() → query Slack (e.g. search.messages, plus conversations.list for channels) and return AppSearchResults.
    • render(selection:) → fetch the message/thread text (e.g. resolve a permalink → conversations.history/conversations.replies) and format it as a self-contained context section.
  3. Register — add SlackAppConnector() to AppConnectorRegistry.all.
  4. Selection type — add a case slack(SlackReference) to AppSelection in AppReference.swift and handle it in AppToken.string(appID:selection:) / AppToken.parse(_:) so the chip round-trips through the note's plain text.
  5. Mention catalog — add a MentionItem (id @slack, label, subtitle, SF Symbol) to MentionCatalog.all and map "@slack": .service in MentionCatalog.appCategory in MentionToken.swift.
  6. Service (optional but cleaner) — put the Slack Web API calls in a SlackService.swift under Sources/ComposerApp/Services/, reading the token from ConnectorSecretStore.
  7. Settings token field — confirm the ENGINES/connectors section of SettingsView renders the token field for any connector whose auth is .apiToken (the existing token-backed connectors already do this — match their wiring).

Acceptance criteria

  • @slack appears in the mention picker under the service category.
  • With a token set, typing in the app-search panel returns Slack results; committing one inserts a resolved chip.
  • At copy time the chip expands into readable message/thread context via SelfContainedRenderer.
  • With no token, the connector shows a clear "needs auth" state rather than failing silently.
  • ./script/build_and_run.sh --verify passes.

References

  • Existing token-backed connectors (@linear, @notion, @sentry) in AppConnectors.swift are the closest templates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions