11import { MouseButton , type KeyEvent , type MouseEvent as TuiMouseEvent , type ScrollBoxRenderable } from "@opentui/core" ;
22import { useKeyboard , useRenderer , useTerminalDimensions } from "@opentui/react" ;
3- import { Suspense , lazy , startTransition , useDeferredValue , useEffect , useLayoutEffect , useRef , useState } from "react" ;
3+ import { Suspense , lazy , startTransition , useDeferredValue , useEffect , useRef , useState } from "react" ;
44import type { AppBootstrap , LayoutMode } from "../core/types" ;
55import { MenuBar } from "./components/chrome/MenuBar" ;
66import { MENU_ORDER , buildMenuSpecs , menuWidth , nextMenuItemIndex , type MenuEntry , type MenuId } from "./components/chrome/menu" ;
@@ -133,29 +133,13 @@ export function App({ bootstrap, onQuit = () => process.exit(0) }: { bootstrap:
133133 setSelectedHunkIndex ( ( current ) => clamp ( current , 0 , maxIndex ) ) ;
134134 } , [ selectedFile ] ) ;
135135
136- useLayoutEffect ( ( ) => {
136+ useEffect ( ( ) => {
137137 if ( ! selectedFile ) {
138138 return ;
139139 }
140140
141- const scrollSelectionIntoView = ( ) => {
142- filesScrollRef . current ?. scrollChildIntoView ( fileRowId ( selectedFile . id ) ) ;
143- if ( selectedFile . metadata . hunks [ selectedHunkIndex ] ) {
144- diffScrollRef . current ?. scrollChildIntoView ( diffHunkId ( selectedFile . id , selectedHunkIndex ) ) ;
145- return ;
146- }
147-
148- diffScrollRef . current ?. scrollChildIntoView ( diffSectionId ( selectedFile . id ) ) ;
149- } ;
150-
151- // Selection changes can race with section windowing, so retry briefly while the new target mounts.
152- scrollSelectionIntoView ( ) ;
153- const retryDelays = [ 0 , 16 , 48 ] ;
154- const timeouts = retryDelays . map ( ( delay ) => setTimeout ( scrollSelectionIntoView , delay ) ) ;
155- return ( ) => {
156- timeouts . forEach ( ( timeout ) => clearTimeout ( timeout ) ) ;
157- } ;
158- } , [ selectedFile , selectedHunkIndex ] ) ;
141+ filesScrollRef . current ?. scrollChildIntoView ( fileRowId ( selectedFile . id ) ) ;
142+ } , [ selectedFile ] ) ;
159143
160144 useEffect ( ( ) => {
161145 // Dismissed notes are hunk-local, so reset them when the review focus moves.
@@ -170,23 +154,13 @@ export function App({ bootstrap, onQuit = () => process.exit(0) }: { bootstrap:
170154 }
171155
172156 filesScrollRef . current ?. scrollChildIntoView ( fileRowId ( nextCursor . fileId ) ) ;
173- diffScrollRef . current ?. scrollChildIntoView ( diffHunkId ( nextCursor . fileId , nextCursor . hunkIndex ) ) ;
174-
175157 setSelectedFileId ( nextCursor . fileId ) ;
176158 setSelectedHunkIndex ( nextCursor . hunkIndex ) ;
177159 } ;
178160
179161 /** Jump the review stream to a file and optionally a specific hunk within it. */
180162 const jumpToFile = ( fileId : string , nextHunkIndex = 0 ) => {
181163 filesScrollRef . current ?. scrollChildIntoView ( fileRowId ( fileId ) ) ;
182- const nextFile =
183- filteredFiles . find ( ( file ) => file . id === fileId ) ?? bootstrap . changeset . files . find ( ( file ) => file . id === fileId ) ;
184- if ( nextFile ?. metadata . hunks [ nextHunkIndex ] ) {
185- diffScrollRef . current ?. scrollChildIntoView ( diffHunkId ( fileId , nextHunkIndex ) ) ;
186- } else {
187- diffScrollRef . current ?. scrollChildIntoView ( diffSectionId ( fileId ) ) ;
188- }
189-
190164 setSelectedFileId ( fileId ) ;
191165 setSelectedHunkIndex ( nextHunkIndex ) ;
192166 } ;
0 commit comments