Skip to content

CLI UX: fix -q/-Q flag collision, make boxed Ink TUI the default for run (and confirm ready parity) #705

Closed

Description

@admarble

Problem

Two related CLI UX issues surfaced while running sequant run:

1. -q / -Q flag collision (footgun)

Commander short flags are case-sensitive, so bin/cli.ts currently has two near-identical short flags on run:

  • -q, --quiet (bin/cli.ts:254) → suppress output
  • -Q, --quality-loop (bin/cli.ts:238) → enable quality loop

A user running npx sequant run 665 -q intending to enable the quality loop instead silently enabled quiet mode. Two bad outcomes at once: no quality loop, and the live renderer is suppressed (see run-progress.ts:73 — the live renderer is only built when !quiet), so they got the old plain journal output and assumed the new UI was missing.

2. New boxed Ink TUI is opt-in for run

The boxed Ink TUI is only mounted when --experimental-tui is passed (run.ts:102-103). Default run falls back to the line-based phase-matrix renderer. The boxed TUI should be the default experience.

Desired behavior (decisions confirmed)

Flags

  • Free -q from quiet. --quiet becomes -s, --quiet (mnemonic: silent). -q no longer maps to quiet.
  • Quality loop responds to both -q and -Q. Keep -Q, --quality-loop as the primary; add -q as an alias that normalizes to options.qualityLoop in runCommand. (Commander 14 only allows one short flag per option definition, so implement -q as a hidden alias option and OR it into qualityLoop at the top of runCommand.)
  • Both -q and -Q produce identical behavior (quality loop on); verified by a CLI parse test.

Boxed TUI as default for run

  • Boxed Ink TUI is the default when stdout is a TTY and output is not suppressed: tuiEnabled = (options.tui !== false) && isTTY.
  • Add --no-tui to opt out → falls back to the line-based phase-matrix renderer (run-progress.ts path).
  • Non-TTY / piped output still safely degrades to the phase-matrix / linear renderer (no Ink writes corrupting pipes).
  • Keep --experimental-tui as a hidden, no-op alias (it's now the default) so existing scripts/muscle-memory don't break.
  • --quiet / -s continues to suppress the renderer entirely (heartbeat-only), regardless of TUI default.

sequant ready parity

Files in scope

  • bin/cli.ts — flag definitions (run command ~line 223-318)
  • src/commands/run.ts — tuiEnabled computation (line 102), qualityLoop normalization
  • src/commands/run-progress.ts — renderer gating (line 73)
  • src/lib/workflow/types.ts — RunOptions (quiet, qualityLoop, experimentalTui, new tui/alias fields)
  • src/commands/ready.ts — verify TUI parity (line 144, 171-182)

Acceptance Criteria summary

  1. -q and -Q both enable the quality loop; neither enables quiet.
  2. --quiet is reachable via -s (and long form); suppresses the renderer.
  3. sequant run shows the boxed Ink TUI by default on a TTY.
  4. --no-tui opts out to the phase-matrix renderer; non-TTY auto-degrades.
  5. --experimental-tui still parses (hidden no-op alias).
  6. sequant ready renders the same full boxed TUI as run.
  7. Help text and any docs/README references updated to reflect the new flags.

Activity

  1. added
    enhancement
    cli
    ui
    on Jun 3, 2026
  2. admarble commented on Jun 3, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (7 ACs, 3 directories)

    AC Quality Check

    Machine AC parse returned 0 (the - [ ] checkboxes under Desired behavior lack AC-N IDs; the authoritative list is the numbered Acceptance Criteria summary 1–7). ACs are concrete and measurable — no vague/unmeasurable flags. One title/body tension: AC-3 says boxed TUI is default "when stdout is a TTY and output is not suppressed," but the formula given (tuiEnabled = (options.tui !== false) && isTTY) omits the !quiet term that the last flag checkbox requires (see Open Question 1).


    Scope Assessment

    Non-Goals: ⚠️ No explicit Non-Goals section. Implicit boundary is sound: terminal-Ink rendering + run flag remap only — no web UI, no renderer internals rewrite.

    Metric Value Status
    Feature count 2 (flag remap; TUI-default + ready parity) ⚠️
    AC items 7 ⚠️
    Directory spread 3 (bin/, src/commands/, src/lib/workflow/) ✅

    Verdict: ⚠️ SCOPE_WARNING — cohesive single subsystem (CLI run rendering/flags), tightly coupled, well-specified. Keep as one issue; do not split.


    Acceptance Criteria

    AC-1: -q and -Q both enable the quality loop; neither enables quiet

    Verification: Integration Test (CLI parse). Reverses existing #658 test cli.integration.test.ts:162 which pins -q→--quiet — that test must be rewritten.
    Scenario: Given run 705 -q and run 705 -Q → When parsed → Then both set options.qualityLoop=true and neither sets quiet.
    Assumptions: Commander 14.0.3 allows only one short per Option, so -q is a hidden alias Option ORed into qualityLoop at the top of runCommand.

    AC-2: --quiet reachable via -s (and long form); suppresses the renderer

    Verification: Integration Test (run --help shows -s, --quiet) + Unit (heartbeat-only path).
    Scenario: Given -s/--quiet → Then renderer + TUI suppressed, LivenessHeartbeat is the only liveness signal.

    AC-3: sequant run shows the boxed Ink TUI by default on a TTY

    Verification: Unit Test on the tuiEnabled computation (run.ts:101) with mocked isTTY.
    Scenario: Given TTY, no --no-tui, not quiet → Then tuiEnabled=true and renderTui mounts.

    AC-4: --no-tui opts out to phase-matrix renderer; non-TTY auto-degrades

    Verification: Unit Test on tuiEnabled (--no-tui → false; non-TTY → false → run-progress.ts line renderer).

    AC-5: --experimental-tui still parses (hidden no-op alias)

    Verification: Integration Test — flag parses without error; hidden from --help.

    AC-6: sequant ready renders the same full boxed TUI as run

    Verification: Manual/Integration (confirmation). Both already mount the same renderTui(provider: SnapshotProvider) (ui/tui/index.ts:32) — run via orchestrator, ready via ReadySnapshotAdapter. Structurally identical for a single issue. Confirm no degraded/single-row divergence; close gap only if found.

    AC-7: Help text and docs/README references updated

    Verification: Manual/Docs check across ALL locations.
    Scope: README.md:22 (TUI-default framing). docs/features/quiet-mode-heartbeat.md is built entirely around -q=quiet (title, every example) → -q→-s throughout, and rewrite the "on by default … without --experimental-tui" gating prose (TUI is now default; heartbeat path is now -s --no-tui or non-TTY).


    Implementation Plan

    Phase 1: Flag remap (-q/-Q/-s)

    1. bin/cli.ts (~254): change -q, --quiet → -s, --quiet. Add a hidden alias Option carrying short -q (e.g. new Option("-q, --quality-loop-alias").hideHelp()) so Commander accepts -q without colliding with -Q, --quality-loop (238).
    2. src/commands/run.ts top of runCommand (~22): options.qualityLoop = Boolean(options.qualityLoop || options.qualityLoopAlias); before any consumer reads it.
    3. src/lib/workflow/types.ts: add the alias field to RunOptions.

    Phase 2: Boxed TUI as default

    1. bin/cli.ts: add --no-tui (Commander surfaces options.tui=false); convert --experimental-tui to a hidden no-op alias (.hideHelp()), keep parsing.
    2. src/commands/run.ts:101: tuiEnabled = (options.tui !== false) && Boolean(process.stdout.isTTY) && !options.quiet; (the !quiet term honors AC-2 — see Open Q1).
    3. Confirm run-progress.ts:61 heartbeat gate (quiet && !tuiEnabled) still yields heartbeat-only under -s (true once step 5 forces tuiEnabled=false when quiet).
    4. RunOptions: add tui?: boolean; keep experimentalTui?.

    Phase 3: Docs + tests

    1. Rewrite fix(cli): -q is short for --quality-loop, not --quiet — silently bypasses quiet-mode rendering #658 tests (AC-1/AC-2/AC-5 assertions). Add parse tests for -q/-Q/-s/--no-tui/--experimental-tui.
    2. AC-7 docs sweep (README + heartbeat doc).

    Rule Touchpoints

    AC Touchpoint Snippet
    AC-1 bin/cli.ts run cmd hidden -q alias Option
    AC-1 src/commands/run.ts:~22 OR alias into options.qualityLoop
    AC-3/4 bin/cli.ts --no-tui default + hidden --experimental-tui
    AC-3/4 src/commands/run.ts:101 tuiEnabled computation
    AC-2 run.ts:101 + run-progress.ts:61 quiet must force tuiEnabled=false, then quiet && !tuiEnabled gives heartbeat

    Design Review

    1. Where does this logic belong? Flag surface in bin/cli.ts; flag normalization (-q→qualityLoop, quiet→suppress) in runCommand as the single composition root, matching how quiet/experimentalTui already feed buildProgressWiring.
    2. Simplest correct approach? Hidden alias Option + one OR line; one !quiet term added to the existing tuiEnabled expression. No renderer changes — renderTui is already shared (AC-6).
    3. Existing pattern? Follows fix(cli): -q is short for --quality-loop, not --quiet — silently bypasses quiet-mode rendering #658's deliberate short-flag pinning (now inverted) and the existing experimentalTui/quiet Boolean-coercion pattern.
    4. What would a senior reviewer challenge? "Does quiet still beat the new TUI default?" — yes, via the !quiet term (step 5). "Did you update the heartbeat doc, not just README?" — yes (AC-7). "Hidden alias long-name collision?" — pick a non-conflicting long name.

    Open Questions

    1. tuiEnabled formula vs AC-2. The issue's formula omits !quiet, but the final flag checkbox says -s suppresses the renderer "regardless of TUI default." Recommendation: include && !options.quiet (Plan step 5). Impact if wrong: -s on a TTY would still mount the full TUI, contradicting AC-2 and disabling the heartbeat.
    2. ui label → browser test? This is terminal Ink, not web. Recommendation: add no-browser-test; do not add the test phase.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: disabled (small, well-bounded surface; SCOPE_WARNING does not force it here given single subsystem)
    Reasoning: Tiny logic surface with an existing test home (cli.integration.test.ts). Skipping testgen avoids stale untracked stubs; tests are written inline in exec. Skip test phase — terminal TUI, not browser.


    Label Review

    Current: enhancement, cli, ui
    Recommended: enhancement, cli, ui, planned, no-browser-test
    Reason: ui here is terminal Ink rendering; no-browser-test prevents the test phase from being auto-added.
    Quality Loop: Won't auto-enable (no complex/refactor label; cohesive scope).

    → gh issue edit 705 --add-label no-browser-test


  3. added
    planned
    on Jun 3, 2026
  4. admarble commented on Jun 3, 2026

    @admarble
    ContributorAuthor

    Exec Progress Update (#705)

    Implemented and pushed as PR #706.

    AC Coverage

    AC Description Status
    AC-1 -q/-Q both enable quality loop; neither enables quiet ✅ Implemented
    AC-2 --quiet reachable via -s; suppresses renderer ✅ Implemented
    AC-3 Boxed Ink TUI default on a TTY ✅ Implemented
    AC-4 --no-tui opts out; non-TTY auto-degrades ✅ Implemented
    AC-5 --experimental-tui parses (hidden no-op) ✅ Implemented
    AC-6 ready renders same full boxed TUI as run ✅ Confirmed (no gap)
    AC-7 Help text + docs/README updated ✅ Implemented

    Key files changed

    • bin/cli.ts — -s, --quiet; hidden -q quality-loop alias; --no-tui; hidden --experimental-tui no-op
    • src/commands/run.ts — alias normalization + resolveTuiEnabled wiring
    • src/commands/run-flags.ts (new) — normalizeQualityLoop, resolveTuiEnabled (pure, unit-tested)
    • src/lib/workflow/types.ts — tui?, qualityLoopAlias? fields; experimentalTui re-documented as no-op
    • Tests: run-flags.test.ts (new), reversed fix(cli): -q is short for --quality-loop, not --quiet — silently bypasses quiet-mode rendering #658 binding in cli.integration.test.ts, updated run-tui.integration.test.ts
    • Docs: README, run-command.md, quiet-mode-heartbeat.md, run-renderer.md, experimental-tui-dashboard.md, CHANGELOG

    AC-6 confirmation

    Both run (run.ts:140) and ready (ready.ts:182) mount the identical renderTui(provider) from src/ui/tui/index.ts → same App component, same full-box treatment. The only difference is the provider/data source (multi-row for run, single-row for ready), which is data-driven, not a degraded path. No code change required.

    Checks

    • npm run build ✅ · npm run lint ✅ (0 warnings) · 69 tests passed across all affected files
    • One pre-existing flaky failure in prompt-wait.test.ts (relay-inbox timer race) is unrelated — fails identically on the clean base; this PR does not touch the prompt/relay system.

    Design note (Open Question 1 resolved)

    Followed the spec recommendation to include && !options.quiet in tuiEnabled so -s suppresses the TUI on a TTY (honors AC-2). The issue body's formula omitted this term; the final flag checkbox required it.

    → Next: /qa 705

  5. added
    no-browser-test
    on Jun 3, 2026
  6. admarble commented on Jun 3, 2026

    @admarble
    ContributorAuthor

    /test — Not Applicable (no browser surface)

    Browser-based testing does not apply to #705. This is a terminal Ink TUI + CLI flag change; the project has no web surface for Chrome DevTools to drive:

    • No app/ / pages/ / components/ / public/ directories.
    • npm run dev is tsx bin/cli.ts (the CLI itself, not an HTTP server); no Next/React-DOM/Vite/Astro/Express.
    • The ui label here denotes terminal Ink rendering, not web UI.

    This matches the /spec recommendation ("Skip test phase — terminal TUI, not browser"). Applied the no-browser-test label so future orchestrated runs skip this phase.

    Coverage

    Metric Count
    Browser tests run 0 (N/A — no web surface)
    Passed / Failed / Blocked 0 / 0 / 0
    Bugs found 0

    Appropriate verification instead

    Functional verification for this CLI feature was already exercised during /exec (see PR #706): run --help shows -Q, -s, --quiet, --no-tui; -q/-Q/-s/--no-tui/--experimental-tui all parse without "unknown option"; resolveTuiEnabled/normalizeQualityLoop unit-tested (69 tests green).

    Recommended next step: /qa 705 (code review + AC validation). For deeper hands-on CLI command capture, /verify 705 is the right tool — not /test.

  7. added a commit that references this issue on Jun 3, 2026
  8. admarble commented on Jun 3, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #705

    AC Coverage

    AC Description Status Notes
    AC-1 -q/-Q both enable quality loop; neither enables quiet ✅ MET Hidden -q, --quality-loop-alias Option + normalizeQualityLoop ORs it into qualityLoop (run.ts:23). --quiet moved off -q. Unit-tested (run-flags.test.ts) + parse-tested (cli.integration.test.ts).
    AC-2 --quiet reachable via -s; suppresses renderer ✅ MET bin/cli.ts -s, --quiet; resolveTuiEnabled !options.quiet term forces TUI off; run-progress.ts heartbeat gate (quiet && !tuiEnabled) → heartbeat-only. Help test asserts -s, --quiet and NOT -q, --quiet.
    AC-3 Boxed Ink TUI default on TTY ✅ MET resolveTuiEnabled({}, true) === true; run.ts mounts renderTui. Unit-tested.
    AC-4 --no-tui opts out; non-TTY auto-degrades ✅ MET --no-tui → options.tui === false; resolveTuiEnabled false for tui:false and isTTY:false. Both unit-tested.
    AC-5 --experimental-tui parses (hidden no-op) ✅ MET addOption(new Option("--experimental-tui").hideHelp()); ignored by resolveTuiEnabled. Parse + hidden-from-help tests.
    AC-6 ready renders same full boxed TUI as run ✅ MET (confirmed) Both call the identical renderTui(provider) from ui/tui/index.ts — run.ts:146 (orchestrator), ready.ts:182 (ReadySnapshotAdapter). Same App; row count is data-driven, not a degraded path. See Manual Test Override.
    AC-7 Help text + docs/README updated ✅ MET README, run-command.md, quiet-mode-heartbeat.md, run-renderer.md, experimental-tui-dashboard.md, CHANGELOG. Live run --help verified.

    Coverage: 7/7 AC items met.


    CI Status

    Check State Impact
    build (22.x) SUCCESS ✅ MET
    typecheck SUCCESS ✅ MET
    validate-plugin SUCCESS ✅ MET
    validate-skills SUCCESS ✅ MET

    CI Summary: 4 passed, 0 pending, 0 failed (run 26864008841, commit 872f568).

    Note — regression caught & fixed during QA: the first push (3bf85aa) failed build (22.x) on a single test — run-orchestrator.integration.test.ts "run.ts under 200 lines" (201 > 200; the #705 comments pushed the thin-adapter over its #503 AC-2 cap). All other 3562 tests passed. Fixed in 872f568 by condensing two comment blocks (logic unchanged; now 199 lines). CI re-run is green.


    Quality Metrics

    Metric Value Status
    Type issues (any) 0 OK
    Deleted tests 0 OK
    Files changed 14 OK
    Lines added / deleted +292 / -77 - (mostly docs + tests; core logic ~50 lines)
    Security patterns 0 OK

    CLI Registration Verification

    Option files modified: Yes (bin/cli.ts, run.ts, types.ts)

    Interface Field Runtime Usage CLI Registered Status
    qualityLoopAlias normalizeQualityLoop (options.qualityLoopAlias) hidden -q, --quality-loop-alias ✅ OK
    tui resolveTuiEnabled (options.tui !== false) --no-tui ✅ OK
    experimentalTui None (no-op; not read in gating) hidden --experimental-tui ✅ OK

    Verification Status: Passed.


    Test Coverage Analysis

    Changed File Tier Has Tests?
    src/commands/run-flags.ts (new) Standard ✅ run-flags.test.ts (12 cases)
    bin/cli.ts Standard ✅ cli.integration.test.ts (help + parse)
    src/commands/run.ts Standard ✅ resolvers unit-tested; LOC integration test
    src/lib/workflow/types.ts Optional - (types only)

    Coverage: core logic fully covered. No critical paths (auth/payment/etc.) touched.


    Code Review

    Strengths:

    • Pure-function extraction (normalizeQualityLoop, resolveTuiEnabled) makes the flag precedence directly and non-tautologically unit-testable, and keeps run.ts a thin adapter.
    • resolveTuiEnabled correctly resolves the spec's Open Question 1 by including the !quiet term, so -s beats the new TUI default (AC-2).
    • Hidden-alias pattern is the right call for Commander 14's one-short-per-Option limit; --experimental-tui preserved as a no-op for backward compat.
    • Docs sweep was thorough — corrected a now-false --quiet+TUI interaction claim in experimental-tui-dashboard.md, not just flag renames.

    Issues: None blocking. (The LOC-cap regression was self-introduced and fixed during this QA pass.)

    Suggestions: None.


    Behavior-Rule Survival Check

    AC Triggered? Survivors Status
    AC-3 ("TUI is the default") Yes None Clean

    The old rule (tuiEnabled = experimentalTui && isTTY) is fully removed. The only residual experimentalTui reference is the AC-5-mandated no-op (hidden Option + type field); resolveTuiEnabled never reads it. Status: Clean.


    Manual Test ACs

    AC Verification Method Status
    AC-6 Manual/Integration (confirmation) 🔄 Overridden

    Manual Test Override

    AC: AC-6
    Requirement: Runtime confirmation that ready and run render identically
    Override: Yes
    Justification: No runtime-divergence surface — both commands invoke the identical renderTui(provider) from ui/tui/index.ts (same App component). The only difference is the snapshot provider/data source, which is the spec's expected "structurally identical for a single issue" outcome. Verified by code trace of both call sites.
    Risk Assessment: Low (equivalent to spec's structural determination; no code path unique to run vs ready in the renderer).


    Execution Evidence

    Test Type Command Result
    Help surface sequant run --help ✅ shows -Q, -s, --quiet, --no-tui; hides -q alias + --experimental-tui
    Flag parse run 1 {-q,-Q,-s,--no-tui,--experimental-tui} --dry-run ✅ all parse, no "unknown option"

    Evidence status: Complete.


    Risk Assessment

    • Likely failure mode: A future option reordering in bin/cli.ts could re-collide -q; the cli.integration.test.ts help-surface assertions guard against silent regression. The hidden alias long-name (--quality-loop-alias) is non-conflicting.
    • Not tested: No end-to-end run on a real TTY exercising the actual Ink mount (worktree has no initialized manifest); mitigated by resolveTuiEnabled unit tests + the pre-existing run-tui.integration.test.ts parse/fallback coverage.
    • Sibling sites considered: ready.ts is the cross-file sibling for the TUI-mount path — reviewed and confirmed it shares the same renderTui contract (AC-6), no divergence.
    • Sibling-line audit: normalizeQualityLoop / resolveTuiEnabled are single call sites in runCommand; no adjacent gating lines with the same pattern.

    Adversarial Re-Read

    Findings: No gaps found, because: (1) traced both renderTui call sites and confirmed structural identity for AC-6; (2) audited the "evidence" — the help/parse outputs are post-fix validations, not bug repros; (3) inspected process state — the only CI failure was a self-introduced LOC-cap regression, now fixed and CI-green at 872f568, no uncommitted/divergent state; (4) cited siblings explicitly (ready.ts cross-file; single-call-site intra-file); (5) checked the spec's implicit Non-Goals — no web-UI / renderer-internals scope crept in (renderer untouched; renderTui reused, not rewritten).

    Status: Clean


    Verdict: READY_FOR_MERGE

    All 7 ACs met, all 4 CI checks green, no any/security/deleted-test issues, comprehensive unit + integration coverage, and a thorough docs sweep. Code quality is high (clean pure-function extraction, correct quiet-precedence). The one CI failure (self-introduced 200-LOC-cap breach) was caught and fixed during this QA pass.

    Documentation

    • README updated (TUI-default framing + opt-out)
    • docs/ updated (4 feature/reference docs)
    • CHANGELOG [Unreleased] entry added

    Documentation: Optionally run /docs 705 before merge, though the feature docs are already updated as part of AC-7.

    Next Steps

    1. Merge PR feat(#705): fix -q/-Q flag collision, make boxed Ink TUI the default for run #706 (human gate — sequant never auto-merges).
    2. No follow-ups required.
  9. added
    ready-for-review
    on Jun 3, 2026
  10. admarble commented on Jun 3, 2026

    @admarble
    ContributorAuthor

    Quality Loop — No Action Needed (exit: READY_FOR_MERGE)

    The orchestrator flagged the prior phase as "QA completed without a parseable verdict" and invoked /loop. On inspecting the authoritative QA comment (not the orchestrator's chat-summary parse), the loop found nothing to fix:

    Signal Value
    QA phase marker verdict: READY_FOR_MERGE @ 872f568 (current HEAD)
    QA prose verdict line ### Verdict: READY_FOR_MERGE (present, line 140)
    AC table 7/7 MET — zero NOT_MET / PARTIALLY_MET
    CI checks 4/4 green (build 22.x, typecheck, validate-plugin, validate-skills)

    Root cause of the false "failure": the verdict parser ran against the conversational turn summary, which didn't carry a Verdict: token in the expected position. The posted GitHub QA comment is well-formed and machine-parseable (both the ### Verdict: prose line and the SEQUANT_PHASE marker). No AC gap, no test/CI failure exists.

    Loop iterations: 0/3 (exit condition met on entry — no actionable findings).
    Final status: READY_FOR_MERGE — PR #706 is ready for the human merge gate.

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

    clienhancementno-browser-testplannedready-for-reviewui

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions