@@ -165,15 +165,11 @@ export function SessionReviewV2(props: SessionReviewV2Props) {
165165 }
166166
167167 const prev = ( ) => {
168- const files = props . files
169- if ( files . length === 0 ) return
170- return files [ ( fileIndex ( ) - 1 + files . length ) % files . length ]
168+ return props . files [ fileIndex ( ) - 1 ]
171169 }
172170
173171 const next = ( ) => {
174- const files = props . files
175- if ( files . length === 0 ) return
176- return files [ ( fileIndex ( ) + 1 ) % files . length ]
172+ return props . files [ fileIndex ( ) + 1 ]
177173 }
178174
179175 const canCycle = ( ) => props . files . length > 0
@@ -195,8 +191,10 @@ export function SessionReviewV2(props: SessionReviewV2Props) {
195191 const target = event . target
196192 if ( target instanceof HTMLElement && ( target . isContentEditable || target . closest ( "input, textarea, select" ) ) ) return
197193 if ( ! props . hasDiffs || ! canCycle ( ) ) return
194+ const file = event . key === "<" ? prev ( ) : next ( )
195+ if ( ! file ) return
198196 event . preventDefault ( )
199- cycle ( event . key === "<" ? prev ( ) : next ( ) )
197+ cycle ( file )
200198 } )
201199
202200 const toolbarStart = ( ) => (
@@ -217,6 +215,7 @@ export function SessionReviewV2(props: SessionReviewV2Props) {
217215 < div class = "flex items-center" >
218216 < TooltipV2
219217 openDelay = { 2000 }
218+ inactive = { ! prev ( ) }
220219 value = {
221220 < >
222221 { i18n . t ( "ui.sessionReviewV2.previousFile" ) }
@@ -229,13 +228,14 @@ export function SessionReviewV2(props: SessionReviewV2Props) {
229228 variant = "ghost"
230229 size = "small"
231230 class = "session-review-v2-file-nav-button"
232- disabled = { ! canCycle ( ) }
231+ disabled = { ! prev ( ) }
233232 onClick = { ( ) => cycle ( prev ( ) ) }
234233 aria-label = { i18n . t ( "ui.sessionReviewV2.previousFile" ) }
235234 />
236235 </ TooltipV2 >
237236 < TooltipV2
238237 openDelay = { 2000 }
238+ inactive = { ! next ( ) }
239239 value = {
240240 < >
241241 { i18n . t ( "ui.sessionReviewV2.nextFile" ) }
@@ -248,7 +248,7 @@ export function SessionReviewV2(props: SessionReviewV2Props) {
248248 variant = "ghost"
249249 size = "small"
250250 class = "session-review-v2-file-nav-button"
251- disabled = { ! canCycle ( ) }
251+ disabled = { ! next ( ) }
252252 onClick = { ( ) => cycle ( next ( ) ) }
253253 aria-label = { i18n . t ( "ui.sessionReviewV2.nextFile" ) }
254254 />
0 commit comments