mirror of
https://github.com/stablyai/orca.git
synced 2026-10-03 08:02:12 +00:00
The five oversized src/main/browser modules and src/main/ipc/browser.ts each carried a file-level `eslint-disable max-lines` and ran 377-654 counted lines against a 300-line budget. AGENTS.md calls for splitting rather than suppressing, and config/max-lines-baseline.txt is a shrink-only ratchet, so this removes all six suppressions and prunes their entries (341 -> 335). Pure move, no behavior change. cdp-ws-proxy is decomposed into collaborating objects rather than free functions because its state is genuinely per-connection: every collaborator is a private readonly instance field built in the constructor with live closures over `this`, so per-connection state stays per-connection. Likewise the screencast pacer's isClosed/isStopping and snapshot capture's getSeq are live thunks, not values captured at wiring time, so guards inside already-armed timers still observe a later stop(). browser-guest-ui.ts is renamed to browser-guest-shortcut-forwarding.ts: after the split it exports exactly one function, setupGuestShortcutForwarding, so the old name no longer described its contents. Also restores a single `webContents.debugger` read in the screencast path. The extraction had left three reads where the original had one; the accessor is stable today, so this is not a behavior fix but it removes a latent divergence. Verified: oxlint clean, ratchet passes, typecheck clean, full unit suite green (remaining failures are pre-existing load flakes in untouched files, each green when re-run serially), no new runtime import cycles, and the IPC channel set diffed identical before/after with all 23 handlers still trust-gated.
26 lines
684 B
TypeScript
26 lines
684 B
TypeScript
import type { WebContents } from 'electron'
|
|
|
|
const DEBUGGER_COMMAND_TIMEOUT_MS = 8_000
|
|
|
|
export async function sendDebuggerCommand(
|
|
dbg: WebContents['debugger'],
|
|
method: string,
|
|
params: Record<string, unknown> = {}
|
|
): Promise<unknown> {
|
|
let timeout: ReturnType<typeof setTimeout> | null = null
|
|
try {
|
|
return await Promise.race([
|
|
Promise.resolve().then(() => dbg.sendCommand(method, params)),
|
|
new Promise<never>((_, reject) => {
|
|
timeout = setTimeout(() => {
|
|
reject(new Error(`Timed out while running ${method}.`))
|
|
}, DEBUGGER_COMMAND_TIMEOUT_MS)
|
|
})
|
|
])
|
|
} finally {
|
|
if (timeout) {
|
|
clearTimeout(timeout)
|
|
}
|
|
}
|
|
}
|