@@ -143,23 +143,23 @@ const App: React.FC = () => {
143143 search . startSearch ( pattern ) ;
144144 } ;
145145
146- const resolveEditorPaneId = useCallback ( ( ) => {
146+ const resolveEditorPaneId = useEvent ( ( ) => {
147147 return layoutActionsRef . current ?. ensureEditorPanel ( editors . activeEditorPaneId ) ;
148- } , [ editors ] ) ;
148+ } ) ;
149149
150- const handleOpenFile = useCallback ( (
150+ const handleOpenFile = useEvent ( (
151151 path : string , line ?: number , column ?: number , mode ?: DiffMode ,
152152 ) => {
153153 const paneId = resolveEditorPaneId ( ) ;
154154 if ( ! paneId ) return ;
155155 editors . openFile ( path , line , column , paneId , mode ) ;
156- } , [ editors , resolveEditorPaneId ] ) ;
156+ } ) ;
157157
158- const handleSelectFile = useCallback ( ( fileId : string ) => {
158+ const handleSelectFile = useEvent ( ( fileId : string ) => {
159159 const paneId = resolveEditorPaneId ( ) ;
160160 if ( ! paneId ) return ;
161161 editors . setActiveFileId ( fileId , paneId ) ;
162- } , [ editors , resolveEditorPaneId ] ) ;
162+ } ) ;
163163
164164 const handleSearchResultClick = ( filePath : string , match : SearchMatch ) => {
165165 handleOpenFile ( filePath , match . line , match . column ) ;
@@ -186,7 +186,10 @@ const App: React.FC = () => {
186186 } , [ editors ] ) ;
187187
188188 const handleCycleEditorDiffMode = useCallback ( ( panelKey : string ) => {
189- editors . cycleEditorDiffMode ( panelKey ) ;
189+ const changed = editors . cycleEditorDiffMode ( panelKey ) ;
190+ if ( changed ) {
191+ editors . focusEditorInPane ( panelKey ) ;
192+ }
190193 } , [ editors ] ) ;
191194
192195 const sessionsArray = useMemo ( ( ) => Array . from ( agents . acpSessions . values ( ) ) , [ agents . acpSessions ] ) ;
@@ -415,7 +418,7 @@ const App: React.FC = () => {
415418 }
416419 } ;
417420
418- const handlePanelAdded = useCallback ( ( panelId : PanelId , panelKey : string ) => {
421+ const handlePanelAdded = useEvent ( ( panelId : PanelId , panelKey : string ) => {
419422 layout . handlePanelAdded ( panelId , panelKey ) ;
420423
421424 if ( panelId === 'changes' ) {
@@ -435,9 +438,9 @@ const App: React.FC = () => {
435438 if ( panelId === 'terminal' ) {
436439 terminalPanes . registerPane ( panelKey ) ;
437440 }
438- } , [ agentPanes , editors , git . fetchGitStatus , git . fetchBranches , layout , terminalPanes ] ) ;
441+ } ) ;
439442
440- const handlePanelRemoved = useCallback ( ( panelId : PanelId , panelKey : string ) => {
443+ const handlePanelRemoved = useEvent ( ( panelId : PanelId , panelKey : string ) => {
441444 layout . handlePanelRemoved ( panelId , panelKey ) ;
442445
443446 if ( panelId === 'editor' ) {
@@ -451,9 +454,9 @@ const App: React.FC = () => {
451454 if ( panelId === 'terminal' ) {
452455 terminalPanes . unregisterPane ( panelKey ) ;
453456 }
454- } , [ agentPanes , editors , layout , terminalPanes ] ) ;
457+ } ) ;
455458
456- const handlePanelActivated = useCallback ( ( panelId : PanelId , panelKey : string ) => {
459+ const handlePanelActivated = useEvent ( ( panelId : PanelId , panelKey : string ) => {
457460 layout . handlePanelActivated ( panelId , panelKey ) ;
458461
459462 if ( panelId === 'editor' ) {
@@ -478,7 +481,7 @@ const App: React.FC = () => {
478481 if ( panelId === 'terminal' ) {
479482 terminalPanes . setActivePaneId ( panelKey ) ;
480483 }
481- } , [ agentPanes , editors , layout , terminalPanes ] ) ;
484+ } ) ;
482485
483486 return (
484487 < div className = "app-container toolbar-header-compact" >
0 commit comments