ccstatusline icon indicating copy to clipboard operation
ccstatusline copied to clipboard

feat: dynamic color thresholds for context percentage widgets

Open simplybychris opened this issue 9 months ago • 2 comments

Summary

  • Context percentage widgets now change color dynamically based on usage level
  • Yellow at warning threshold, red at danger threshold
  • Configurable presets via t keybind in TUI editor: default (50/75%), conservative (30/60%), aggressive (70/90%), off
  • Works on both Context % and Context % (usable) widgets
  • Thresholds based on actual usage, not display value (works correctly with inverse/remaining mode)

Implementation

  • New getEffectiveColor() optional method on Widget interface
  • Renderer checks getEffectiveColor before falling back to static item.color
  • Shared threshold logic in src/utils/color-thresholds.ts
  • Threshold config stored in widget metadata (no schema changes needed)

Test plan

  • [x] 99 tests passing (47 new), covering:
    • Threshold color helper: all presets, boundaries, edge cases (0%, 100%)
    • Both widgets: getEffectiveColor at each threshold level
    • Preset cycling via handleEditorAction
    • Editor display labels
    • Inverse mode uses usage % not display %
    • Usable widget uses usableTokens (160k) not maxTokens (200k)
  • [x] TypeScript type check passes
  • [x] Build passes

simplybychris avatar Feb 15 '26 18:02 simplybychris

@sirmalloc check it please mate, because it will be cool to setup different colors for different context levels :)

simplybychris avatar Feb 15 '26 18:02 simplybychris

Any plans to merge this @sirmalloc ?

mdefeche avatar Jun 03 '26 07:06 mdefeche