Skip to content

Fix Discord /acp action arg to respect inline values (#32753)#32766

Closed
maweibin wants to merge 2 commits intoopenclaw:mainfrom
maweibin:fix/32753-discord-acp-action-autocomplete
Closed

Fix Discord /acp action arg to respect inline values (#32753)#32766
maweibin wants to merge 2 commits intoopenclaw:mainfrom
maweibin:fix/32753-discord-acp-action-autocomplete

Conversation

@maweibin
Copy link
Copy Markdown
Contributor

@maweibin maweibin commented Mar 3, 2026

Fixes #32753

Summary

  • Make Discord native commands use autocomplete for the argsMenu argument even when it has <=25 static choices.
  • For /acp, this makes the action argument use autocomplete so inline values like /acp close are passed through correctly.

Background

Previously, the Discord command builder only enabled autocomplete when:

  • arg.choices was a function, or
  • the resolved choices length was > 25.

For /acp, the action arg has 16 static choices, so Discord used static choices instead of autocomplete. When a user typed /acp close and hit enter, Discord did not treat "close" as a selected choice value and sent null for action. OpenClaw then treated this as “no value provided” and invoked resolveCommandArgMenu, showing the picker UI instead of executing the chosen action.

Changes

  • In buildDiscordCommandOptions, compute the args-menu argument name using the same rules as resolveCommandArgMenu:
    • When argsMenu === "auto", use the first arg with resolved choices.
    • When argsMenu is an object, use argsMenu.arg.
  • Force shouldAutocomplete = true for the args-menu argument whenever it has any resolved choices, so Discord will:
    • Use autocomplete instead of static choices for that arg.
    • Pass through inline values typed by the user (e.g. /acp close -> action="close").

Impact

  • /acp on Discord now respects inline action values and no longer pops up the picker when the user already typed a valid action.
  • Other commands that use argsMenu will also have their menu arg use autocomplete, but behavior remains compatible: static choices are still respected, and the choice list is capped at 25 as before.

Testing

  • pnpm test src/discord/monitor/native-command --run

…ment so inline values are passed instead of forcing the dropdown.

For /acp this makes the `action` arg use autocomplete even with <=25 static choices, so typing `/acp close` sends `action="close"` and resolveCommandArgMenu skips the picker instead of showing the menu.

Fixes openclaw#32753.
@openclaw-barnacle openclaw-barnacle bot added channel: discord Channel integration: discord size: XS labels Mar 3, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 3, 2026

Greptile Summary

This PR fixes a Discord /acp UX regression where typing /acp close inline sent null for action because Discord was using static choices (not autocomplete) for the arg, causing OpenClaw to ignore the provided value and show the picker UI.

The fix adds argsMenuArgName computation in buildDiscordCommandOptions that mirrors the existing logic in resolveCommandArgMenu, then forces shouldAutocomplete = true for that arg so Discord always uses autocomplete and forwards inline values correctly.

Key changes and notes:

  • The new argsMenuArgName derivation correctly handles both argsMenu === "auto" (find first arg with resolved choices) and argsMenu as a CommandArgMenuSpec object (use argsMenu.arg).
  • Logic is consistent with resolveCommandArgMenu in commands-registry.ts, so the two code paths stay in sync.
  • No new test coverage was added for buildDiscordCommandOptions; the referenced test command (pnpm test src/discord/monitor/native-command) only hits the existing model-picker test, leaving the fixed logic untested.

Confidence Score: 4/5

  • Safe to merge — the fix is minimal, correct, and backward-compatible; no critical issues found.
  • The new argsMenuArgName derivation faithfully mirrors resolveCommandArgMenu, the isMenuArg flag is applied correctly, and the change does not affect any arg that is not an argsMenu arg. The only gap is the absence of a unit test for the changed code path, leaving the behavior unguarded against future regressions.
  • No files require special attention; the single changed file (src/discord/monitor/native-command.ts) is straightforward.

Last reviewed commit: c234b29

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.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines 101 to +129
@@ -115,9 +123,10 @@ function buildDiscordCommandOptions(params: {
};
}
const resolvedChoices = resolveCommandArgChoices({ command, arg, cfg });
const isMenuArg = argsMenuArgName !== undefined && arg.name === argsMenuArgName;
const shouldAutocomplete =
resolvedChoices.length > 0 &&
(typeof arg.choices === "function" || resolvedChoices.length > 25);
(isMenuArg || 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.

No test coverage for the fixed behavior

buildDiscordCommandOptions has no dedicated test file (only native-command.model-picker.test.ts exists), so the bug this PR fixes — and the new isMenuArg / shouldAutocomplete path — is not covered by automated tests. If this logic drifts out of sync with resolveCommandArgMenu in the future, there is nothing to catch it.

Consider adding a unit test that:

  1. Builds options for a command with argsMenu: "auto" and ≤ 25 static choices (e.g. a mock of /acp).
  2. Asserts that the argsMenu arg's option object has autocomplete set (or, equivalently, does not have a static choices array).

This would give direct regression coverage for the inline-value pass-through behavior described in #32753.

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

Comment:
**No test coverage for the fixed behavior**

`buildDiscordCommandOptions` has no dedicated test file (only `native-command.model-picker.test.ts` exists), so the bug this PR fixes — and the new `isMenuArg` / `shouldAutocomplete` path — is not covered by automated tests. If this logic drifts out of sync with `resolveCommandArgMenu` in the future, there is nothing to catch it.

Consider adding a unit test that:
1. Builds options for a command with `argsMenu: "auto"` and ≤ 25 static choices (e.g. a mock of `/acp`).
2. Asserts that the argsMenu arg's option object has `autocomplete` set (or, equivalently, does **not** have a static `choices` array).

This would give direct regression coverage for the inline-value pass-through behavior described in #32753.

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

@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: XS

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