fix(tui): refresh virtual transcript on viewport resize

Notify scroll subscribers when ScrollBox viewport bounds change and key virtual-history updates on viewport height so resize/keyboard changes remount the tail rows instead of leaving stale spacers visible.
This commit is contained in:
Brooklyn Nicholson
2026-05-23 13:41:46 -05:00
parent 874c2b1fe6
commit 4fea02cc16
3 changed files with 78 additions and 18 deletions
+14 -13
View File
@@ -51,6 +51,18 @@ const SLIDE_STEP = 12
const NOOP = () => {}
export const virtualHistorySnapshotKey = (s?: ScrollBoxHandle | null): string => {
if (!s) {
return 'none'
}
const target = s.getScrollTop() + s.getPendingDelta()
const bin = Math.floor(target / QUANTUM)
const viewportHeight = Math.max(0, s.getViewportHeight())
return `${s.isSticky() ? ~bin : bin}:${viewportHeight}`
}
const upperBound = (arr: ArrayLike<number>, target: number, length = arr.length) => {
let lo = 0
let hi = length
@@ -186,19 +198,8 @@ export function useVirtualHistory(
useSyncExternalStore(
subscribe,
() => {
const s = scrollRef.current
if (!s) {
return NaN
}
const target = s.getScrollTop() + s.getPendingDelta()
const bin = Math.floor(target / QUANTUM)
return s.isSticky() ? ~bin : bin
},
() => NaN
() => virtualHistorySnapshotKey(scrollRef.current),
() => 'none'
)
useEffect(() => {