Skip to content

fix(discord): always use autocomplete for slash command choices#32767

Closed
scoootscooob wants to merge 1 commit intoopenclaw:mainfrom
scoootscooob:fix/discord-acp-autocomplete-32753
Closed

fix(discord): always use autocomplete for slash command choices#32767
scoootscooob wants to merge 1 commit intoopenclaw:mainfrom
scoootscooob:fix/discord-acp-autocomplete-32753

Conversation

@scoootscooob
Copy link
Copy Markdown
Contributor

Summary

  • /acp close (and other commands with <25 static choices) sends action = null because Discord's static dropdown UI doesn't pass through typed inline values
  • Changed buildDiscordCommandOptions to always use autocomplete: true when an arg has choices, regardless of count
  • With autocomplete, Discord passes the typed value through and users can both pick from suggestions AND type inline

What did NOT change

  • Autocomplete handler logic (filtering, slicing to 25, respond format) — unchanged
  • Commands without choices (free-text input args) — unchanged
  • resolveCommandArgMenu / button picker fallback — unchanged, it correctly returns null when args.values[argName] != null

Test plan

  • New unit tests verify autocomplete is used for args with choices (under and over 25)
  • New unit test verifies no autocomplete for args without choices
  • Existing native-command.model-picker.test.ts tests still pass

Closes #32753

🤖 Generated with Claude Code

…claw#32753)

Static choices force Discord's dropdown UI which sends null for
typed-in values (e.g. /acp close).  Switching to autocomplete lets
users both pick from suggestions and type inline values.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 3, 2026

Greptile Summary

This PR fixes a Discord UX bug where slash commands with static choices (fewer than 25) sent null for the argument value when a user typed inline rather than selecting from the dropdown. The fix changes buildDiscordCommandOptions to always use autocomplete: true whenever an arg has any choices, replacing the old threshold-based logic.

Key changes:

  • shouldAutocomplete simplified from resolvedChoices.length > 0 && (typeof arg.choices === "function" || resolvedChoices.length > 25) to just resolvedChoices.length > 0 — clean and correct.
  • buildDiscordCommandOptions exported (@internal) so unit tests can import it directly.
  • New test file native-command.autocomplete.test.ts covers under-25 choices, over-25 choices, and no-choices cases with appropriate assertions.
  • One minor leftover: the choices variable block (lines 138–143) is now dead code since its guard condition (resolvedChoices.length > 0 && !autocomplete) can never be true after the simplification, but it's harmless.

Confidence Score: 4/5

  • This PR is safe to merge; the fix is minimal, well-tested, and addresses a real Discord API behavior issue.
  • The logic change is a one-line simplification that correctly captures the intended behavior. Tests cover all three relevant cases. The only issue is a now-unreachable choices assignment block that is harmless dead code — a minor cleanup opportunity but not a correctness concern.
  • Lines 138–143 of src/discord/monitor/native-command.ts contain dead code that could be cleaned up.

Last reviewed commit: f5e524a

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

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 3, 2026

Additional Comments (1)

src/discord/monitor/native-command.ts
Dead code: choices is now always undefined

Since shouldAutocomplete is now resolvedChoices.length > 0, the autocomplete variable is always defined whenever resolvedChoices.length > 0. This means the condition resolvedChoices.length > 0 && !autocomplete on line 139 can never be true, so choices will always be assigned undefined. The entire block is unreachable.

Consider simplifying to:

    const choices = undefined;

Or removing the choices variable entirely and just passing choices: undefined (or omitting it) in the returned object. This would make the intent clearer and avoid confusion for future readers.

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

Comment:
**Dead code: `choices` is now always `undefined`**

Since `shouldAutocomplete` is now `resolvedChoices.length > 0`, the `autocomplete` variable is always defined whenever `resolvedChoices.length > 0`. This means the condition `resolvedChoices.length > 0 && !autocomplete` on line 139 can never be `true`, so `choices` will always be assigned `undefined`. The entire block is unreachable.

Consider simplifying to:

```suggestion
    const choices = undefined;
```

Or removing the `choices` variable entirely and just passing `choices: undefined` (or omitting it) in the returned object. This would make the intent clearer and avoid confusion for future readers.

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