diff --git a/apps/web/src/components/DiffPanel.tsx b/apps/web/src/components/DiffPanel.tsx index 561bcd2b3e04..8fe7d65356a4 100644 --- a/apps/web/src/components/DiffPanel.tsx +++ b/apps/web/src/components/DiffPanel.tsx @@ -35,7 +35,7 @@ import { useFilesystemReadAccess } from "~/state/filesystem"; import { useOpenInPreferredEditor } from "../editorPreferences"; import { useFileContextMenuHandler } from "../fileContextMenu"; import { type DraftId } from "../composerDraftStore"; -import { openDiffFilePrimaryAction } from "../diffFileActions"; +import { openDiffFilePrimaryAction, resolveDiffPathForWorkspace } from "../diffFileActions"; import { toolCallDiff } from "../lib/toolCallDiff"; import { useCheckpointDiff, useTurnItemDetail } from "~/state/queries"; import { revisionedQuery } from "~/state/revisionedQuery"; @@ -862,6 +862,16 @@ export default function DiffPanel({ )?.cwd, }; }; + // A mention names the file from the thread's folder, the way the file viewer opens it. + const threadMentionPath = (filePath: string) => { + const repositoryFile = repositoryFileTarget(filePath); + if (repositoryFile?.insideThreadFolder === false) return null; + return resolveDiffPathForWorkspace({ + filePath, + workspaceRoot: activeCwd, + repositoryRoot: repositoryFile ? undefined : diffPathRepositoryRoot, + }); + }; const openDiffFile = (filePath: string) => { const repositoryFile = repositoryFileTarget(filePath); openDiffFilePrimaryAction({ @@ -1798,6 +1808,8 @@ export default function DiffPanel({ selectedPath={selectedFilePath} revealRequestId={selectedFileRevealRequestId} onSelectFile={revealDiffFile} + workspaceRoot={activeCwd} + mentionPath={threadMentionPath} /> ) : null} diff --git a/apps/web/src/components/diffs/DiffFileTree.browser.test.tsx b/apps/web/src/components/diffs/DiffFileTree.browser.test.tsx index 73b99454faa8..32373806fb46 100644 --- a/apps/web/src/components/diffs/DiffFileTree.browser.test.tsx +++ b/apps/web/src/components/diffs/DiffFileTree.browser.test.tsx @@ -2,6 +2,9 @@ import { FileTree } from "@pierre/trees"; import { expect, it, vi } from "vite-plus/test"; import { page, userEvent } from "vite-plus/test/browser"; +import { ComposerHandleContext, type ComposerHandleRef } from "~/composerHandleContext"; +import { dismissContextMenu } from "~/contextMenuFallback"; + import { render } from "../../../test/render"; import { DiffFileTree, type DiffFileTreeEntry } from "./DiffFileTree"; @@ -16,7 +19,12 @@ it("expands every folder without asking the tree about all folders for each one" using getItem = vi.spyOn(FileTree.prototype, "getItem"); await using _screen = await render(