feat(integration): slash commands framework (LC-76) #165
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/lc-76-slash-commands"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Slash-command framework (LC-76). Typing
/<command>in the compose box runs a command instead of posting literal text. Built-ins:/help,/me,/shrug,/poll(LC-66),/remind(LC-63), plus admin-defined custom commands.Design
post_messageroutes a leading-/body throughroutes::slash::try_dispatch, which runs after every access / posting / rate-limit gate (no RBAC bypass). ReturnsNonefor unrecognized commands -> falls back to posting the literal text (commands can't grief a stray/).crate::commandsholds built-in metadata (name, description, usage,admin_only) - one source of truth for/help+ autocomplete. Execution inroutes::slash./helprenders an ephemeral panel OOB into#lc-command-result(invoker-only, never broadcast, no DB write)./meposts an italic action;/shrugappends the glyph./pollreusespolls::create_poll;/remindposts the note + sets an LC-63 reminder on it for the author.0039,slash_commands_custom): managed at/admin/slash-commands.static_textsubstitutes{args};webhook_postPOSTs args as JSON and posts the (capped) response.admin_onlyrefused for non-admins.GET /api/slash-commands?q=returns a role-filtered dropdown, wired into the composer with a/wordtrigger + click-to-insert (parallel to@mention).Acceptance criteria
/helplists registered commands with descriptions./me <text>posts a third-person styled message./remindand/pollinvoke their features./foofalls back to literal text./giphyomitted (no Giphy integration shipped, per the issue's "if shipped").Tests
routes_slash.rs:/helpephemeral (no message),/me,/shrug,/remind(post + reminder), unknown fallback, custom static_text, admin-only RBAC, autocomplete. Migration0039appended to hand-rolled lists.just check,just test,just test-saasgreen.🤖 Generated with Claude Code
Typing /<command> in the compose box now runs a command instead of posting literal text. Built-ins: /help, /me, /shrug, /poll (LC-66), /remind (LC-63). Plus admin-defined custom commands. Unknown /foo falls back to posting the literal text, so commands never grief a user who happens to type a slash. Dispatch: post_message routes a leading-/ body through routes::slash::try_dispatch, which runs AFTER every access / posting / rate-limit gate, so a command cannot bypass room RBAC. try_dispatch returns None for unrecognized commands (fall through to a normal message) and Some(response) when handled. Built-in registry: crate::commands holds the built-in metadata (name, description, usage, admin_only) - the single source of truth for /help and the autocomplete dropdown. Execution lives in routes::slash: - /help renders an ephemeral panel OOB into #lc-command-result (visible only to the invoker, never broadcast, no DB write). - /me posts an italic third-person action; /shrug appends the shrug glyph. - /poll reuses polls::parse_command + create_poll; /remind posts the note and sets a LC-63 reminder on it for the author at the parsed time (15m/1h/3h/1d). Custom commands (migration 0039, slash_commands_custom): admins add them on /admin/slash-commands. static_text substitutes {args} into a template; webhook_post POSTs the args as JSON to a URL and posts the (capped) response body. admin_only commands are refused for non-admins (RBAC acceptance). Admin CRUD page mirrors the link-filter pattern (validate + re-render on error, redirect on success, mod-log entries). Autocomplete: GET /api/slash-commands?q= returns a dropdown of matching commands (role-filtered), wired into the composer with a `/word` trigger + click-to-insert, parallel to the @mention typeahead. Tests: routes_slash.rs covers /help ephemeral (not broadcast, no message), /me, /shrug, /remind (posts + reminder), unknown fallback to literal, custom static_text substitution, admin-only RBAC rejection, and the autocomplete endpoint. Migration 0039 appended to the hand-rolled migration lists. just check, just test, just test-saas all green. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>