Skip to content

Commit 15243f1

Browse files
authored
improve parallel mode init error messages (#3426)
* improve parallel mode init error messages * add changeset
1 parent 15fa99c commit 15243f1

File tree

4 files changed

+32
-17
lines changed

4 files changed

+32
-17
lines changed

.changeset/silver-eagles-post.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@kilocode/cli": patch
3+
---
4+
5+
Improves error message clarity when initiating parallel mode

cli/src/parallel/__tests__/determineBranch.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe("determineParallelBranch", () => {
5555
}
5656

5757
await expect(determineParallelBranch(input)).rejects.toThrow(
58-
"Error: parallel mode requires the current working directory to be a git repository",
58+
"Parallel mode requires the current working directory to be a git repository",
5959
)
6060
})
6161

@@ -111,9 +111,7 @@ describe("determineParallelBranch", () => {
111111
existingBranch,
112112
}
113113

114-
await expect(determineParallelBranch(input)).rejects.toThrow(
115-
`Error: Branch "${existingBranch}" does not exist`,
116-
)
114+
await expect(determineParallelBranch(input)).rejects.toThrow(`Branch "${existingBranch}" does not exist`)
117115

118116
expect(branchExists).toHaveBeenCalledWith(mockCwd, existingBranch)
119117
})

cli/src/parallel/determineBranch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export async function determineParallelBranch({
2727
const { isRepo, branch } = await getGitInfo(cwd)
2828

2929
if (!isRepo) {
30-
const errorMessage = "Error: parallel mode requires the current working directory to be a git repository"
30+
const errorMessage = "Parallel mode requires the current working directory to be a git repository"
3131
logs.error(errorMessage, "ParallelMode")
3232
throw new Error(errorMessage)
3333
}
@@ -46,7 +46,7 @@ export async function determineParallelBranch({
4646
const exists = await branchExists(cwd, existingBranch)
4747

4848
if (!exists) {
49-
const errorMessage = `Error: Branch "${existingBranch}" does not exist`
49+
const errorMessage = `Branch "${existingBranch}" does not exist`
5050
logs.error(errorMessage, "ParallelMode")
5151
throw new Error(errorMessage)
5252
}

cli/src/parallel/parallel.ts

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,28 @@ export type Input = {
6161
* Get parameters for parallel mode execution
6262
*/
6363
export async function getParallelModeParams({ cwd, prompt, existingBranch }: Input) {
64-
// Determine branch and worktree path
65-
const { worktreeBranch, worktreePath } = await determineParallelBranch({
66-
cwd,
67-
prompt,
68-
...(existingBranch && { existingBranch }),
69-
})
70-
71-
return {
72-
worktreeBranch,
73-
worktreePath,
64+
try {
65+
// Determine branch and worktree path
66+
const { worktreeBranch, worktreePath } = await determineParallelBranch({
67+
cwd,
68+
prompt,
69+
...(existingBranch && { existingBranch }),
70+
})
71+
72+
return {
73+
worktreeBranch,
74+
worktreePath,
75+
}
76+
} catch (error) {
77+
const message = error instanceof Error ? error.message : String(error)
78+
79+
logs.error("Error determining parallel branch", "ParallelMode", {
80+
error: message,
81+
})
82+
83+
console.error(`Failed to start parallel mode: ${message}`)
84+
85+
process.exit(1)
7486
}
7587
}
7688

@@ -79,7 +91,7 @@ const agentCommitInstruction =
7991

8092
/**
8193
* Finish parallel mode by having the extension agent generate a commit message and committing changes,
82-
* then cleaning up the git worktree
94+
* then cleaning up the git worktree.
8395
* This function should be called from the CLI dispose method when in parallel mode
8496
* Since it's part of the dispose flow, this function must never throw an error
8597
*/

0 commit comments

Comments
 (0)