diff --git a/apps/tui/src/main/kotlin/com/correx/apps/tui/reducer/RootReducer.kt b/apps/tui/src/main/kotlin/com/correx/apps/tui/reducer/RootReducer.kt index 725ec8c8..70f124fa 100644 --- a/apps/tui/src/main/kotlin/com/correx/apps/tui/reducer/RootReducer.kt +++ b/apps/tui/src/main/kotlin/com/correx/apps/tui/reducer/RootReducer.kt @@ -194,6 +194,9 @@ object RootReducer { // Diff scrolling in APPROVAL mode when expanded. is Action.NavigateUp -> { if (withBgReset.displayState == DisplayState.APPROVAL && withBgReset.diffExpanded) { + // TODO(diff-scroll): cap scrollOffset at totalLines - PREVIEW_MAX_LINES to prevent + // scrolling past the end of the diff. Needs total line count in state or a clamp + // communicated from ApprovalSurface. withBgReset.copy(diffScrollOffset = maxOf(0, withBgReset.diffScrollOffset - 1)) } else if (withBgReset.displayState == DisplayState.IN_SESSION && prevInputMode == InputMode.ROUTER) { val selectedId = withBgReset.sessions.selectedId @@ -235,6 +238,8 @@ object RootReducer { // Diff scrolling in APPROVAL mode when expanded. is Action.NavigateDown -> { if (withBgReset.displayState == DisplayState.APPROVAL && withBgReset.diffExpanded) { + // TODO(diff-scroll): cap scrollOffset at totalLines - PREVIEW_MAX_LINES; same issue + // as NavigateUp above — the reducer doesn't know the diff length. withBgReset.copy(diffScrollOffset = withBgReset.diffScrollOffset + 1) } else if (withBgReset.displayState == DisplayState.IN_SESSION && prevInputMode == InputMode.ROUTER) { val selectedId = withBgReset.sessions.selectedId