From 90e6efadadb847ad3e1df931eda7e07b6a3362bf Mon Sep 17 00:00:00 2001 From: Aditya Tripathi Date: Wed, 16 Sep 2026 09:29:32 +0000 Subject: [PATCH] fix(metrics): rAF chart render, container image resolution, tab loading state, hi-fi skeleton --- app/Livewire/Fleet/Metrics.php | 37 +++++++++------- .../fleet/metrics-placeholder.blade.php | 42 ++++++++++++++----- .../views/livewire/fleet/metrics.blade.php | 42 ++++++++++++------- 3 files changed, 82 insertions(+), 39 deletions(-) diff --git a/app/Livewire/Fleet/Metrics.php b/app/Livewire/Fleet/Metrics.php index 679fdf5593..901fc7cdcd 100644 --- a/app/Livewire/Fleet/Metrics.php +++ b/app/Livewire/Fleet/Metrics.php @@ -143,8 +143,9 @@ class Metrics extends Component ); foreach ($current as $c) { - $meta = $this->resolveContainer($server, $c['id']); - $containers[] = array_merge($c, ['server' => $server->name, 'name' => $meta['name'], 'link' => $meta['link']]); + // Names/images are resolved lazily for the displayed rows only (containerMeta), + // so a server with many containers doesn't trigger a resolve storm here. + $containers[] = array_merge($c, ['server' => $server->name]); } $series['cpu'][] = $client->history('cpu', $from); @@ -185,30 +186,38 @@ class Metrics extends Component /** * Resolve a Sentinel container id (the resource uuid Sentinel keys by) to a - * team-owned resource name + metrics link, memoized. Shows the raw id when no - * team-owned resource matches, so a Sentinel id never discloses another team's name. + * team-owned resource name, docker image, and metrics link, memoized. Shows the raw + * id and no image when no team-owned resource matches, so a Sentinel id never + * discloses another team's resource. * - * @return array{name: string, link: ?string} + * @return array{name: string, image: ?string, link: ?string} */ - protected function resolveContainer(Server $server, string $id): array + public function containerMeta(string $id): array { if (isset($this->containerMetaCache[$id])) { return $this->containerMetaCache[$id]; } - $app = Application::ownedByCurrentTeam()->with('environment.project')->whereUuid($id)->first(); + $teamId = currentTeam()?->id; + $resource = $teamId ? getResourceByUuid($id, $teamId) : null; + $image = null; $link = null; - if ($app && data_get($app, 'environment.project.uuid')) { - $link = route('project.application.metrics', [ - 'project_uuid' => $app->environment->project->uuid, - 'environment_uuid' => $app->environment->uuid, - 'application_uuid' => $app->uuid, - ]); + if ($resource) { + $image = data_get($resource, 'docker_registry_image_name') ?: data_get($resource, 'image'); + + if ($resource instanceof Application && data_get($resource, 'environment.project.uuid')) { + $link = route('project.application.metrics', [ + 'project_uuid' => $resource->environment->project->uuid, + 'environment_uuid' => $resource->environment->uuid, + 'application_uuid' => $resource->uuid, + ]); + } } return $this->containerMetaCache[$id] = [ - 'name' => $app?->name ?? $id, + 'name' => $resource?->name ?? $id, + 'image' => $image ?: null, 'link' => $link, ]; } diff --git a/resources/views/livewire/fleet/metrics-placeholder.blade.php b/resources/views/livewire/fleet/metrics-placeholder.blade.php index f67be9c225..f65f4e4319 100644 --- a/resources/views/livewire/fleet/metrics-placeholder.blade.php +++ b/resources/views/livewire/fleet/metrics-placeholder.blade.php @@ -1,18 +1,38 @@ -
-
-

Metrics

-

Resource usage across your servers.

+
+ {{-- Header (real chrome; only the data below is a skeleton) --}} +
+
+

Metrics

+

+ Resource usage across every server, reported by Sentinel. +

+
+ + {{-- Filter bar --}} +
+ + +
- + + +
- @foreach (['CPU', 'Memory used'] as $label) -
- {{ $label }} - -
+ @foreach (['CPU', 'Memory used', 'Network throughput', 'Load average', 'Disk usage'] as $label) + + + @endforeach
+ + + + + + + +
diff --git a/resources/views/livewire/fleet/metrics.blade.php b/resources/views/livewire/fleet/metrics.blade.php index 07bd0d9e0d..0687779d0c 100644 --- a/resources/views/livewire/fleet/metrics.blade.php +++ b/resources/views/livewire/fleet/metrics.blade.php @@ -174,13 +174,18 @@ $serverListboxOptions = array_merge( -
- @foreach (['cpu' => 'CPU', 'memory' => 'Memory', 'disk' => 'Disk', 'network' => 'Network'] as $m => $mlabel) - - @endforeach +
+ +
+ @foreach (['cpu' => 'CPU', 'memory' => 'Memory', 'disk' => 'Disk', 'network' => 'Network'] as $m => $mlabel) + + @endforeach +
@if (empty($topContainers)) @@ -189,23 +194,28 @@ $serverListboxOptions = array_merge( description="Container metrics need a Sentinel build with the bulk endpoints." />
@else -
+
Container Server {{ ['cpu' => 'CPU', 'memory' => 'Memory', 'disk' => 'Disk', 'network' => 'Network'][$containerMetric] }}
@foreach ($topContainers as $c) + @php $meta = $this->containerMeta($c['id']); @endphp
-
- @if ($c['link']) - {{ $c['name'] }} +
+ @if ($meta['link']) + {{ $meta['name'] }} @else - {{ $c['name'] }} + {{ $meta['name'] }} + @endif + @if ($meta['image']) + {{ $meta['image'] }} @endif
-
{{ $c['server'] }}
-
+
{{ $c['server'] }}
+
@switch($containerMetric) @case('memory'){{ formatBytes($c['memUsed'] ?? 0) }}@break @case('disk'){{ formatBytes($c['diskBytes'] ?? 0) }}@break @@ -223,6 +233,9 @@ $serverListboxOptions = array_merge( @script @endscript