fix: show summary and pause on loop exit — tmux doesn't vanish abruptly
This commit is contained in:
44
loop.sh
44
loop.sh
@@ -151,6 +151,31 @@ cleanup() {
|
|||||||
[ "$AUTO_HOOKS" = true ] && remove_hooks
|
[ "$AUTO_HOOKS" = true ] && remove_hooks
|
||||||
release_lock
|
release_lock
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Show final status and wait so tmux doesn't vanish
|
||||||
|
finish() {
|
||||||
|
local exit_code="${1:-0}"
|
||||||
|
local reason="${2:-}"
|
||||||
|
echo ""
|
||||||
|
echo "═══════════════════════════════════════════════════════"
|
||||||
|
echo " LOOP FINISHED"
|
||||||
|
echo "═══════════════════════════════════════════════════════"
|
||||||
|
echo ""
|
||||||
|
echo " Stories: $(story_counts 2>/dev/null || echo 'N/A')"
|
||||||
|
echo " Iterations: $ITERATION / $MAX_ITERATIONS"
|
||||||
|
[ -n "$reason" ] && echo " Reason: $reason"
|
||||||
|
echo ""
|
||||||
|
echo " Progress: .loop/progress.md"
|
||||||
|
echo " Stories: .loop/prd.json"
|
||||||
|
echo ""
|
||||||
|
if any_stories_blocked 2>/dev/null; then
|
||||||
|
echo " ⚠ Some stories are blocked. Run /agent-loop:triage"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
echo " Press Enter to close, or Ctrl+C to keep this terminal open."
|
||||||
|
read -r 2>/dev/null || true
|
||||||
|
exit "$exit_code"
|
||||||
|
}
|
||||||
LOOP_AGENT_TMPFILE=""
|
LOOP_AGENT_TMPFILE=""
|
||||||
|
|
||||||
if [ "$AUTO_HOOKS" = true ]; then
|
if [ "$AUTO_HOOKS" = true ]; then
|
||||||
@@ -301,9 +326,8 @@ while [ "$ITERATION" -lt "$MAX_ITERATIONS" ]; do
|
|||||||
|
|
||||||
# Check if all stories already pass
|
# Check if all stories already pass
|
||||||
if all_stories_pass 2>/dev/null; then
|
if all_stories_pass 2>/dev/null; then
|
||||||
log_header "All Stories Complete! ($(story_counts))"
|
|
||||||
snapshot_for_archive
|
snapshot_for_archive
|
||||||
exit 0
|
finish 0 "All stories complete"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Capture which story the generator will work on (highest-priority incomplete)
|
# Capture which story the generator will work on (highest-priority incomplete)
|
||||||
@@ -312,17 +336,12 @@ while [ "$ITERATION" -lt "$MAX_ITERATIONS" ]; do
|
|||||||
|
|
||||||
# No actionable story — all remaining are passed or blocked
|
# No actionable story — all remaining are passed or blocked
|
||||||
if [ -z "$CURRENT_STORY_ID" ]; then
|
if [ -z "$CURRENT_STORY_ID" ]; then
|
||||||
if [ "$RESUME" = true ]; then
|
|
||||||
log "Resume mode: no actionable stories remaining."
|
|
||||||
else
|
|
||||||
log "No actionable stories remaining (all passed or blocked)."
|
|
||||||
fi
|
|
||||||
snapshot_for_archive
|
snapshot_for_archive
|
||||||
if any_stories_blocked 2>/dev/null; then
|
if any_stories_blocked 2>/dev/null; then
|
||||||
log "Some stories are blocked and need human review. Run /agent-loop:triage for details."
|
finish $EXIT_ALL_BLOCKED "Some stories blocked — needs human review"
|
||||||
exit $EXIT_ALL_BLOCKED
|
else
|
||||||
|
finish $EXIT_OK "No actionable stories remaining"
|
||||||
fi
|
fi
|
||||||
exit $EXIT_OK
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Capture git state before generator runs (for evaluator diff)
|
# Capture git state before generator runs (for evaluator diff)
|
||||||
@@ -449,8 +468,5 @@ Rejected $REJECTIONS times. Needs human review. Last reason: $REASON
|
|||||||
done
|
done
|
||||||
|
|
||||||
# --- Max iterations reached ---
|
# --- Max iterations reached ---
|
||||||
log_header "Max Iterations Reached ($MAX_ITERATIONS)"
|
|
||||||
log "Stories completed: $(story_counts)"
|
|
||||||
log "Run /agent-loop:triage to generate a handoff brief."
|
|
||||||
snapshot_for_archive
|
snapshot_for_archive
|
||||||
exit $EXIT_MAX_ITERATIONS
|
finish $EXIT_MAX_ITERATIONS "Max iterations reached ($MAX_ITERATIONS)"
|
||||||
|
|||||||
Reference in New Issue
Block a user