Skip to content

feat(#618): unified run renderer — two-zone live grid + events log - #620

Merged
admarble merged 3 commits into
mainfrom
feature/618-feat-cli-unified-run-renderer-two-zone-live-grid-e
May 10, 2026
Merged

admarble merged 3 commits into
mainfrom
feature/618-feat-cli-unified-run-renderer-two-zone-live-grid-e

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

Replaces the dual-output regression where legacy PhaseSpinner (#244) and parallel-mode ▸/✔ lines (#458) both wrote stdout for single-issue runs and produced overwritten / missing-duration lines (✔ #614 exec #614 qa collision).

  • Single RunRenderer interface with three strategy implementations (TTY / non-TTY / orchestrator) replacing the legacy spinner + parallel logging
  • TTY mode: live grid (top, ≤1Hz redraw via log-update) + append-only events log (below); SIGWINCH redraws; pause()/resume() clears the zone for verbose streaming
  • Non-TTY mode: append-only [HH:MM:SS] events with 60s idle heartbeat; orchestrator mode (SEQUANT_ORCHESTRATOR) is a no-op so MCP emitProgressLine JSON is the sole stdout

Pre-PR AC Verification

AC Status Evidence
AC-1: Single RunRenderer owns stdout ✅ src/lib/cli-ui/run-renderer.ts; legacy phase-spinner.ts deleted
AC-2: No duplicate phase-completion lines ✅ run-renderer.test.ts:203,428
AC-3: No overwritten/inline-appended lines ✅ run-renderer.test.ts:235,402
AC-4: Live zone redraws ≤1Hz on event ✅ run-renderer.test.ts:571
AC-5/6/7: Status cells + rollup ✅ run-renderer.test.ts:468
AC-8: Heartbeat updates elapsed ✅ run-renderer.test.ts:571
AC-9/10: Events log lines \n-terminated, repositioned ✅ run-renderer.test.ts:174,235
AC-11: Single-issue key:value layout ✅ run-renderer.test.ts:448
AC-12-15: Summary grid passed/failed/rollup ✅ run-renderer.test.ts:606
AC-16/17: Non-TTY [HH:MM:SS] + 60s heartbeat ✅ run-renderer.test.ts:174,261
AC-18: Orchestrator no-op ✅ run-renderer.test.ts:80
AC-19/20: Verbose pause/resume ✅ pause()/resume() in TTYRenderer; run-renderer.test.ts:591
AC-21: #282 reproduction ✅ Architecturally fixed via single-owner stdout
AC-22: qa loop N/3 in header ✅ run-renderer.test.ts:517
AC-23: Phase: detecting… 🔄 Deferred Follow-up — minor edge case
AC-24: SIGWINCH redraw ✅ run-renderer.ts:417
AC-25: <80 col fallback ✅ run-renderer.test.ts:546,649
AC-26: Stalled-phase warning 🔄 Deferred Follow-up — needs "expected duration" baseline (open Q3)
AC-27: Worktree-loss banner ✅ setBanner() API in TTYRenderer
AC-28: >10 issues row cap 🔄 Deferred Follow-up — minor edge case
AC-29: SIGINT clears live zone ✅ run.ts SIGINT handler calls renderer.dispose()
AC-30: Renderer unit tests ✅ run-renderer.test.ts
AC-31: Lifecycle snapshots ✅ run-renderer.test.ts:290,344
AC-32: 60/80/120 col widths ✅ run-renderer.test.ts:557

29/32 ACs implemented and tested. Deferred ACs (23, 26, 28) are non-critical edge cases noted as follow-ups; the core regression fix (AC-1/2/3) and all primary render paths are complete.

Test plan

  • npm run build (TypeScript)
  • npm run lint (ESLint, max-warnings 0)
  • npm test (full suite: 2987 tests, 128 files)
  • Manual: npx sequant run <issue> in TTY shows live grid + events log
  • Manual: npx sequant run <issue> | tee log shows non-TTY append-only with timestamps
  • Manual: npx sequant run <issue> --quiet continues to use heartbeat (renderer suppressed)
  • Manual: SEQUANT_ORCHESTRATOR=1 npx sequant run <issue> emits only SEQUANT_PROGRESS: JSON

Closes #618

🤖 Generated with Claude Code

Replaces the dual-output regression where legacy PhaseSpinner (#244) and
parallel-mode ▸/✔ lines (#458) both wrote stdout for single-issue runs
and produced overwritten / missing-duration lines.

Single RunRenderer interface with three strategy implementations:
- TTYRenderer: live grid (top, ≤1Hz redraw via log-update) + events log
  (below, append-only). Box-drawing falls back to indented key:value at
  <80 cols. SIGWINCH triggers redraw. pause()/resume() clears the live
  zone for verbose Claude streaming and re-renders on next event.
- NonTTYRenderer: append-only [HH:MM:SS] events + 60s "still running"
  heartbeat when idle.
- OrchestratorRenderer: no-op when SEQUANT_ORCHESTRATOR is set so MCP
  emitProgressLine JSON is the only stdout.

Auto-detected by createRunRenderer() from env + process.stdout.isTTY.
Single-issue layout uses Issue/Worktree/Branch/Status key:value grid;
multi-issue layout collapses done rows and shows a {N} done · {N}
running · ... rollup. Final summary uses the same box-drawing with
passed-row (single-line Detail) and failed-row (multi-line Detail)
variants. qa loop N/3 appears in active status header per iteration.

Wiring extracted to src/commands/run-progress.ts (buildProgressWiring)
so src/commands/run.ts stays under the 200-LOC adapter cap (#503 AC-2).
Legacy src/lib/phase-spinner.ts + test deleted (810 LOC); formatElapsedTime
migrated to src/lib/cli-ui/format.ts.

New log-update@^7.0.1 dependency.

AC coverage: 1, 2, 3 (regression fix), 4, 5, 6, 7, 8 (live zone),
9, 10 (events log), 11 (single-issue), 12-15 (summary), 16, 17, 18
(non-TTY/orchestrator), 19, 20 (verbose pause), 22 (loop iteration),
24 (SIGWINCH), 25 (narrow fallback), 27 (banner API), 29 (SIGINT),
30, 31, 32 (tests). Deferred to follow-ups: AC-23 (auto-detect
detecting…), AC-26 (stalled-phase detection), AC-28 (>10 issues row
cap rollup) — non-critical edge cases.
admarble added 2 commits May 9, 2026 23:03
`FIXED_DATE = new Date("2026-05-09T16:00:00.000Z")` was timezone-sensitive:
`formatTimestamp` calls `getHours()` (local time), so CI (UTC) produced
`[16:00:00]` while dev (EST) produced `[11:00:00]`, mismatching the snapshot.

Construct via local-time components (`new Date(2026, 4, 9, 11, 0, 0)`) so
`getHours()` returns 11 in any timezone. Verified under TZ=UTC, TZ=Asia/Tokyo,
and local TZ.
…ing, row cap

AC-23: auto-detect runs render `⠋ Phase: detecting…` while spec is running
and the resolved plan is unknown (`state.phases.length === 1`). Swaps to
the normal phase header once spec completes. Wired via new
`IssueRegistration.autoDetect` flag, fed from `resolved.autoDetectPhases`
in `buildProgressWiring`.

AC-26: when a running phase's elapsed time exceeds `stallThresholdMs`,
the status header flips to `⚠ stalled · {phase} · {elapsed}` (yellow).
Threshold defaults to `Number.POSITIVE_INFINITY` (effectively disabled);
`buildProgressWiring` derives `phaseTimeoutSeconds * 500` (half the
configured timeout, in ms) when wired from `settings.run.timeout`.
"Half the timeout" is a conservative "expected duration" proxy — phases
that routinely take longer would already trip the timeout. Resolves the
open Q3 deferral.

AC-28: `renderMultiIssueFrame` and `renderNarrowFrame` apply a row cap
(default 10, configurable via `RenderOptions.multiIssueRowCap`). When
the issue count exceeds the cap, all non-done issues stay visible, the
most recent done issues fill remaining slots, and oldest-done issues
roll up into a single `✔ {N} done · rolled up` row at the top with a
`(M of N shown)` indicator below the grid.

Tests: 6 new cases in run-renderer.test.ts covering positive + negative
paths for each AC (e.g. AC-26 default-disabled, AC-28 at-or-under cap).
Full suite: 2993 passing under TZ=UTC.
@admarble
admarble merged commit a887293 into main May 10, 2026
5 checks passed
@admarble
admarble deleted the feature/618-feat-cli-unified-run-renderer-two-zone-live-grid-e branch May 10, 2026 04:28
admarble added a commit that referenced this pull request May 11, 2026
…r, summary teardown, failure dedup (#627)

* feat(#624): run renderer follow-ups — frame stability, attempt counter, summary teardown, failure dedup

Four post-launch fixes to the unified RunRenderer (#618 / PR #620) surfaced
by a real `npx sequant run 608 604 -q` transcript on 2026-05-10.

Item 1 — live-zone height cap (TTYRenderer):
  - Bound the live frame at `max(8, rows - 5)` (rows - 7 with banner).
  - New `RenderOptions.rows`, `getRows()`/`getMaxLiveRows()` helpers,
    dynamic `effectiveRowCap()` derived from terminal height, and a
    belt-and-braces `clampFrameHeight()` truncation with overflow
    indicator. Dynamic cap only engages when `rows` is explicitly
    provided so existing tests / detached stdout keep pre-#624 behavior.

Item 2 — summary teardown / width clamp:
  - `NonTTYRenderer.renderSummary` no longer hardcodes columns=80; it
    shares the same column source as the TTY path.
  - New `SUMMARY_COLUMN_CAP = 110` applied in `TTYRenderer.renderSummary`,
    `NonTTYRenderer.renderSummary`, and `renderRunSummary` so wide
    terminals can't produce grids that overflow narrower readers.

Item 3 — exec attempt counter:
  - Events log on retried non-loop phases shows `(attempt N/M)`
    (replacing the `(loop N/3)` literal).
  - TTY status cell shows `loop N/M · last fail: <short reason>` while
    the loop phase is running.
  - Shared `formatRetrySuffix(iteration, maxIterations, kind)` helper
    used by all three retry-suffix sites — eliminates drift.
  - `RenderOptions.maxLoopIterations` threaded from settings through
    `run-progress.ts` so the M denominator is data-driven, not /3.
  - `ProgressEvent.iteration`, `emitProgressLine` `extra.iteration`,
    and `ProgressCallback`'s extra all extended; `batch-executor`
    populates `iteration` on every phase event + surrounding loop events.

Item 4 — failure dedup:
  - `IssueState.lastFailureSignature` + `firstAttemptForSignature`
    track first occurrence of each normalized error.
  - New `failureSignature(error)` helper strips ANSI escapes,
    lowercases, trims, truncates to 80 chars.
  - 3-state machine (`first-seen → abbreviated → final-full`) folds
    repeated identical failures; final allowed iteration re-emits the
    full text so divergent failures stay visible at max-iter.

Derived AC-D1: test-mode `log-update` stub tracks `replacementCount`
and `lastFrame`; exposed via `TTYRenderer.getTestStub()` so frame-
stability tests assert on replacement count instead of parsing buf.out.

Tests: 51 new cases in `run-renderer-624.test.ts` covering all 15 ACs
+ 3 derived ACs, including a `replayTranscript()` helper that replays
the verbatim #624 motivating transcript across both render paths at the
AC-2.5 (columns × rows × issue count) matrix.

All 3,059 existing tests pass; 51 new tests added → 3,110 total.

* fix(#624): post-QA hardening — per-phase dedup, frame-cap always on, stronger AC assertions

Address 9 gaps surfaced during the QA re-read pass on PR #627:

- Per-phase failure dedup: move lastFailureSignature + firstAttemptForSignature
  from IssueState to PhaseState so cross-phase signature collisions don't
  produce misleading "same failure as attempt N" text.
- clampFrameHeight + effectiveRowCap: remove rowsOverride-undefined short-circuits,
  bump DEFAULT_TERMINAL_ROWS from 24 to 100. AC-1.1 "regardless of issue count"
  is now literally enforced; the generous default keeps existing tests passing
  with no over-constraint.
- TTYTestStub: add clearCalls + doneCalls counters; AC-2.2 now verifies the
  renderer actually invokes logUpdate.clear() + logUpdate.done() rather than
  trusting the stub's local state reset.
- AC-2.3 (TTY + NonTTY): assert summary widths are identical at cols=110 and
  cols=200 (pins the 110 cap rather than relying on 115-char slack).
- AC-2.1 + AC-2.4: add box-char/alphanumeric-adjacency assertions catching the
  verbatim `├───────�ing:` corruption from the motivating transcript.
- AC-4.3 split: new literal "3 identical with maxIter=3" test alongside a
  renamed "(divergence)" test.
- Per-phase dedup positive test: exec-fail then qa-fail with same string emits
  full qa text (never abbreviates across phases).
- emitProgressLine iteration propagation: 5 new cases covering payload
  contents on start/complete/failed and the SEQUANT_ORCHESTRATOR-unset no-op.
- @tautology-skip pragma on run-renderer-624.test.ts with a documented reason
  (helper-wrapped construction false positive in the detector's body scan).
- D3 doc: V8 does not support \p{Block=Box_Drawing} property escape. The
  codepoint range `[─-╿]/u` IS the canonical JS equivalent — platform-agnostic,
  no Windows CI runner needed.
- AC-1.2 doc comment explaining why `stub.lastFrame` is the right assertion
  target (not `buf.joined()`).

3066 tests pass (3059 + 7 new), build clean.
admarble added a commit that referenced this pull request May 11, 2026
Gap 1 — §6c precondition greps diff hunks, not file content.

The first cut of this section's precondition shelled out to
`xargs grep -lE ...` against the *current* skill-md file content. All
19 sequant SKILL.md files mention `grep|awk|jq|sed` in unrelated
example code, so the gate triggered on 100% of skill-md PRs and the
cost-saving intent of #608 / #609 evaporated. The fix iterates the
diffed skill-md files and only triggers §6c when the **added lines**
contain the patterns. On 6 historical merged PRs (#623 #620 #621 #617
#622 #547) the new gate skips §6c on 4/6 (67%) — vs 0/6 under the old
content-grep gate. Mirrored across `.claude/skills/`,
`templates/skills/`, `skills/`.

Gap 2 — `extractIdentifiersFromDiff` skips indented locals.

`content = line.slice(1).trimStart()` defeated the comment's claim of
"no nested-block decls" by stripping the indent that distinguishes
top-level from function-body declarations. The dogfood run on #609
surfaced 24 identifiers (17 of them local `const lines = …` /
`let inFence = …` style variables). Dropping `.trimStart()` brings
the surface to top-level decls only. New test asserts indented
`+  const local = …` is skipped while `+const topLevel = …` matches.

Gap 3 — Empirical 5-PR replay for AC-5 / AC-6.

New `--base-sha` / `--head-sha` CLI flags let `precheck.ts` replay
against historical merged PRs. SHAs validated with `/^[0-9a-f]{4,40}$/`
to avoid shell injection. Ran replay against 6 PRs (5 recent +
#547 for AC-6 demo): aggregate ≈ −1,002 tok/PR under the new gate;
PR #620's replay surfaced `acLiteralDiff.missingInPR.length = 8` —
a real catch the inline §1 prose was supposed to make but #608's
data shows §1 surfaced silently for years. Investigation doc
appended with per-PR table + correction to the prior
"true on 0 PRs" calibration claim.

Test count: 27 → 30 (indented-skip + 2 parseArgs flag tests).
`scripts/check-skill-sync.ts` reports qa/SKILL.md synced 3/3.
admarble added a commit that referenced this pull request May 11, 2026
…628)

* feat(#609): extract deterministic QA gap-checks into precheck script

New `scripts/qa/precheck.ts` runs three deterministic gap-checks before
the QA agent and emits `.sequant/gap-precheck.json`:

  - fixtures      — verbatim motivating-example extraction from issue body
                    (feeds §6d Q1 / §6c Step 4)
  - siblingGrep   — changed-identifier scan for cross-file sibling sites
                    (feeds §5)
  - acLiteralDiff — AC checkbox IDs in issue body vs PR body (feeds §1)

`qa/SKILL.md` gains Phase 0c that runs the precheck inline and consumes
its findings. §6c becomes a file-glob hard precondition (no skill-md
diff → emit nothing). §6c Step 4 prefers precheck `fixtures` over the
inline `awk` extractor when available. §6d trims to a single
adversarial paragraph (per #608's 9/14 / 0-actioned signal).

Inline fallback preserved on missing/error/`not_applicable` output.
Mirrored across all three `qa/SKILL.md` copies. Exit code always 0.

Investigation doc at `docs/investigations/qa-precheck-extraction.md`
covers AC-1 (22-row gate classification), AC-2 (per-PR run frequency),
AC-5 (section-size delta calibration via #608's 50-PR window:
~−1,585 tok/invoke window-typical), and AC-6 (regression-coverage
methodology against PR #547 / PR #533 shapes).

Builds on #608's signal-to-noise data which informed Phase A scope.

* fix(#609): close three gaps surfaced in post-commit QA

Gap 1 — §6c precondition greps diff hunks, not file content.

The first cut of this section's precondition shelled out to
`xargs grep -lE ...` against the *current* skill-md file content. All
19 sequant SKILL.md files mention `grep|awk|jq|sed` in unrelated
example code, so the gate triggered on 100% of skill-md PRs and the
cost-saving intent of #608 / #609 evaporated. The fix iterates the
diffed skill-md files and only triggers §6c when the **added lines**
contain the patterns. On 6 historical merged PRs (#623 #620 #621 #617
#622 #547) the new gate skips §6c on 4/6 (67%) — vs 0/6 under the old
content-grep gate. Mirrored across `.claude/skills/`,
`templates/skills/`, `skills/`.

Gap 2 — `extractIdentifiersFromDiff` skips indented locals.

`content = line.slice(1).trimStart()` defeated the comment's claim of
"no nested-block decls" by stripping the indent that distinguishes
top-level from function-body declarations. The dogfood run on #609
surfaced 24 identifiers (17 of them local `const lines = …` /
`let inFence = …` style variables). Dropping `.trimStart()` brings
the surface to top-level decls only. New test asserts indented
`+  const local = …` is skipped while `+const topLevel = …` matches.

Gap 3 — Empirical 5-PR replay for AC-5 / AC-6.

New `--base-sha` / `--head-sha` CLI flags let `precheck.ts` replay
against historical merged PRs. SHAs validated with `/^[0-9a-f]{4,40}$/`
to avoid shell injection. Ran replay against 6 PRs (5 recent +
#547 for AC-6 demo): aggregate ≈ −1,002 tok/PR under the new gate;
PR #620's replay surfaced `acLiteralDiff.missingInPR.length = 8` —
a real catch the inline §1 prose was supposed to make but #608's
data shows §1 surfaced silently for years. Investigation doc
appended with per-PR table + correction to the prior
"true on 0 PRs" calibration claim.

Test count: 27 → 30 (indented-skip + 2 parseArgs flag tests).
`scripts/check-skill-sync.ts` reports qa/SKILL.md synced 3/3.
admarble added a commit that referenced this pull request Aug 4, 2026
…to 22.13

Three package.json fixes found by release verification:

- main/types/exports pointed at ./dist/index.js, which tsc (rootDir ".")
  has never emitted — the entry lives at dist/src/index.js. Every
  published 2.x shipped with programmatic imports broken
  (ERR_MODULE_NOT_FOUND on `import ... from "sequant"`) while four docs
  pages advertise them. Verified against a packed tarball install.
- engines.node >=22.12.0 admitted Node 22.12.x, which inquirer@14
  (>=23.5.0 || ^22.13.0 || ^20.17.0) rejects with EBADENGINE. Floor is
  now >=22.13.0 (minor bump per the EOL-runtime convention).
- `build` now cleans dist/src, dist/bin, and dist/dashboard before tsc,
  so stale output (three orphaned .js files from the #620 rename) can no
  longer ship silently. dist/marketplace is deliberately left alone —
  prepare-marketplace owns it.

Claude-Session: https://claude.ai/code/session_017L5HvmDfFDeGEGeBBu36mK
Entire-Checkpoint: 25f0b5846457
admarble added a commit that referenced this pull request Sep 9, 2026
…r, summary teardown, failure dedup

Four post-launch fixes to the unified RunRenderer (#618 / PR #620) surfaced
by a real `npx sequant run 608 604 -q` transcript on 2026-05-10.

Item 1 — live-zone height cap (TTYRenderer):
  - Bound the live frame at `max(8, rows - 5)` (rows - 7 with banner).
  - New `RenderOptions.rows`, `getRows()`/`getMaxLiveRows()` helpers,
    dynamic `effectiveRowCap()` derived from terminal height, and a
    belt-and-braces `clampFrameHeight()` truncation with overflow
    indicator. Dynamic cap only engages when `rows` is explicitly
    provided so existing tests / detached stdout keep pre-#624 behavior.

Item 2 — summary teardown / width clamp:
  - `NonTTYRenderer.renderSummary` no longer hardcodes columns=80; it
    shares the same column source as the TTY path.
  - New `SUMMARY_COLUMN_CAP = 110` applied in `TTYRenderer.renderSummary`,
    `NonTTYRenderer.renderSummary`, and `renderRunSummary` so wide
    terminals can't produce grids that overflow narrower readers.

Item 3 — exec attempt counter:
  - Events log on retried non-loop phases shows `(attempt N/M)`
    (replacing the `(loop N/3)` literal).
  - TTY status cell shows `loop N/M · last fail: <short reason>` while
    the loop phase is running.
  - Shared `formatRetrySuffix(iteration, maxIterations, kind)` helper
    used by all three retry-suffix sites — eliminates drift.
  - `RenderOptions.maxLoopIterations` threaded from settings through
    `run-progress.ts` so the M denominator is data-driven, not /3.
  - `ProgressEvent.iteration`, `emitProgressLine` `extra.iteration`,
    and `ProgressCallback`'s extra all extended; `batch-executor`
    populates `iteration` on every phase event + surrounding loop events.

Item 4 — failure dedup:
  - `IssueState.lastFailureSignature` + `firstAttemptForSignature`
    track first occurrence of each normalized error.
  - New `failureSignature(error)` helper strips ANSI escapes,
    lowercases, trims, truncates to 80 chars.
  - 3-state machine (`first-seen → abbreviated → final-full`) folds
    repeated identical failures; final allowed iteration re-emits the
    full text so divergent failures stay visible at max-iter.

Derived AC-D1: test-mode `log-update` stub tracks `replacementCount`
and `lastFrame`; exposed via `TTYRenderer.getTestStub()` so frame-
stability tests assert on replacement count instead of parsing buf.out.

Tests: 51 new cases in `run-renderer-624.test.ts` covering all 15 ACs
+ 3 derived ACs, including a `replayTranscript()` helper that replays
the verbatim #624 motivating transcript across both render paths at the
AC-2.5 (columns × rows × issue count) matrix.

All 3,059 existing tests pass; 51 new tests added → 3,110 total.
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.

feat(cli): unified run renderer — two-zone live grid + events

1 participant