Skip to content

feat: add --disable-commands flag to hide and disable slash commands in TUI#2913

Merged
dgageot merged 1 commit into
docker:mainfrom
dgageot:board/a7b0512f057b0683
May 28, 2026
Merged

feat: add --disable-commands flag to hide and disable slash commands in TUI#2913
dgageot merged 1 commit into
docker:mainfrom
dgageot:board/a7b0512f057b0683

Conversation

@dgageot
Copy link
Copy Markdown
Member

@dgageot dgageot commented May 28, 2026

Users sometimes want to limit which slash commands are available in the TUI—for example, to hide commands that shouldn't be used in a particular environment or workflow. This change adds a --disable-commands flag to docker agent run and docker agent exec that lets you specify which commands to hide.

The flag accepts a comma-separated list of slash command names, like --disable-commands="/cost,/eval,/model". Leading slashes are optional and matching is case-insensitive (/Cost, cost, /cost all disable /cost). When set, the specified commands are completely hidden and disabled: they're stripped from the command palette (Ctrl+K), the slash-command parser, and the editor completion popup. The filtering happens in a single commandCategories() chokepoint, so all three surfaces inherit the behavior consistently.

@dgageot dgageot requested a review from a team as a code owner May 28, 2026 12:36
gtardif
gtardif previously approved these changes May 28, 2026
Copy link
Copy Markdown

@docker-agent docker-agent left a comment

Choose a reason for hiding this comment

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

Assessment: 🟡 NEEDS ATTENTION

Comment thread pkg/tui/tui.go Outdated
Comment thread pkg/tui/tui.go
if c == "" {
continue
}
if !strings.HasPrefix(c, "/") {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[LOW] WithDisabledCommands is case-sensitive — /Cost silently fails to disable /cost

The function normalizes leading slashes (e.g. "cost""/cost") and trims whitespace, but does not fold to lowercase. If a programmatic caller passes "/Cost" or "/COST", the map lookup m.disabledCommands[item.SlashCommand] will not match the actual slash command (which is stored in lowercase). The command will silently remain enabled.

The doc comment currently only mentions the slash-prefix normalization. In practice, all defined slash commands use lowercase, so interactive users of the CLI flag are unlikely to encounter this. But the WithDisabledCommands public API gives no indication that casing matters.

Suggestion: either add a note to the doc comment (// Case-sensitive: entries must match the exact casing of the slash command.) or normalize with strings.ToLower.

@aheritier aheritier added area/cli CLI commands, flags, output formatting area/tui For features/issues/fixes related to the TUI kind/feat PR adds a new feature (maps to feat: commit prefix) status/needs-rebase PR has merge conflicts or is out of date with main labels May 28, 2026
@aheritier aheritier marked this pull request as draft May 28, 2026 14:32
@dgageot
Copy link
Copy Markdown
Member Author

dgageot commented May 28, 2026

Addressed review feedback:

  • MEDIUM (in-place mutation in commandCategories): dropped the slices.DeleteFunc simplification commit. The original implementation already allocated fresh slices and is restored as the only behavior, so custom builders returning shared/cached slices are no longer at risk.
  • LOW (case-sensitive matching in WithDisabledCommands): entries are now lower-cased after trimming, so /Cost, cost, and /cost all disable /cost. Doc comment updated; new test case matching is case-insensitive covers the behavior.

Rebased on top of origin/main (the snapshot test fix already landed there as ac2ff3add, so the duplicate commit was dropped). Branch force-pushed.

@dgageot dgageot marked this pull request as ready for review May 28, 2026 14:51
Copy link
Copy Markdown

@docker-agent docker-agent left a comment

Choose a reason for hiding this comment

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

Assessment: 🟡 NEEDS ATTENTION

One medium-severity finding in the newly added filter. The guard condition for empty categories and the redundant outer guard in are clean. Flag wiring through , normalization logic, and test coverage are all correct.

Comment thread pkg/tui/tui.go
for _, cat := range categories {
items := make([]commands.Item, 0, len(cat.Commands))
for _, item := range cat.Commands {
if m.disabledCommands[item.SlashCommand] {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[MEDIUM] Case-insensitive filtering silently fails for dynamic commands with uppercase names

WithDisabledCommands normalises user input to lowercase before storing in the disabledCommands map (e.g. "MyTool""/mytool"), but the lookup in commandCategories() uses item.SlashCommand verbatim — with no strings.ToLower applied to the registered value.

For built-in commands this is harmless (they're hardcoded as lowercase strings like "/cost", "/eval"). However, dynamically-registered entries — agent commands and skill commands — are built as "/" + name where name comes directly from the runtime registry:

// pkg/tui/commands/commands.go (existing, not in diff)
SlashCommand: "/" + name,      // agent command — name not lowercased
SlashCommand: "/" + skillName, // skill command — skillName not lowercased

If any such name contains uppercase letters (e.g. "MySkill""/MySkill"), passing --disable-commands=/myskill adds "/myskill" to the map, but the lookup m.disabledCommands["/MySkill"] misses it. The PR's claim of case-insensitive matching only holds for the user-input side, not for the registered value side.

Fix: lowercase item.SlashCommand at the point of lookup:

if m.disabledCommands[strings.ToLower(item.SlashCommand)] {

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

Labels

area/cli CLI commands, flags, output formatting area/tui For features/issues/fixes related to the TUI kind/feat PR adds a new feature (maps to feat: commit prefix)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants