From 78f2e9b174b3ddfd61a249ca856cb2efc02b0033 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Fri, 16 Oct 2026 05:33:31 -0700 Subject: [PATCH] test(terminal): load the host runtime in setup so the alt-screen chain fits its test limit (#29661) --- ...ote-snapshot-alt-screen-host-chain.test.ts | 64 ++++++++++++++----- 1 file changed, 49 insertions(+), 15 deletions(-) diff --git a/src/renderer/src/components/terminal-pane/remote-snapshot-alt-screen-host-chain.test.ts b/src/renderer/src/components/terminal-pane/remote-snapshot-alt-screen-host-chain.test.ts index b0b35e0e000..e3b84fadecd 100644 --- a/src/renderer/src/components/terminal-pane/remote-snapshot-alt-screen-host-chain.test.ts +++ b/src/renderer/src/components/terminal-pane/remote-snapshot-alt-screen-host-chain.test.ts @@ -1,5 +1,5 @@ import type * as React from 'react' -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest' import { Terminal } from '@xterm/headless' import { TerminalStreamOpcode, @@ -159,24 +159,54 @@ async function render(events: PaneEvent[]): Promise { return term } +type HostModules = { + OrcaRuntimeService: new (store: null) => HostRuntime + sendSnapshotFrames: (send: HostSendFrame, options: Record) => unknown + serializeBudgetedRequestedSnapshot: ( + runtime: HostRuntime, + ptyId: string, + scrollbackRows: number + ) => Promise + installMultiplexFlowControl: (build: HostConnection) => void +} + +let hostModules: HostModules | null = null + +// Why a hook: the first load of the main runtime graph takes ~19s cold, and charged to the first +// test it crossed the 30s test limit whenever the directory ran in parallel. +async function loadHostModules(): Promise { + const [runtime, publication, flowControl] = await Promise.all([ + vi.importActual>( + '../../../../main/runtime/orca-runtime' + ), + vi.importActual>( + '../../../../main/runtime/rpc/methods/terminal/terminal-snapshot-publication' + ), + vi.importActual>( + '../../../../main/runtime/rpc/methods/terminal/terminal-multiplex-flow-control' + ) + ]) + return { + OrcaRuntimeService: runtime.OrcaRuntimeService, + sendSnapshotFrames: publication.sendSnapshotFrames, + serializeBudgetedRequestedSnapshot: publication.serializeBudgetedRequestedSnapshot, + installMultiplexFlowControl: flowControl.installMultiplexFlowControl + } +} + /** Real host + client chain: returns what the remote transport hands the pane for the push. */ async function publishHostRecovery( missed: string ): Promise<{ data: string; meta: PtyReplayDataMeta; published: HostSnapshot }> { - const { OrcaRuntimeService } = await vi.importActual<{ - OrcaRuntimeService: new (store: null) => HostRuntime - }>('../../../../main/runtime/orca-runtime') - const { sendSnapshotFrames, serializeBudgetedRequestedSnapshot } = await vi.importActual<{ - sendSnapshotFrames: (send: HostSendFrame, options: Record) => unknown - serializeBudgetedRequestedSnapshot: ( - runtime: HostRuntime, - ptyId: string, - scrollbackRows: number - ) => Promise - }>('../../../../main/runtime/rpc/methods/terminal/terminal-snapshot-publication') - const { installMultiplexFlowControl } = await vi.importActual<{ - installMultiplexFlowControl: (build: HostConnection) => void - }>('../../../../main/runtime/rpc/methods/terminal/terminal-multiplex-flow-control') + if (!hostModules) { + throw new Error('host modules are loaded in beforeAll') + } + const { + OrcaRuntimeService, + sendSnapshotFrames, + serializeBudgetedRequestedSnapshot, + installMultiplexFlowControl + } = hostModules const host = new OrcaRuntimeService(null) host.setPtyController({ @@ -301,6 +331,10 @@ async function publishHostRecovery( } describe('host-published recovery snapshot onto a live alt screen', () => { + beforeAll(async () => { + hostModules = await loadHostModules() + }) + beforeEach(async () => { vi.clearAllMocks() transportFactoryQueue = []