Channel-neutral {:dynamic {:limits [...]}} row formatters.
Hoisted from the TUI extension (channel_tui/limits_fmt.clj) so
every channel — TUI footer, TUI provider cards — renders the SAME
compact account-quota summary from a provider's normalized limits
report. The TUI namespace now aliases these vars; other channels
consume them through vis.core.
The interesting account-level rows (:zai-coding-plan-5h,
:codex-7d, :premium_interactions, ...) live under
[:dynamic :limits]; static :rpm/:tpm are svar catalog
defaults, identical for every provider, useful only as fallback.
Channel-neutral `{:dynamic {:limits [...]}}` row formatters.
Hoisted from the TUI extension (`channel_tui/limits_fmt.clj`) so
every channel — TUI footer, TUI provider cards — renders the SAME
compact account-quota summary from a provider's normalized limits
report. The TUI namespace now aliases these vars; other channels
consume them through `vis.core`.
The interesting account-level rows (`:zai-coding-plan-5h`,
`:codex-7d`, `:premium_interactions`, ...) live under
`[:dynamic :limits]`; static `:rpm`/`:tpm` are svar catalog
defaults, identical for every provider, useful only as fallback.Known account-level rolling plan windows (Codex / Z.ai 5h + 7d). These are surfaced as a PAIR: when a provider omits data for one window, its companion row carries no usage signal but must STILL render so both windows stay visible (the whole point of the provider keeping a placeholder row).
Known account-level rolling plan windows (Codex / Z.ai 5h + 7d). These are surfaced as a PAIR: when a provider omits data for one window, its companion row carries no usage signal but must STILL render so both windows stay visible (the whole point of the provider keeping a placeholder row).
(account-plan-window-row? row)True when the row is one of the known account plan windows (Codex / Z.ai
5h + 7d), REGARDLESS of whether it currently carries usage signal. :id is
coerced via ->kw so a report that crossed the gateway wire (string ids)
matches the same as an in-process one (keyword ids).
True when the row is one of the known account plan windows (Codex / Z.ai 5h + 7d), REGARDLESS of whether it currently carries usage signal. `:id` is coerced via `->kw` so a report that crossed the gateway wire (string ids) matches the same as an in-process one (keyword ids).
(dynamic-summary limits)(dynamic-summary limits max-rows)Compact one-line summary of the most informative :dynamic :limits
rows for a provider's normalized limits report.
Picks rows with signal first, falls back to all rows when nothing
has signal yet (so a fresh, all-zero report still surfaces SOMETHING
rather than collapsing to empty). Takes up to max-rows (default 2)
and joins them with ·.
Returns nil when there's nothing to render.
Compact one-line summary of the most informative `:dynamic :limits` rows for a provider's normalized limits report. Picks rows with signal first, falls back to all rows when nothing has signal yet (so a fresh, all-zero report still surfaces SOMETHING rather than collapsing to empty). Takes up to `max-rows` (default 2) and joins them with ` · `. Returns nil when there's nothing to render.
(format-limit-number n)Render a numeric usage/limit/remaining value with a single-decimal
suffix when the value is non-integral, else as a clean integer.
Locale/ROOT keeps the JVM locale from injecting a comma decimal
separator next to English suffix text.
Render a numeric usage/limit/remaining value with a single-decimal suffix when the value is non-integral, else as a clean integer. `Locale/ROOT` keeps the JVM locale from injecting a comma decimal separator next to English suffix text.
(format-limit-usage {:keys [used limit remaining is-unlimited] :as row})Render the usage/remaining portion of a row as a short string, choosing the most informative shape the row's numbers allow:
is-unlimited flag -> "unlimited"Returns nil only when the row carries no usage signal at all, so
callers can (when usage ...) to skip empty cells.
Render the usage/remaining portion of a row as a short string, choosing the most informative shape the row's numbers allow: - explicit `is-unlimited` flag -> "unlimited" - percentage-style row -> "47% left" - used + limit + remaining -> "3/5 used (2 left)" - used + limit -> "3/5 used" - remaining + limit -> "2/5 left" - remaining only -> "2 left" - used only -> "3 used" - none of the above -> nil Returns nil only when the row carries no usage signal at all, so callers can `(when usage ...)` to skip empty cells.
(generic-limit-has-signal? row)True when the row has usage or reset signal worth surfacing. Used to prefer informative rows when the visible area is tight. A reset timestamp is signal even when the provider reports zero remaining and omits a limit: that's exactly when the user needs to know when credits come back.
True when the row has usage or reset signal worth surfacing. Used to prefer informative rows when the visible area is tight. A reset timestamp is signal even when the provider reports zero remaining and omits a limit: that's exactly when the user needs to know when credits come back.
(generic-limit-label row)Human label for a dynamic-limit row. Hand-rolled overrides for the
widely-known plan rows; fallback derives a label from :label or
:id, trimming the redundant Quota / Quota (%) suffixes the
raw provider rows ship with. :id is coerced via ->kw so the
overrides match whether the report came in-process (keyword ids) or
across the gateway wire (string ids).
Human label for a dynamic-limit row. Hand-rolled overrides for the widely-known plan rows; fallback derives a label from `:label` or `:id`, trimming the redundant ` Quota` / ` Quota (%)` suffixes the raw provider rows ship with. `:id` is coerced via `->kw` so the overrides match whether the report came in-process (keyword ids) or across the gateway wire (string ids).
(label+usage row)Compose "<label> <usage>" for a single row, or "<label>"
when the row has no usage signal. Returns nil when both are
blank/absent.
Compose `"<label> <usage>"` for a single row, or `"<label>"` when the row has no usage signal. Returns nil when both are blank/absent.
(percentage-limit-row? {:keys [id kind limit remaining]})True when the row is best displayed as a percent-remaining (the
provider reports a 0-100 percentage rather than raw token counts).
The ID allowlist covers the Codex / Z.ai plan windows; the
:rate + :limit 100 heuristic catches generic percentage rows
(the Anthropic Claude windows). id/kind are coerced via ->kw
so a report that crossed the gateway wire (string values) matches
the same as an in-process one (keyword values).
True when the row is best displayed as a percent-remaining (the provider reports a 0-100 percentage rather than raw token counts). The ID allowlist covers the Codex / Z.ai plan windows; the `:rate` + `:limit 100` heuristic catches generic percentage rows (the Anthropic Claude windows). `id`/`kind` are coerced via `->kw` so a report that crossed the gateway wire (string values) matches the same as an in-process one (keyword values).
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |