Skip to content

[Feature]: Support slash commands mid-prompt, not only at the start #16262

@luisfelipesena

Description

@luisfelipesena

Verify there is no existing issue for this

  • I searched existing issues and this is not a duplicate

Description

Currently, slash commands (/undo, /new, /compact, custom commands) only trigger when typed at the very beginning of an empty prompt. The regex rawText.match(/^\/(\S*)$/) requires the entire input to be just the slash command.

This means users cannot type context first and then invoke a slash command, e.g.:

  • explain the auth flow /compact — does nothing
  • fix the bug in auth.ts /undo — does nothing

Expected: Typing / after a space anywhere in the prompt should open the slash command popover, just like @ mentions work mid-prompt today.

After selecting:

  • Custom commands: replace the /trigger fragment with the expanded command, keep surrounding text
  • Builtin commands: remove the /trigger fragment, keep surrounding text, execute the command

Related: the @ mention popover already works mid-prompt via textBeforeCursor.match(/@(\S*)$/). Slash commands should behave the same way.

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions