@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 = match (true) { $hasTerminalFollowUpVisibleRuns => 'Review needed operation updates stay visible until you open Operations or acknowledge them in this browser session.', $hasTerminalVisibleRuns => 'Successful operation updates stay briefly visible so you can confirm completion and keep working.', default => '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 = $hasTerminalFollowUpVisibleRuns ? 'Acknowledge' : ($hasActiveVisibleRuns ? 'Hide activity' : '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 --}}