fix(web): open the file a bare filename reference names #6297
MergedBrechard(GitHub profile, opens in a new tab)merged 4 commits into
main fromrefs/pull/6297/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/web/src/workspaceBasenameLookup.ts lines 79 to 80OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +60,21 @@60+61+/**62+ * The best index entry for a basename, or null to leave the path alone. Search63+ * results arrive ranked, so the first exact filename match wins; a fuzzy match64+ * on some other file is worse than the honest "not found" error.65+ */66+export function pickWorkspaceBasenameMatch(67+ basename: string,68+ entries: ReadonlyArray<WorkspaceEntryCandidate>,69+): string | null {70+ const target = basename.trim();71+ if (!target) return null;72+ const files = entries.filter((entry) => entry.kind === "file");73+ // Exact first: a workspace holding both `Foo.ts` and `foo.ts` must not open74+ // whichever the index happened to rank higher. The case-insensitive pass75+ // then covers a reference whose casing drifted from the file on disk, which76+ // is the common shape on macOS and Windows.77+ const exact = files.find((entry) => basenameOfPath(entry.path) === target);78+ if (exact) return exact.path;79+ const folded = target.toLowerCase();80+ return files.find((entry) => basenameOfPath(entry.path).toLowerCase() === folded)?.path ?? null;apps/web/src/components/ChatMarkdown.tsx lines 1453 to 1462OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1434,3 +1447,16 @@14341447 },14351448 [createAssetUrl, openPreview, preparedConnection, threadRef],14361449 );1450+ // `ChatView.tsx:3301` names a file without saying where it lives, so the link1451+ // resolver can only place it at the workspace root and the read fails there.1452+ // Ask the workspace index for the real location before opening the surface.1453+ const openFileInPanel = useCallback(1454+ (workspaceRelativePath: string, line: number | undefined) => {1455+ if (!threadRef) return;1456+ const openAt = (path: string) =>1457+ useRightPanelStore.getState().openFile(threadRef, path, line);1458+ if (!cwd || !needsWorkspaceBasenameLookup(workspaceRelativePath)) {1459+ openAt(workspaceRelativePath);1460+ return;1461+ }1462+ const isLatestLookup = claimWorkspaceBasenameLookup();
- apps/web/src/components/ChatMarkdown.tsx line 1462Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1434,3 +1447,14 @@14341447 },14351448 [createAssetUrl, openPreview, preparedConnection, threadRef],14361449 );1450+ // `ChatView.tsx:3301` names a file without saying where it lives, so the link1451+ // resolver can only place it at the workspace root and the read fails there.1452+ // Ask the workspace index for the real location before opening the surface.1453+ const openFileInPanel = useCallback(1454+ (workspaceRelativePath: string, line: number | undefined) => {1455+ if (!threadRef) return;1456+ const openAt = (path: string) =>1457+ useRightPanelStore.getState().openFile(threadRef, path, line);1458+ if (!cwd || !needsWorkspaceBasenameLookup(workspaceRelativePath)) {1459+ openAt(workspaceRelativePath);1460+ return;
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge merged this2cb1a26
juliusmarminge closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
7684cc41-8bcb-4402-9ba6-e844802962b8You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.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.
❤️ Share