mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
* feat(resources): end local terminals with checked identity checks - Add a PTYs view to the Resource Manager that lists local terminals and can end one. Before stopping, the host confirms the terminal's incarnation, agent ownership, and attachments. This prevents ending a same-ID replacement that started after the list was read. - Bump the daemon protocol to v50 and gate the new fenced kill on it. Older daemons ignore the extra fields, so the client refuses End instead of sending an unchecked kill. - Admit diagnostic reads (PTY listing and memory snapshot) only while the Resources view is visible, so a hidden window does no background scanning. - Report incarnation and host on spawn and exit events so the renderer can match them to the terminal it showed. - Replace the popover's terminal-session list with the new inventory and move memory polling into the Resources view. * Show unrouted daemon PTYs in the Resource Manager * Simplify PTY controls and clarify safe termination * Format local build compatibility protocol lists * Add PTY resource management localization strings * Harden PTY resource manager test fixtures * Use typed IPC event in PTY kill test fixture * Refine local PTY resource view model typing * Refine local PTY resource view model typing * Include local host identity in PTY lifecycle event tests
72 lines
2.5 KiB
TypeScript
72 lines
2.5 KiB
TypeScript
import {
|
|
KEY_LATENCY_SAMPLES,
|
|
MAX_MEDIAN_KEY_LATENCY_MS,
|
|
MAX_WORST_KEY_LATENCY_MS,
|
|
interactivePromptScript,
|
|
waitForMarkerLatency,
|
|
median
|
|
} from './helpers/terminal-typing-benchmark'
|
|
import { randomUUID } from 'node:crypto'
|
|
import { rmSync, writeFileSync } from 'node:fs'
|
|
import path from 'node:path'
|
|
import { test, expect } from './helpers/orca-app'
|
|
import {
|
|
focusActiveTerminalInput,
|
|
waitForActivePanePtyId,
|
|
waitForActiveTerminalManager,
|
|
waitForTerminalOutput,
|
|
sendToTerminal
|
|
} from './helpers/terminal'
|
|
import { ensureTerminalVisible, waitForActiveWorktree, waitForSessionReady } from './helpers/store'
|
|
|
|
test.describe('Terminal typing latency', () => {
|
|
test('interactive prompt echoes typed keys without visible lag', async ({
|
|
orcaPage,
|
|
testRepoPath
|
|
}, testInfo) => {
|
|
await waitForSessionReady(orcaPage)
|
|
await waitForActiveWorktree(orcaPage)
|
|
await ensureTerminalVisible(orcaPage)
|
|
await waitForActiveTerminalManager(orcaPage, 30_000)
|
|
|
|
const ptyId = await waitForActivePanePtyId(orcaPage)
|
|
const runId = randomUUID()
|
|
const scriptPath = path.join(testRepoPath, `.orca-typing-benchmark-${runId}.mjs`)
|
|
writeFileSync(scriptPath, interactivePromptScript(runId))
|
|
let commandSent = false
|
|
try {
|
|
await sendToTerminal(orcaPage, ptyId, `node ${JSON.stringify(scriptPath)}\r`)
|
|
commandSent = true
|
|
await waitForTerminalOutput(orcaPage, `TYPING_READY_${runId}`, 10_000)
|
|
await focusActiveTerminalInput(orcaPage)
|
|
|
|
const latencies: number[] = []
|
|
for (const [index, char] of [...KEY_LATENCY_SAMPLES].entries()) {
|
|
const seq = index + 1
|
|
const marker = `TYPING_KEY_${runId}_${seq}`
|
|
const start = performance.now()
|
|
await orcaPage.keyboard.type(char)
|
|
await waitForMarkerLatency(orcaPage, marker, MAX_WORST_KEY_LATENCY_MS)
|
|
latencies.push(performance.now() - start)
|
|
}
|
|
|
|
const medianLatency = median(latencies)
|
|
const worstLatency = Math.max(...latencies)
|
|
testInfo.annotations.push({
|
|
type: 'terminal-typing-latency',
|
|
description: `median=${medianLatency.toFixed(1)}ms worst=${worstLatency.toFixed(1)}ms samples=${latencies
|
|
.map((value) => value.toFixed(1))
|
|
.join(',')}`
|
|
})
|
|
|
|
expect(medianLatency).toBeLessThan(MAX_MEDIAN_KEY_LATENCY_MS)
|
|
expect(worstLatency).toBeLessThan(MAX_WORST_KEY_LATENCY_MS)
|
|
} finally {
|
|
if (commandSent) {
|
|
await sendToTerminal(orcaPage, ptyId, '\x03').catch(() => undefined)
|
|
}
|
|
rmSync(scriptPath, { force: true })
|
|
}
|
|
})
|
|
})
|