From f1fde5cb01cc28053978258813dcf545fc3ceee4 Mon Sep 17 00:00:00 2001 From: Sheldon Finlay Date: Fri, 27 Mar 2026 15:17:13 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20show=20summary=20and=20pause=20on=20loop?= =?UTF-8?q?=20exit=20=E2=80=94=20tmux=20doesn't=20vanish=20abruptly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- loop.sh | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/loop.sh b/loop.sh index 09bb913..e9fd960 100755 --- a/loop.sh +++ b/loop.sh @@ -151,6 +151,31 @@ cleanup() { [ "$AUTO_HOOKS" = true ] && remove_hooks 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="" if [ "$AUTO_HOOKS" = true ]; then @@ -301,9 +326,8 @@ while [ "$ITERATION" -lt "$MAX_ITERATIONS" ]; do # Check if all stories already pass if all_stories_pass 2>/dev/null; then - log_header "All Stories Complete! ($(story_counts))" snapshot_for_archive - exit 0 + finish 0 "All stories complete" fi # 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 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 if any_stories_blocked 2>/dev/null; then - log "Some stories are blocked and need human review. Run /agent-loop:triage for details." - exit $EXIT_ALL_BLOCKED + finish $EXIT_ALL_BLOCKED "Some stories blocked — needs human review" + else + finish $EXIT_OK "No actionable stories remaining" fi - exit $EXIT_OK fi # Capture git state before generator runs (for evaluator diff) @@ -449,8 +468,5 @@ Rejected $REJECTIONS times. Needs human review. Last reason: $REASON done # --- 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 -exit $EXIT_MAX_ITERATIONS +finish $EXIT_MAX_ITERATIONS "Max iterations reached ($MAX_ITERATIONS)"