@@ -5,12 +5,10 @@ import { useNavigate, useParams, useSearch } from "@tanstack/react-router";
55import { ThreadId , type TurnId } from "@okcode/contracts" ;
66import { CheckIcon , ChevronDownIcon , Columns2Icon , Rows3Icon , TextWrapIcon } from "lucide-react" ;
77import { useCallback , useEffect , useMemo , useRef , useState } from "react" ;
8- import { openInPreferredEditor } from "../editorPreferences" ;
98import { gitBranchesQueryOptions } from "~/lib/gitReactQuery" ;
109import { checkpointDiffQueryOptions } from "~/lib/providerReactQuery" ;
1110import { cn } from "~/lib/utils" ;
12- import { readNativeApi } from "../nativeApi" ;
13- import { resolvePathLinkTarget } from "../terminal-links" ;
11+ import { useCodeViewerStore } from "../codeViewerStore" ;
1412import { parseDiffRouteSearch , stripDiffSearchParams } from "../diffRouteSearch" ;
1513import { useTheme } from "../hooks/useTheme" ;
1614import { buildPatchCacheKey } from "../lib/diffRendering" ;
@@ -220,7 +218,7 @@ function DiffFileSection(props: {
220218 type = "button"
221219 className = "min-w-0 flex-1 truncate text-left font-mono text-[11px] text-foreground/90 underline-offset-2 hover:underline"
222220 onClick = { ( ) => onOpenInEditor ( filePath ) }
223- title = { `Open ${ filePath } in editor ` }
221+ title = { `Open ${ filePath } ` }
224222 >
225223 { filePath }
226224 </ button >
@@ -476,16 +474,13 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
476474 target ?. scrollIntoView ( { block : "nearest" } ) ;
477475 } , [ selectedFilePath , renderableFiles ] ) ;
478476
479- const openDiffFileInEditor = useCallback (
477+ const openFileInCodeViewer = useCodeViewerStore ( ( state ) => state . openFile ) ;
478+ const openDiffFileInCodeViewer = useCallback (
480479 ( filePath : string ) => {
481- const api = readNativeApi ( ) ;
482- if ( ! api ) return ;
483- const targetPath = activeCwd ? resolvePathLinkTarget ( filePath , activeCwd ) : filePath ;
484- void openInPreferredEditor ( api , targetPath ) . catch ( ( error ) => {
485- console . warn ( "Failed to open diff file in editor." , error ) ;
486- } ) ;
480+ if ( ! activeCwd ) return ;
481+ openFileInCodeViewer ( activeCwd , filePath ) ;
487482 } ,
488- [ activeCwd ] ,
483+ [ activeCwd , openFileInCodeViewer ] ,
489484 ) ;
490485 const updateActiveReviewState = useCallback (
491486 ( updater : ( current : DiffFileReviewStateByPath ) => DiffFileReviewStateByPath ) => {
@@ -687,7 +682,7 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
687682 fileDiff = { fileDiff }
688683 fileKey = { themedFileKey }
689684 filePath = { filePath }
690- onOpenInEditor = { openDiffFileInEditor }
685+ onOpenInEditor = { openDiffFileInCodeViewer }
691686 onToggleAccepted = { onToggleFileAccepted }
692687 onToggleCollapsed = { onToggleFileCollapsed }
693688 resolvedTheme = { resolvedTheme }
0 commit comments