Repository navigation
Description
Summary
TTYRenderer.pause() / TTYRenderer.resume() are dead code in production. batch-executor.ts never passes the spinner argument to executePhaseWithRetry, so the renderer's pause/resume protocol — which onPause (logUpdateClear()) and onResume (redraw()) implement correctly — is never invoked.
Discovered during the #652 investigation (now tracked in #655).
Evidence
src/lib/workflow/phase-executor.ts defines:
interface PhasePauseHandle {
pause(): void;
resume(): void;
}
export async function executePhaseWithRetry(
...,
spinner?: PhasePauseHandle,
): Promise<...> { ... }src/lib/workflow/batch-executor.ts calls executePhaseWithRetry at three sites (lines 548, 813, 966). None of them pass the spinner argument. Because the parameter is optional, TypeScript accepts it silently.
src/lib/cli-ui/run-renderer.ts (~line 881):
protected onPause(): void {
this.logUpdateClear(); // erases the live zone so verbose output lands on clean stdout
}
protected onResume(): void {
this.redraw(); // re-establishes the live zone
}This is correctly designed but never reached.
Why it matters
In --verbose mode, the Claude SDK's text output is forwarded directly to process.stdout.write() (via config.onOutput). With pause/resume wired, the renderer would clear the live zone before subprocess-style output streams in. Without it, the live frame's 1Hz redraw collides with the verbose text — producing visual corruption in the live zone (not the event log).
In non-verbose mode (the default for npx sequant run ... -q), no SDK output reaches stdout, so the dead code doesn't currently produce visible harm. But the latent bug means any future feature that adds out-of-band stdout writes (live spinner annotations, agent progress streams, etc.) will have no quiescence protocol available — even though one exists.
Reproduction
- Run any phase in verbose mode:
npx sequant run <issue> --verbose - Observe the live zone redrawing while verbose text streams below it
- Expected: live zone disappears (paused) during verbose streaming, reappears after
- Actual: live zone keeps redrawing; output is interleaved
Acceptance criteria
-
batch-executor.tsat all three call sites passes aPhasePauseHandlederived from the activeTTYRenderer - The handle calls
renderer.pause()before subprocess execution starts andrenderer.resume()after - Manual smoke test in verbose mode: live zone quiesces during streaming
- Unit test: verify
spinner.pausewas called when verbose output is generated
Notes
- Could be tied to the renderer's
PhasePauseHandleinterface — perhapsTTYRenderershould expose a method that returns a handle (getPhasePauseHandle()) to keep encapsulation clean - The
PhasePauseHandleinterface lives inphase-executor.ts; the renderer doesn't currently know about it. Either move the interface up to a shared location or have the renderer implement it directly.
Activity
admarble commentedon May 17, 2026
Design preference for /spec
For the open architectural question in Notes: prefer
TTYRendererimplementsPhasePauseHandledirectly, with the interface extracted to a shared module.Rationale:
pause()/resume()methods already match thePhasePauseHandleshape — adding agetPhasePauseHandle()factory is an indirection for no real benefit.cli-ui→workflowtypes is one-way, no circular dep. The renderer consuming a workflow contract matches how the UI consumes other workflow types.batch-executor.tscan then pass the renderer instance directly at all 3 call sites (?? undefinedfalls out naturally for-qmode where the renderer isn't wired — seerun-progress.ts:46-49vs:59-60).Suggested layout:
PhasePauseHandlefromphase-executor.tsintosrc/lib/workflow/types.ts(or a dedicatedphase-pause-handle.tsif that file doesn't exist).TTYRenderer implements PhasePauseHandleinrun-renderer.ts.phase-executor.tsimports the interface from the new location.AC-3 note: "Manual smoke test in verbose mode" is HITL —
/execshould either defer it (track asAC-3 deferred, requires manual verification) or substitute an automated equivalent (e.g., spy onrenderer.pausecalls during a mocked verbose stream and assert the live zone is cleared before subprocess output writes). Either is acceptable; do not block the PR on producing a manual smoke transcript.admarble commentedon May 17, 2026
/spec — Plan (656)
Complexity: Standard (4 ACs, 3 directories) · Verdict: ✅ SCOPE_OK
Phases: exec → qa · Quality loop: off · testgen: skipped (bug label)
Plan
PhasePauseHandlefromsrc/lib/workflow/phase-executor.ts:19-22tosrc/lib/workflow/types.ts. Update the import inphase-executor.ts. Adopt the design preference from the issue comment: interface lives inworkflow/types.ts, not in a new dedicated file.implements PhasePauseHandletoBaseRenderer(src/lib/cli-ui/run-renderer.ts:119). Pure type assertion —pause()/resume()already exist and behave correctly (onPausecallslogUpdateClear;onResumecallsredraw).RunInit,OrchestratorConfig,BatchExecutionContext,IssueExecutionContextwithphasePauseHandle?: PhasePauseHandle. Mirror the existingonProgressplumbing convention.batch-executor.ts:548(spec),:813(phase loop),:966(loop). PassphasePauseHandleas thespinnerargument toexecutePhaseWithRetry.src/commands/run.tspassesphasePauseHandle: renderer ?? undefinedtoRunOrchestrator.run. Quiet/TUI modes naturally fall through withundefined.pause/resumeordering aroundexecutePhaseFn, including the error/finally path. AC-3: either HITL transcript in PR, or substitute the automated equivalent (assertlogUpdateClearprecedes mocked driver stdout writes).Verification
executePhaseWithRetryreceives the handle at spec, phase, and loop call sitespausecalled before driver execution,resumecalled after (incl. error paths)--verbosestreaming; substitute =logUpdateClearprecedes stdout writes in mocked stream testspinner.pauseinvoked whenconfig.onOutputfires during verbose modeOpen questions
Conflict risk
feature/652-fix-cli-renderer-bottom-output(open) editsrun-renderer.ts. This issue's edit there is one line (implements PhasePauseHandle). Land #652 first if close to merge; otherwise rebase.admarble commentedon May 17, 2026
/exec — Progress Update
PR: #659
Status: Implementation complete — ready for /qa
AC Coverage
batch-executor.ts:549,:815,:968— handle passed at all three call sites; 3 tests inbatch-executor.test.ts("#656 AC-1")phase-pause-handle.test.ts): pause → driver-end → resume, debounced to a single pair per phase, stderr path also triggers pausephase-pause-handle.test.tsAC-4 group — realexecutePhasewith mocked driver; SDK-boundary wiring assertedFiles Changed
src/lib/workflow/types.ts—PhasePauseHandleextracted here; added toBatchExecutionContext,IssueExecutionContextsrc/lib/workflow/phase-executor.ts— importsPhasePauseHandlefromtypes.tsinstead of defining locallysrc/lib/workflow/run-orchestrator.ts—RunInit,OrchestratorConfiggainphasePauseHandle?; threaded throughexecuteOneIssuesrc/lib/workflow/batch-executor.ts— destructuresphasePauseHandle, passes at all threeexecutePhaseWithRetrycall sitessrc/lib/cli-ui/run-renderer.ts—BaseRenderer implements PhasePauseHandle(single-line type assertion)src/commands/run.ts—phasePauseHandle: renderer ?? undefinedat both composition roots (TUI + standard)src/lib/workflow/phase-pause-handle.test.ts— new test file (5 cases)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)CHANGELOG.md—[Unreleased] / FixedentryChecks
npm run buildnpm run lintworkflow/,cli-ui/,commands/: 1264/1266 pass; 1 pre-existing ENOENT race inprompt-wait.test.ts(unrelated, verified onmain); 1 skipPre-PR Confidence Check
--verbosesmoke is deferred per the /spec comment's disposition — the automated ordering test substitutes for it but does not exercise a real terminal redraw. If reviewers want the HITL transcript before merge, it's a 1-minute test.run.tscomposition-root wiring is two one-line changes that are validated indirectly viaRunOrchestrator.runintegration tests; no dedicated test covers therenderer ?? undefinedselection. Acceptable because the type signature enforces the contract (the wiring would not compile otherwise) and theBaseRenderer implements PhasePauseHandlechange is a pure type assertion.Quality Plan Alignment
N/A — No Feature Quality Planning section in the /spec comment for this issue.
admarble commentedon May 17, 2026
QA Review for Issue #656
Size Gate
AC Coverage
batch-executor.tspassesPhasePauseHandleat all three call sitesbatch-executor.ts:555(spec),:821(phase loop),:975(/loop) — all forwardphasePauseHandle. 3 forwarding tests inbatch-executor.test.ts("#656 AC-1") assert the handle lands at every call.renderer.pause()before subprocess andrenderer.resume()afterphase-pause-handle.test.tsrecords order:pause → driver-start → driver-end → resume. Stderr path also pauses. Debounce-to-one-pair-per-phase verified (matches #283 guard).spinner.pauseinvoked when verbose output is generatedphase-pause-handle.test.ts("#656 AC-4") asserts driver receivesonOutputcallback; AC-2 ordering test covers the pause-on-fire behavior end-to-end.Coverage: 4/4 AC items fully met
Original ACs: 4/4 met
Derived ACs: None — no Feature Quality Planning section in /spec.
Manual Test Override
AC: AC-3
Requirement: Manual smoke test in
--verbosemode confirming live zone quiescesOverride: Yes
Justification: Equivalent unit test coverage — the AC-2 ordering test (
phase-pause-handle.test.ts) asserts the exact contract a manual smoke would observe:handle.pause()fires before the first stdout write fromcfg.onOutput, andhandle.resume()fires after the driver returns. The renderer'sonPauseislogUpdateClear()(clears the live zone) andonResumeisredraw()— both pre-existing and unit-tested elsewhere. The runtime composition (renderer ?? undefinedincommands/run.ts) is enforced by TypeScript via structural typing onPhasePauseHandle. Approved disposition from /spec comment: "Either is acceptable; do not block the PR on producing a manual smoke transcript."Risk Assessment: Low
Quality Plan Verification
Result: N/A — No Feature Quality Planning section in the /spec comment for this issue.
CI Status
typecheckvalidate-pluginvalidate-skillsbuild (20.x)build (22.x)CI Summary: 5 passed, 0 pending, 0 failed
CI-related AC items: None — no AC mentions CI explicitly.
Quality Metrics
any)Build Verification
Result: N/A —
npm run buildnot run locally; CItypecheck+build (20.x)+build (22.x)all SUCCESS on PR #659.Test Coverage Analysis
src/lib/workflow/types.tsphase-pause-handle.test.ts+batch-executor.test.tssrc/lib/workflow/phase-executor.tsphase-pause-handle.test.ts(new) + existingphase-executor.test.tssrc/lib/workflow/batch-executor.tsbatch-executor.test.ts(new "#656 AC-1" describe block)src/lib/workflow/run-orchestrator.tssrc/lib/cli-ui/run-renderer.tsBaseRenderer implements PhasePauseHandleis a pure type assertion; runtime methods covered by existing renderer testssrc/commands/run.tsRunOrchestrator.runintegration testsCoverage: 6/6 changed source files have direct or indirect test coverage
Critical paths without tests: None
New tests added: 8 cases (3 AC-1 forwarding + 5 AC-2/3/4 behavior). All 44 tests in
phase-pause-handle.test.ts+batch-executor.test.tspass locally.Code Review
Strengths:
PhasePauseHandlelives inworkflow/types.tssocli-uidepends on workflow (one-way, correct layer direction). No circular dep.BaseRenderer implements RunRenderer, PhasePauseHandle— pure type assertion (pause/resume already existed since feat(cli): unified run renderer — two-zone live grid + events #618 / Claude output truncation during phase streaming #283).batch-executor.executeBatch→runIssueWithLogging→executePhaseWithRetry).commands/run.ts) covers both TUI and standard paths uniformly withrenderer ?? undefined.RunRendererinterface already declaredpause()/resume()inrun-renderer-types.ts:117-119, so the handle satisfies structural typing without forcing the renderer interface to extendPhasePauseHandledirectly.[Unreleased] / Fixedis detailed and accurate.Issues:
Suggestions (non-blocking, optional follow-up):
resume()call atphase-executor.ts:702is positioned afterawait driver.executePhase()but is NOT inside a try/finally. If the driver were to throw (rather than return{ success: false }), the renderer would remain paused. This is pre-existing behavior on main — the pause/resume code was added in Claude output truncation during phase streaming #283 / feat(cli): unified run renderer — two-zone live grid + events #618 without the try/finally, just never wired to a live renderer. Now that the handle reaches a live renderer, the latent risk is exposed. A try/finally around the driver call (or atry/catchthat resumes before re-throwing) would close the gap. Suitable as a small follow-up issue; not a regression introduced by this PR.Test Quality Review
order[]array of pause/driver/resume events), not internals.child_process,agents-md, andgetDrivermocked — external/boundary mocks, not internal logic.vi.clearAllMocks()inbeforeEach.Issues Found: None.
Anti-Pattern Detection
Dependency Audit
Result: N/A —
package.jsonnot modified.Code Patterns
Critical Issues: 0
Warnings: 0
Call-Site Review
New exported functions detected: 0 (the change is type-passing wiring — no new functions exported).
Result: N/A.
Execution Evidence
Result: N/A — No
scripts/or CLI command files modified. All changes are library code undersrc/lib/+src/commands/run.ts(wiring through existing composition root). Verified via test suite:Script Verification Override
Result: N/A — No script files modified;
/verifynot applicable.Skill Command Verification
Result: N/A — No
.claude/skills/**/*.mdfiles modified.Detection Pattern Verification
Result: N/A — No pattern changes in skill markdown.
CLI Registration Verification
Result: N/A —
RunOptionsnot modified; no new CLI flags added. (PhasePauseHandleis an internal type, not a user-facing option.)Manual Test ACs
Manual Test Enforcement: 1/1 manual-test ACs addressed via approved override.
Smoke Test
Result: Not Required — change is internal wiring through an existing composition root; no new workflow surface. Same code paths exercised by every
sequant runinvocation are covered by the new 8 unit tests.CHANGELOG Verification
### Fixed)(#656))Result: CHANGELOG requirements met.
Risk Assessment
driver.executePhase()throws an uncaught exception (not the current pattern — drivers return{ success: false }), the renderer stays paused for the remainder of the run becausespinner?.resume()atphase-executor.ts:702is outside any try/finally. This is pre-existing behavior on main (the pause/resume block predates this PR — see Claude output truncation during phase streaming #283 / feat(cli): unified run renderer — two-zone live grid + events #618); this PR exposes the latent gap by wiring the handle to a live renderer for the first time.success: trueand observablecfg.onOutputinvocations; no test simulates an uncaught throw from the driver.executePhaseWithRetry(batch-executor.ts:551,:817,:971) — all updated symmetrically. No other production callers —run-compat.tsre-exports only; remaining matches are test files. Composition root has two paths (runCommand's TUI branch and standard branch) — both passrenderer ?? undefined.runIssueWithLoggingupdated; no adjacent calls in the same function with the same root cause (handle-missing pattern). Destructuring ofphasePauseHandlemirrored at every layer (executeBatch,runIssueWithLogging,executeOneIssuein run-orchestrator).Adversarial Re-Read
Findings: No blocking gaps. Scanned:
pause → driver-start → driver-end → resumeordering test inphase-pause-handle.test.ts:69-115. The test asserts the exact post-fix behavior, not a pre-fix repro. ✅expect()call (verified by reading the test file). No bug-repro mislabeled as validation. ✅origin/feature/656-..., no stashes, all 5 CI checks green at HEAD720fafa. ✅batch-executor.tsenumerated; no other production callers. Intra-file (§4 Q5) — none, single-function fix. ✅await driver.executePhase()in try/finally — flagged as an optional follow-up in the suggestions section, deliberately not bundled. ✅Status: Clean
Behavior-Rule Survival Check
Status: N/A — No AC asserts a behavior rule (
default | always | never | rule | behavior | skip); the detector does not trigger on the AC text in this issue.Verdict: READY_FOR_MERGE
All 4 ACs met (AC-3 via approved override per /spec disposition). 8 new test cases pass locally; full PR CI green (typecheck, build 20.x/22.x, validate-skills, validate-plugin). Wiring is minimal, symmetric, and correct: interface relocated cleanly to
workflow/types.ts, renderer satisfies the contract via existing methods, handle threaded throughRunInit → OrchestratorConfig → BatchExecutionContext → IssueExecutionContextmirroring the establishedonProgressplumbing convention. No new exported functions, no anti-patterns, no security-sensitive paths. The one latent gap (driver-throws leaves renderer paused) is pre-existing on main and worth a small follow-up, not a blocker for this PR.Documentation
[Unreleased] / Fixedwith full context and issue referenceNext Steps
await driver.executePhase()atphase-executor.ts:693in try/finally sospinner?.resume()fires even if the driver throws. Pre-existing latent risk now exposed by the live-renderer wiring; trivial to close.Documentation: Before merging, run
/docs 656if you want a feature documentation entry (recommended for internal-only fixes: skip).fix(#656): wire renderer pause/resume into phase execution (#659)
docs(#647): AC-1 capture — Mechanism #1 reproducing at 2181 occurrenc…
fix(#656): wire renderer pause/resume into phase execution