Files
kilocode/packages/kilo-vscode/webview-ui/agent-manager/pending-create.ts
T
Josh Lambert d0dd908fb0 fix(agent-manager): extract pending-create below the app size cap
PR #12931 grew AgentManagerApp.tsx to 2808 lines, over its 2800
max-lines ESLint cap. Main's push workflows path-filter the lint job so
the breakage is latent there, but every kilo-vscode PR fails merge CI.
Extract the cross-project pending-create controller into
pending-create.ts instead of raising the cap.
2026-08-06 09:49:22 -04:00

35 lines
1.1 KiB
TypeScript

import { createSignal } from "solid-js"
/**
* Tracks a cross-project worktree creation so the target project is activated
* once its worktree is ready, and abandons the pending activation when the
* creation fails or completes through another flow.
*/
export function usePendingCreate(
active: () => string | undefined,
activate: (projectId: string, worktreeId: string) => void,
) {
const [pending, setPending] = createSignal<{ projectId: string }>()
const schedule = (projectId: string) => {
if (projectId === active()) return
if (pending()) return
setPending({ projectId })
}
const abandon = (projectId?: string) => {
if (pending()?.projectId === projectId) setPending(undefined)
}
const setup = (ev: { status: string; projectId?: string; worktreeId?: string }) => {
if (pending()?.projectId !== ev.projectId) return
if (ev.status === "ready" && ev.projectId && ev.worktreeId) {
setPending(undefined)
activate(ev.projectId, ev.worktreeId)
}
if (ev.status === "error") setPending(undefined)
}
return { schedule, abandon, setup }
}