@php $runs = $runs ?? collect(); $overflowCount = (int) ($overflowCount ?? 0); $tenant = $tenant ?? null; $visibleRunCount = $runs->count(); $activeRunCount = (int) ($activeRunCount ?? ($runs->filter(fn ($run): bool => $run instanceof \App\Models\OperationRun && $run->isCurrentlyActive())->count() + $overflowCount)); $primaryRun = $runs->first(); $hasActiveVisibleRuns = $runs->contains(fn ($run): bool => $run instanceof \App\Models\OperationRun && $run->isCurrentlyActive()); $hasTerminalFollowUpVisibleRuns = $runs->contains(fn ($run): bool => $run instanceof \App\Models\OperationRun && ! $run->isCurrentlyActive() && $run->requiresOperatorReview()); $hasTerminalVisibleRuns = $runs->contains(fn ($run): bool => $run instanceof \App\Models\OperationRun && ! $run->isCurrentlyActive()); $usesCollectivePrimaryAction = $visibleRunCount > 1; $operationsCollectionLabel = \App\Support\OperationRunLinks::collectionLabel(); $operationsIndexUrl = $tenant ? \App\Support\OpsUx\OperationRunUrl::index($tenant) : null; $primaryActionLabel = $usesCollectivePrimaryAction ? 'Review operations' : 'View operation'; $bannerTitle = $hasTerminalVisibleRuns ? 'Operation updates' : 'Active operations'; $bannerHelper = $hasTerminalVisibleRuns ? 'Recent operation updates stay inside the tenant shell until you need the diagnostics view.' : 'Queued and running work stays inside the tenant shell until you need the diagnostics view.'; $primaryActionUrl = null; if ($usesCollectivePrimaryAction) { $primaryActionUrl = $operationsIndexUrl; } elseif ($tenant && $primaryRun) { $primaryActionUrl = \App\Support\OpsUx\OperationRunUrl::view($primaryRun, $tenant); } $tertiaryActionLabel = $hasActiveVisibleRuns ? 'Hide activity' : ($hasTerminalFollowUpVisibleRuns ? ($visibleRunCount > 1 ? 'Dismiss updates' : 'Dismiss') : 'Dismiss'); @endphp {{-- Cleanup is delegated to the shared poller helper, which uses teardownObserver and new MutationObserver. --}} {{-- Widget must always be mounted, even when empty, so it can receive Livewire events --}}