Skip to content

fix(web): support spaces in composer file mentions#2625

Open
GuilhermeVieiraDev wants to merge 1 commit into
pingdotgg:mainfrom
GuilhermeVieiraDev:fix/composer-file-mentions-with-spaces
Open

fix(web): support spaces in composer file mentions#2625
GuilhermeVieiraDev wants to merge 1 commit into
pingdotgg:mainfrom
GuilhermeVieiraDev:fix/composer-file-mentions-with-spaces

Conversation

@GuilhermeVieiraDev
Copy link
Copy Markdown
Contributor

@GuilhermeVieiraDev GuilhermeVieiraDev commented May 10, 2026

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.md inserted @MY FILE.md , and on re-parse only @MY became a mention while FILE.md stayed 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:

image image

After:

image

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

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 serializeComposerMentionPath and 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-logic now 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

  • Adds serializeComposerMentionPath in composer-editor-mentions.ts to quote and escape paths containing whitespace or special characters, producing @"..." tokens.
  • Updates the mention regex to recognize both quoted (@"...") and unquoted mention tokens, with proper unescaping of quoted content.
  • Updates ChatComposer.tsx and ComposerMentionNode.getTextContent to serialize paths before insertion/rendering.
  • Fixes cursor expansion and collapse in composer-logic.ts to account for the extra characters introduced by quoting.
  • Behavioral Change: mentions with spaces now serialize as @"path with spaces" instead of @path with spaces, which changes the raw text stored in the composer.

Macroscope summarized affff43.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 10, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 57b6a111-7858-4882-bc55-65eb4acd331b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels May 10, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 10, 2026

Approvability

Verdict: 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.

@GuilhermeVieiraDev GuilhermeVieiraDev force-pushed the fix/composer-file-mentions-with-spaces branch from 80da058 to aac0024 Compare May 12, 2026 20:07
@reactreview
Copy link
Copy Markdown

reactreview Bot commented May 12, 2026

Note

No issues found

@GuilhermeVieiraDev GuilhermeVieiraDev force-pushed the fix/composer-file-mentions-with-spaces branch from aac0024 to affff43 Compare May 31, 2026 03:28
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit affff43. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Using the @ syntax to reference files does not respect whitespace

1 participant