mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-11 03:31:55 +00:00
fix(tui): refresh virtual offsets after row resize (#20898)
This commit is contained in:
parent
5044e1cbf1
commit
da6019820a
2 changed files with 48 additions and 3 deletions
|
|
@ -130,6 +130,9 @@ export function useVirtualHistory(
|
|||
})
|
||||
|
||||
const [hasScrollRef, setHasScrollRef] = useState(false)
|
||||
// Height cache writes happen in layout effects; bump once so offsets and
|
||||
// clamp bounds rebuild without waiting for the next scroll/input event.
|
||||
const [measuredHeightVersion, bumpMeasuredHeightVersion] = useState(0)
|
||||
const metrics = useRef({ sticky: true, top: 0, vp: 0 })
|
||||
const lastScrollTopRef = useRef(0)
|
||||
|
||||
|
|
@ -434,6 +437,7 @@ export function useVirtualHistory(
|
|||
useLayoutEffect(() => {
|
||||
const s = scrollRef.current
|
||||
let dirty = false
|
||||
let heightDirty = false
|
||||
|
||||
// Give the renderer the mounted-row coverage for passive scroll clamping.
|
||||
// Clamp MUST use the EFFECTIVE (deferred) range, not the immediate one.
|
||||
|
|
@ -474,6 +478,7 @@ export function useVirtualHistory(
|
|||
if (h > 0 && heights.current.get(k) !== h) {
|
||||
heights.current.set(k, h)
|
||||
dirty = true
|
||||
heightDirty = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -499,7 +504,11 @@ export function useVirtualHistory(
|
|||
offsetVersion.current++
|
||||
onHeightsChangeRef.current?.(heights.current)
|
||||
}
|
||||
})
|
||||
|
||||
if (heightDirty) {
|
||||
bumpMeasuredHeightVersion(n => n + 1)
|
||||
}
|
||||
}, [effEnd, effStart, items, liveTailActive, measuredHeightVersion, n, offsets, scrollRef, sticky, total, vp])
|
||||
|
||||
return {
|
||||
bottomSpacer: Math.max(0, total - (offsets[effEnd] ?? total)),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue