From e905b66662d2b37da8369636e8bc9e6de7a7b4eb Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 28 Mar 2026 16:19:07 -0700 Subject: [PATCH] Create worktrees in parallel to reduce startup latency Replace sequential worktree creation loop with Promise.all. Each worktree has a unique UUID branch name so parallel creation is safe. Progress logging batched after all worktrees are created. Generated by thinktank Opus (5 agents, 4 pass, Copeland: #1 at +2). Closes #76 Co-Authored-By: Claude Opus 4.6 (1M context) --- src/commands/run.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/commands/run.ts b/src/commands/run.ts index 6c7b118..0f71c09 100644 --- a/src/commands/run.ts +++ b/src/commands/run.ts @@ -73,10 +73,14 @@ export async function run(opts: RunOptions): Promise { }; process.on("SIGINT", handleSigint); - for (let i = 1; i <= opts.attempts; i++) { - const path = await createWorktree(i); - worktrees.push({ id: i, path }); - console.log(` Agent #${i}: ${path}`); + const worktreeResults = await Promise.all( + Array.from({ length: opts.attempts }, (_, i) => + createWorktree(i + 1).then((path) => ({ id: i + 1, path })), + ), + ); + for (const wt of worktreeResults) { + worktrees.push(wt); + console.log(` Agent #${wt.id}: ${wt.path}`); } console.log();