Files
orca/tests/e2e/pty-input-write-queue-ssh.spec.ts
T
Jinjing c0c893d171 fix(pty): bound cooked reply queue (#13422)
* fix(pty): bound cooked reply queue

* fix(pty): bound cooked reply queue

Implement bounded storage for cooked-echo-safe replies: 64 pending
replies and 4096 UTF-16 code units. Shed oldest replies on overflow,
never ordinary input. Add drain failure containment with generation
fencing to prevent stale operations from clearing fresh input after
clear() reuse.

* fix(pty): report pty id in drain failures

When the async drain yields, the owner may rebind to a different PTY
before the failure surfaces. Pass the failing pty id so the transport can
ignore stale failures from a rebound owner. Also tighten the pending
reply queue size bound to prevent half-written entries.
2026-08-10 12:17:21 -07:00

67 lines
2.4 KiB
TypeScript

import { test } from './helpers/orca-app'
import { connectDockerSshRelayTarget } from './helpers/docker-ssh-relay-connection'
import {
cleanupDockerSshRelayTarget,
startDockerSshRelayTarget,
type DockerSshRelayTarget
} from './helpers/docker-ssh-relay-target'
import {
execInTerminal,
waitForActivePanePtyId,
waitForActiveTerminalManager,
waitForTerminalOutput
} from './helpers/terminal'
import { ensureTerminalVisible, waitForActiveWorktree, waitForSessionReady } from './helpers/store'
const RUN_DOCKER_SSH = process.env.ORCA_E2E_SSH_DOCKER === '1'
function shellQuote(value: string): string {
return `'${value.replaceAll("'", "'\\''")}'`
}
function remoteOscQueryScript(runId: string): string {
return [
"process.stdin.setEncoding('utf8')",
'if (process.stdin.isTTY) process.stdin.setRawMode(true)',
'process.stdin.resume()',
"let received = ''",
`process.stdout.write('REMOTE_OSC_READY_${runId}\\n')`,
"process.stdin.on('data', (chunk) => {",
' received += chunk',
" if (received.includes('\\x1b]10;rgb:')) {",
` process.stdout.write('REMOTE_OSC_REPLY_${runId}\\n')`,
' process.exit(0)',
' }',
'})',
"setTimeout(() => process.stdout.write('\\x1b]10;?\\x1b\\\\'), 100)"
].join(';')
}
test.describe('PTY input write queue over SSH', () => {
test.skip(!RUN_DOCKER_SSH, 'Set ORCA_E2E_SSH_DOCKER=1 to run Docker-backed SSH E2E.')
test.skip(process.platform === 'win32', 'Docker SSH E2E uses POSIX ssh tooling.')
test('returns an xterm OSC query reply through the live SSH PTY', async ({
orcaPage
}, testInfo) => {
test.slow()
let target: DockerSshRelayTarget | null = null
try {
target = startDockerSshRelayTarget(testInfo)
await waitForSessionReady(orcaPage)
await waitForActiveWorktree(orcaPage)
await connectDockerSshRelayTarget(orcaPage, target)
await ensureTerminalVisible(orcaPage, 45_000)
await waitForActiveTerminalManager(orcaPage, 60_000)
const ptyId = await waitForActivePanePtyId(orcaPage, 60_000)
const runId = String(Date.now())
await execInTerminal(orcaPage, ptyId, `node -e ${shellQuote(remoteOscQueryScript(runId))}`)
await waitForTerminalOutput(orcaPage, `REMOTE_OSC_READY_${runId}`, 30_000, 80_000)
await waitForTerminalOutput(orcaPage, `REMOTE_OSC_REPLY_${runId}`, 30_000, 80_000)
} finally {
cleanupDockerSshRelayTarget(target)
}
})
})