Fix Discord /acp action arg to respect inline values (#32753)#32766
Fix Discord /acp action arg to respect inline values (#32753)#32766maweibin wants to merge 2 commits intoopenclaw:mainfrom
Conversation
…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.
Greptile SummaryThis PR fixes a Discord The fix adds Key changes and notes:
Confidence Score: 4/5
Last reviewed commit: c234b29 |
| @@ -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); | |||
There was a problem hiding this 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:
- Builds options for a command with
argsMenu: "auto"and ≤ 25 static choices (e.g. a mock of/acp). - Asserts that the argsMenu arg's option object has
autocompleteset (or, equivalently, does not have a staticchoicesarray).
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.|
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. |
Fixes #32753
Summary
argsMenuargument even when it has <=25 static choices./acp, this makes theactionargument use autocomplete so inline values like/acp closeare passed through correctly.Background
Previously, the Discord command builder only enabled
autocompletewhen:arg.choiceswas a function, orFor
/acp, theactionarg has 16 static choices, so Discord used staticchoicesinstead of autocomplete. When a user typed/acp closeand hit enter, Discord did not treat"close"as a selected choice value and sentnullforaction. OpenClaw then treated this as “no value provided” and invokedresolveCommandArgMenu, showing the picker UI instead of executing the chosen action.Changes
buildDiscordCommandOptions, compute the args-menu argument name using the same rules asresolveCommandArgMenu:argsMenu === "auto", use the first arg with resolved choices.argsMenuis an object, useargsMenu.arg.shouldAutocomplete = truefor the args-menu argument whenever it has any resolved choices, so Discord will:/acp close->action="close").Impact
/acpon Discord now respects inlineactionvalues and no longer pops up the picker when the user already typed a valid action.argsMenuwill 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