Skip to content

[codex] keep scoped package references as text#4167

Open
maxwellyoung wants to merge 1 commit into
pingdotgg:mainfrom
maxwellyoung:codex/fix-scoped-package-mentions
Open

[codex] keep scoped package references as text#4167
maxwellyoung wants to merge 1 commit into
pingdotgg:mainfrom
maxwellyoung:codex/fix-scoped-package-mentions

Conversation

@maxwellyoung

@maxwellyoung maxwellyoung commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #4142.

What changed

  • keep common unquoted @scope/package references as plain composer text instead of file-mention pills
  • preserve canonical autocomplete-generated file links, including paths under @scope/
  • preserve explicit quoted path mentions for ambiguous paths
  • add regression coverage at the shared tokenizer, web segmentation, and Lexical paste-command boundaries

Why

The shared inline-token grammar treated every whitespace-delimited @value as a file mention. The paste handler appends a virtual delimiter before parsing, so pasting a command such as yarn expo install @expo/ui immediately converted the package reference into a folder pill.

Scoped package syntax is ambiguous with a bare relative path. Current file autocomplete already serializes selected paths as canonical Markdown file links, so leaving the ambiguous bare form as package text fixes the paste behavior without weakening selected file mentions. The shared tokenizer is used by web and native mobile composers.

Verification

  • vp check (passes with 10 existing warnings outside this diff)
  • vp run typecheck
  • focused tokenizer, segmentation, and paste tests: 32 passed
  • vp test: 608 files and 4,829 tests passed; 2 files and 7 tests skipped by the existing suite
  • git diff --check

Note

Keep scoped package references (e.g. @scope/pkg) as plain text instead of mentions

  • Adds SCOPED_PACKAGE_REFERENCE_REGEX in composerInlineTokens.ts to detect unquoted @scope/pkg patterns and skip them during mention token collection.
  • Canonical markdown file links to scoped paths and explicitly quoted mentions continue to resolve as mentions.
  • Behavioral Change: unquoted @-prefixed text matching a scoped package pattern (e.g. from yarn add @scope/pkg or import @scope/pkg) no longer becomes a mention.

Macroscope summarized dd78482.


Note

Low Risk
Localized composer parsing change with broad test coverage; no auth, data, or API surface changes.

Overview
Unquoted @scope/package text no longer becomes file-mention pills in the shared composer inline-token grammar (collectMentionTokens in composerInlineTokens.ts). A SCOPED_PACKAGE_REFERENCE_REGEX guard skips bare paths that look like npm scoped packages (e.g. @expo/ui), which fixes paste flows such as yarn expo install @expo/ui turning into folder mentions.

Explicit and autocomplete paths still mention: canonical Markdown file links like [sub](@scope/pkg/sub) and quoted mentions (@"expo/ui") continue to produce mention tokens; ordinary file mentions (e.g. @README.md) are unchanged.

Regression tests were added at the shared tokenizer, web splitPromptIntoComposerSegments, and Lexical registerComposerInlineTokenPaste boundaries.

Reviewed by Cursor Bugbot for commit dd78482. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

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: 1264ea01-c994-401b-859d-132f9d2220b6

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Jul 19, 2026
Comment thread packages/shared/src/composerInlineTokens.ts Outdated
@maxwellyoung
maxwellyoung marked this pull request as ready for review July 19, 2026 21:40
Comment thread packages/shared/src/composerInlineTokens.ts Outdated
Comment thread packages/shared/src/composerInlineTokens.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR changes how scoped package references are parsed in the composer, but an unresolved review comment identifies that the new regex may incorrectly treat legitimate file paths like src/index.ts as scoped packages, causing a regression in mention handling.

You can customize Macroscope's approvability policy. Learn more.

PR: pingdotgg#4167

Co-authored-by: codex <codex@users.noreply.github.com>
@juliusmarminge
juliusmarminge force-pushed the codex/fix-scoped-package-mentions branch from e535195 to dd78482 Compare July 20, 2026 16:52

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes using high effort 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 dd78482. Configure here.

const quotedPath = match[2];
const path = quotedPath !== undefined ? quotedPath.replace(/\\(.)/g, "$1") : (match[3] ?? "");
if (!path) {
if (!path || (quotedPath === undefined && SCOPED_PACKAGE_REFERENCE_REGEX.test(path))) {

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.

Bare path mentions still expected

Medium Severity

SCOPED_PACKAGE_REFERENCE_REGEX treats common repo paths like src/index.ts as scoped packages, so bare @src/index.ts no longer becomes a mention. An existing cursor collapse/expand regression in composer-logic.test.ts still assumes that path is a mention, and unlike the segmentation tests it was not updated for the new rule.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit dd78482. Configure here.

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

Labels

size:XS 0-9 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]: paste @expo/ui in the chat convert it into ui folder automatically

1 participant