feat(app): support slash commands mid-prompt#16263
Open
luisfelipesena wants to merge 4 commits intoanomalyco:devfrom
Open
feat(app): support slash commands mid-prompt#16263luisfelipesena wants to merge 4 commits intoanomalyco:devfrom
luisfelipesena wants to merge 4 commits intoanomalyco:devfrom
Conversation
Previously, slash commands only triggered when / was the entire input (regex: /^\/(\S*)$/). Now they trigger after any whitespace boundary, matching the @mention behavior. Changes: - Regex now matches (^|\s)/command at cursor position - Track slashStart position in store to know where / was typed - handleSlashSelect replaces only the /command fragment, preserving surrounding text for custom commands - Builtin commands remove the /trigger fragment and execute normally - Backward compatible: / at start of empty input still works
Upstream removed pendingAutoAccept from store. Keep slashStart (added by this branch) and drop pendingAutoAccept.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #16262
Type of change
What does this PR do?
Slash commands (
/undo,/new, custom commands) only worked when typed at the start of an empty prompt. The detection regex wasrawText.match(/^\/(\S*)$/)which required the entire input to be just the slash command.This changes three things:
textBeforeCursor.match(/(^|\s)\/(\S*)$/)— detects/after any whitespace, matching how@mentions already work mid-prompt.slashStartso we know exactly which text fragment to replace./triggerfragment is replaced (custom commands) or removed (builtin commands), keeping surrounding text and cursor position intact.Original behavior is preserved: typing
/cmdalone in an empty prompt works exactly as before.How did you verify your code works?
explain auth /undo— triggers undo, keeps "explain auth " in prompt/newalone — clears and triggers new session (original behavior)fix bug /compact— triggers compact, text preservedhttps://example.com/path— no false trigger (/ not preceded by whitespace)/triggerreplaced inline, cursor positioned correctlyScreenshots / recordings
Checklist