feat(web): clicking a composer mention chip opens the file - #6299
feat(web): clicking a composer mention chip opens the file#6299Brechard wants to merge 3 commits into
Conversation
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>
|
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 Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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: 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>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort 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 0cc9440. Configure here.
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>

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:linesuffix, 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
onOpenMentionFilehandler. Hosts without a panel (e.g. Settings appearance preview) omit it, so those chips stay inert.Adds
resolveComposerMentionFileTargetto normalize relative, absolute,~/, Windows, and:linemention paths into a workspace-relative target (ornulloutside the workspace). Renames the editor chip context toComposerChipActionsContextso 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
resolveComposerMentionFileTargetto resolve a mention path against the active workspace root, returning a workspace-relative path and optional line number, ornullif the path is outside the workspace or invalid.ComposerTerminalContextActionsContexttoComposerChipActionsContextinComposerPromptEditor.tsxto accommodate the newonOpenMentionFilehandler alongside the existingonRemoveTerminalContext.Macroscope summarized e9a99bf.