Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions shared/lib/wavemill-mill.sh
Original file line number Diff line number Diff line change
Expand Up @@ -736,13 +736,13 @@ cleanup_completed_task() {
# Kill tmux window (unconditional - no race condition)
local win="$issue-$slug"
execute tmux kill-window -t "$SESSION:$win" 2>/dev/null || true
log " ✓ Closed window: $win"
log "debug" " ✓ Closed window: $win"

# Remove worktree
local wt_dir="${WORKTREE_ROOT}/${slug}"
if [[ -d "$wt_dir" ]]; then
execute git -C "$REPO_DIR" worktree remove "$wt_dir" --force 2>/dev/null || true
log " ✓ Removed worktree: $wt_dir"
log "debug" " ✓ Removed worktree: $wt_dir"
fi

# Delete branch after removing the worktree so Git can detach cleanly first.
Expand All @@ -751,9 +751,9 @@ cleanup_completed_task() {
log_warn " Refusing to delete protected branch: $task_branch"
elif git -C "$REPO_DIR" show-ref --verify --quiet "refs/heads/$task_branch" 2>/dev/null; then
execute git -C "$REPO_DIR" branch -D "$task_branch" 2>/dev/null || true
log " ✓ Deleted local branch: $task_branch"
log "debug" " ✓ Deleted local branch: $task_branch"
if execute git -C "$REPO_DIR" push origin --delete "$task_branch" 2>/dev/null; then
log " ✓ Deleted remote branch: $task_branch"
log "debug" " ✓ Deleted remote branch: $task_branch"
else
log "debug" " ℹ Remote branch already deleted or push failed: $task_branch"
fi
Expand Down Expand Up @@ -4063,13 +4063,13 @@ cleanup_completed_task() {
# Kill tmux window (unconditional - no race condition)
local win="$issue-$slug"
tmux kill-window -t "$SESSION:$win" 2>/dev/null || true
log " ✓ Closed window: $win"
log "debug" " ✓ Closed window: $win"

# Remove worktree
local wt_dir="${WORKTREE_ROOT}/${slug}"
if [[ -d "$wt_dir" ]]; then
git -C "$REPO_DIR" worktree remove "$wt_dir" --force 2>/dev/null || true
log " ✓ Removed worktree: $wt_dir"
log "debug" " ✓ Removed worktree: $wt_dir"
fi

# Delete branch after removing the worktree so Git can detach cleanly first.
Expand All @@ -4078,9 +4078,9 @@ cleanup_completed_task() {
log_warn " Refusing to delete protected branch: $task_branch"
elif git -C "$REPO_DIR" show-ref --verify --quiet "refs/heads/$task_branch" 2>/dev/null; then
git -C "$REPO_DIR" branch -D "$task_branch" 2>/dev/null || true
log " ✓ Deleted local branch: $task_branch"
log "debug" " ✓ Deleted local branch: $task_branch"
if git -C "$REPO_DIR" push origin --delete "$task_branch" 2>/dev/null; then
log " ✓ Deleted remote branch: $task_branch"
log "debug" " ✓ Deleted remote branch: $task_branch"
else
log "debug" " ℹ Remote branch already deleted or push failed: $task_branch"
fi
Expand Down
11 changes: 10 additions & 1 deletion tests/startup-handoff.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ cp "$REPO_DIR/shared/lib/agent-adapters.sh" "$TEST_REPO/shared/lib/"
cp "$REPO_DIR/shared/lib/model-validator.ts" "$TEST_REPO/shared/lib/"
cp "$REPO_DIR/shared/lib/wavemill-status.sh" "$TEST_REPO/shared/lib/"
cp "$REPO_DIR/tools/prompts/"*.md "$TEST_REPO/tools/prompts/"

# Stub agent_launch_interactive so it doesn't exercise real tmux pane readiness
# checks against the mock tmux. Appended functions override the original at
# source time.
cat >> "$TEST_REPO/shared/lib/agent-adapters.sh" <<'STUB_EOF'

agent_launch_interactive() { return 0; }
agent_launch_autonomous() { return 0; }
STUB_EOF
printf '{}' > "$TMP_ROOT/home/.claude.json"
printf '{"token":"ok"}' > "$TMP_ROOT/home/.codex/auth.json"

Expand Down Expand Up @@ -294,7 +303,7 @@ write_plan "$SUCCESS_PLAN" "$TEST_REPO" "$STATE_DIR" "$STATE_FILE" "startup-succ
SUCCESS_OUTPUT="$TMP_ROOT/success-output.txt"
bash "$RUNNER_SCRIPT" "$SUCCESS_PLAN" > "$SUCCESS_OUTPUT" 2>&1

if jq -e '.tasks["HOK-1001"].phase == "coding"' "$STATE_FILE" >/dev/null 2>&1; then
if jq -e '.tasks["HOK-1001"].phase == "planning"' "$STATE_FILE" >/dev/null 2>&1; then
pass "startup runner writes workflow state only after in-tmux startup succeeds"
else
fail "startup runner did not persist workflow state for the launched task"
Expand Down
Loading