fix(terminals): negotiate explicit close intent for paired runtimes (#10129)

This commit is contained in:
OrcaWin
2026-07-27 15:22:55 -07:00
committed by GitHub
parent 0f91af821d
commit 24706ccff0
29 changed files with 1231 additions and 45 deletions
@@ -11,11 +11,13 @@ import {
publicKeyToBase64
} from './e2ee-crypto'
import { RemoteRuntimeRequestConnection } from './remote-runtime-request-connection'
import { SESSION_TAB_CLOSE_INTENT_RUNTIME_CAPABILITY } from './protocol-version'
type TestServer = {
wss: WebSocketServer
pairing: PairingOffer
requests: unknown[]
auths: unknown[]
connectionCount: () => number
}
@@ -54,6 +56,11 @@ describe('RemoteRuntimeRequestConnection', () => {
_meta: { runtimeId: 'runtime-test' }
})
expect(server.connectionCount()).toBe(1)
expect(server.auths).toContainEqual(
expect.objectContaining({
clientCapabilities: [SESSION_TAB_CLOSE_INTENT_RUNTIME_CAPABILITY]
})
)
expect(server.requests).toMatchObject([
{ method: 'status.get' },
{ method: 'terminal.send', params: { terminal: 't1', text: 'ab' } }
@@ -66,6 +73,7 @@ describe('RemoteRuntimeRequestConnection', () => {
async function createServer(): Promise<TestServer> {
const serverKeyPair = generateKeyPair()
const requests: unknown[] = []
const auths: unknown[] = []
let connectionCount = 0
const wss = new WebSocketServer({ port: 0 })
servers.push(wss)
@@ -94,7 +102,12 @@ async function createServer(): Promise<TestServer> {
}
if (!authenticated) {
const auth = JSON.parse(plaintext) as { type: string; deviceToken: string }
expect(auth).toEqual({ type: 'e2ee_auth', deviceToken: 'device-token' })
auths.push(auth)
expect(auth).toEqual({
type: 'e2ee_auth',
deviceToken: 'device-token',
clientCapabilities: [SESSION_TAB_CLOSE_INTENT_RUNTIME_CAPABILITY]
})
authenticated = true
sendEncrypted(ws, sharedKey, { type: 'e2ee_authenticated' })
return
@@ -133,6 +146,7 @@ async function createServer(): Promise<TestServer> {
wss,
pairing,
requests,
auths,
connectionCount: () => connectionCount
}
}