Skip to content

fix(web): open the file a bare filename reference names - #6297

Open
Brechard wants to merge 4 commits into
pingdotgg:mainfrom
Brechard:fix/file-reference-basename-lookup
Open

fix(web): open the file a bare filename reference names#6297
Brechard wants to merge 4 commits into
pingdotgg:mainfrom
Brechard:fix/file-reference-basename-lookup

Conversation

@Brechard

@Brechard Brechard commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #6292.

Clicking ChatView.tsx:3301 fails with "Failed to read workspace file 'ChatView.tsx'". The :line suffix is what makes it a link, but the filename alone doesn't say where the file is, so it resolves against the workspace root.

When a path has no directory in it, this asks the workspace index where the file actually is before opening the panel. Only an exact filename match counts — a fuzzy match on some other file would be worse than the error you get today, so anything else keeps the old path and the old message. Paths that already carry a directory skip the lookup entirely and open synchronously, as before.

Two lookups can be in flight at once and the index makes no promise about the order it answers in, so each one claims a sequence and drops its result if a later click superseded it.

No screenshots: the visible change is a chip that used to open an error page now opening the file.

🤖 Generated with Claude Code


Note

Low Risk
Focused UX bugfix for chat file links with conservative exact-match logic and unit tests; no auth, security, or data-handling changes.

Overview
Bare filename links in chat markdown now resolve to a real workspace path before opening the right panel, fixing clicks like ChatView.tsx:3301 that previously failed against the workspace root.

When the path has no directory segment, openFileInPanel queries projectEnvironment.searchEntries and opens only an unambiguous exact (or single case-insensitive) basename match. Paths that already include a directory still open synchronously. Concurrent lookups are sequenced so a later click wins if an earlier search settles out of order.

MarkdownFileLink now takes an onOpenInPanel callback instead of calling the right-panel store directly.

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

Note

Resolve bare filename references to project file paths when opening files from chat links

  • When a file link in chat references a bare filename (no directory separator), the new openFileInPanel callback in ChatMarkdown.tsx queries the project index to find a matching file path.
  • Match selection prefers an exact basename match, falls back to a unique case-insensitive match, and uses the original path if ambiguous or unresolved.
  • Concurrent rapid clicks are handled via claimWorkspaceBasenameLookup in workspaceBasenameLookup.ts, ensuring only the latest click's lookup result is applied.
  • MarkdownFileLink now accepts an onOpenInPanel callback instead of calling the right panel store directly, making the open logic configurable by the parent.

Macroscope summarized dcb40ad.

Clicking `ChatView.tsx:3301` in a message fails with "Failed to read
workspace file 'ChatView.tsx'". The `:line` suffix is what makes the span a
link at all, but the name alone says nothing about where the file is, so it
resolves against the workspace root, which is rarely where it lives. Agents
write references in that shape constantly.

When the path has no directory in it, ask the workspace index where the file
is before opening the panel. Only an exact filename match counts; anything
else keeps the old path and the old error, since guessing at a fuzzy match
would be worse than saying nothing. Paths that already carry a directory skip
the lookup and open synchronously as before.

Two lookups can be in flight at once, and the index makes no promise about
the order it answers in, so each claims a sequence and drops its result if a
later click superseded it.

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: 7684cc41-8bcb-4402-9ba6-e844802962b8

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 the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Aug 12, 2026
@github-actions github-actions Bot added the size:L 100-499 changed lines (additions + deletions). label Aug 12, 2026
Comment thread apps/web/src/workspaceBasenameLookup.ts Outdated
Comment thread apps/web/src/components/ChatMarkdown.tsx Outdated

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

Comment thread apps/web/src/components/ChatMarkdown.tsx
@macroscopeapp

macroscopeapp Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved dcb40ad

This bug fix corrects bare filename opening behavior with well-tested, self-contained helper functions. The change has clear intent, limited scope, and comprehensive test coverage.

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

rodrigoB-CB and others added 3 commits August 12, 2026 11:38
Two review findings on the same guard:

The lookup sequence was claimed inside the async branch, so a click on a path
that opens synchronously never advanced it. An older basename lookup still
read as current and reopened its file over the one the newer click had already
opened. Every open claims now.

The case-insensitive fallback returned whichever entry the index ranked first,
so `FOO.ts` in a workspace holding both `Foo.ts` and `foo.ts` opened one of
them arbitrarily. There is no right answer there, so it resolves to nothing
and the reference reports itself unresolved.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The previous commit's message said this was done; it was not. The edit never
reached the file and I pushed and answered the reviewer as though it had.

A click on a path that opens synchronously now claims the sequence too, so it
supersedes any basename lookup already in flight instead of letting that
lookup land afterwards and take the panel back.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The new module was 57% comment lines against a 1% median for apps/web/src,
with a file-header essay and a doc block on every export. Trimmed to the
register the neighbouring modules use: a short note only where the reason is
not visible from the code.

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.

Clicking Foo.tsx:42 fails when the file isn't at the workspace root

2 participants