Skip to content
Closed
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
25 changes: 19 additions & 6 deletions shared/lib/agent-adapters.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,18 @@ _pane_child_count() {
} | wc -l | tr -d ' '
}

_pane_metadata_unavailable() {
local target="$1"
local pane_pid current_command

tmux list-panes -t "$target" >/dev/null 2>&1 || return 1

pane_pid=$(tmux display-message -t "$target" -p '#{pane_pid}' 2>/dev/null || echo "")
current_command=$(tmux display-message -t "$target" -p '#{pane_current_command}' 2>/dev/null || echo "")

[[ -z "$pane_pid" && -z "$current_command" ]]
}

_pane_descendant_pids() {
local root_pid="$1"
local queue="$root_pid"
Expand Down Expand Up @@ -1609,10 +1621,11 @@ agent_pane_is_ready() {
local pane_pid
pane_pid=$(tmux display-message -t "$target" -p '#{pane_pid}' 2>/dev/null || echo "")
if [[ -z "$pane_pid" ]]; then
# Some lifecycle tests use a minimal tmux mock that accepts send-keys but
# cannot report pane metadata. In that environment, treat readiness as
# unverifiable rather than hard-failing the launch.
return 0
if _pane_metadata_unavailable "$target"; then
_agent_log_debug "Pane $target metadata unavailable; assuming ready"
return 0
fi
return 1
fi

local current_command
Expand Down Expand Up @@ -1655,8 +1668,8 @@ agent_verify_launch() {
current_command=$(_pane_current_command "$target")
children=$(_pane_child_count "$target")

if [[ -z "$current_command" && -z "$children" ]]; then
_agent_log_debug "Launch verification unavailable for $target; accepting best-effort dispatch"
if _pane_metadata_unavailable "$target"; then
_agent_log_debug "Launch verification unavailable for $target; assuming success"
return 0
fi

Expand Down
6 changes: 3 additions & 3 deletions shared/lib/wavemill-mill.sh
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ cleanup_completed_task() {
if [[ "$task_branch" == "main" || "$task_branch" == "master" ]]; then
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
execute git -C "$REPO_DIR" branch -D "$task_branch" >/dev/null 2>&1 || true
log " ✓ 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"
Expand Down Expand Up @@ -1106,7 +1106,7 @@ cleanup_stale_tasks() {
if [[ "$branch" == "main" || "$branch" == "master" ]]; then
log_warn " Refusing to delete protected branch: $branch"
else
git -C "$REPO_DIR" branch -D "$branch" 2>/dev/null || true
git -C "$REPO_DIR" branch -D "$branch" >/dev/null 2>&1 || true
git -C "$REPO_DIR" push origin --delete "$branch" 2>/dev/null || true
fi
fi
Expand Down Expand Up @@ -4058,7 +4058,7 @@ cleanup_completed_task() {
if [[ "$task_branch" == "main" || "$task_branch" == "master" ]]; then
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
git -C "$REPO_DIR" branch -D "$task_branch" >/dev/null 2>&1 || true
log " ✓ 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"
Expand Down
8 changes: 8 additions & 0 deletions tests/cleanup-branch.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ else
fail "cleanup logging still reports generic branch deletion"
fi

if grep -Fq 'branch -D "$task_branch" >/dev/null 2>&1 || true' <<< "$HEREDOC_CONTENT" \
&& grep -Fq 'branch -D "$task_branch" >/dev/null 2>&1 || true' <<< "$outer_cleanup" \
&& grep -Fq 'branch -D "$branch" >/dev/null 2>&1 || true' "$MILL_SCRIPT"; then
pass "cleanup suppresses git branch deletion stdout in backlog paths"
else
fail "cleanup still leaks git branch deletion stdout"
fi

if grep -Fq 'Remote branch already deleted or push failed: $task_branch' <<< "$HEREDOC_CONTENT" \
&& grep -Fq 'Remote branch already deleted or push failed: $task_branch' <<< "$outer_cleanup"; then
pass "cleanup tolerates already-deleted remote branches"
Expand Down
Loading