Skip to content

feat(usage_limits): per-window session/weekly tokens and a {bar} placeholder - #202

Open
nh13 wants to merge 1 commit into
stephenleo:mainfrom
nh13:nh13/feat-usage-limits-per-period
Open

feat(usage_limits): per-window session/weekly tokens and a {bar} placeholder#202
nh13 wants to merge 1 commit into
stephenleo:mainfrom
nh13:nh13/feat-usage-limits-per-period

Conversation

@nh13

@nh13 nh13 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Adds two capabilities to [cship.usage_limits], both opt-in and backward-compatible.

Per-window tokens

$cship.usage_limits.session and $cship.usage_limits.weekly (aliases .five_hour / .seven_day) render a single standard window, colored by that window's own utilization — unlike $cship.usage_limits, whose threshold color keys off max(5h, 7d). This lets the session and weekly limits sit on separate lines and escalate (green → yellow → red) independently.

{bar} placeholder

A proportional Unicode bar usable in five_hour_format / seven_day_format, with bar_width, bar_filled_char, and bar_empty_char config (mirrors context_bar's fill math). It is scoped to the per-window formats only — the per-model and extra-usage formats leave {bar} literal. Combined with the per-window tokens, each window can show its own progress bar:

[cship]
lines = ["$cship.usage_limits.session", "$cship.usage_limits.weekly"]

[cship.usage_limits]
five_hour_format   = "5h {bar} {pct}%"
seven_day_format   = "7d {bar} {pct}%"
bar_width          = 20
warn_threshold     = 50
warn_style         = "yellow"
critical_threshold = 80
critical_style     = "bold red"

Notes

  • Default $cship.usage_limits output is unchanged — the shared per-window formatter produces byte-identical text when no {bar} is present, and show_per_model / extra-usage / separator handling is preserved.
  • bar_width is clamped to a sane maximum, and the bar string is built only when {bar} is actually referenced.
  • render_bar is kept local with a "keep in sync" note rather than refactoring context_bar in this feature PR — happy to extract a shared helper if you'd prefer.
  • cship explain reports the per-window tokens as plan-unavailable on Enterprise (alongside the per-model sub-tokens) instead of a misleading fetch-failure hint.

Docs & tests

docs/configuration.md, docs/faq.md, README.md, and the committed config-schema.json are updated. New unit tests cover bar rendering (incl. 0-width, clamping, floor semantics), placeholder substitution, the {bar} negative scope in per-model/extra formats, independent per-window coloring, and the aliases. cargo fmt, clippy --all-targets (0 warnings), and the full suite pass.

…older

Add $cship.usage_limits.session and .weekly tokens (aliases .five_hour /
.seven_day) that render a single standard window colored by that window's
own utilization, rather than max(5h, 7d) as $cship.usage_limits does. This
lets the session and weekly limits live on separate lines and escalate
independently.

Add a {bar} placeholder to the per-window format strings, plus bar_width /
bar_filled_char / bar_empty_char config, so each window can show its own
proportional Unicode progress bar (mirroring context_bar).

Docs, JSON schema, and README updated; unit tests cover bar rendering,
placeholder substitution, independent per-window coloring, and aliases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant