Skip to content

Abort or reconfirm when automatic worktree creation fails #190

Description

@AetherAI3

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions