Skip to content

feat(web): clicking a composer mention chip opens the file - #6299

Open
Brechard wants to merge 3 commits into
pingdotgg:mainfrom
Brechard:feat/composer-mention-chip-opens-file
Open

feat(web): clicking a composer mention chip opens the file#6299
Brechard wants to merge 3 commits into
pingdotgg:mainfrom
Brechard:feat/composer-mention-chip-opens-file

Conversation

@Brechard

@Brechard Brechard commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #6296.

An @-mentioned file shows as a chip in the composer, but you can't look at the file without sending the message first.

The chip opens the file in the right panel on click, where a file link in a rendered message already opens it. A host with no panel to open — the appearance preview in Settings — passes no handler, and its chips stay inert with no pointer cursor.

Mention paths arrive workspace-relative from autocomplete, but can be typed by hand as absolute, with ~/, or with a :line suffix, so they go through a resolver that normalizes those and returns null for anything outside the workspace. The two chip actions (remove a terminal context, open a mention) now share one editor context rather than nesting a second provider, which keeps the diff off the surrounding JSX.

No screenshots: the chip gains a pointer cursor and a hover tint, and clicking it opens the file beside the thread.

🤖 Generated with Claude Code


Note

Low Risk
UI affordance that reuses the existing right-panel openFile path. Path resolution fails closed outside the workspace and is covered by unit tests.

Overview
Composer @-mention chips can now open the referenced file in the right panel before you send the message—same surface chat file links already use.

Click or Enter/Space on a chip calls through a new optional onOpenMentionFile handler. Hosts without a panel (e.g. Settings appearance preview) omit it, so those chips stay inert.

Adds resolveComposerMentionFileTarget to normalize relative, absolute, ~/, Windows, and :line mention paths into a workspace-relative target (or null outside the workspace). Renames the editor chip context to ComposerChipActionsContext so open and remove share one provider.

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

Note

Make composer mention chips clickable to open the referenced file in the right panel

  • Mention chips in the chat composer are now rendered as interactive buttons; clicking or pressing Enter/Space opens the referenced file in the right panel, optionally scrolling to the specified line.
  • Adds resolveComposerMentionFileTarget to resolve a mention path against the active workspace root, returning a workspace-relative path and optional line number, or null if the path is outside the workspace or invalid.
  • Chips remain inert when no handler is provided or when path resolution fails (e.g. no active thread/project, path escapes workspace root).
  • Renames ComposerTerminalContextActionsContext to ComposerChipActionsContext in ComposerPromptEditor.tsx to accommodate the new onOpenMentionFile handler alongside the existing onRemoveTerminalContext.

Macroscope summarized e9a99bf.

An `@`-mentioned file shows up in the composer as a chip, but there was no way
to look at the file without sending the message first.

The chip is now clickable and opens the file in the right panel, the same
place a file link in a rendered message opens it. Hosts that have no panel to
open — the appearance preview in Settings, for one — pass no handler, and
their chips stay inert with no pointer cursor.

A mention path comes from autocomplete as workspace-relative, but can be typed
by hand as absolute, with `~/`, or with a `:line` suffix, so it goes through a
resolver that normalizes all of those and returns null for anything outside
the workspace.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 12, 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 Plus

Run ID: cf9d0f65-49ca-4cab-b495-685143c06df6

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

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:L 100-499 changed lines (additions + deletions). labels Aug 12, 2026
Comment thread apps/web/src/components/ComposerPromptEditor.tsx
Comment thread apps/web/src/composerMentionFileTarget.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR adds a new user-facing feature where clicking mention chips opens the referenced file. While well-implemented with comprehensive tests and proper path security checks, new interactive UI capabilities warrant human review.

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

Two review findings.

The workspace containment check compared the whole path exactly, which is
right for a POSIX root but rejects `C:\Repo\src\file.ts` against a `C:\repo`
root — the filesystem behind a drive letter does not distinguish those, so the
chip went inert on a valid mention. The comparison now follows the root: exact
for POSIX, folded for a Windows drive. That also retires the drive-letter
uppercasing in `toPosixPath`, which was doing half of this job.

The chip was pointer-only. It carries `role="button"` and `tabIndex` now, with
Enter and Space opening the file; both keys are stopped before Lexical sees
them so they do not also type into the prompt.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@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 0cc9440. Configure here.

Comment thread apps/web/src/components/ComposerPromptEditor.tsx
Making the chip focusable for keyboard users also meant a plain click moved
focus onto it, blurring the editor so typing went nowhere until the composer
was clicked again. Preventing the default on mousedown keeps focus and the
caret where they were; Tab and Enter still reach the chip.

Also trims this change's comments to the register the surrounding modules use.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 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.

No way to open a file you've @-mentioned in the composer

2 participants