Skip to content

feat(slack): add /cc slash command gateway and harden command parsing#116

Open
lethanhson9901 wants to merge 1 commit intochenhg5:mainfrom
lethanhson9901:codex/slack-slash-pr
Open

feat(slack): add /cc slash command gateway and harden command parsing#116
lethanhson9901 wants to merge 1 commit intochenhg5:mainfrom
lethanhson9901:codex/slack-slash-pr

Conversation

@lethanhson9901
Copy link

Summary

This PR improves the Slack integration in three related areas:

  1. Add native Slack slash command support through a /cc gateway
  2. Harden @mention command parsing for non-standard whitespace
  3. Update Slack setup and usage documentation

What Changed

Native Slack slash command gateway

Slack integration now handles Socket Mode slash_commands events and routes /cc ... into
the existing cc-connect command engine.

Examples:

  • /cc help
  • /cc model
  • /cc status
  • /cc mycustom

This keeps Slack-native command handling aligned with the existing built-in, custom command,
and skill command paths.

More robust mention command parsing

@cc_connect /model now parses correctly even when Slack inserts non-ASCII whitespace, such
as:

  • non-breaking spaces
  • newlines after the mention

This avoids falling through to normal chat handling when the user intended to run a command.

Alias compatibility for slash-style input

Alias resolution now also works when the input is slash-prefixed, so Slack gateway input
like /cc 帮助 can still resolve to alias-backed commands.

Documentation updates

docs/slack.md now documents:

  • required commands OAuth scope
  • how to create a /cc slash command in Slack
  • the three supported Slack input styles:
    • native slash command: /cc ...
    • mention flow: @cc_connect /model
    • DM plain-text fallback: /model

Why

Before this change:

  • Slack users could not use a native slash command path for cc-connect commands
  • direct Slack /model usage was confusing because Slack interprets it as a native Slack
    command
  • mention-based commands were brittle when Slack emitted unexpected whitespace
  • docs did not clearly explain the Slack-specific command model

This PR makes Slack command usage more reliable and much easier to understand.

Implementation Notes

  • Handles socketmode.EventTypeSlashCommand in the Slack platform
  • Uses /cc as a gateway command and normalizes the payload into the existing engine
    command format
  • Reuses the same session key model as other Slack message flows
  • Keeps replies as normal channel messages rather than ephemeral responses
  • Limits native slash-command handling to /cc to avoid overreaching Slack app
    configuration assumptions

Tests

Added/updated tests for:

  • mention parsing with non-breaking space and newline
  • /cc slash command normalization
  • slash command event dispatch into the platform message handler
  • slash-prefixed alias resolution

Verification run:

  • go test -count=1 ./platform/slack ./core
  • go test -count=1 ./...

Backward Compatibility

Existing Slack usage continues to work:

  • @cc_connect /model
  • DM plain-text commands like /model

This PR only adds a native Slack command path via /cc.

@chenhg5
Copy link
Owner

chenhg5 commented Mar 14, 2026

Thanks for this PR! Overall it looks great — it's backward compatible and adds a clean way to use cc-connect commands in Slack.

A few suggestions:


1. Make the gateway command configurable

Currently /cc is hardcoded. It would be better to make it configurable so users can choose their own gateway command name:

[[projects.platforms]]
  type = "slack"
  [projects.platforms.options]
    gateway_command = "cc"  # default: "cc", user can change to "ai", "bot", etc.

This way:

  • Users can pick a command name that fits their workflow
  • Avoids conflicts if /cc is already used by another Slack app

2. Future enhancement: prefix-based commands for better autocomplete

The current gateway approach (/cc model) only supports static usage hints.

A potential future enhancement would be a prefix mode where each command is registered individually (/cc_model, /cc_help, /cc_new, etc.). This would give users Slack's native autocomplete dropdown when they type /cc_.

This is more complex (requires registering N commands, handling dynamic skills/aliases), so it can be a follow-up PR. But worth considering for better UX.


Once the gateway_command config option is added, I'm happy to merge this. Thanks!

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.

2 participants