Commit Graph

4 Commits

Author SHA1 Message Date
nicolargo
5c649d113d test(v5): align cpu tests with new prominent flags
The cpu schema was updated so:
  total       prominent True  (kept)
  system      prominent False (kept)
  user        prominent False (kept)
  iowait      prominent True  (was False) — surface sustained I/O wait
  dpc         prominent False (kept)
  steal       prominent False (was True)  — non-prominent escalation
  ctx_switches prominent False (was True) — non-prominent escalation

Renames test_system_user_iowait_dpc_are_watched_non_prominent →
test_system_user_dpc_are_watched_non_prominent (iowait moved out).
Adds test_iowait_is_watched_prominent. Updates _levels assertions for
steal and ctx_switches to expect prominent=False. Updates the cpu
render-test fixture's _levels.steal accordingly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 16:43:03 +02:00
nicolargo
cbed074842 feat(v5): add short_name renderer hint (v4 parity)
Plugins can declare an optional short_name in fields_description for
compact label display in tight per-plugin renderers:

  ctx_switches.short_name = 'ctx_sw'
  soft_interrupts.short_name = 'sw_int'
  interrupts.short_name = 'inter'

A new field_label(schema, field_name, prefer_short=False) helper
encapsulates the resolution order:
  - prefer_short=True: short_name -> label -> field name
  - prefer_short=False (default, generic renderer): label -> field name

The cpu render_curses_v5 now pulls every column label via
field_label(..., prefer_short=True) instead of hardcoding labels.

Mirrors v4 short_name (cf. curse_add_stat in plugins/plugin/model.py).
Documented in architecture decisions section 3.2 and SKILL-plugin.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 16:07:10 +02:00
nicolargo
b6a48993ce feat(v5): stable column widths, prominent-on-any-level reverse, 3-cycle alert warmup
Three TUI/alerts corrections raised by the v4 visual review:

1. Column widths now floored to a per-unit minimum so cells don't jiggle
   cycle-to-cycle:
     percent     6 chars  ('100.0%')
     bytes       6        ('999.9G')
     bytespers   8        ('999.9G/s')
     seconds     6        ('1d23h ')
     number      5
     bool        3
   An explicit `column_width` in fields_description still overrides.
   cpu's bespoke 3-col grid uses the same approach with fixed value
   columns of 6 chars.

2. _attr_for now applies A_REVERSE (background highlight) when a cell is
   prominent AND carries any non-DEFAULT alert level (OK/CAREFUL/WARNING/
   CRITICAL) — previously only WARNING and CRITICAL. Matches v4 behaviour
   for *_LOG decorations on watched-prominent fields.

3. GlancesAlerts now skips ingestion for the first N refresh cycles per
   plugin (default N=3, configurable via [alerts] warmup_cycles). Rates
   and threshold-derived _levels can fire spuriously at startup before
   the system has settled — this matches v4's behaviour of ignoring logs
   during the same warmup. The TUI colouring is unaffected (it reads
   _levels directly from the payload).

Test fixtures now default to warmup_cycles=0 so existing assertions
remain valid; three new tests cover the warmup behaviour explicitly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 15:08:49 +02:00
nicolargo
76f53646d8 feat(v5): cpu plugin — per-plugin TUI renderer mirroring v4 msg_curse
3-col x 4-row grid layout:
  CPU      4.5%      idle   95.5%       ctx_sw   6.7K
    user   3.8%       irq    0.0%   interrupts   3.0K
  system   0.7%      nice    0.0%       sw_int   1.8K
  iowait   0.0%     steal    0.0%        guest   0.0%

OS variants:
- Linux:   col1=user/system/iowait, col3 line4=guest
- Windows: col1=idle/core/dpc,      col3 line4=syscalls
- col3 line3 = soft_interrupts (Linux) or ctx_switches (fallback)

ctx_switches/interrupts/sw_int values use K/M scaling (matches v4's
auto_unit + min_symbol cosmetics for these counters).

Reference: glances/plugins/cpu/__init__.py::msg_curse.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 14:43:11 +02:00