chore: add TODO for unbounded scrollOffset in diff view
The diffScrollOffset in NavUp/NavDown has no upper bound — it can scroll past the last line. The ApprovalSurface clamps the viewport with coerceIn/minOf, so it doesn't crash, but the offset keeps growing. Marked with TODO(diff-scroll) in both handlers.
This commit is contained in:
@@ -194,6 +194,9 @@ object RootReducer {
|
|||||||
// Diff scrolling in APPROVAL mode when expanded.
|
// Diff scrolling in APPROVAL mode when expanded.
|
||||||
is Action.NavigateUp -> {
|
is Action.NavigateUp -> {
|
||||||
if (withBgReset.displayState == DisplayState.APPROVAL && withBgReset.diffExpanded) {
|
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))
|
withBgReset.copy(diffScrollOffset = maxOf(0, withBgReset.diffScrollOffset - 1))
|
||||||
} else if (withBgReset.displayState == DisplayState.IN_SESSION && prevInputMode == InputMode.ROUTER) {
|
} else if (withBgReset.displayState == DisplayState.IN_SESSION && prevInputMode == InputMode.ROUTER) {
|
||||||
val selectedId = withBgReset.sessions.selectedId
|
val selectedId = withBgReset.sessions.selectedId
|
||||||
@@ -235,6 +238,8 @@ object RootReducer {
|
|||||||
// Diff scrolling in APPROVAL mode when expanded.
|
// Diff scrolling in APPROVAL mode when expanded.
|
||||||
is Action.NavigateDown -> {
|
is Action.NavigateDown -> {
|
||||||
if (withBgReset.displayState == DisplayState.APPROVAL && withBgReset.diffExpanded) {
|
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)
|
withBgReset.copy(diffScrollOffset = withBgReset.diffScrollOffset + 1)
|
||||||
} else if (withBgReset.displayState == DisplayState.IN_SESSION && prevInputMode == InputMode.ROUTER) {
|
} else if (withBgReset.displayState == DisplayState.IN_SESSION && prevInputMode == InputMode.ROUTER) {
|
||||||
val selectedId = withBgReset.sessions.selectedId
|
val selectedId = withBgReset.sessions.selectedId
|
||||||
|
|||||||
Reference in New Issue
Block a user