mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 19:11:03 +08:00
d0dd908fb0
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.
35 lines
1.1 KiB
TypeScript
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 }
|
|
}
|