Skip to content

fix: Slash Command Autocomplete vs. Auto-Execute Fix (#2257)#2275

Open
yunus25jmi1 wants to merge 1 commit intodocker:mainfrom
yunus25jmi1:feature/slash-command-autocomplete-fix
Open

fix: Slash Command Autocomplete vs. Auto-Execute Fix (#2257)#2275
yunus25jmi1 wants to merge 1 commit intodocker:mainfrom
yunus25jmi1:feature/slash-command-autocomplete-fix

Conversation

@yunus25jmi1
Copy link
Copy Markdown
Contributor

I have successfully implemented a root-cause fix for the issue where pressing Tab to autocomplete a slash command would immediately execute it instead of just completing the text.

Root Cause Analysis:
In pkg/tui/components/completion/completion.go, both Enter and Tab were bound to the same key binding, causing auto-submit completions (like slash commands) to execute immediately upon selection with either key.

Solution Implemented:

  • Separate Tab and Enter key bindings in completion.go.
  • Tab now autocompletes text only (AutoExecute=false).
  • Enter executes the command (AutoExecute=true).
  • Updated editor.go to handle the AutoExecute flag.
  • Added comprehensive tests in pkg/tui/components/completion/autocomplete_test.go.

Verification:

  • pkg/tui/components/completion tests: 6/6 PASS
  • pkg/tui/components/editor tests: PASS
  • Successful build of project and binary

Fixes #2257

@yunus25jmi1 yunus25jmi1 requested a review from a team as a code owner March 29, 2026 07:56
@yunus25jmi1 yunus25jmi1 force-pushed the feature/slash-command-autocomplete-fix branch from a5614de to 68994bd Compare March 29, 2026 08:01
@k33g
Copy link
Copy Markdown
Contributor

k33g commented Apr 1, 2026

@yunus25jmi1 does it fix the the call of a skill with a slash command (#1819)?

@yunus25jmi1
Copy link
Copy Markdown
Contributor Author

@yunus25jmi1 does it fix the the call of a skill with a slash command (#1819)?

Yes, this is going to resolve the Issue #1819

@yunus25jmi1 yunus25jmi1 force-pushed the feature/slash-command-autocomplete-fix branch from c7a7fd8 to 0030b96 Compare April 4, 2026 16:45
@yunus25jmi1 yunus25jmi1 force-pushed the feature/slash-command-autocomplete-fix branch from 0030b96 to 68994bd Compare April 4, 2026 17:58
@yunus25jmi1
Copy link
Copy Markdown
Contributor Author

Hi @dgageot, could you please review this PR? This is a focused fix for the slash command autocomplete issue (#2257) that also resolves #1819. The PR now contains only 1 commit with the fix. Tests pass locally and the project builds successfully. Thank you!

@yunus25jmi1
Copy link
Copy Markdown
Contributor Author

Hi @dgageot and maintainers, I noticed that PR #2325 by @joshbarrington also addresses issues #2257 and #1819 with a different implementation approach. This PR takes a simpler route by removing AutoComplete from the command interface and driving behavior directly through the Update function.

Since both PRs aim to fix the same issues, could you please clarify which direction you'd prefer to proceed with? I'm happy to close #2275 in favor of #2325 if that's the preferred approach, or I can update my PR if needed. Thanks!

Copy link
Copy Markdown
Contributor

@krissetto krissetto left a comment

Choose a reason for hiding this comment

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

same concerns as i described here need to be addressed first

#2325 (comment)

@yunus25jmi1 yunus25jmi1 force-pushed the feature/slash-command-autocomplete-fix branch from 68994bd to 739b523 Compare April 4, 2026 20:47
@yunus25jmi1
Copy link
Copy Markdown
Contributor Author

Updated Fix - Addressing Both PRs and the Regression

I've updated this PR with a unified fix that addresses:

  1. Original issue ([enhancement] Slash Command auto complete vs. auto execute #2257): Slash command Tab autocomplete no longer executes immediately
  2. @krissetto's concerns: Fixed the regression that broke @attachment functionality

Changes Made

The fix implements a rule-based system in the completion.SelectedMsg handler:

  1. Rule 1: Action items (like Browse files...) now ALWAYS execute regardless of Tab/Enter
  2. Rule 2: Empty value defensive check
  3. Rule 3: Slash commands (/) only submit on Enter; file attachments (@) NEVER auto-send
  4. Rule 4: Fixed token replacement to use full trigger word (e.g., @, /e)

Behavior After Fix

  • Slash commands: Tab inserts text, Enter inserts + sends
  • File attachments: Tab inserts + attaches, Enter inserts + attaches (never sends)
  • Browse files: Both Tab and Enter open the file picker

This fix combines the best of both approaches while ensuring @attachment UX remains intact. Build and tests pass.

@yunus25jmi1
Copy link
Copy Markdown
Contributor Author

Addressing Both PRs

I want to acknowledge @joshbarrington's PR #2325 which also addresses issues #2257 and #1819 with a different approach.

My approach (#2275): Separated Tab and Enter key bindings with an flag in the completion component. Tab sets , Enter sets .

Joshbarrington's approach (#2325): Removed from the command interface and drove behavior directly through the Update function.

This unified fix combines the best of both:

  • Keeps the Tab/Enter distinction (your contribution)
  • Removes the requirement for action items so "Browse files..." works on both Tab and Enter
  • Uses full trigger word for token replacement (fixes the @ disappearing bug)
  • Ensures file attachments (@) NEVER auto-send - they always just insert text

This addresses @krissetto's feedback about not breaking @attachment functionality while fixing the slash command autocomplete issue. Build and tests pass.

I have successfully implemented a root-cause fix for the issue where pressing Tab to autocomplete a slash command would immediately execute it instead of just completing the text.

Root Cause Analysis:
In pkg/tui/components/completion/completion.go, both Enter and Tab were bound to the same key binding, causing auto-submit completions (like slash commands) to execute immediately upon selection with either key.

Solution Implemented:
- Separate Tab and Enter key bindings in completion.go.
- Tab now autocompletes text only (AutoExecute=false).
- Enter executes the command (AutoExecute=true).
- Updated editor.go to handle the AutoExecute flag.
- Added comprehensive tests in pkg/tui/components/completion/autocomplete_test.go.

Verification:
- pkg/tui/components/completion tests: 6/6 PASS
- pkg/tui/components/editor tests: PASS
- Successful build of project and binary

Fixes docker#2257
@yunus25jmi1 yunus25jmi1 force-pushed the feature/slash-command-autocomplete-fix branch from 739b523 to 47f949b Compare April 4, 2026 20:59
@yunus25jmi1
Copy link
Copy Markdown
Contributor Author

Updated: Refactored to match joshbarrington's naming convention

I've refactored the variable naming to align with @joshbarrington's PR #2325:

The unified fix now includes:

  1. completion.go: field (Enter=true, Tab=false)
  2. editor.go: Uses with rule-based system:
    • Rule 1: Action items ALWAYS execute (regardless of Tab/Enter)
    • Rule 2: Empty value defensive check
    • Rule 3: Slash commands (/) only submit on Enter; file attachments (@) NEVER auto-send
    • Rule 4: Fixed token replacement to use full trigger word

Build and tests pass.

@yunus25jmi1 yunus25jmi1 requested a review from krissetto April 4, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[enhancement] Slash Command auto complete vs. auto execute

3 participants