mirror of
https://github.com/stablyai/orca.git
synced 2026-10-29 16:17:51 +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.
79 lines
2.7 KiB
TypeScript
79 lines
2.7 KiB
TypeScript
import type { Store } from '../persistence'
|
|
import { resolveGitStatusUpstreamRef } from '../git/status-upstream-ref'
|
|
import { gitExecFileAsync } from '../git/runner'
|
|
import {
|
|
getSshGitProvider,
|
|
getSshGitProviderGeneration,
|
|
SSH_GIT_PROVIDER_UNAVAILABLE_MESSAGE
|
|
} from '../providers/ssh-git-dispatch'
|
|
import { resolveRegisteredWorktreePath } from './registered-worktree-roots-cache'
|
|
import {
|
|
getLocalGitOptionsForRepo,
|
|
getLocalRepoForRegisteredWorktree
|
|
} from './local-worktree-runtime-options'
|
|
import { setWorktreeGitStatusRefWatch } from './worktree-base-directory-watcher'
|
|
import type { GitStatusRefBindingRequest } from './worktree-git-status-ref-watch'
|
|
|
|
export type GitStatusUpstreamRefWatchRequest = Omit<
|
|
GitStatusRefBindingRequest,
|
|
'providerGeneration'
|
|
>
|
|
|
|
const UPSTREAM_REF_RESOLUTION_TIMEOUT_MS = 15_000
|
|
|
|
function boundedSignal(signal: AbortSignal): AbortSignal {
|
|
return AbortSignal.any([signal, AbortSignal.timeout(UPSTREAM_REF_RESOLUTION_TIMEOUT_MS)])
|
|
}
|
|
|
|
export function applyGitStatusUpstreamRefWatchRequest(
|
|
store: Store,
|
|
args: GitStatusUpstreamRefWatchRequest
|
|
): Promise<void> {
|
|
const providerGeneration = args.connectionId
|
|
? getSshGitProviderGeneration(args.connectionId)
|
|
: undefined
|
|
return setWorktreeGitStatusRefWatch(
|
|
{ ...args, ...(providerGeneration !== undefined ? { providerGeneration } : {}) },
|
|
async (bindingSignal) => {
|
|
if (!args.branch || !args.upstreamName) {
|
|
return undefined
|
|
}
|
|
const signal = boundedSignal(bindingSignal)
|
|
if (args.connectionId) {
|
|
const provider = getSshGitProvider(args.connectionId)
|
|
if (!provider) {
|
|
throw new Error(SSH_GIT_PROVIDER_UNAVAILABLE_MESSAGE)
|
|
}
|
|
return resolveGitStatusUpstreamRef(
|
|
(gitArgs, cwd, requestSignal) =>
|
|
provider.exec(gitArgs, cwd, {
|
|
signal: requestSignal,
|
|
timeoutMs: UPSTREAM_REF_RESOLUTION_TIMEOUT_MS
|
|
}),
|
|
args.worktreePath,
|
|
args.branch,
|
|
args.upstreamName,
|
|
signal
|
|
)
|
|
}
|
|
|
|
const worktreePath = await resolveRegisteredWorktreePath(args.worktreePath, store)
|
|
const repo = getLocalRepoForRegisteredWorktree(store, args.worktreePath, worktreePath)
|
|
const gitOptions = getLocalGitOptionsForRepo(store, repo)
|
|
return resolveGitStatusUpstreamRef(
|
|
(gitArgs, cwd, requestSignal) =>
|
|
gitExecFileAsync(gitArgs, {
|
|
cwd,
|
|
signal: requestSignal,
|
|
timeout: UPSTREAM_REF_RESOLUTION_TIMEOUT_MS,
|
|
...(gitOptions.wslDistro ? { wslDistro: gitOptions.wslDistro } : {})
|
|
}),
|
|
worktreePath,
|
|
args.branch,
|
|
args.upstreamName,
|
|
signal
|
|
)
|
|
}
|
|
)
|
|
}
|