Problem
prepareWorkspace promises an isolated worktree when gh is authenticated, but a failed git worktree add silently changes the execution target to the original checkout and still returns proceed: true. With --yes, no user can review that change of plan before the coding agent starts.
Reproduction (current main, b037891)
Use the injected Runner in prepareWorkspace with gh auth status successful, --is-inside-work-tree returning true, and every git worktree add returning a failure such as permission denied. Use ctx.flags.yes = true and a non-TTY PromptIO.
Observed return value after the worktree attempts fail:
{"cwd":"C:/scratch/repo","proceed":true}
The notes first say “Spinning up an isolated worktree so your branch stays untouched…” and then “working in place.” The caller receives no indication that it must stop or obtain new consent.
Relevant code: src/commands/code_support.ts in prepareWorkspace; src/core/worktree.ts in createGatedWorktree. test/repo_gate.test.ts covers successful creation and unauthenticated in-place behavior, but not failure after isolation was attempted.
Expected
A worktree failure must not begin the coding task on the original branch under the prior --yes approval. Abort with the Git error, or in an interactive session require a fresh explicit choice to work in place. Add a regression test for the failed worktree path, including --yes.
Problem
prepareWorkspacepromises an isolated worktree whenghis authenticated, but a failedgit worktree addsilently changes the execution target to the original checkout and still returnsproceed: true. With--yes, no user can review that change of plan before the coding agent starts.Reproduction (current
main,b037891)Use the injected
RunnerinprepareWorkspacewithgh auth statussuccessful,--is-inside-work-treereturningtrue, and everygit worktree addreturning a failure such as permission denied. Usectx.flags.yes = trueand a non-TTYPromptIO.Observed return value after the worktree attempts fail:
{"cwd":"C:/scratch/repo","proceed":true}The notes first say “Spinning up an isolated worktree so your branch stays untouched…” and then “working in place.” The caller receives no indication that it must stop or obtain new consent.
Relevant code:
src/commands/code_support.tsinprepareWorkspace;src/core/worktree.tsincreateGatedWorktree.test/repo_gate.test.tscovers successful creation and unauthenticated in-place behavior, but not failure after isolation was attempted.Expected
A worktree failure must not begin the coding task on the original branch under the prior
--yesapproval. Abort with the Git error, or in an interactive session require a fresh explicit choice to work in place. Add a regression test for the failed worktree path, including--yes.