fix: enable slash command chaining on any line in multiline input#12029
Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
Draft
fix: enable slash command chaining on any line in multiline input#12029roomote-v0[bot] wants to merge 1 commit intomainfrom
roomote-v0[bot] wants to merge 1 commit intomainfrom
Conversation
Previously, slash commands only worked on the first line of the textarea. This was because shouldShowContextMenu(), handleChange(), and insertMention() all checked against the full text value rather than the current line where the cursor is positioned. Changes: - shouldShowContextMenu: extract current line from cursor position and check if it starts with "/" instead of checking entire text - ChatTextArea handleChange: same current-line extraction for slash command detection and query building - insertMention: when isSlashCommand is true, replace only the slash token on the current line instead of the entire text content Closes #12028
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.
Related GitHub Issue
Closes: #12028
Description
This PR attempts to address Issue #12028. Feedback and guidance are welcome.
Previously, slash commands only worked on the first line of the textarea because the detection logic checked the entire text value (
text.startsWith("/")) rather than the current line where the cursor sits.Three targeted changes were made:
shouldShowContextMenu()(context-mentions.ts): Extracts the current line from the text based on cursor position and checks if that line starts with/(instead of checking the full text).handleChange()(ChatTextArea.tsx): Same current-line extraction approach for slash command detection and search query building.insertMention()(context-mentions.ts): WhenisSlashCommandis true, replaces only the slash token on the current line (from line start to cursor) instead of replacing the entire text content. This preserves content on other lines.Test Procedure
context-mentions.spec.tsto reflect the new per-line behaviorshouldShowContextMenuinsertMentioncd webview-ui && npx vitest run src/utils/__tests__/context-mentions.spec.tsPre-Submission Checklist
Documentation Updates
Additional Notes
The backend slash command parsing (
src/core/mentions/index.ts) already usescommandRegexGlobalwhich handles multiline text correctly, so no backend changes were needed.Interactively review PR in Roo Code Cloud