Skip to content

fix(#656): wire renderer pause/resume into phase execution - #659

Merged
admarble merged 1 commit into
mainfrom
feature/656-fix-cli-renderer-pause-resume-is-dead-code-batch-e
May 17, 2026
Merged

admarble merged 1 commit into
mainfrom
feature/656-fix-cli-renderer-pause-resume-is-dead-code-batch-e

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

  • batch-executor.ts now passes a PhasePauseHandle to executePhaseWithRetry at all three call sites (spec, phase loop, /loop) — the renderer's pause() / resume() protocol was dead code in production because the optional argument was always undefined.
  • Under --verbose, the live zone now clears (logUpdateClear()) before SDK output streams in and redraws after the agent call completes, eliminating the visual collision between the 1Hz frame and verbose subprocess text.
  • PhasePauseHandle moved from phase-executor.ts into workflow/types.ts; BaseRenderer implements it directly (no factory).

Pre-PR AC Verification

AC Source Description Status Evidence
AC-1 Original batch-executor.ts at all three call sites passes a PhasePauseHandle derived from the active TTYRenderer ✅ Implemented src/lib/workflow/batch-executor.ts:549, :815, :968; verified by tests in batch-executor.test.ts ("#656 AC-1")
AC-2 Original The handle calls renderer.pause() before subprocess execution starts and renderer.resume() after ✅ Implemented Recorder-based ordering test in phase-pause-handle.test.ts (pause → driver-end → resume)
AC-3 Original Manual smoke test in verbose mode: live zone quiesces during streaming ✅ Implemented (automated substitute per spec) Same ordering test as AC-2 acts as the automated equivalent suggested by the /spec comment
AC-4 Original Unit test: verify spinner.pause was called when verbose output is generated ✅ Implemented phase-pause-handle.test.ts "#656 AC-2/AC-4" group — exercises real executePhase with a mocked driver

Files Changed

  • src/lib/workflow/types.ts — PhasePauseHandle definition + threaded through BatchExecutionContext, IssueExecutionContext
  • src/lib/workflow/phase-executor.ts — import PhasePauseHandle from types.ts instead of defining locally
  • src/lib/workflow/run-orchestrator.ts — RunInit + OrchestratorConfig gain phasePauseHandle?; threaded through executeOneIssue
  • src/lib/workflow/batch-executor.ts — destructure phasePauseHandle from context; pass as the spinner argument at all three executePhaseWithRetry call sites
  • src/lib/cli-ui/run-renderer.ts — BaseRenderer implements PhasePauseHandle
  • src/commands/run.ts — pass phasePauseHandle: renderer ?? undefined for both TUI and standard paths
  • src/lib/workflow/phase-pause-handle.test.ts — new test file (5 cases) covering AC-2 / AC-3 / AC-4
  • src/lib/workflow/batch-executor.test.ts — new "fix(cli): renderer pause/resume is dead code — batch-executor never passes spinner argument #656 AC-1" describe block (3 cases) covering handle forwarding at all sites
  • CHANGELOG.md — [Unreleased] / Fixed entry

Test plan

  • npm run build — passes
  • npm run lint — passes
  • npx vitest run src/lib/workflow/ src/lib/cli-ui/ src/commands/ — 1264/1266 pass; the 1 failure (prompt-wait.test.ts ENOENT race) exists on main and is unrelated to this PR
  • AC-1: handle forwarded at spec/exec/qa/loop call sites
  • AC-2: pause precedes first stdout chunk, resume runs after driver returns, debounced to one pair per phase, quiet mode never calls either
  • AC-3 (automated substitute): ordering test asserts logUpdateClear-style pause precedes driver output and resume follows
  • AC-4: driver receives an onOutput callback that fires spinner.pause on first chunk
  • Manual smoke in npx sequant run <issue> --verbose (HITL — deferred per /spec; automated substitute covers the assertion)

Notes

  • AC-3 disposition: per the /spec comment ("either is acceptable; do not block the PR on producing a manual smoke transcript"), this PR uses the automated equivalent — the recorder-based ordering test in phase-pause-handle.test.ts asserts the pause → driver-output → resume sequence. The optional manual transcript is left for follow-up if desired.
  • The handle is wired via type-only inheritance (implements PhasePauseHandle) rather than a getPhasePauseHandle() factory, matching the design preference in the /spec comment (renderer's pause/resume already match the shape).
  • executePhaseWithRetry's spinner parameter name is preserved to minimize churn; new code refers to it as phasePauseHandle at the call-site level.

Closes #656

`batch-executor.ts` never passed the `spinner` argument to
`executePhaseWithRetry`, making `TTYRenderer.pause()` / `resume()` dead
code under `--verbose`. The live zone redraw collided with streaming
Claude SDK text.

- Move `PhasePauseHandle` from `phase-executor.ts` into
  `workflow/types.ts` so the cli-ui layer can implement it without the
  workflow layer reaching back into cli-ui.
- `BaseRenderer implements PhasePauseHandle` — pure type assertion;
  `pause()` / `resume()` already had the correct semantics
  (`onPause` → `logUpdateClear`, `onResume` → `redraw`).
- Thread `phasePauseHandle?` through `RunInit` → `OrchestratorConfig` →
  `BatchExecutionContext` → `IssueExecutionContext`, mirroring the
  existing `onProgress` plumbing.
- Pass the handle at all three `executePhaseWithRetry` call sites in
  `batch-executor.ts` (spec, phase loop, /loop).
- Wire `phasePauseHandle: renderer ?? undefined` at the `run.ts`
  composition root for both the TUI and standard paths. Quiet / TUI
  modes naturally fall through with `undefined`.
- Tests:
  - AC-1: handle forwarded at spec / exec / qa / loop call sites
    (`batch-executor.test.ts`).
  - AC-2: pause precedes the first stdout chunk; resume runs after the
    driver returns; debounced to a single pair per phase; stderr path
    also triggers pause; quiet mode never calls either
    (`phase-pause-handle.test.ts`).
  - AC-4: driver receives `onOutput`, isolating the SDK-boundary wiring
    assertion.
  - AC-3 substitute (automated): the AC-2 ordering test asserts the
    `logUpdateClear` → driver-output → `redraw` sequence via the
    `pause` / `resume` recorder.

Entire-Checkpoint: eba281a09bec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cli): renderer pause/resume is dead code — batch-executor never passes spinner argument

1 participant