mirror of
https://github.com/stablyai/orca.git
synced 2026-09-30 08:03:12 +00:00
The six oversized src/main/ipc modules each carried a file-level `eslint-disable max-lines` and ran 427-671 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. Each file is cut along the seams it already had: pet splits into format allowlist / storage paths / symlink-safe copy / bundle manifest + import; filesystem-auth into path-containment primitives, the config-derived allow-list, and the git-registered root cache; notifications into sound selection, native lifecycle, permission probe, and burst cooldown; crash-reporting into renderer error reports, breadcrumbs, and sender. The IPC surface is proved intact rather than assumed: comparing (method, channel) multisets between HEAD and the split gives 49 registrations across 49 distinct channels on both sides. filesystem-auth's security boundary keeps its acyclic layering -- containment primitives, then allow-list, then root cache, then path-resolution orchestration -- with no layer gaining a back-edge. Also keeps clipboard-ipc-handlers.test.ts under the 800-line test budget. The split had briefly added a redundant vi.mock for isENOENT (byte-identical to the real implementation) that pushed it to 801; the mock is dropped in favor of the real function, with realpath added to the existing node:fs/promises mock. Verified: oxlint clean, ratchet passes, typecheck clean, full unit suite green (the one remaining failure is a pre-existing load flake in an untouched file, green when re-run serially), no new runtime import cycles among 617 modules, and no lint suppression added anywhere.
33 lines
962 B
TypeScript
33 lines
962 B
TypeScript
const remoteWorkspacePatchTailByTargetId = new Map<string, Promise<void>>()
|
|
|
|
export async function queueRemoteWorkspacePatch<T>(
|
|
targetId: string,
|
|
operation: () => Promise<T>
|
|
): Promise<T> {
|
|
const previous = remoteWorkspacePatchTailByTargetId.get(targetId) ?? Promise.resolve()
|
|
let release!: () => void
|
|
const tail = new Promise<void>((resolve) => {
|
|
release = resolve
|
|
})
|
|
const queued = previous.catch(() => {}).then(() => tail)
|
|
remoteWorkspacePatchTailByTargetId.set(targetId, queued)
|
|
|
|
await previous.catch(() => {})
|
|
try {
|
|
return await operation()
|
|
} finally {
|
|
release()
|
|
if (remoteWorkspacePatchTailByTargetId.get(targetId) === queued) {
|
|
remoteWorkspacePatchTailByTargetId.delete(targetId)
|
|
}
|
|
}
|
|
}
|
|
|
|
export function clearRemoteWorkspacePatchTails(): void {
|
|
remoteWorkspacePatchTailByTargetId.clear()
|
|
}
|
|
|
|
export function getRemoteWorkspacePatchTailCount(): number {
|
|
return remoteWorkspacePatchTailByTargetId.size
|
|
}
|