Skip to content

Slash command autocomplete should trigger mid-line, not only at the start of the prompt #40719

Closed as not planned

Description

@Soushi888

Problem

In the TUI prompt, / only opens the command autocomplete menu when it is the first character of the input. Typing:

fix the bug then /commit

does not surface command suggestions at /commit. You have to move the cursor to the start, or know the command name with no completion help.

This is inconsistent with the existing @ mention trigger, which already works anywhere in the line when preceded by whitespace.

Proposed approach

Mirror mentionTriggerIndex for /:

  • Extract a shared tokenTriggerIndex(value, offset, trigger) helper from mentionTriggerIndex (DRY, no parallel logic).
  • Add slashTriggerIndex reusing the same whitespace-preceded rule, so foo /comp triggers but https://x, foo/bar, MM/DD do not. Newline counts as a separator; Unicode display width handled via the existing promptOffsetWidth path.
  • Make server-command onSelect and hide() index-aware so selecting a command mid-line replaces only the typed token, not the whole line.
  • Reopen the menu when the cursor steps back onto a / token anywhere in the line, mirroring the @ reopen path.

The start-of-line case (store.index === 0) is preserved unchanged; the mid-line path is purely additive.

Edge case worth flagging

/ appears in prose more often than @ (paths, URLs, dates, division). The whitespace-preceded rule rejects https:// and foo/bar, but reviewers may want to weigh in on extra guards.

Verification

  • I have verified this behavior does not exist in the latest version
  • I have searched for existing issues and PRs that cover this

Working implementation exists locally, ~40 lines across packages/tui/src/prompt/display.ts and packages/tui/src/component/prompt/autocomplete.tsx, plus a slashTriggerIndex test suite mirroring the existing mention-trigger cases. Happy to open the PR once there is sign-off on the direction.

Activity

  1. github-actions commented on Aug 5, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. Soushi888 commented on Aug 5, 2026

    @Soushi888
    Author

    Closing as a duplicate of #40689 (filed a couple of hours earlier, same request). Moved the technical detail and implementation sketch over there so it's not lost.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions