@@ -4,10 +4,15 @@ import { useLayoutStore } from "@/stores/layoutStore";
44import { useFolderStore } from "@/stores/FolderStore" ;
55import { FileTree } from "@/components/filetree/FileTreeView" ;
66import { FileViewer } from "@/components/filetree/FileViewer" ;
7+ import { GitStatusView } from "@/components/filetree/GitStatusView" ;
8+ import { DiffViewer } from "@/components/filetree/DiffViewer" ;
79import { useState } from "react" ;
810import { ConfigDialog } from "@/components/dialogs/ConfigDialog" ;
911import { AppToolbar } from "@/components/layout/AppToolbar" ;
1012import { useConversationStore } from "@/stores/ConversationStore" ;
13+ import { Tabs , TabsList , TabsTrigger , TabsContent } from "@/components/ui/tabs" ;
14+ import { invoke } from "@tauri-apps/api/core" ;
15+ import { GitBranch } from "lucide-react" ;
1116
1217export default function ChatPage ( ) {
1318
@@ -28,29 +33,99 @@ export default function ChatPage() {
2833
2934 const { currentFolder } = useFolderStore ( ) ;
3035 const [ isConfigOpen , setIsConfigOpen ] = useState ( false ) ;
36+ const [ diffFile , setDiffFile ] = useState < { original : string ; current : string ; fileName : string } | null > ( null ) ;
37+
38+ const handleDiffClick = async ( filePath : string ) => {
39+ try {
40+ console . log ( 'handleDiffClick called with:' , filePath ) ;
41+ console . log ( 'currentFolder:' , currentFolder ) ;
42+
43+ // Try with currentFolder first, then fallback to direct path
44+ const fullPath = currentFolder ? `${ currentFolder } /${ filePath } ` : filePath ;
45+ console . log ( 'Trying full path:' , fullPath ) ;
46+
47+ const result = await invoke < { original_content : string ; current_content : string ; has_changes : boolean } > ( "get_git_file_diff" , {
48+ filePath : fullPath
49+ } ) ;
50+
51+ if ( result . has_changes ) {
52+ // Clear selected file to avoid conflicts
53+ closeFile ( ) ;
54+ // Set diff file and ensure panel is visible
55+ setDiffFile ( {
56+ original : result . original_content ,
57+ current : result . current_content ,
58+ fileName : filePath
59+ } ) ;
60+ }
61+ } catch ( error ) {
62+ console . error ( "Failed to get diff:" , error ) ;
63+ console . error ( "Tried path:" , currentFolder ? `${ currentFolder } /${ filePath } ` : filePath ) ;
64+ }
65+ } ;
3166
3267 // No auto-initialization - let user start conversations manually
3368
3469 return (
3570 < div className = "h-full flex overflow-hidden" >
36- { /* Left Panel - File Tree */ }
71+ { /* Left Panel - File Tree and Git Status */ }
3772 { showFileTree && (
3873 < div className = "w-64 border-r h-full flex-shrink-0" >
39- < FileTree
40- currentFolder = { currentFolder || undefined }
41- onFileClick = { openFile }
42- />
74+ < Tabs defaultValue = "files" className = "h-full flex flex-col" >
75+ < TabsList className = "grid w-full grid-cols-2" >
76+ < TabsTrigger value = "files" > Files</ TabsTrigger >
77+ < TabsTrigger value = "git" >
78+ < GitBranch size = { 14 } className = "mr-1.5" />
79+ Git
80+ </ TabsTrigger >
81+ </ TabsList >
82+ < TabsContent value = "files" className = "flex-1 overflow-hidden mt-0" >
83+ < FileTree
84+ currentFolder = { currentFolder || undefined }
85+ onFileClick = { ( path ) => {
86+ console . log ( 'ChatPage: opening file from FileTree' , path ) ;
87+ setDiffFile ( null ) ; // Clear any existing diff view
88+ openFile ( path ) ;
89+ } }
90+ />
91+ </ TabsContent >
92+ < TabsContent value = "git" className = "flex-1 overflow-hidden mt-0" >
93+ < GitStatusView
94+ currentFolder = { currentFolder || undefined }
95+ onDiffClick = { handleDiffClick }
96+ />
97+ </ TabsContent >
98+ </ Tabs >
4399 </ div >
44100 ) }
45101
46102 { /* Main Content Area */ }
47103 < div className = "flex-1 min-h-0 h-full flex min-w-0 overflow-hidden" >
48- { /* Middle Panel - FileViewer */ }
49- { showFilePanel && selectedFile && (
104+ { /* Middle Panel - FileViewer or DiffViewer */ }
105+ { ( showFilePanel && selectedFile ) || diffFile ? (
50106 < div className = "flex-1 min-w-0 border-r overflow-hidden" >
51- < FileViewer filePath = { selectedFile } onClose = { closeFile } />
107+ { diffFile ? (
108+ < div className = "h-full flex flex-col" >
109+ < div className = "p-2 border-b bg-gray-50 flex items-center justify-between" >
110+ < span className = "text-sm font-medium" > Diff: { diffFile . fileName } </ span >
111+ < button
112+ onClick = { ( ) => setDiffFile ( null ) }
113+ className = "text-gray-500 hover:text-gray-700"
114+ >
115+ ×
116+ </ button >
117+ </ div >
118+ < DiffViewer
119+ original = { diffFile . original }
120+ current = { diffFile . current }
121+ fileName = { diffFile . fileName }
122+ />
123+ </ div >
124+ ) : selectedFile ? (
125+ < FileViewer filePath = { selectedFile } onClose = { closeFile } />
126+ ) : null }
52127 </ div >
53- ) }
128+ ) : null }
54129
55130 { /* Right Panel - Chat/Notes */ }
56131 < div className = "flex flex-col flex-1 min-w-0 overflow-hidden" >
0 commit comments