fix(terminal): retain pending DPR recovery

This commit is contained in:
Neil
2026-08-23 14:16:18 -07:00
parent 41f6f88fe0
commit 46f608b64b
2 changed files with 23 additions and 1 deletions
@@ -229,4 +229,26 @@ describe('useTerminalWindowWakeRecovery', () => {
window.dispatchEvent(new Event('resize'))
expect(repairPaneWebglCanvasDprMismatchMock).toHaveBeenCalledTimes(1)
})
it('retains a dpr transition until the visible manager is available', () => {
const pane = { id: 1, terminal: {} }
const managerRef: { current: PaneManager | null } = { current: null }
vi.stubGlobal('devicePixelRatio', 1)
renderHook(() =>
useTerminalWindowWakeRecovery({
isVisible: true,
managerRef,
isActiveRef: { current: true },
isVisibleRef: { current: true }
})
)
vi.stubGlobal('devicePixelRatio', 2)
window.dispatchEvent(new Event('resize'))
expect(repairPaneWebglCanvasDprMismatchMock).not.toHaveBeenCalled()
managerRef.current = { getPanes: () => [pane] } as unknown as PaneManager
window.dispatchEvent(new Event('resize'))
expect(repairPaneWebglCanvasDprMismatchMock).toHaveBeenCalledWith(pane)
})
})
@@ -122,11 +122,11 @@ export function useTerminalWindowWakeRecovery({
if (devicePixelRatio === observedDevicePixelRatio) {
return
}
observedDevicePixelRatio = devicePixelRatio
const manager = managerRef.current
if (!manager || !isVisibleRef.current) {
return
}
observedDevicePixelRatio = devicePixelRatio
for (const pane of manager.getPanes?.() ?? []) {
if (repairPaneWebglCanvasDprMismatch(pane)) {
presentPaneViewport(pane)