Skip to content

Conversation

@notAreYouScared
Copy link
Member

@notAreYouScared notAreYouScared commented Nov 23, 2025

chrome_Hf5CztnrVc
chrome_VzpyZlihOY

@coderabbitai
Copy link

coderabbitai bot commented Nov 23, 2025

📝 Walkthrough

Walkthrough

Adds a ProgressBarColumn component and HasProgress trait, integrates progress bars into server list and entry blades (replacing textual CPU/Memory/Disk), updates Server::formatResource signature to accept precision, adds WARNING_THRESHOLD constant to ListServers, and caches Node system info/statistics.

Changes

Cohort / File(s) Change Summary
New progress bar component
app/Filament/Components/Tables/Columns/ProgressBarColumn.php, resources/views/livewire/columns/progress-bar-column.blade.php
Adds ProgressBarColumn class with fluent API (maxValue, helperLabel, thresholds), progress computation, status/color resolution, color normalization, and a Blade partial that renders color-resolved progress bars with optional danger animation.
Progress concerns & ServerEntry integration
app/Filament/Components/Tables/Columns/Concerns/HasProgress.php, app/Filament/Components/Tables/Columns/ServerEntryColumn.php
Introduces HasProgress trait exposing threshold and color setters/getters and status→color mapping; ServerEntryColumn uses the trait and sets default danger/warning/primary colors in setUp().
Server list page updates
app/Filament/App/Resources/Servers/Pages/ListServers.php
Replaces cpu/memory/disk TextColumns with ProgressBarColumn instances, wires per-column maxValue/thresholds/colors/helperLabel closures, updates uptime tooltip to pass precision, and adds public const WARNING_THRESHOLD = 0.7 (keeps DANGER_THRESHOLD = 0.9).
Server model formatting change
app/Models/Server.php
Changes method signature to formatResource(ServerResourceType $resourceType, int $precision = 2) and uses provided precision when formatting percentage and converted resource values.
Blade views updated to use progress bars
resources/views/livewire/server-entry.blade.php, resources/views/livewire/server-entry-placeholder.blade.php
Replaces inline CPU/Memory/Disk textual outputs with progress-bar-column partials and per-resource state/max/label/color closures via serverEntryColumn helper; adjusts layout and helper labels.
Node caching/requests adjusted
app/Models/Node.php
systemInformation() and statistics() now cache results for 360 seconds under nodes.{id}.system_information / nodes.{id}.statistics, simplify exception handling inside cached closures, and use !empty checks for returned data.

Sequence Diagram(s)

sequenceDiagram
    participant Page as ListServers / Entry Blade
    participant EntryCol as ServerEntryColumn
    participant ProgressCol as ProgressBarColumn
    participant Server as Server Model
    participant BladeComp as progress-bar-column (Blade)
    participant Node as Node Model / Cache

    Page->>EntryCol: instantiate (setUp: default colors, thresholds)
    Page->>ProgressCol: configure per-column closures (state,max,label,color,thresholds)
    ProgressCol->>Server: evaluate closures to get current state/helper label
    ProgressCol->>Node: fetch system/statistics (cached)
    Node-->>ProgressCol: return cached data
    ProgressCol->>ProgressCol: compute percentage & status, resolve color
    ProgressCol->>BladeComp: render with props (state,max,percentage,color,label,ARIA)
    BladeComp->>Browser: display progress bar UI (animate if danger), show helper label
Loading

Possibly related PRs

  • Add server icons #1906 — modifies the same server-entry Blade views and ListServers page; overlaps UI/template and Server model formatting changes.

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.16% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add progress bars to client area' clearly and directly summarizes the main change—introducing progress bar visualization components to the client-facing UI.
Description check ✅ Passed The description consists of two image attachments demonstrating the new progress bars in the client area, which are directly related to the changeset's primary objective.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
app/Models/Server.php (1)

485-511: Fix bitwise AND operator; verify base:3 parameter intent for server limits display.

Line 501 uses bitwise AND (&) instead of logical AND (&&). While this technically evaluates in a boolean context, it does not short-circuit and is semantically incorrect:

if ($resourceAmount === 0 & $resourceType->isLimit()) {

Should be:

if ($resourceAmount === 0 && $resourceType->isLimit()) {

Additionally, line 510 is the only place in the codebase that calls convert_bytes_to_readable() with an explicit base: 3 parameter, which forces all byte values to display in GiB/GB units. This differs from all other byte conversions, which omit the base parameter and auto-select units. Confirm that always formatting server limits in GB scale matches your intended UI output, or consider removing the parameter to let the helper function auto-detect the appropriate unit.

app/Filament/App/Resources/Servers/Pages/ListServers.php (1)

174-214: Remove the unused getResourceColor method.

Verification confirms this method is never called anywhere in the codebase. Since ProgressBarColumn now handles threshold-based coloring internally, this method is dead code and should be removed to reduce maintenance burden.

Remove lines 174-214 from app/Filament/App/Resources/Servers/Pages/ListServers.php.

🧹 Nitpick comments (2)
app/Filament/Components/Tables/Columns/ServerEntryColumn.php (1)

5-180: Color/threshold API looks solid; consider aligning normalizeColor() with ProgressBarColumn for consistency.

The added threshold and color API (warning/danger percent, per‑status colors, and getProgressColorForStatus) is well‑structured and should work cleanly with the progress‑bar views. One small improvement: normalizeColor() here is slightly different from the version in ProgressBarColumn (alias handling vs. array handling order and how the first shade is selected). For long‑term maintainability and to avoid subtle divergences, it’s worth copying the exact implementation from ProgressBarColumn::normalizeColor() so both components resolve arrays and aliases identically.

app/Filament/Components/Tables/Columns/ProgressBarColumn.php (1)

186-217: Consider extracting threshold defaults as class constants.

The progress calculation methods are well-implemented with proper null safety and clamping. However, the hardcoded threshold defaults (0.7 and 0.9) on Lines 205-206 could optionally be extracted as class constants for better maintainability and discoverability.

If you'd like to make the defaults more explicit, consider this refactor:

 class ProgressBarColumn extends Column
 {
     protected string $view = 'livewire.columns.progress-bar-column';
 
+    private const DEFAULT_WARNING_THRESHOLD = 0.7;
+    private const DEFAULT_DANGER_THRESHOLD = 0.9;
+
     // Accept int or float for max values
     protected int|float|Closure|null $maxValue = null;

Then update the usage:

-        $dangerThreshold = ($dangerPercent !== null ? $dangerPercent : 0.9) * 100;
-        $warningThreshold = ($warningPercent !== null ? $warningPercent : 0.7) * 100;
+        $dangerThreshold = ($dangerPercent !== null ? $dangerPercent : self::DEFAULT_DANGER_THRESHOLD) * 100;
+        $warningThreshold = ($warningPercent !== null ? $warningPercent : self::DEFAULT_WARNING_THRESHOLD) * 100;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 25c8ff3 and 7d7eb2c.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • app/Filament/App/Resources/Servers/Pages/ListServers.php (5 hunks)
  • app/Filament/Components/Tables/Columns/ProgressBarColumn.php (1 hunks)
  • app/Filament/Components/Tables/Columns/ServerEntryColumn.php (1 hunks)
  • app/Models/Server.php (2 hunks)
  • resources/views/livewire/columns/progress-bar-column.blade.php (1 hunks)
  • resources/views/livewire/server-entry-placeholder.blade.php (2 hunks)
  • resources/views/livewire/server-entry.blade.php (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
app/Models/Server.php (1)
app/helpers.php (2)
  • format_number (108-116)
  • convert_bytes_to_readable (36-49)
app/Filament/App/Resources/Servers/Pages/ListServers.php (3)
app/Filament/Components/Tables/Columns/ProgressBarColumn.php (4)
  • ProgressBarColumn (10-261)
  • warningThresholdPercent (61-66)
  • dangerThresholdPercent (73-78)
  • maxValue (49-54)
app/Filament/Components/Tables/Columns/ServerEntryColumn.php (2)
  • warningThresholdPercent (42-47)
  • dangerThresholdPercent (54-59)
app/Models/Server.php (3)
  • Server (134-525)
  • formatResource (485-511)
  • retrieveResources (475-483)
app/Filament/Components/Tables/Columns/ServerEntryColumn.php (1)
app/Filament/Components/Tables/Columns/ProgressBarColumn.php (9)
  • warningThresholdPercent (61-66)
  • dangerThresholdPercent (73-78)
  • dangerColor (88-93)
  • warningColor (106-111)
  • color (124-129)
  • setUp (38-47)
  • getColor (134-137)
  • normalizeColor (143-167)
  • getWarningColor (116-119)
app/Filament/Components/Tables/Columns/ProgressBarColumn.php (1)
app/Filament/Components/Tables/Columns/ServerEntryColumn.php (12)
  • warningThresholdPercent (42-47)
  • dangerThresholdPercent (54-59)
  • dangerColor (69-74)
  • warningColor (87-92)
  • color (105-110)
  • setUp (33-40)
  • getColor (115-118)
  • getWarningThresholdPercent (49-52)
  • getDangerThresholdPercent (61-64)
  • getDangerColor (79-82)
  • normalizeColor (126-154)
  • getWarningColor (97-100)
🔇 Additional comments (11)
resources/views/livewire/server-entry-placeholder.blade.php (1)

3-4: Placeholder progress bars are wired correctly.

The placeholder now reuses the same progress‑bar partial and ServerEntryColumn color logic as the live view, with safe 0‑valued state, correct max fallbacks, and sensible labels (including ∞ for unlimited limits). This keeps the skeleton UI visually consistent without introducing edge‑case risks.

Also applies to: 45-61, 64-80, 83-99

app/Filament/App/Resources/Servers/Pages/ListServers.php (3)

38-42: LGTM!

The threshold constants are well-defined and appropriately scoped for reuse across grid and table columns.


57-60: LGTM!

The threshold configuration for the grid columns correctly uses the class constants.


76-76: LGTM!

The precision parameter enhances the uptime display accuracy.

app/Filament/Components/Tables/Columns/ProgressBarColumn.php (7)

10-36: LGTM!

The property declarations are well-typed and properly documented with PHPDoc for complex array types.


38-47: LGTM!

The default color initialization and helper label setup are appropriate and follow framework conventions.


49-59: LGTM!

The max value methods follow the fluent API pattern correctly and handle closure evaluation properly.


61-83: LGTM!

The threshold methods are implemented consistently with proper closure evaluation.


85-137: LGTM!

The color methods follow a consistent pattern with proper evaluation and normalization.


169-184: LGTM!

The helper label methods correctly provide context (state and percentage) during evaluation and handle null results safely.


219-260: LGTM!

The label and color resolution methods are well-implemented with appropriate fallback logic to ensure non-null return values as documented.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (3)
resources/views/livewire/server-entry.blade.php (3)

67-87: Add defensive array access for node stats to prevent notices.

Line 70 directly accesses $serverNodeSystemInfo['cpu_count'] without null coalescing. If this key is missing from the node data, PHP will emit an undefined array key notice, and the fallback calculation will become null * 100 = 0.

Apply defensive access:

-                    $cpuMax = \App\Enums\ServerResourceType::CPULimit->getResourceAmount($server) === 0 ? ($serverNodeSystemInfo['cpu_count'] * 100) : \App\Enums\ServerResourceType::CPULimit->getResourceAmount($server);
+                    $cpuMax = \App\Enums\ServerResourceType::CPULimit->getResourceAmount($server) === 0 ? (($serverNodeSystemInfo['cpu_count'] ?? 0) * 100) : \App\Enums\ServerResourceType::CPULimit->getResourceAmount($server);

111-131: Add defensive array access for disk stats to prevent notices.

Line 114 directly accesses $serverNodeStatistics['disk_total'] without null coalescing. If this key is missing, PHP will emit an undefined array key notice.

Apply defensive access:

-                    $diskMax = \App\Enums\ServerResourceType::DiskLimit->getResourceAmount($server) === 0 ? $serverNodeStatistics['disk_total'] : \App\Enums\ServerResourceType::DiskLimit->getResourceAmount($server);
+                    $diskMax = \App\Enums\ServerResourceType::DiskLimit->getResourceAmount($server) === 0 ? ($serverNodeStatistics['disk_total'] ?? 0) : \App\Enums\ServerResourceType::DiskLimit->getResourceAmount($server);

89-109: Add defensive array access for memory stats to prevent notices.

Line 92 directly accesses $serverNodeStatistics['memory_total'] without null coalescing. If this key is missing, PHP will emit an undefined array key notice.

Apply defensive access:

-                    $memMax = \App\Enums\ServerResourceType::MemoryLimit->getResourceAmount($server) === 0 ? $serverNodeStatistics['memory_total'] : \App\Enums\ServerResourceType::MemoryLimit->getResourceAmount($server);
+                    $memMax = \App\Enums\ServerResourceType::MemoryLimit->getResourceAmount($server) === 0 ? ($serverNodeStatistics['memory_total'] ?? 0) : \App\Enums\ServerResourceType::MemoryLimit->getResourceAmount($server);
🧹 Nitpick comments (1)
app/Filament/Components/Tables/Columns/ServerEntryColumn.php (1)

126-154: Refactor normalizeColor() to match ProgressBarColumn's clearer logic flow.

The current implementation works but is harder to follow than ProgressBarColumn's approach. Line 132 extracts array values for alias checking, then Line 147 checks is_array again. This creates a confusing execution path.

For consistency and clarity, match ProgressBarColumn's logic flow:

 protected function normalizeColor(string|array|null $color): string|array|null
 {
     if ($color === null) {
         return null;
     }
 
-    $lower = strtolower(trim(is_array($color) ? (string) ($color[500] ?? '') : (string) $color));
+    if (is_array($color)) {
+        $first = $color[500] ?? reset($color);
+
+        return Color::convertToRgb((string) $first);
+    }
+
+    $lower = strtolower(trim($color));
     $aliases = [
         'danger' => FilamentColor::getColor('danger'),
         'warning' => FilamentColor::getColor('warning'),
         'primary' => FilamentColor::getColor('primary'),
     ];
 
     if (isset($aliases[$lower])) {
         $resolved = $aliases[$lower];
         $resolvedArray = (array) $resolved;
         $value = reset($resolvedArray);
 
         return Color::convertToRgb((string) $value);
     }
 
-    if (is_array($color)) {
-        $first = $color[500] ?? reset($color);
-
-        return Color::convertToRgb((string) $first);
-    }
-
     return Color::convertToRgb($color);
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d7eb2c and 173b94b.

📒 Files selected for processing (5)
  • app/Filament/App/Resources/Servers/Pages/ListServers.php (5 hunks)
  • app/Filament/Components/Tables/Columns/ProgressBarColumn.php (1 hunks)
  • app/Filament/Components/Tables/Columns/ServerEntryColumn.php (1 hunks)
  • resources/views/livewire/columns/progress-bar-column.blade.php (1 hunks)
  • resources/views/livewire/server-entry.blade.php (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • resources/views/livewire/columns/progress-bar-column.blade.php
🧰 Additional context used
🧬 Code graph analysis (2)
app/Filament/App/Resources/Servers/Pages/ListServers.php (3)
app/Filament/Components/Tables/Columns/ProgressBarColumn.php (5)
  • ProgressBarColumn (10-265)
  • warningThresholdPercent (61-66)
  • dangerThresholdPercent (73-78)
  • maxValue (49-54)
  • helperLabel (173-178)
app/Filament/Components/Tables/Columns/ServerEntryColumn.php (2)
  • warningThresholdPercent (42-47)
  • dangerThresholdPercent (54-59)
app/Models/Server.php (3)
  • Server (134-525)
  • formatResource (485-511)
  • retrieveResources (475-483)
app/Filament/Components/Tables/Columns/ServerEntryColumn.php (1)
app/Filament/Components/Tables/Columns/ProgressBarColumn.php (10)
  • warningThresholdPercent (61-66)
  • dangerThresholdPercent (73-78)
  • dangerColor (88-93)
  • warningColor (106-111)
  • color (124-129)
  • setUp (38-47)
  • getColor (134-137)
  • getDangerColor (98-101)
  • normalizeColor (143-171)
  • getWarningColor (116-119)
🔇 Additional comments (22)
app/Filament/Components/Tables/Columns/ServerEntryColumn.php (6)

5-7: LGTM!

The new imports (Closure, Color, FilamentColor) are appropriate for the threshold and color management functionality being added.


14-31: LGTM!

The property declarations for thresholds and colors are well-structured and consistent with the ProgressBarColumn pattern. The PHPDoc annotations clearly document the array shapes.


33-40: LGTM!

The setUp() method correctly initializes default colors and follows the same pattern as ProgressBarColumn, ensuring consistent behavior across components.


42-64: LGTM!

The threshold setters and getters are correctly implemented with fluent interface support and proper Closure evaluation.


66-118: LGTM!

The color setters and getters are well-implemented with proper PHPDoc annotations, fluent interface support, and normalization of evaluated colors.


156-180: LGTM!

The getProgressColorForStatus() method correctly resolves colors based on status with appropriate fallbacks, mirroring ProgressBarColumn::getProgressColor() for consistent behavior across components.

app/Filament/App/Resources/Servers/Pages/ListServers.php (6)

8-8: LGTM!

The import of ProgressBarColumn and the addition of WARNING_THRESHOLD constant are appropriate. Making the thresholds public constants allows them to be reused across components.

Also applies to: 38-42


58-59: LGTM!

The threshold configuration on ServerEntryColumn correctly wires the class constants, ensuring consistent threshold behavior across grid and table views.


76-76: LGTM!

The addition of precision parameter (2) for the uptime tooltip provides more detailed time information, improving user experience.


90-96: LGTM!

The CPU ProgressBarColumn is correctly configured with appropriate null coalescing (?? 0), reasonable maxValue logic for unlimited cases, and proper precision for CPU display.


97-103: LGTM!

The Memory ProgressBarColumn correctly handles missing data with ?? 0 and properly converts memory limit to bytes for consistent units with the state value.


104-110: LGTM!

The Disk ProgressBarColumn correctly handles missing data with ?? 0 and properly converts disk limit to bytes for consistent units with the state value.

app/Filament/Components/Tables/Columns/ProgressBarColumn.php (10)

1-36: LGTM!

The class structure and property declarations are well-designed with appropriate types and nullability, providing a solid foundation for the progress bar functionality.


38-47: LGTM!

The setUp() method appropriately initializes default colors and provides a sensible default helperLabel implementation.


49-59: LGTM!

The maxValue setter and getter are correctly implemented with flexible type support (int, float, Closure) and proper evaluation.


61-83: LGTM!

The threshold setters and getters follow a consistent pattern with proper Closure evaluation and fluent interface support.


85-137: LGTM!

The color setters and getters are consistently implemented across all three color properties (danger, warning, primary) with proper normalization.


143-171: LGTM!

The normalizeColor() method correctly handles null values (addressing previous review feedback) and follows a clean, logical flow: null check → array handling → alias resolution → RGB conversion.


173-188: LGTM!

The helperLabel implementation provides flexibility by passing both state and percentage to the closure, enabling various label formatting options.


190-200: LGTM!

The progress percentage calculation correctly handles edge cases (null values, zero max) and bounds the result between 0 and 100.


202-221: LGTM!

The status determination logic correctly applies configurable thresholds with sensible defaults (0.9 for danger, 0.7 for warning) and evaluates them in the right order.


223-264: LGTM!

Both methods are well-implemented:

  • getProgressLabel() provides a flexible labeling system with sensible fallback
  • getProgressColor() guarantees a non-null color through a robust fallback chain (status-based → primary → gray)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
app/Filament/App/Resources/Servers/Pages/ListServers.php (1)

38-42: Clarify threshold semantics (ratio vs percent) for consistency.

You’re using WARNING_THRESHOLD = 0.7 / DANGER_THRESHOLD = 0.9 both in getResourceColor() (as ratios of the limit) and in warningThresholdPercent() / dangerThresholdPercent() on ServerEntryColumn and ProgressBarColumn. Given the method names end in *Percent, it’d be good to confirm those APIs expect 0–1 ratios (70% as 0.7) and not 0–100 values.

If they expect 0–100, these values will effectively be 0.7% / 0.9% thresholds. Either:

  • Keep them as ratios and ensure the column classes also treat them as ratios, or
  • Change the constants to 70.0 / 90.0 (and possibly rename to *_PERCENT) if the column logic works in whole percentages.

This will keep color/status behavior aligned between getResourceColor() and the progress-bar columns.

Also applies to: 58-59

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 173b94b and 0cb3906.

📒 Files selected for processing (2)
  • app/Filament/App/Resources/Servers/Pages/ListServers.php (5 hunks)
  • app/Models/Node.php (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/Filament/App/Resources/Servers/Pages/ListServers.php (4)
app/Filament/Components/Tables/Columns/ProgressBarColumn.php (4)
  • ProgressBarColumn (10-265)
  • warningThresholdPercent (61-66)
  • dangerThresholdPercent (73-78)
  • maxValue (49-54)
app/Filament/Components/Tables/Columns/ServerEntryColumn.php (2)
  • warningThresholdPercent (42-47)
  • dangerThresholdPercent (54-59)
app/Models/Server.php (3)
  • Server (134-525)
  • formatResource (485-511)
  • retrieveResources (475-483)
app/Enums/ServerResourceType.php (1)
  • getResourceAmount (21-35)
🔇 Additional comments (3)
app/Models/Node.php (2)

317-335: LGTM! Good caching strategy for system information.

The 360-second cache TTL appropriately balances freshness with reduced load on the daemon API. The exception handling provides graceful degradation with user-friendly error messages.


370-370: Good defensive improvement.

Changing from $data['memory_total'] to !empty($data['memory_total']) better handles edge cases where the key exists but contains null or zero values.

app/Filament/App/Resources/Servers/Pages/ListServers.php (1)

76-76: Uptime tooltip change looks good.

Using formatResource(ServerResourceType::Uptime, 2) keeps the tooltip formatting centralized and consistent with other resource displays; no issues spotted here.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
app/Filament/App/Resources/Servers/Pages/ListServers.php (1)

174-214: Remove the unused getResourceColor method.

The getResourceColor method is dead code—it's defined at lines 174-214 but never called anywhere in the codebase. Since its threshold logic is now handled by ProgressBarColumn, this method can be safely removed.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0cb3906 and dfb304c.

📒 Files selected for processing (1)
  • app/Filament/App/Resources/Servers/Pages/ListServers.php (5 hunks)
🔇 Additional comments (5)
app/Filament/App/Resources/Servers/Pages/ListServers.php (5)

8-8: LGTM!

The import of ProgressBarColumn and the threshold constants are well-defined and used consistently throughout the file.

Also applies to: 38-40


58-59: LGTM!

Properly configures the threshold percentages using the defined constants.


76-76: The method signature properly supports the varying parameter usage—no fixes needed.

The method definition in app/Models/Server.php (line 485) declares int $precision = 2 as an optional parameter:

public function formatResource(ServerResourceType $resourceType, int $precision = 2): string

The varying usage across the codebase is intentional:

  • CPU/CPULimit: precision 0 (percentage-based, no decimals)
  • Memory/MemoryLimit/Disk/DiskLimit/Uptime: default precision 2 (absolute values with 2 decimal places)

This is a well-designed pattern where resource type determines precision requirements. No code changes are required.

Likely an incorrect or invalid review comment.


97-103: The original review comment is incorrect; no changes are needed.

The statistics() method in app/Models/Node.php (line 346) always returns an array with guaranteed keys including 'memory_total' => 0 as a default value. Accessing $server->node->statistics()['memory_total'] is safe and will never produce an undefined array key error. This is consistent with how the rest of the codebase accesses these keys directly without defensive null coalescing (e.g., NodeMemoryChart.php:30, NodeStorageChart.php:40-75).

Likely an incorrect or invalid review comment.


104-110: ****

The review comment's concern is unfounded. The statistics() method in app/Models/Node.php (lines 346-383) guarantees that 'disk_total' is always present in the returned array:

  • It defines $default with 'disk_total' => 0 (line 357)
  • Return paths are either: $data from the daemon API (if successful) or $default (if the request fails or lacks expected data)
  • Both paths ensure the key exists, eliminating any undefined array key risk

Direct array access without null coalescing is safe. The suggested defensive code change is unnecessary.

Likely an incorrect or invalid review comment.

Traits are cool, Allow the user to input anything into the color, rgb/rgba/hex/oklch. Remove normalize color
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
app/Filament/Components/Tables/Columns/ServerEntryColumn.php (1)

5-22: Trait integration and default colors look solid

Using HasProgress here and wiring Filament theme colors in setUp() is consistent with ProgressBarColumn and should keep server entries visually aligned. If you want stricter encapsulation, you could optionally switch to the trait setters (dangerColor(), warningColor(), color()) instead of touching the protected properties directly, but the current approach is functionally fine.

app/Filament/Components/Tables/Columns/ProgressBarColumn.php (1)

21-30: Reuse HasProgress color resolver and align return types

The progress math and thresholds look good, but getProgressColor() is re‑implementing logic that already exists in HasProgress::getProgressColorForStatus(), and its declared return type omits Color even though the trait allows Color inputs:

  • dangerColor(), warningColor(), color() in HasProgress accept Color instances.
  • getProgressColorForStatus() already maps status → color and falls back to 'gray' when all branches are null.

To avoid divergence and better match the trait’s contract, you could:

  1. Delegate getProgressColor() to the trait helper:
public function getProgressColor(): string|array|Color
{
    return $this->getProgressColorForStatus($this->getProgressStatus());
}
  1. Update the return type / phpdoc to include Color (or, alternatively, normalize any Color to a string/array here).

This keeps all status→color rules in one place and makes the PHP types accurately reflect what callers — including your Blade view — may receive.

Also applies to: 61-71, 73-92, 107-135

app/Filament/Components/Tables/Columns/Concerns/HasProgress.php (1)

15-57: Clarify threshold semantics and centralize status→color mapping

The trait cleanly encapsulates thresholds and colors, and getProgressColorForStatus() provides a nice single point for status→color resolution with sensible fallbacks.

Two small improvements to consider:

  • Document expected threshold range: Callers currently need to infer that warningThresholdPercent / dangerThresholdPercent are fractions (e.g. 0.7 meaning 70%) rather than “percent points” (e.g. 70). A short note in the method phpdocs (or property docblocks) stating “value between 0 and 1” would prevent misconfiguration.
  • Encourage reuse from columns: ProgressBarColumn::getProgressColor() currently duplicates the same match/fallback logic; having it delegate to getProgressColorForStatus($this->getProgressStatus()) will keep behavior consistent if you ever tweak the mapping or defaults here.

These are non‑blocking, but they’ll make the trait easier to use correctly and reduce duplication in the columns.

Also applies to: 112-135

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dfb304c and 28d32b1.

📒 Files selected for processing (4)
  • app/Filament/Components/Tables/Columns/Concerns/HasProgress.php (1 hunks)
  • app/Filament/Components/Tables/Columns/ProgressBarColumn.php (1 hunks)
  • app/Filament/Components/Tables/Columns/ServerEntryColumn.php (1 hunks)
  • resources/views/livewire/columns/progress-bar-column.blade.php (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/Filament/Components/Tables/Columns/ProgressBarColumn.php (2)
app/Filament/Components/Tables/Columns/ServerEntryColumn.php (1)
  • setUp (15-22)
app/Filament/Components/Tables/Columns/Concerns/HasProgress.php (7)
  • dangerColor (61-66)
  • getColor (107-110)
  • warningColor (79-84)
  • color (97-102)
  • getDangerThresholdPercent (53-56)
  • getDangerColor (71-74)
  • getWarningColor (89-92)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (3)
resources/views/livewire/server-entry.blade.php (2)

92-92: Add null coalescing for memory_total to prevent undefined key errors.

The memory_total key is accessed without null coalescing. If the node statistics return incomplete data (e.g., on connection error), this will throw an undefined array key error.

Apply this fix:

-$memMax = \App\Enums\ServerResourceType::MemoryLimit->getResourceAmount($server) === 0 ? $serverNodeStatistics['memory_total'] : \App\Enums\ServerResourceType::MemoryLimit->getResourceAmount($server);
+$memMax = \App\Enums\ServerResourceType::MemoryLimit->getResourceAmount($server) === 0 ? ($serverNodeStatistics['memory_total'] ?? 0) : \App\Enums\ServerResourceType::MemoryLimit->getResourceAmount($server);

114-114: Add null coalescing for disk_total to prevent undefined key errors.

Same issue as memory—disk_total should have a null coalescing fallback.

Apply this fix:

-$diskMax = \App\Enums\ServerResourceType::DiskLimit->getResourceAmount($server) === 0 ? $serverNodeStatistics['disk_total'] : \App\Enums\ServerResourceType::DiskLimit->getResourceAmount($server);
+$diskMax = \App\Enums\ServerResourceType::DiskLimit->getResourceAmount($server) === 0 ? ($serverNodeStatistics['disk_total'] ?? 0) : \App\Enums\ServerResourceType::DiskLimit->getResourceAmount($server);
app/Filament/App/Resources/Servers/Pages/ListServers.php (1)

94-94: Critical operator precedence bug in CPU maxValue.

Same issue as in the Blade file: ['cpu_count'] ?? 0 * 100 evaluates as ['cpu_count'] ?? 0 due to operator precedence.

Apply this fix:

-->maxValue(fn (Server $server) => ServerResourceType::CPULimit->getResourceAmount($server) === 0 ? ($server->node->systemInformation()['cpu_count'] ?? 0 * 100) : ServerResourceType::CPULimit->getResourceAmount($server))
+->maxValue(fn (Server $server) => ServerResourceType::CPULimit->getResourceAmount($server) === 0 ? (($server->node->systemInformation()['cpu_count'] ?? 0) * 100) : ServerResourceType::CPULimit->getResourceAmount($server))
🧹 Nitpick comments (1)
resources/views/livewire/columns/progress-bar-column.blade.php (1)

33-50: Minor: Extra whitespace in CSS selectors.

There's extra whitespace before the { in the keyframe and class declarations (Lines 35, 47). While most browsers handle this, it's cleaner to remove it.

-@keyframes {{ $animClass }}                               {
+@keyframes {{ $animClass }} {
-.{{ $animClass }}                               {
+.{{ $animClass }} {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 28d32b1 and 459e8cf.

📒 Files selected for processing (4)
  • app/Filament/App/Resources/Servers/Pages/ListServers.php (5 hunks)
  • app/Filament/Components/Tables/Columns/ProgressBarColumn.php (1 hunks)
  • resources/views/livewire/columns/progress-bar-column.blade.php (1 hunks)
  • resources/views/livewire/server-entry.blade.php (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-23T23:36:27.096Z
Learnt from: notAreYouScared
Repo: pelican-dev/panel PR: 1924
File: resources/views/livewire/server-entry.blade.php:6-7
Timestamp: 2025-11-23T23:36:27.096Z
Learning: In the Pelican Panel codebase, the `$server->node` relationship will never be null, so defensive null checks using the null-safe operator (`?->`) are not needed when accessing the node or its methods.

Applied to files:

  • resources/views/livewire/server-entry.blade.php
  • app/Filament/App/Resources/Servers/Pages/ListServers.php
🧬 Code graph analysis (1)
app/Filament/Components/Tables/Columns/ProgressBarColumn.php (1)
app/Filament/Components/Tables/Columns/Concerns/HasProgress.php (8)
  • dangerColor (61-66)
  • getColor (107-110)
  • warningColor (79-84)
  • color (97-102)
  • getDangerThresholdPercent (53-56)
  • getWarningThresholdPercent (41-44)
  • getDangerColor (71-74)
  • getWarningColor (89-92)
🔇 Additional comments (4)
app/Filament/App/Resources/Servers/Pages/ListServers.php (1)

38-40: Good addition of the WARNING_THRESHOLD constant.

The threshold constants are well-defined and consistently applied across both grid and table column configurations.

resources/views/livewire/columns/progress-bar-column.blade.php (1)

53-67: Good accessibility implementation.

The progress bar correctly implements ARIA attributes (role="progressbar", aria-valuenow, aria-valuemin, aria-valuemax, aria-label) for screen reader support.

app/Filament/Components/Tables/Columns/ProgressBarColumn.php (2)

60-70: Well-implemented percentage calculation with proper bounds.

The method correctly handles null states and zero/negative max values, and clamps the result to 0-100%.


131-156: Solid color resolution logic.

The static resolveColor method properly handles objects (with various color conversion methods), arrays (using shade 500 or first value), and strings. The final string check ensures type safety.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
resources/views/livewire/server-entry.blade.php (3)

91-92: Add null coalescing for memory_total to match CPU pattern.

Unlike the CPU block (line 70) which uses ?? 0 for cpu_count, this line directly accesses $serverNodeStatistics['memory_total']. If the key is absent, PHP will emit a notice.

-                    $memMax = \App\Enums\ServerResourceType::MemoryLimit->getResourceAmount($server) === 0 ? $serverNodeStatistics['memory_total'] : \App\Enums\ServerResourceType::MemoryLimit->getResourceAmount($server);
+                    $memMax = \App\Enums\ServerResourceType::MemoryLimit->getResourceAmount($server) === 0 ? ($serverNodeStatistics['memory_total'] ?? 0) : \App\Enums\ServerResourceType::MemoryLimit->getResourceAmount($server);

113-114: Add null coalescing for disk_total for consistency.

Same issue as the memory block—direct array access without null coalescing.

-                    $diskMax = \App\Enums\ServerResourceType::DiskLimit->getResourceAmount($server) === 0 ? $serverNodeStatistics['disk_total'] : \App\Enums\ServerResourceType::DiskLimit->getResourceAmount($server);
+                    $diskMax = \App\Enums\ServerResourceType::DiskLimit->getResourceAmount($server) === 0 ? ($serverNodeStatistics['disk_total'] ?? 0) : \App\Enums\ServerResourceType::DiskLimit->getResourceAmount($server);

67-131: Consider extracting repeated progress bar logic.

The CPU, Memory, and Disk blocks share nearly identical structure. While acceptable for a Blade template, you could reduce duplication by iterating over a configuration array:

@php
    $resources = [
        ['type' => \App\Enums\ServerResourceType::CPU, 'limitType' => \App\Enums\ServerResourceType::CPULimit, 'maxFallback' => ($serverNodeSystemInfo['cpu_count'] ?? 0) * 100, 'precision' => 0],
        ['type' => \App\Enums\ServerResourceType::Memory, 'limitType' => \App\Enums\ServerResourceType::MemoryLimit, 'maxFallback' => $serverNodeStatistics['memory_total'] ?? 0, 'precision' => null],
        ['type' => \App\Enums\ServerResourceType::Disk, 'limitType' => \App\Enums\ServerResourceType::DiskLimit, 'maxFallback' => $serverNodeStatistics['disk_total'] ?? 0, 'precision' => null],
    ];
@endphp

@foreach($resources as $resource)
    <div class="w-full max-w-xs">
        @php
            $current = $resource['type']->getResourceAmount($server);
            $max = $resource['limitType']->getResourceAmount($server) === 0 ? $resource['maxFallback'] : $resource['limitType']->getResourceAmount($server);
            // ... rest of closures
        @endphp
        @include('livewire.columns.progress-bar-column', [...])
    </div>
@endforeach

This is optional—the current explicit approach is also maintainable and clear.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 459e8cf and 3b8fa0b.

📒 Files selected for processing (1)
  • resources/views/livewire/server-entry.blade.php (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-23T23:36:27.096Z
Learnt from: notAreYouScared
Repo: pelican-dev/panel PR: 1924
File: resources/views/livewire/server-entry.blade.php:6-7
Timestamp: 2025-11-23T23:36:27.096Z
Learning: In the Pelican Panel codebase, the `$server->node` relationship will never be null, so defensive null checks using the null-safe operator (`?->`) are not needed when accessing the node or its methods.

Applied to files:

  • resources/views/livewire/server-entry.blade.php
🔇 Additional comments (2)
resources/views/livewire/server-entry.blade.php (2)

1-11: Initialization block looks good.

The setup correctly initializes the server entry column with a sensible fallback, retrieves node statistics, and establishes threshold defaults (70% warning, 90% danger). Based on learnings, the $server->node relationship is guaranteed to exist, so no defensive null checks are needed here.


67-87: CPU progress bar implementation is correct.

The operator precedence issue from the previous review has been properly fixed with (($serverNodeSystemInfo['cpu_count'] ?? 0) * 100). The fallback logic, percentage calculation, and status determination are all sound.

@notAreYouScared notAreYouScared merged commit 2dd6e3d into main Nov 28, 2025
25 checks passed
@notAreYouScared notAreYouScared deleted the charles/progress-bars branch November 28, 2025 23:04
@github-actions github-actions bot locked and limited conversation to collaborators Nov 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants