mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-07 02:51:50 +00:00
perf(tui): lazily seed virtual history heights (#16523)
This commit is contained in:
parent
9b55365f6f
commit
98d75dea5a
3 changed files with 75 additions and 22 deletions
|
|
@ -218,23 +218,15 @@ export function useMainApp(gw: GatewayClient) {
|
|||
return cache
|
||||
}, [heightCacheKey])
|
||||
|
||||
const initialHeights = useMemo(() => {
|
||||
const out = new Map<string, number>()
|
||||
|
||||
for (const row of virtualRows) {
|
||||
out.set(
|
||||
row.key,
|
||||
heightCache.get(row.key) ??
|
||||
estimatedMsgHeight(row.msg, cols, {
|
||||
compact: ui.compact,
|
||||
details: detailsVisible,
|
||||
limitHistory: row.index < virtualRows.length - FULL_RENDER_TAIL_ITEMS
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
return out
|
||||
}, [cols, detailsVisible, heightCache, ui.compact, virtualRows])
|
||||
const estimateRowHeight = useCallback(
|
||||
(index: number) =>
|
||||
estimatedMsgHeight(virtualRows[index]!.msg, cols, {
|
||||
compact: ui.compact,
|
||||
details: detailsVisible,
|
||||
limitHistory: index < virtualRows.length - FULL_RENDER_TAIL_ITEMS
|
||||
}),
|
||||
[cols, detailsVisible, ui.compact, virtualRows]
|
||||
)
|
||||
|
||||
const syncHeightCache = useCallback(
|
||||
(heights: ReadonlyMap<string, number>) => {
|
||||
|
|
@ -250,7 +242,8 @@ export function useMainApp(gw: GatewayClient) {
|
|||
)
|
||||
|
||||
const virtualHistory = useVirtualHistory(scrollRef, virtualRows, cols, {
|
||||
initialHeights,
|
||||
estimateHeight: estimateRowHeight,
|
||||
initialHeights: heightCache,
|
||||
liveTailActive: turnLiveTailActive,
|
||||
onHeightsChange: syncHeightCache
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue