# Introducing bunqueue top: k9s-Style Terminal UI for Queues

Meet bunqueue top: a zero-dependency live terminal dashboard with truecolor Braille charts, 6 views, deterministic DLQ clustering, and live broker controls.

Canonical: https://bunqueue.dev/blog/bunqueue-top/

---

A zero-dependency live terminal dashboard built right into the bunqueue CLI. Watch truecolor Braille throughput waves, cluster dead-letter failures by root cause, drill into jobs and logs, and pause or rate-limit queues over a single persistent TCP+TLS connection.

![](https://github.com/egeominotti.png?size=64) [egeominotti](https://github.com/egeominotti)

When a production queue starts backing up at 2 a.m., you are already in a terminal. Opening a browser tab, logging into a web dashboard, clicking through three modals, and squinting at raw JSON dead-letter entries is friction you do not need during an incident.

Starting in **[bunqueue v2.9.24](https://bunqueue.dev/blog/bunqueue-v2-9-24/)**, `bunqueue top` brings a full interactive terminal control plane straight to your shell:

```bash
# Try it right now with zero setup (built-in live simulator)
bunx bunqueue top --demo

# Or attach to a live broker on localhost:6789
bunx bunqueue top
```

## Try it right here in your browser

The widget below is not a mockup or a recorded GIF. It imports the exact same TypeScript reducer, selector engine, Braille renderer, DLQ clusterer, and demo data source that power `bunqueue top --demo` in your terminal. Click a row or focus the terminal to drive it with real keys (`1` through `7`, `j`/`k`, `Enter`, `Esc`, `p`, `l`, `c`, `d`, `R`, `A`, `P`, `s`, `t`, `:`, `v`, `Space`, `?`).

*[Interactive top tui simulator: open the HTML page to view it.]*

## Zero dependencies, zero broker overhead

Most terminal UIs pull in React reconcilers, Yoga layout engines, or native curses bindings. `bunqueue top` ships with **zero new runtime dependencies** and makes **zero changes** to broker hot paths, shard locks, persistence schemas, or the binary wire protocol.

Instead, the entire TUI lives inside 33 focused TypeScript modules under `src/cli/top/` (every file at or below 296 lines) and speaks to any existing bunqueue server over one persistent TCP+TLS+Auth MessagePack connection using 28 already-supported wire commands (`Auth`, `Hello`, `DashboardOverview`, `DashboardQueues`, `DashboardQueue`, `GetQueueLimits`, `GetJob`, `GetLogs`, `GetDlqStats`, `Dlq`, `ListWebhooks`, `Pause`, `Resume`, `RateLimit`, `RateLimitClear`, `SetConcurrency`, `ClearConcurrency`, `PUSH`, `Drain`, `Cancel`, `Promote`, `Discard`, `RetryDlq`, `PurgeDlq`, `SetWebhookEnabled`, `RemoveWebhook`, `CronDelete`, and `CompactMemory`), plus optional zero-DDL SQLite or PostgreSQL 17-19 inspection and signal delivery for `[7] Workflows`.

- **No extra HTTP polling loops:** One persistent TCP socket multiplexes overview, queue, worker, cron, webhook, and detail calls with automatic reconnect after broker restarts.
- **No leaked terminal state:** Alternate screen, raw mode, and cursor visibility are torn down in guarded cleanup paths on `q`, `Ctrl+C`, `SIGTERM`, `SIGHUP`, stdin EOF, and mid-session `EPIPE` errors.
- **No external runtime required:** Works wherever `bunqueue` runs, over SSH, inside `tmux`, in Kubernetes `kubectl exec` pods, or piped through CI scripts with `--once` and `--json`.

## Seven views, split preview, and full drill-down

Everything on a broker is one keystroke away:

| Key | View | What you see and control |
| --- | --- | --- |
| `1` | **Queues** | Live depth, waiting/active/delayed/DLQ counts, per-tick delta (`+`/`-`), heat load bars, pause (`p`), rate limit (`l`), concurrency (`c`), quick push (`n`), drain (`D`), drill-down (`Enter`) |
| `2` | **Workers** | Connected worker pool, subscribed queues, active vs processed vs failed jobs, heartbeat age |
| `3` | **Crons** | Scheduled cron jobs, cron expression or `repeatEvery`, next execution countdown, total runs, delete (`X`) |
| `4` | **DLQ Triage** | Deterministic root-cause error clusters sorted by share, attempt patterns, canary single-job retry (`R`), retry all (`A`), purge (`P`), inspect sample (`Enter`) |
| `5` | **Webhooks** | Registered endpoints with scrubbed URL credentials and query secrets, event lists, delivery stats, enable/disable (`e`), remove (`X`) |
| `6` | **Activity** | Live event stream automatically derived from snapshot diffs (DLQ spikes, pause/resume transitions, disk-full alerts, new queues, operator actions) |
| `7` | **Workflows** | Zero-DDL Workflow Engine executions over SQLite (`--workflow-db`) or PostgreSQL 17-19 (`--workflow-pg`), step-by-step inspect (`Enter`), and live transactional `waitFor` signal delivery (`s`) |

Press `v` to toggle the bottom split preview pane, `t` to cycle through four curated truecolor themes (`cyber`, `tokyo`, `amber`, `mono`), `+/-` to adjust the polling interval live from `200 ms` to `5 s`, `r` to refresh on demand, and `Space` to freeze the screen while reading stack traces.

From any queue, press `Enter` to open **Queue Inspect** (active, waiting, delayed, and DLQ tabs plus live rate and concurrency limits). Press `Enter` again on any job to open **Job Inspect** with redacted payload JSON, execution logs, progress bar, and direct actions (`m` promote delayed job, `X` discard to DLQ, `x` cancel).

## Deterministic DLQ triage that protects your terminal

Dead-letter queues usually contain thousands of near-identical failures differing only by a UUID, timestamp, IP address, or request ID. Pulling the newest tail of the DLQ (`--limit`, default `200`, up to `1,000`), `bunqueue top` normalizes those dynamic tokens deterministically on the client and groups errors into ranked root-cause clusters with percentage shares and retry attempt patterns.

Because dead-letter payloads and error strings come from untrusted external inputs, `bunqueue top` scrubs every string before writing to the terminal:

1. **Terminal escape neutralization:** Strips CSI, OSC, DCS/APC sequences, and C0/C1 control characters from queue names, job IDs, prompts, errors, and confirmation banners so malicious payloads cannot spoof terminal titles or corrupt the layout.
2. **Inline secret and PII redaction:** Masks `Bearer` tokens, JWTs, Stripe-style keys (`sk_live_*`, `pk_live_*`, `rk_*`), email addresses, webhook URL credentials and sensitive query parameters, and `password`/`secret`/`token`/`api_key`/`authorization`/`cookie` pairs (including JSON-quoted keys) with `[REDACTED]`.
3. **Canary retry before bulk replay:** Press `R` (guarded by a `y/N` prompt) to retry one representative sample job from the top cluster first. Verify it drains cleanly before hitting `A` (also guarded by a `y/N` prompt) to replay the entire DLQ.

## k9s-style command palette and scriptable snapshots

Operators used to `k9s` can press `:` anywhere to open the command palette:

```text
:queues          :workers         :crons           :webhooks        :activity
:dlq billing     :theme tokyo     :pause billing   :resume billing
:drain billing   :compact         :help            :quit
```

For shell scripts, cron health checks, and CI smoke tests, `--once` prints a single frame and exits cleanly without entering raw mode, while `--json` outputs the full structured snapshot:

```bash
# Single terminal frame for quick SSH inspection
bunqueue top --once --view dlq -q billing

# Structured JSON snapshot for jq pipelines
bunqueue top --once --json | jq '{waiting: .snapshot.stats.waiting, dlq: .snapshot.stats.dlq, p99AckMs: .snapshot.latency.percentiles.ack.p99}'
```

Exit codes stay predictable for automation: `0` on clean exit or snapshot, `1` on broker connection, authentication, or runtime error, and `2` on invalid CLI flags.

## Verified over a real OS PTY and SQLite broker

Beyond unit tests for argument parsing, key decoding, Braille geometry, ANSI width truncation, and stale-reply race guards, `bunqueue top` is covered by **57 automated tests (584 assertions across 7 test files)**. That includes a realistic end-to-end test that boots a real SQLite-backed bunqueue TCP broker, drives live traffic with real `Queue` and `Worker` clients, attaches the compiled CLI over a real operating-system PTY (`Bun.spawn(..., { terminal })`), and exercises live navigation, pause/resume, rate limits, concurrency limits, DLQ clustering, canary retry, command palette navigation, and clean terminal restoration on both `q` and `SIGTERM`.

## Next steps

- Read the full flag, hotkey, and command palette reference in the [Terminal UI (`bunqueue top`) guide](https://bunqueue.dev/guide/top/).
- See everything else shipping alongside `bunqueue top` in [bunqueue v2.9.24](https://bunqueue.dev/blog/bunqueue-v2-9-24/).
- Run `bunx bunqueue top --demo` in your own terminal to test all four themes and live Braille throughput charts locally.
