feat(tpagectl): add progress feedback and colored output #602

Merged
fuzzy merged 1 commit from feat/tpagectl-progress-feedback into main 2026-08-08 09:14:14 +00:00
Owner

What

Implements Phase 7 progress feedback (roadmap #269) using the org's own thwap/konsoru ANSI library (added as the only new dependency).

  • New internal/tpagectl/ui wrapper — terminal-aware rendering over konsoru: colored Success/Warning/Error text, an animated spinner (StartSpinner/Stop), and a progress bar (NewProgressBar/Inc/Finish). Color and animation activate only when the destination is a terminal and NO_COLOR is unset; redirected/piped output stays plain (existing output assertions unchanged).
  • Colored output (#268) — error line rendered red on stderr (kept multi-line with the hint), --insecure and keychain-unavailable warnings yellow, and success confirmations green across site create/delete/update, deployment promote/rollback, preview deploy/delete, token set/clear, login, plus status health/ready values (ok/ready green, unhealthy/not ready red).
  • Spinners (#266)preview deploy wait loop, login device-flow wait, and deployment promote (also closes #207).
  • Progress bar (#267)preview delete --all delete loop.

Why

Roadmap task #269; also clears the Phase-3 leftover #207.

Testing

  • ui unit tests: non-terminal → no color, no spinner, no bar output; colorize on when enabled; NO_COLOR honored; spinner writes cursor hide/show + frames; bar renders + done; zero-total bar is a no-op
  • All command tests pass unchanged (non-TTY fallback keeps exact messages: Site registered:, Deleted 2 preview(s)…, Health: ok, etc.)
  • go test -race ./... passes (27 packages)
  • golangci-lint run clean
  • pre-commit hooks pass (gofmt, go mod tidy, go test)

Breaking Changes

None. Colored/rendered output only appears on an interactive terminal; exit codes and messages are unchanged.

Notes

git.lan.thwap.org/thwap/konsoru v1.0.1 added to go.mod and vendored (requires golang.org/x/term, already vendored at a newer version; MVS keeps v0.44.0).

Closes #207
Closes #266
Closes #267
Closes #268
Closes #269

## What Implements Phase 7 progress feedback (roadmap #269) using the org's own **`thwap/konsoru`** ANSI library (added as the only new dependency). - **New `internal/tpagectl/ui` wrapper** — terminal-aware rendering over konsoru: colored `Success`/`Warning`/`Error` text, an animated spinner (`StartSpinner`/`Stop`), and a progress bar (`NewProgressBar`/`Inc`/`Finish`). Color and animation activate only when the destination is a terminal **and** `NO_COLOR` is unset; redirected/piped output stays plain (existing output assertions unchanged). - **Colored output (#268)** — error line rendered red on stderr (kept multi-line with the hint), `--insecure` and keychain-unavailable warnings yellow, and success confirmations green across `site create/delete/update`, `deployment promote/rollback`, `preview deploy/delete`, `token set/clear`, `login`, plus `status` health/ready values (`ok`/`ready` green, `unhealthy`/`not ready` red). - **Spinners (#266)** — `preview deploy` wait loop, `login` device-flow wait, and `deployment promote` (**also closes #207**). - **Progress bar (#267)** — `preview delete --all` delete loop. ## Why Roadmap task #269; also clears the Phase-3 leftover #207. ## Testing - [x] `ui` unit tests: non-terminal → no color, no spinner, no bar output; colorize on when enabled; `NO_COLOR` honored; spinner writes cursor hide/show + frames; bar renders + `done`; zero-total bar is a no-op - [x] All command tests pass unchanged (non-TTY fallback keeps exact messages: `Site registered:`, `Deleted 2 preview(s)…`, `Health: ok`, etc.) - [x] `go test -race ./...` passes (27 packages) - [x] `golangci-lint run` clean - [x] pre-commit hooks pass (gofmt, go mod tidy, go test) ## Breaking Changes None. Colored/rendered output only appears on an interactive terminal; exit codes and messages are unchanged. ## Notes `git.lan.thwap.org/thwap/konsoru v1.0.1` added to go.mod and vendored (requires `golang.org/x/term`, already vendored at a newer version; MVS keeps v0.44.0). Closes #207 Closes #266 Closes #267 Closes #268 Closes #269
feat(tpagectl): add progress feedback and colored output
All checks were successful
Test and Release / lint (pull_request) Successful in 4m39s
Test and Release / test (pull_request) Successful in 24m17s
acaad4e7bd
Add internal/tpagectl/ui wrapping the konsoru ANSI library (added as the
only new dependency) for terminal-aware rendering: colored success/warning/
error text, an animated spinner, and a progress bar. All rendering is
gated on the destination being a terminal and honors NO_COLOR; redirected
output stays plain and uncluttered.

Wire it up:
- Color (#268): error line rendered red on stderr, --insecure and
  keychain-unavailable warnings yellow, and success confirmations green
  across site create/delete/update, deployment promote/rollback, preview
  deploy/delete, token set/clear, login, and the status health/ready
  values (green ok, red unhealthy).
- Spinners (#266): preview deploy wait loop, login device-flow wait, and
  deployment promote (closes #207).
- Progress bar (#267): preview delete --all loop.

go.mod/vendor updated for git.lan.thwap.org/thwap/konsoru v1.0.1.

Closes #207
Closes #266
Closes #267
Closes #268
Closes #269
the.auditor left a comment

Clean, well-scoped addition. The ui wrapper degrades correctly to plain output for non-terminals (all existing message-assertion tests unchanged), terminal/NO_COLOR detection is spec-compliant, spinner/progress-bar goroutines are properly synchronized (Stop drains done before callers write), and the konsoru dependency is vendored cleanly (BSD-3 license, golang.org/x/term already present at v0.44.0 with no version bump). Approving; one low-priority formatting finding filed.

Suggestions

  1. cmd/tpagectl/main.go:44 – The red coloring splits clierr.Render(err) at the first newline, assuming one error line + one hint line. When a friendly status embeds a multi-line response body (5xx/401 detail), the split cuts mid-error and the hint: line gets folded into the tail — styling and hint separation are mangled (all text still prints). Split on the hint: marker instead. Filed as #603.

Questions

  • With --verbose on a terminal, zap log lines can interleave with spinner frames during waitForPreview polling (spinner writes \r-based frames while the logger writes independently). Cosmetic, but worth confirming it's acceptable as-is.
  • ui.New re-probes the terminal on every call — trivial for a CLI, no action needed.

Praise

  • Non-TTY fallback preserving exact prior output strings is a nice touch, verified by the unchanged command tests.
  • Zero-total progress bar no-op and NO_COLOR handling are correct.
  • deployment promote finally clears #207 via the spinner path without changing non-animated behavior.
Clean, well-scoped addition. The `ui` wrapper degrades correctly to plain output for non-terminals (all existing message-assertion tests unchanged), terminal/`NO_COLOR` detection is spec-compliant, spinner/progress-bar goroutines are properly synchronized (`Stop` drains `done` before callers write), and the konsoru dependency is vendored cleanly (BSD-3 license, `golang.org/x/term` already present at v0.44.0 with no version bump). Approving; one low-priority formatting finding filed. ## Suggestions 1. `cmd/tpagectl/main.go:44` – The red coloring splits `clierr.Render(err)` at the first newline, assuming one error line + one hint line. When a friendly status embeds a multi-line response body (5xx/401 detail), the split cuts mid-error and the `hint:` line gets folded into the tail — styling and hint separation are mangled (all text still prints). Split on the `hint:` marker instead. Filed as #603. ## Questions - With `--verbose` on a terminal, zap log lines can interleave with spinner frames during `waitForPreview` polling (spinner writes `\r`-based frames while the logger writes independently). Cosmetic, but worth confirming it's acceptable as-is. - `ui.New` re-probes the terminal on every call — trivial for a CLI, no action needed. ## Praise - Non-TTY fallback preserving exact prior output strings is a nice touch, verified by the unchanged command tests. - Zero-total progress bar no-op and `NO_COLOR` handling are correct. - `deployment promote` finally clears #207 via the spinner path without changing non-animated behavior.
fuzzy scheduled this pull request to auto merge when all checks succeed 2026-08-08 08:24:01 +00:00
fuzzy merged commit acaad4e7bd into main 2026-08-08 09:14:14 +00:00
fuzzy deleted branch feat/tpagectl-progress-feedback 2026-08-08 09:14:15 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/thwap-pagesd!602
No description provided.