mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 00:02:31 +00:00
* test: reproduce accumulated-workspace typing latency through real PTYs * test: make the bench harness self-checks falsifiable Review found four assertions that could not fail and one fixture gap: - `missingPtyArrivalCount`/`missingEchoCount` were hardcoded `0` and `validateExpectedSeqs` throws before them, so every assertion on them was vacuous and every report read `0`. The throw is the real guard and is already covered; drop the vestigial fields. - An absent status controller returned an all-zero result, which satisfied its own accepted-equals-generated equality. Assert presence first. - The byte-pacing control had only an upper bound, so a generator emitting no stream bytes passed. Add the lower bound. - `lineageEvery: 1` built zero lineage: no ordinal satisfies `% 1 === 1`. Offset the interval and cover the densest setting. - The documented control command never set ORCA_TYPING_BENCH, so it skipped instead of running.
70 lines
2.2 KiB
TypeScript
70 lines
2.2 KiB
TypeScript
import type { Page } from '@stablyai/playwright-test'
|
|
import { switchToWorktree } from './helpers/store'
|
|
import {
|
|
ensureActiveWorktreePaneLoad,
|
|
type TerminalLoadPane
|
|
} from './artificial-opencode-pane-interactions'
|
|
|
|
export async function createTypingLoadWorkspaces(
|
|
page: Page,
|
|
firstWorktreeId: string,
|
|
paneCount: number,
|
|
workspaceCount: number,
|
|
visitedWorkspaces: number,
|
|
createdIds: string[]
|
|
): Promise<TerminalLoadPane[]> {
|
|
const panes: TerminalLoadPane[] = []
|
|
const count = Math.min(paneCount, workspaceCount)
|
|
const visitedCount = Math.max(count, visitedWorkspaces)
|
|
for (let index = 0; index < visitedCount; index++) {
|
|
let worktreeId = firstWorktreeId
|
|
if (index > 0) {
|
|
worktreeId = await page.evaluate(
|
|
async ({ firstWorktreeId, index }) => {
|
|
const state = window.__store?.getState()
|
|
const owner = Object.values(state?.worktreesByRepo ?? {})
|
|
.flat()
|
|
.find((row) => row.id === firstWorktreeId)
|
|
if (!state || !owner) {
|
|
throw new Error('Benchmark load repository is unavailable')
|
|
}
|
|
const result = await state.createWorktree(
|
|
owner.repoId,
|
|
`typing-load-${Date.now()}-${index}`,
|
|
undefined,
|
|
'skip'
|
|
)
|
|
return result.worktree.id
|
|
},
|
|
{ firstWorktreeId, index }
|
|
)
|
|
createdIds.push(worktreeId)
|
|
}
|
|
await switchToWorktree(page, worktreeId)
|
|
const loadIndex = index - (visitedCount - count)
|
|
const countHere =
|
|
loadIndex < 0 ? 1 : Math.floor(paneCount / count) + (loadIndex < paneCount % count ? 1 : 0)
|
|
const mounted = await ensureActiveWorktreePaneLoad(page, countHere)
|
|
if (loadIndex >= 0) {
|
|
panes.push(...mounted)
|
|
}
|
|
}
|
|
return panes
|
|
}
|
|
|
|
export async function removeTypingLoadWorkspaces(
|
|
page: Page,
|
|
createdIds: readonly string[]
|
|
): Promise<void> {
|
|
for (const id of createdIds) {
|
|
await page.evaluate(async (worktreeId) => {
|
|
const result = await window.__store
|
|
?.getState()
|
|
.removeWorktree({ id: worktreeId, executionHostId: null }, true)
|
|
if (!result?.ok) {
|
|
throw new Error(`Benchmark cleanup failed: ${result?.error ?? 'store unavailable'}`)
|
|
}
|
|
}, id)
|
|
}
|
|
}
|