Skip to main content

Module active

Module active 

Source
Expand description

Active-vendor state file. Set by --cycle-next / --cycle-prev (which Waybar’s on-scroll-up/on-scroll-down invoke), read by the widget on every tick. The TUI does NOT consult this — it has its own tab state.

On-disk shape: a single line with the vendor slug (e.g. openai). Located at <cache-dir>/active_vendor.

Functions§

cycle
Cycle the active vendor by delta positions through enabled (which preserves canonical order). Wraps. If no state exists, starts at start (usually [ui] primary or anthropic).
cycle_at
Cycle using an explicit state-file path. The real-path cycle is a thin wrapper over this; tests drive this with a TempDir path so the cycle + persistence logic is covered without reading or writing the real cache.
read
Read the persisted active vendor, if any. None means “no override — callers fall back to [ui] primary or anthropic”.
read_from
Read the persisted active vendor from an explicit path. The real-path read is a thin wrapper over this; tests use this directly with a TempDir-backed path so they never touch ~/.cache/ai-usagebar.
write
Persist vendor as the active one. Atomic.
write_to
Persist vendor to an explicit path. Atomic. Test-friendly counterpart to [write] (mirrors crate::cache::Cache::at vs for_vendor).