Skip to content

Commit b848b7e

Browse files
authored
fix(app): session timeline jumping on scroll (anomalyco#18993)
1 parent e837dcc commit b848b7e

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

packages/app/src/pages/session.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,19 @@ function createSessionHistoryWindow(input: SessionHistoryWindowInput) {
246246

247247
if (added <= 0) return
248248
if (growth <= 0) return
249+
250+
if (opts?.prefetch) {
251+
const current = turnStart()
252+
preserveScroll(() => setTurnStart(current + growth))
253+
return
254+
}
255+
249256
if (turnStart() !== start) return
250257

251-
const reveal = !opts?.prefetch
252258
const currentRendered = renderedUserMessages().length
253259
const base = Math.max(beforeRendered, currentRendered)
254-
const target = reveal ? Math.min(afterVisible, base + turnBatch) : base
255-
const nextStart = Math.max(0, afterVisible - target)
256-
preserveScroll(() => setTurnStart(nextStart))
260+
const target = Math.min(afterVisible, base + turnBatch)
261+
preserveScroll(() => setTurnStart(Math.max(0, afterVisible - target)))
257262
}
258263

259264
const onScrollerScroll = () => {

0 commit comments

Comments
 (0)