Skip to content

Spinner + verbose log interleaving garbles terminal output #282

Closed

Description

@admarble

Description

When running sequant run with --verbose, the StateManager verbose messages (📊 State saved: .sequant/state.json) interleave with the phase spinner's terminal control character updates, causing garbled output. Additionally, verbose mode outputs repetitive low-value messages that obscure the useful signals.

Reproduction

npx sequant run 1 --quality-loop --verbose

Observed Behavior

The worktree path display gets garbled:

  Issue #1
    Worktree: /Users/tony/Documeequant/state.json

Expected:

  Issue #1
    Worktree: /Users/tony/Documents/Projects/worktrees/feature/1-feat-foundation-...
📊 State saved: .sequant/state.json

The 📊 State saved message overwrites part of the spinner line mid-render because both console.log() calls from StateManager and the spinner's in-place terminal updates (\r / ANSI escape codes) are writing to stdout without coordination.

Verbose noise

📊 State saved: .sequant/state.json fires 10+ times per run and adds no information beyond what the phase transition messages already convey. Useful signals like Phase spec → completed get buried in repetitive state-save lines.

Useful (keep):

  • 📊 Phase spec → in_progress for issue #1
  • 📊 Phase spec → completed for issue #1
  • 📊 Issue #1 status → ready_for_merge

Noise (suppress or demote):

  • 📊 State saved: .sequant/state.json (repeated per transition)
  • 📊 Metrics saved: .sequant/metrics.json

Root Cause

  • Phase spinner uses terminal control characters to update in-place (every 5s via ELAPSED_UPDATE_INTERVAL_MS)
  • StateManager.saveState() calls console.log() when verbose: true (state-manager.ts ~line 139)
  • These two output mechanisms are uncoordinated — when a state save fires while the spinner is mid-render, the outputs collide

Acceptance Criteria

  • Verbose state tracking messages do not overwrite or interleave with spinner output
  • Worktree paths and phase progress are always fully readable in --verbose mode
  • Repetitive low-value messages (State saved, Metrics saved) are suppressed or only emitted at a debug level, not in standard --verbose
  • Phase transitions and status changes remain visible in --verbose mode
  • Non-verbose mode remains unaffected

Possible Approaches

  1. Pause spinner before verbose logs: Temporarily stop the spinner, emit the log, resume spinner
  2. Buffer verbose messages: Queue them and flush when spinner completes or pauses
  3. Use spinner's own logging API: Route verbose messages through the spinner so it can coordinate output
  4. Tiered verbosity: Keep --verbose for operator-useful signals, add --debug for state-save level detail

Context

Discovered during pm-projects experiment (sequant run 1 --quality-loop --verbose). Only affects --verbose mode since StateManager messages are gated behind the verbose flag.

Activity

  1. added
    bug
    on Feb 15, 2026
  2. admarble commented on Feb 15, 2026

    @admarble
    ContributorAuthor

    Spec Plan — #282 Spinner + Verbose Log Interleaving

    Root Cause

    Two distinct problems:

    1. Spinner garbling: configureUI() is never called with verbose: true from run.ts. Even in --verbose mode, shouldAnimate() returns true in TTY, creating AnimatedSpinner (ora-based with \r + ANSI cursor control). When StateManager.saveState() calls console.log() concurrently, the outputs collide and garble the terminal.

    2. Verbose noise: saveState() logs 📊 State saved: ... on EVERY call. Since higher-level methods (e.g., initializeIssue, updatePhaseStatus) also have their own verbose logs AND call saveState() internally, you get redundant messages. Same pattern in MetricsWriter.saveMetrics().

    Acceptance Criteria

    • AC-1: Verbose state tracking messages do not overwrite or interleave with spinner output
    • AC-2: Worktree paths and phase progress are always fully readable in --verbose mode
    • AC-3: Repetitive low-value messages (State saved, Metrics saved) are suppressed
    • AC-4: Phase transitions and status changes remain visible in --verbose mode
    • AC-5: Non-verbose mode remains unaffected

    Implementation Plan

    Phase 1: Fix spinner garbling (AC-1, AC-2)

    1. In src/commands/run.ts (~line 1665), add configureUI({ verbose: true }) when config.verbose is true. This switches shouldAnimate() → false, using TextSpinner (line-based output, no cursor control).

    Phase 2: Suppress verbose noise (AC-3)

    1. In src/lib/workflow/state-manager.ts, remove the verbose log from saveState() (lines 138-140). The operation-level logs (phase transitions, issue init, etc.) already provide the meaningful signals.

    2. In src/lib/workflow/metrics-writer.ts, remove the verbose log from saveMetrics() (lines 129-131). Keep the recordRun() verbose log which provides operation-level info.

    Phase 3: Verify remaining verbose messages (AC-4)

    1. Confirm these operator-useful messages are preserved:
      • 📊 Phase X → Y for issue #N
      • 📊 Issue #N status → X
      • 📊 Initialized issue #N: title
      • All other operation-level logs

    Scope: 3 files, ~5 lines changed. Minimal risk.

    Non-Goals

    • Not adding a --debug verbosity level (can be done later if needed)
    • Not changing LogWriter verbose messages (those are file-write confirmations, less noisy)
    • Not changing the spinner pause/resume mechanism for streaming output (already works correctly)

    Verification Criteria

    AC Method Scenario
    AC-1 Unit Test Verify configureUI is called with verbose: true when verbose mode enabled
    AC-2 Integration Test Run with --verbose --dry-run and verify no garbled output
    AC-3 Unit Test Verify saveState() no longer calls console.log
    AC-4 Unit Test Verify updatePhaseStatus() still logs phase transitions when verbose
    AC-5 Unit Test Verify configureUI NOT called with verbose when verbose mode disabled

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: disabled
    Reasoning: Small, focused bug fix with clear scope. No UI changes.

  3. added a commit that references this issue on Feb 15, 2026
    d1bcc39
  4. admarble commented on Feb 15, 2026

    @admarble
    ContributorAuthor

    /fullsolve Complete

    Issue: #282 — Spinner + verbose log interleaving garbles terminal output
    Status: READY_FOR_MERGE

    Summary

    Two fixes for --verbose mode terminal garbling:

    1. Propagate verbose to cli-ui — Added ui.configure({ verbose: true }) in run.ts so spinners use TextSpinner (line-based console.log()) instead of AnimatedSpinner (ora with \r/ANSI cursor control). This eliminates the collision between spinner updates and verbose log output.

    2. Suppress noise — Removed repetitive 📊 State saved and 📊 Metrics saved messages from saveState()/saveMetrics(). These fired 10+ times per run and buried useful signals. All 12 operator-useful verbose messages (phase transitions, status changes, etc.) are preserved.

    AC Coverage

    AC Description Status
    AC-1 Verbose messages don't overwrite/interleave with spinner ✅ MET
    AC-2 Worktree paths and phase progress always readable ✅ MET
    AC-3 Repetitive low-value messages suppressed ✅ MET
    AC-4 Phase transitions and status changes remain visible ✅ MET
    AC-5 Non-verbose mode unaffected ✅ MET

    Quality

    • Build: ✅ Pass
    • Lint: ✅ Pass (0 errors, 0 warnings)
    • Tests: ✅ 1218/1218 passed
    • CI: ✅ 6/6 checks passed
    • Type issues: 0
    • Deleted tests: 0
    • Files changed: 3 (+7/-8 lines)

    PR

    PR: #284

  5. added 2 commits that reference this issue on Feb 15, 2026
    7dae48d
    c81e07a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions