@@ -36,13 +36,12 @@ interface GitDiffFile {
3636}
3737
3838export function PatchView ( ) {
39- const { aiConfig } = useAppStore ( ) ;
39+ const { aiConfig, projectRoot : globalProjectRoot , setProjectRoot } = useAppStore ( ) ;
4040 const { t } = useTranslation ( ) ;
4141 const [ isExportDialogOpen , setIsExportDialogOpen ] = useState ( false ) ;
4242 const [ isSidebarOpen , setIsSidebarOpen ] = useState ( true ) ;
4343 const [ mode , setMode ] = useState < PatchMode > ( 'diff' ) ;
4444
45- const [ patchProjectRoot , setPatchProjectRoot ] = useState < string | null > ( null ) ;
4645 const [ yamlInput , setYamlInput ] = useState ( '' ) ;
4746
4847 const [ files , setFiles ] = useState < PatchFileItem [ ] > ( [ ] ) ;
@@ -62,7 +61,6 @@ export function PatchView() {
6261 file : null
6362 } ) ;
6463
65- const [ gitProjectRoot , setGitProjectRoot ] = useState < string | null > ( null ) ;
6664 const [ commits , setCommits ] = useState < GitCommit [ ] > ( [ ] ) ;
6765 const [ baseHash , setBaseHash ] = useState < string > ( '' ) ;
6866 const [ compareHash , setCompareHash ] = useState < string > ( '' ) ;
@@ -81,7 +79,7 @@ export function PatchView() {
8179 if ( ! files . some ( f => f . id === MANUAL_DIFF_ID ) ) {
8280 const manualItem : PatchFileItem = { id : MANUAL_DIFF_ID , path : 'Manual Comparison' , original : '' , modified : '' , status : 'success' , isManual : true } ;
8381 setFiles ( prev => [ manualItem , ...prev ] ) ;
84- if ( ! selectedFileId && ! gitProjectRoot ) {
82+ if ( ! selectedFileId && ! globalProjectRoot ) {
8583 setSelectedFileId ( MANUAL_DIFF_ID ) ;
8684 }
8785 }
@@ -98,7 +96,8 @@ export function PatchView() {
9896 try {
9997 const selected = await openDialog ( { directory : true , multiple : false } ) ;
10098 if ( typeof selected === 'string' ) {
101- setPatchProjectRoot ( selected ) ;
99+ // Update global project root - shared across all features
100+ setProjectRoot ( selected ) ;
102101 showNotification ( t ( 'patch.projectLoaded' ) ) ;
103102 }
104103 } catch ( e ) {
@@ -121,15 +120,15 @@ export function PatchView() {
121120 } ;
122121
123122 useEffect ( ( ) => {
124- if ( mode !== 'patch' || ! patchProjectRoot || ! yamlInput . trim ( ) ) {
123+ if ( mode !== 'patch' || ! globalProjectRoot || ! yamlInput . trim ( ) ) {
125124 if ( mode === 'patch' ) setFiles ( [ ] ) ;
126125 return ;
127126 }
128127
129128 const timer = setTimeout ( async ( ) => {
130129 const filePatches = parseMultiFilePatch ( yamlInput ) ;
131130 const newFiles : PatchFileItem [ ] = await Promise . all ( filePatches . map ( async ( fp ) => {
132- const fullPath = `${ patchProjectRoot } /${ fp . filePath } ` ;
131+ const fullPath = `${ globalProjectRoot } /${ fp . filePath } ` ;
133132 try {
134133 const original = await readTextFile ( fullPath ) ;
135134 const result = applyPatches ( original , fp . operations ) ;
@@ -165,7 +164,7 @@ export function PatchView() {
165164 } , 300 ) ;
166165
167166 return ( ) => clearTimeout ( timer ) ;
168- } , [ mode , patchProjectRoot , yamlInput , t ] ) ;
167+ } , [ mode , globalProjectRoot , yamlInput , t ] ) ;
169168
170169 const handleAiFix = async ( file : PatchFileItem ) => {
171170 if ( isFixing || ! file . original ) return ;
@@ -219,7 +218,8 @@ export function PatchView() {
219218 try {
220219 const selected = await openDialog ( { directory : true , multiple : false } ) ;
221220 if ( typeof selected === 'string' ) {
222- setGitProjectRoot ( selected ) ;
221+ // Update global project root - shared across all features
222+ setProjectRoot ( selected ) ;
223223 setIsGitLoading ( true ) ;
224224 try {
225225 const result = await invoke < GitCommit [ ] > ( `${ GIT_PLUGIN_PREFIX } get_git_commits` , { projectPath : selected } ) ;
@@ -241,13 +241,13 @@ export function PatchView() {
241241 } ;
242242
243243 const handleGenerateDiff = async ( ) => {
244- if ( ! gitProjectRoot || ! baseHash || ! compareHash ) return ;
244+ if ( ! globalProjectRoot || ! baseHash || ! compareHash ) return ;
245245 setIsGitLoading ( true ) ;
246- setFiles ( prev => prev . filter ( p => p . isManual ) ) ;
246+ setFiles ( prev => prev . filter ( p => p . isManual ) ) ;
247247 setSelectedFileId ( null ) ;
248248 try {
249249 const result = await invoke < GitDiffFile [ ] > ( `${ GIT_PLUGIN_PREFIX } get_git_diff` , {
250- projectPath : gitProjectRoot ,
250+ projectPath : globalProjectRoot ,
251251 oldHash : baseHash ,
252252 newHash : compareHash ,
253253 } ) ;
@@ -298,7 +298,7 @@ export function PatchView() {
298298 } ;
299299
300300 const handleExportTrigger = ( ) => {
301- if ( ! gitProjectRoot || ! baseHash || ! compareHash ) return ;
301+ if ( ! globalProjectRoot || ! baseHash || ! compareHash ) return ;
302302 if ( selectedExportIds . size === 0 ) {
303303 showNotification ( t ( 'patch.selectOne' ) , "warning" ) ;
304304 return ;
@@ -307,9 +307,9 @@ export function PatchView() {
307307 } ;
308308
309309 const performExport = async ( format : ExportFormat , layout : ExportLayout ) => {
310- setIsExportDialogOpen ( false ) ;
310+ setIsExportDialogOpen ( false ) ;
311311 setIsExporting ( true ) ;
312-
312+
313313 try {
314314 const extMap : Record < ExportFormat , string > = {
315315 'Markdown' : 'md' ,
@@ -328,7 +328,7 @@ export function PatchView() {
328328 const selectedList = Array . from ( selectedExportIds ) ;
329329
330330 await invoke ( `${ GIT_PLUGIN_PREFIX } export_git_diff` , {
331- projectPath : gitProjectRoot ,
331+ projectPath : globalProjectRoot ,
332332 oldHash : baseHash ,
333333 newHash : compareHash ,
334334 format : format ,
@@ -351,12 +351,12 @@ export function PatchView() {
351351 < div className = "h-full flex overflow-hidden bg-background relative" >
352352 < div className = { cn ( "shrink-0 transition-all duration-300 ease-in-out overflow-hidden border-r border-border" , isSidebarOpen ? "w-[350px] opacity-100" : "w-0 opacity-0 border-none" ) } >
353353 < div className = "w-[350px] h-full" >
354- < PatchSidebar
354+ < PatchSidebar
355355 mode = { mode } setMode = { setMode }
356- projectRoot = { patchProjectRoot } onLoadProject = { handleLoadPatchProject }
356+ projectRoot = { globalProjectRoot } onLoadProject = { handleLoadPatchProject }
357357 yamlInput = { yamlInput } onYamlChange = { setYamlInput } onClearYaml = { handleClear }
358358 files = { files } selectedFileId = { selectedFileId } onSelectFile = { setSelectedFileId }
359- gitProjectRoot = { gitProjectRoot } onBrowseGitProject = { handleBrowseGitProject }
359+ gitProjectRoot = { globalProjectRoot } onBrowseGitProject = { handleBrowseGitProject }
360360 commits = { commits } baseHash = { baseHash } setBaseHash = { setBaseHash }
361361 compareHash = { compareHash } setCompareHash = { setCompareHash }
362362 onCompare = { handleGenerateDiff } isGitLoading = { isGitLoading }
@@ -376,15 +376,15 @@ export function PatchView() {
376376 </ div >
377377 ) }
378378
379- < DiffWorkspace
379+ < DiffWorkspace
380380 selectedFile = { currentFile || null }
381381 onSave = { handleSaveClick }
382382 onCopy = { async ( txt ) => { await writeClipboard ( txt ) ; showNotification ( t ( 'patch.copied' ) ) ; } }
383383 onManualUpdate = { handleManualUpdate }
384384 isSidebarOpen = { isSidebarOpen }
385385 onToggleSidebar = { ( ) => setIsSidebarOpen ( ! isSidebarOpen ) }
386386 isReadOnly = { currentFile ?. isManual !== true }
387- onExport = { mode === 'diff' && gitProjectRoot ? handleExportTrigger : undefined }
387+ onExport = { mode === 'diff' && globalProjectRoot ? handleExportTrigger : undefined }
388388 />
389389 </ div >
390390 < ExportDialog
0 commit comments