Recover task and surface error when worktree prep fails (#629)#661
Merged
Conversation
Failed background worktree/PTY preparation (empty repo, missing base branch) left the task stranded in-progress with a misleading "[session ended]" terminal that survived restarts and showed no error. Revert the task to todo via revertPreparingTaskToTodo on prep failure and push a new taskPreparationFailed message that the renderer shows as a toast. createWorktree now distinguishes an empty repository from a missing base branch and returns a clearer "no commits yet" message. Fixes #629
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #629. When background worktree/PTY preparation failed (empty repo with no commits, or a configured base branch that doesn't exist), the task was left stranded in
in-progresswith no worktree and no PTY. The terminal showed a misleading dim "[session ended]", the state survived app restarts, and no error reached the user.prepareTaskInBackgroundnow reverts the task totodoviarevertPreparingTaskToTodoon a genuine prep failure (cleaning up any half-created worktree and releasing ports) instead of only clearing the preparing spinner.taskPreparationFailedpush message → the renderer surfaces the real error as atoast.error(mirrors the existingcolumnAgentFailedpattern); i18n added for en/ru/es.git.createWorktreenow distinguishes an empty repository (no commits) from a missing base branch and returns a clearer "no commits yet — create an initial commit" message.moveTask) was already safe (renderer reverts the optimistic update on throw); this change targets the fire-and-forget background prep path used by Launch Variants / Add Attempts.Reproduce-first: updated the empty-repo test in
git-worktree.test.tsand rewrote the four prep-failure tests inrpc-handlers.test.tsto assert revert-to-todo + the new push event.bun run lintandbun run testare green.Reported by @sworgkh.
Decision record:
decisions/069-worktree-prep-failure-revert.md.