diff --git a/ui-tui/packages/hermes-ink/src/ink/ink.tsx b/ui-tui/packages/hermes-ink/src/ink/ink.tsx index 4e0c54ec9e..036954a770 100644 --- a/ui-tui/packages/hermes-ink/src/ink/ink.tsx +++ b/ui-tui/packages/hermes-ink/src/ink/ink.tsx @@ -467,13 +467,29 @@ export default class Ink { this.resizeSettleTimer = setTimeout(() => { this.resizeSettleTimer = null - if (this.isUnmounted || this.isPaused || !this.altScreenActive || !this.options.stdout.isTTY) { + if ( + this.isUnmounted || + this.isPaused || + !this.altScreenActive || + !this.options.stdout.isTTY || + this.currentNode === null || + this.pendingResizeRender + ) { return } - this.resetFramesForAltScreen() - this.needsEraseBeforePaint = true - this.scheduleRender() + this.pendingResizeRender = true + queueMicrotask(() => { + this.pendingResizeRender = false + + if (this.isUnmounted || this.isPaused || !this.altScreenActive || !this.options.stdout.isTTY || this.currentNode === null) { + return + } + + this.resetFramesForAltScreen() + this.needsEraseBeforePaint = true + this.render(this.currentNode) + }) }, 160) } } @@ -1954,6 +1970,10 @@ export default class Ink { clearTimeout(this.drainTimer) this.drainTimer = null } + if (this.resizeSettleTimer !== null) { + clearTimeout(this.resizeSettleTimer) + this.resizeSettleTimer = null + } reconciler.updateContainerSync(null, this.container, null, noop) reconciler.flushSyncWork()