Commit graph

2 commits

Author SHA1 Message Date
Ubuntu
fdc6493258 gui: add Delivered + Confirmed (acked) columns to consumers page
Surfaces ConsumerInfo.delivered.consumer_seq (total delivered) and
ConsumerInfo.ack_floor.consumer_seq (total acknowledged) as new columns
on the /consumers page between WAITING and CREATED.

Reuses the existing ConsumerInfo objects already fetched — no new NATS
calls. Both fields use safe getattr access and render '—' when None.
Legend updated to clarify these are consumer-level counters, not
end-to-end mesh delivery confirmation.

Bump version 0.14.8 → 0.14.9.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-29 04:31:49 +00:00
a38eaaa4fd
gui: add consumers admin page (view + delete JetStream consumers) (#117)
* gui: add consumers admin page (view + delete JetStream consumers)

Adds GET /consumers (list all stream consumers grouped by stream) and
POST /consumers/{stream}/{consumer}/delete. Archive-* consumers are
protected in both the template (no delete button rendered) and the POST
handler (hard refuse before touching NATS). CSRF validated, audit
logged via CONSUMER_DELETE action, DB conn acquired same pattern as
api_keys_delete.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* gui: fix consumers_info coroutine usage + list-returning test mock + None-guard counts

- routes.py: change `async for ci in js.consumers_info(stream_name)` to
  `for ci in await js.consumers_info(stream_name)` — nats-py 2.14.0
  consumers_info() is a plain coroutine returning list[ConsumerInfo], not
  an async iterable; the old form threw TypeError silently (swallowed by
  except), causing every stream to show "unavailable" and zero consumers.
- test_consumers.py: replace async-generator mock with AsyncMock returning
  a list, matching the real API; also fix inline consumers_info_raising in
  the error test (remove dead yield); add explicit regression guard asserting
  consumer names appear in the template context.
- consumers_list.html: guard num_pending/num_ack_pending/num_redelivered/
  num_waiting with `… if … is not none else '—'` to prevent "None" in cells.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* gui: make consumers_delete guards DB-independent + add rendered-HTML tests

Builds on the consumers_info coroutine fix:

- consumers_delete: acquire the DB pool only when actually writing the
  audit (after the CSRF / archive-guard / NATS-unavailable early exits)
  and use a local `get_js` import. Previously `pool = get_pool()` ran at
  the top, so the CSRF-reject, archive-refuse and NATS-down paths all
  needed an initialized DB pool, and the module-level get_js bound at
  import time ignored test patches of central.gui.nats.get_js. Mirrors
  the local-import pattern the streams routes already use.
- tests: add TestConsumersListHtmlRender — renders consumers_list.html
  through the real Jinja2 environment and asserts the consumer NAME
  reaches the HTML body, the central-owned label gates on `protected`,
  and None counts render an em dash rather than the literal "None".
  Stronger than the context-dict checks; the coroutine/None regressions
  cannot return. All 4 delete-route tests now pass (were failing on an
  uninitialized-pool RuntimeError).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Ubuntu <zvx@cortex.echo6.co>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-28 19:41:39 -06:00