Repository navigation
servcheck: keep legend chips equal width using the longest label - #129
Merged
Merged
Conversation
The status legend already used the chip design but with min-width:0, so chips could shrink below their labels (overflow) when the row got tight. servcheck_legend() now computes the longest label and emits it as a --servcheck-chip-min CSS variable (calc(<longest>ch + 1.5rem)); css/common.css uses it as a shared min-width (falling back to max-content), matching the Monitor/Thold/Syslog legends so chips stay equal width as the legend wraps. Added includes/functions.php to the coverage <source> with no-op html_start_box/html_end_box bootstrap stubs and a new ServcheckLegendTest so the changed renderer lines are covered by the patch-coverage gate.
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Wrapped flex rows do not preserve equal chip widths, and the new test does not verify the calculated width.
Review effort: Balanced
Findings: 1
Open (3)
What changed in this PR
Updates the servcheck status legend to size chips from the longest label.
Changes:
- Computes and applies a shared chip minimum width.
- Adds renderer coverage and supporting test stubs.
- Updates coverage configuration and changelog.
| File | Description |
|---|---|
includes/functions.php |
Computes the legend chip width. |
css/common.css |
Applies the shared minimum width. |
tests/Unit/ServcheckLegendTest.php |
Tests legend rendering. |
tests/bootstrap-unit.php |
Adds HTML helper stubs. |
phpunit.xml |
Adds renderer coverage. |
CHANGELOG.md |
Documents the refinement. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
xmacan
approved these changes
Oct 7, 2026
xmacan
previously approved these changes
Oct 7, 2026
…act chip min Follow-up on the longest-label chip work: the flex: 1 1 0 + flex-wrap layout distributes free space per wrapped line, so a partial last row stretched its chips wider than full rows. Switch .servcheck_legend to a grid (repeat(auto-fill, minmax(var(--servcheck-chip-min), 1fr))) so every chip shares an equal column across all rows. The test now asserts the exact calc(Nch + 1.5rem) value instead of just the calc( prefix.
…to the legend test Review follow-up (#129): auto-fit collapses empty tracks so chips fill the legend width on a single row while staying equal across wrapped rows. The new ServcheckLegendTest.php now carries the repository's standard GPL v2 header (matching CspNonceTest.php).
Defence-in-depth: wrap the legend chip display text in html_escape() so markup or HTML entities in a translated label cannot alter the legend DOM. Applied consistently across the thold/monitor/servcheck/mactrack/syslog fleet legends. The chip-min sizing still measures the unescaped label length, so layout is unchanged.
xmacan
approved these changes
Oct 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description
Brings the servcheck status legend in line with the equal-width chip refinement already applied to the Monitor, Thold and Syslog legends.
servcheck's legend was already rendered as chips, but with
min-width: 0, so the chips could shrink below their labels and overflow when the row got tight. CSS can't measure the widest sibling, soservcheck_legend()now computes the longest label and emits it as a--servcheck-chip-minCSS variable (calc(<longest>ch + 1.5rem));css/common.cssuses that as a sharedmin-width(falling back tomax-content).Because every chip shares the same minimum, the equal
flex-growkeeps them equal width, and they wrap as a tidy grid.white-space: nowrapis retained, so labels never clip.Related Issue
Consistency follow-up to the chip-legend treatment across the Monitor/Thold/Syslog plugins.
Motivation and Context
Keeps the legend reading as a clean, uniform key rather than a row of mismatched (or clipped) chip widths as it wraps.
How Has This Been Tested?
php -lclean onincludes/functions.php, the new test, and the bootstrap.css/common.cssis brace-balanced.includes/functions.phpto the coverage<source>with no-ophtml_start_box()/html_end_box()bootstrap stubs and a newtests/Unit/ServcheckLegendTest.phpthat rendersservcheck_legend()and asserts one chip per state plus the--servcheck-chip-mincontainer, so the changed renderer lines are covered by the patch-coverage gate. No new translatable strings (the labels come fromincludes/arrays.php).Types of changes
Checklist: