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)
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 |
aac0024 to
affff43
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit affff43. Configure here.
| for (const segment of segments) { | ||
| if (segment.type === "mention") { | ||
| const expandedLength = segment.path.length + 1; | ||
| const expandedLength = serializeComposerMentionPath(segment.path).length + 1; |
There was a problem hiding this comment.
Backslash mention cursor length mismatch
Low Severity
expandCollapsedComposerCursor and collapseExpandedComposerCursor now size mention spans with serializeComposerMentionPath, which quotes paths containing \. The mention parser still accepts unquoted tokens whose path includes backslashes, so a prompt like @src\file.ts can be parsed as one mention while the literal @… token in value stays shorter than the serialized form. Collapsed/expanded cursor mapping then uses the wrong offsets in that string.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit affff43. Configure here.


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
Low Risk
Localized composer mention parsing/serialization and UI cursor logic; simple paths remain unquoted and behavior is covered by new unit tests.
Overview
Composer file mentions now support paths with spaces by quoting only when needed (
@"My File.md") while simple paths stay unchanged (@src/index.ts).Adds
serializeComposerMentionPathand updates the mention tokenizer to accept quoted tokens with escape/unescape handling. Insertion (ChatComposer) and Lexical mention text (ComposerMentionNode) use serialization so the stored prompt matches what the parser expects.Collapsed ↔ expanded cursor mapping in
composer-logicnow uses serialized mention length so chips and caret behavior stay correct for quoted mentions. Tests cover parsing, serialization, selection boundaries, and cursor round-trips.Reviewed by Cursor Bugbot for commit affff43. 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 affff43.