fix(web): open the file a bare filename reference names - #6297
Conversation
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>
|
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 |
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 d4f5f15. Configure here.
ApprovabilityVerdict: 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. |
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>

Fixes #6292.
Clicking
ChatView.tsx:3301fails with "Failed to read workspace file 'ChatView.tsx'". The:linesuffix 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:3301that previously failed against the workspace root.When the path has no directory segment,
openFileInPanelqueriesprojectEnvironment.searchEntriesand 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.MarkdownFileLinknow takes anonOpenInPanelcallback 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
openFileInPanelcallback in ChatMarkdown.tsx queries the project index to find a matching file path.claimWorkspaceBasenameLookupin workspaceBasenameLookup.ts, ensuring only the latest click's lookup result is applied.MarkdownFileLinknow accepts anonOpenInPanelcallback instead of calling the right panel store directly, making the open logic configurable by the parent.Macroscope summarized dcb40ad.