Repository navigation
Conversation
Surfaces a TTY liveness line and a stall warning during quiet runs so users can distinguish "agent working" from "process hung" without inspecting state.json or ps/lsof. - AC-1: TTY-only \r-rewritten line every 30s with elapsed + mtime age - AC-2: One-shot ⚠ warning when state.json mtime gap > 5m, resets on activity, fires in both TTY and non-TTY (CI logs benefit too) - AC-3: Single shared setInterval, fs.stat per active phase, fully suppressed when not quiet; ShutdownManager cleanup - AC-4: 21 unit tests + 8 integration tests against real state.json Liveness source: .sequant/state.json mtime (StateManager.saveState writes 3-10x per phase). Issue body's run-*.json premise was incorrect (LogWriter.finalize is the only writer); the spec design call-out caught this. Wired in src/commands/run.ts only when options.quiet && !tuiEnabled.
`stop()` previously called `dispose()` when `phases.size` hit 0, which set `stopped = true` and silently no-op'd every subsequent `start()`. In a single-issue sequential run (spec → stop → exec → stop → ...), this killed the heartbeat after the first phase — exactly the use case that closes #574 was supposed to cover. Parallel runs masked the bug because phases.size rarely drops to 0 between the staggered stop/start pairs. The 21-test suite missed it because parallel-mode tests start two phases first, and the lone stop()-using test terminates the lifecycle. Fix: in `stop()`, only clear the timer when phases empty out (no orphaned polls). Don't set `stopped = true`. Explicit dispose() from run.ts's `finally` block remains the terminal teardown path. Adds a sequential start → stop → start regression test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LivenessHeartbeat(src/lib/workflow/heartbeat.ts) closes the silent--q-window gap from issue feat(run): -q mode silent for entire phase duration — no liveness or stall signal #574 — TTY-only\r-rewritten heartbeat every 30s + one-shot stall warning when.sequant/state.jsonmtime gap exceeds 5m.StateManager.saveState()writes 3-10x per phase. The issue body'srun-*.json-mtime premise was wrong (LogWriter.finalize()is the only writer); the spec call-out caught this and routed tostate.jsoninstead.src/commands/run.tsonly whenoptions.quiet === true && !tuiEnabled. Single sharedsetInterval,unref-ed so it never keeps the event loop alive.try/finallycleanup on completion;ShutdownManagercleanup mirrorsPhaseSpinnerpattern.Pre-PR AC Verification
\rrewrite every 30s, no-op non-TTY)src/lib/workflow/heartbeat.ts:170-220(tick + writeHeartbeat); 5 unit tests cover TTY/non-TTY/format/stop/parallelheartbeat.ts:196-244(warningFired flag + writeStallWarning); 6 unit tests cover fire-once, no-rerun, reset, both modes, suffix present/absentheartbeat.ts:120-163(single setInterval, enabled gate, dispose); 6 unit tests (cadence, parallel, disabled, ShutdownManager registration)src/lib/workflow/heartbeat.test.ts(21 tests) +__tests__/integration/heartbeat.integration.test.ts(8 tests against real state.json on disk)Quality Plan Alignment
quiet === trueonly, whereonProgresswould otherwise beundefined— no\rinterleavingfs.statSync+ reuse offormatElapsedTimefromphase-spinner.tsTest plan
npm run build— passesnpm run lint— passes (max-warnings 0)npm test -- src/lib/workflow/heartbeat.test.ts— 21/21 passnpm test -- __tests__/integration/heartbeat.integration.test.ts— 8/8 passnpm test -- src/lib/workflow/— 804/804 pass (no regressions)npx sequant run <issue> -qin real TTY — heartbeat rewrites every 30snpx sequant run <issue> -q | cat— no heartbeat output⚠warning appears onceCloses #574