fix(web): support spaces in composer file mentions#2625
fix(web): support spaces in composer file mentions#2625GuilhermeVieiraDev wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved Self-contained bug fix adding quoted path support for file mentions containing spaces. Changes are limited to parsing/serialization logic with comprehensive test coverage and no broader runtime impact. You can customize Macroscope's approvability policy. Learn more. |
80da058 to
aac0024
Compare
|
Note No issues found |
What Changed
Fixed composer file mentions for files and folders whose paths contain whitespace.
The composer now serializes paths with spaces as quoted mention tokens, while leaving simple paths unchanged:
@src/index.ts@"My File.md"Quoted tokens are parsed back into a single mention chip, and the chip still shows the clean filename without quotes.
Fixes #2571.
Why
The previous mention parser treated a mention as
@followed by non-whitespace characters. That worked for paths like@AGENTS.md, but broke for paths containing spaces.Selecting
MY FILE.mdinserted@MY FILE.md, and on re-parse only@MYbecame a mention whileFILE.mdstayed as plain text. This was visible in the composer and could also send an incomplete file reference to the agent.Quoting only paths that need it keeps the common representation backwards-compatible and readable, while giving whitespace-containing paths a clear token boundary.
UI Changes
Before:
After:
Checklist
Note
Medium Risk
Moderate risk because it changes mention token parsing/serialization and cursor mapping logic, which can affect editor selection behavior and the on-wire prompt text for mentions with special characters.
Overview
Adds support for quoted file mention tokens so paths with whitespace (and quotes/backslashes) can be inserted and re-parsed as a single
@mention (e.g.@"My File.md").Introduces
serializeComposerMentionPathand updates mention rendering/insertion (ComposerPromptEditortext content andChatComposerpath completion) plus cursor expand/collapse calculations to use the serialized token length. Updates mention parsing regex to accept quoted tokens with escapes and extends tests to cover quoted mention splitting, unescaping, boundary detection, and cursor mapping.Reviewed by Cursor Bugbot for commit aac0024. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix composer file mentions to support paths with spaces
serializeComposerMentionPathincomposer-editor-mentions.tsto quote and escape paths containing whitespace or special characters, producing@"..."tokens.@"...") and unquoted mention tokens, with proper unescaping of quoted content.ChatComposer.tsxandComposerMentionNode.getTextContentto serialize paths before insertion/rendering.composer-logic.tsto account for the extra characters introduced by quoting.@"path with spaces"instead of@path with spaces, which changes the raw text stored in the composer.Macroscope summarized aac0024.