Skip to content

Discord: accept inline /acp action args via autocomplete#32800

Closed
zwright8 wants to merge 4 commits intoopenclaw:mainfrom
zwright8:codex/discord-acp-inline-autocomplete
Closed

Discord: accept inline /acp action args via autocomplete#32800
zwright8 wants to merge 4 commits intoopenclaw:mainfrom
zwright8:codex/discord-acp-inline-autocomplete

Conversation

@zwright8
Copy link
Copy Markdown

@zwright8 zwright8 commented Mar 3, 2026

Summary

  • switch Discord /acp action option wiring from static choices to autocomplete
  • keep existing choice suggestions while allowing inline typed values (for example /acp close)
  • add tests verifying /acp uses autocomplete and non-ACP action args still use static choices

Why

With static choices on /acp action, Discord can return action=null when users type inline without selecting from the dropdown, which triggers the fallback button menu. Using autocomplete preserves suggestions but allows direct inline action input.

Closes #32753.

Testing

  • pnpm exec oxfmt --check src/discord/monitor/native-command.ts src/discord/monitor/native-command.options.test.ts
  • pnpm exec vitest run src/discord/monitor/native-command.options.test.ts

@openclaw-barnacle openclaw-barnacle bot added channel: discord Channel integration: discord size: S labels Mar 3, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 3, 2026

Greptile Summary

This PR switches the /acp command's action option from static Discord choices to autocomplete, fixing a bug where Discord returns action=null for inline-typed values (e.g. /acp close) and triggers the fallback button menu.

Key changes:

  • native-command.ts: Introduces isAcpActionArg flag in buildDiscordCommandOptions to force autocomplete for the acp/action arg, bypassing the existing "only autocomplete when choices > 25 or dynamic" guard. Because autocomplete is truthy, the static choices field is correctly set to undefined — Discord forbids both being set simultaneously.
  • native-command.options.test.ts: New test file asserting that /acp action gets an autocomplete function and no choices, and that non-acp commands (e.g. voice) retain their static choices.

The logic is correct and the fix is well-scoped. One minor architectural concern: the generic buildDiscordCommandOptions function now contains a hardcoded check for a specific command key ("acp"). If more commands need the same opt-in behaviour, this will accumulate special cases; a preferAutocomplete flag on CommandArgDefinition would be a more extensible design.

Confidence Score: 4/5

  • Safe to merge — the fix is correct and well-tested; only a minor architectural style concern exists.
  • The change is small, targeted, and logically sound. Discord's mutual-exclusivity of choices and autocomplete is handled correctly. Tests cover both the new autocomplete path and the existing static-choices path. The only reason this isn't a 5 is the hardcoded command.key === "acp" check inside a generic builder function, which could become a maintenance issue as more commands need similar treatment.
  • No files require special attention.

Last reviewed commit: 6e7e168

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +118 to +122
const isAcpActionArg = command.key === "acp" && arg.name === "action";
const shouldAutocomplete =
resolvedChoices.length > 0 &&
(typeof arg.choices === "function" || resolvedChoices.length > 25);
isAcpActionArg ||
(resolvedChoices.length > 0 &&
(typeof arg.choices === "function" || resolvedChoices.length > 25));
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.

Command-specific logic in a generic builder

buildDiscordCommandOptions is a generic helper, but isAcpActionArg introduces a hardcoded "acp" key check for a single command. If other commands need the same "prefer autocomplete over static choices" behaviour in the future, this will grow into an increasing list of special cases.

A more extensible approach would be to add an optional flag to CommandArgDefinition (e.g. preferAutocomplete?: boolean) and have the /acp command set it in the registry. That keeps the generic builder free of command-specific knowledge and makes the opt-in explicit and discoverable.

This is a style/architecture suggestion rather than a bug, so the current code is functionally correct.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/discord/monitor/native-command.ts
Line: 118-122

Comment:
**Command-specific logic in a generic builder**

`buildDiscordCommandOptions` is a generic helper, but `isAcpActionArg` introduces a hardcoded `"acp"` key check for a single command. If other commands need the same "prefer autocomplete over static choices" behaviour in the future, this will grow into an increasing list of special cases.

A more extensible approach would be to add an optional flag to `CommandArgDefinition` (e.g. `preferAutocomplete?: boolean`) and have the `/acp` command set it in the registry. That keeps the generic builder free of command-specific knowledge and makes the opt-in explicit and discoverable.

This is a style/architecture suggestion rather than a bug, so the current code is functionally correct.

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@zwright8
Copy link
Copy Markdown
Author

zwright8 commented Mar 3, 2026

Addressed in the latest head commit (e41fc1e).

I removed the command-specific acp check from buildDiscordCommandOptions and switched to an arg-level opt-in:

  • added preferAutocomplete?: boolean to CommandArgDefinition
  • set preferAutocomplete: true on /acp action in the command registry
  • generic builder now checks arg.preferAutocomplete === true

This keeps the builder generic and makes autocomplete preference explicit/discoverable per argument.

@thewilloftheshadow
Copy link
Copy Markdown
Member

Superseded by #33136, which consolidates the /acp inline action autocomplete fix plus the bound-thread bot system message guard. Closing in favor of that PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: /acp slash command ignores inline arg, shows menu anyway

2 participants