diff --git a/glances/plugins/load/render_curses_v5.py b/glances/plugins/load/render_curses_v5.py index ef6d8ee8..6cdc32ae 100644 --- a/glances/plugins/load/render_curses_v5.py +++ b/glances/plugins/load/render_curses_v5.py @@ -73,11 +73,15 @@ def render(payload: dict[str, Any], fields_desc: dict[str, dict[str, Any]]) -> l return [Row(cells=[Cell(text="LOAD", color=ColorRole.HEADER)])] # Line 1: title + cpucore suffix. + # The value cell width must match the body load-average value width + # (`_LOAD_VALUE_WIDTH = 6`) so the right edges of every line in the + # block align. v4 padded the int with `{:3}core` (7 chars), which + # made the corecount cell 1 char wider than the load-average values + # and produced a visible 1-char overhang. header_cells: list[Cell] = [Cell(text="LOAD".ljust(_LOAD_LABEL_WIDTH), color=ColorRole.HEADER)] cores = payload.get("cpucore") if isinstance(cores, (int, float)) and cores > 0: - # v4 format: `{:3}core` — `' 4core'` for 4 cores. - header_cells.append(Cell(text=f"{int(cores):>3}core".rjust(_LOAD_VALUE_WIDTH))) + header_cells.append(Cell(text=f"{int(cores)}core".rjust(_LOAD_VALUE_WIDTH))) else: header_cells.append(Cell(text="".rjust(_LOAD_VALUE_WIDTH))) rows: list[Row] = [Row(cells=header_cells)] diff --git a/tests/test_plugin_load_render_curses_v5.py b/tests/test_plugin_load_render_curses_v5.py index c6329e23..3f41d4d4 100644 --- a/tests/test_plugin_load_render_curses_v5.py +++ b/tests/test_plugin_load_render_curses_v5.py @@ -130,3 +130,19 @@ def test_render_columns_align(load_payload, load_fields): rows = render(load_payload, load_fields) label_widths = {len(r.cells[0].text) for r in rows if r.cells} assert len(label_widths) == 1 + + +def test_render_value_cells_share_width_across_header_and_body(load_payload, load_fields): + """The corecount cell (header) and the load-average cells (body) must + have the same width so right edges align. Earlier bug: `{:3}core` + produced 7-char header value vs 6-char body values → 1-char overhang.""" + rows = render(load_payload, load_fields) + widths = {len(r.cells[1].text) for r in rows if len(r.cells) >= 2} + assert len(widths) == 1, f"value cells not uniform: {widths}" + + +def test_render_total_line_width_matches_across_rows(load_payload, load_fields): + """Each line's total rendered width (cells joined with 1 space) is identical.""" + rows = render(load_payload, load_fields) + totals = {sum(len(c.text) for c in r.cells) + max(0, len(r.cells) - 1) for r in rows} + assert len(totals) == 1, f"line widths differ: {totals}"