@@ -10,6 +10,7 @@ import { toolDisplayStyles } from '@/lib/typography';
1010import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter' ;
1111import { useDirectoryStore } from '@/stores/useDirectoryStore' ;
1212import { useSessionStore } from '@/stores/useSessionStore' ;
13+ import { useUIStore } from '@/stores/useUIStore' ;
1314import { ScrollableOverlay } from '@/components/ui/ScrollableOverlay' ;
1415import type { ContentChangeReason } from '@/hooks/useChatScrollManager' ;
1516
@@ -1221,6 +1222,7 @@ const ToolExpandedContent: React.FC<ToolExpandedContentProps> = ({
12211222const ToolPart : React . FC < ToolPartProps > = ( { part, isExpanded, onToggle, syntaxTheme, isMobile, onContentChange, hasPrevTool = false , hasNextTool = false , isVSCode = false } ) => {
12221223 const state = part . state ;
12231224 const currentDirectory = useDirectoryStore ( ( s ) => s . currentDirectory ) ;
1225+ const autoOpenDiff = useUIStore ( ( s ) => s . autoOpenDiff ) ;
12241226
12251227 const isTaskTool = part . tool . toLowerCase ( ) === 'task' ;
12261228
@@ -1390,6 +1392,7 @@ const ToolPart: React.FC<ToolPartProps> = ({ part, isExpanded, onToggle, syntaxT
13901392 const isNowCompleted = state . status === 'completed' ;
13911393 previousStatusRef . current = state . status ;
13921394
1395+ if ( ! autoOpenDiff ) return ;
13931396 if ( ! isVSCode || ! wasNotCompleted || ! isNowCompleted ) return ;
13941397 if ( ! isEditTool || ! diffContent ) return ;
13951398 if ( ! runtime ?. editor ?. openAIDiff ) return ;
@@ -1406,7 +1409,7 @@ const ToolPart: React.FC<ToolPartProps> = ({ part, isExpanded, onToggle, syntaxT
14061409 diff : diffContent ,
14071410 label : `AI Edit: ${ filePath . split ( '/' ) . pop ( ) || filePath } ` ,
14081411 } ) ;
1409- } , [ state . status , isVSCode , isEditTool , diffContent , runtime , input , metadata , currentDirectory ] ) ;
1412+ } , [ state . status , isVSCode , isEditTool , diffContent , runtime , input , metadata , currentDirectory , autoOpenDiff ] ) ;
14101413
14111414 if ( ! isFinalized && ! isTaskTool ) {
14121415 return null ;
0 commit comments