chore(lint): parallelize worktree terminal bootstrap

Start each bootstrap terminal concurrently via Promise.all. Since every
spec creates an independent terminal and returns a standalone result,
parallelization preserves order while removing two no-await-in-loop
warnings.
This commit is contained in:
Mohamed Boudra
2026-04-24 03:23:45 +07:00
parent 5ad911e00d
commit 6fcc4c736b

View File

@@ -530,41 +530,43 @@ async function runWorktreeTerminalBootstrap(
return;
}
const results: WorktreeBootstrapTerminalResult[] = [];
for (const spec of terminalSpecs) {
try {
const terminal = await options.terminalManager.createTerminal({
cwd: options.worktree.worktreePath,
name: spec.name,
env: runtimeEnv,
});
await waitForTerminalBootstrapReadiness(terminal);
terminal.send({
type: "input",
data: `${spec.command}\r`,
});
results.push({
name: terminal.name ?? spec.name ?? null,
command: spec.command,
status: "started",
terminalId: terminal.id,
error: null,
});
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
options.logger?.warn(
{ agentId: options.agentId, command: spec.command, err: error },
"Failed to bootstrap worktree terminal",
);
results.push({
name: spec.name ?? null,
command: spec.command,
status: "failed",
terminalId: null,
error: message,
});
}
}
const terminalManager = options.terminalManager;
const results = await Promise.all(
terminalSpecs.map(async (spec): Promise<WorktreeBootstrapTerminalResult> => {
try {
const terminal = await terminalManager.createTerminal({
cwd: options.worktree.worktreePath,
name: spec.name,
env: runtimeEnv,
});
await waitForTerminalBootstrapReadiness(terminal);
terminal.send({
type: "input",
data: `${spec.command}\r`,
});
return {
name: terminal.name ?? spec.name ?? null,
command: spec.command,
status: "started",
terminalId: terminal.id,
error: null,
};
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
options.logger?.warn(
{ agentId: options.agentId, command: spec.command, err: error },
"Failed to bootstrap worktree terminal",
);
return {
name: spec.name ?? null,
command: spec.command,
status: "failed",
terminalId: null,
error: message,
};
}
}),
);
await options.appendTimelineItem(
buildTerminalTimelineItem({