From f2a017a0636ade05626b20f5357fe520a3b1bc0c Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Sun, 2 Nov 2025 17:10:34 +0100 Subject: [PATCH] fix: revert to original dispatch approach with unique wire:key per monitor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause analysis: - Changed from dispatch to property binding broke the activity monitor completely - ActivityMonitor component expects activityMonitor event, not property binding - Original approach was correct: use dispatch + event listeners Solution: - Revert to original dispatch('activityMonitor', $activity->id) calls - Use @if conditionals to render only one monitor at a time (removes from DOM) - Add unique wire:key to each monitor instance to prevent conflicts - S3 download monitor: wire:key="s3-download-{{ $resource->uuid }}" - Database restore monitor: wire:key="database-restore-{{ $resource->uuid }}" This ensures: - Activity monitors display correctly when processes start - Only one monitor is rendered at a time (S3 download OR database restore) - Each monitor has unique identity via wire:key - Event listeners work as designed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/Livewire/ActivityMonitor.php | 8 ---- app/Livewire/Project/Database/Import.php | 9 ++-- .../project/database/import.blade.php | 45 ++++++++++--------- 3 files changed, 27 insertions(+), 35 deletions(-) diff --git a/app/Livewire/ActivityMonitor.php b/app/Livewire/ActivityMonitor.php index c30a46d62..54034ef7a 100644 --- a/app/Livewire/ActivityMonitor.php +++ b/app/Livewire/ActivityMonitor.php @@ -44,14 +44,6 @@ public function hydrateActivity() $this->activity = Activity::find($this->activityId); } - public function updatedActivityId($value) - { - if ($value) { - $this->hydrateActivity(); - $this->isPollingActive = true; - } - } - public function polling() { $this->hydrateActivity(); diff --git a/app/Livewire/Project/Database/Import.php b/app/Livewire/Project/Database/Import.php index c82784822..3e9ff160d 100644 --- a/app/Livewire/Project/Database/Import.php +++ b/app/Livewire/Project/Database/Import.php @@ -68,8 +68,6 @@ class Import extends Component public bool $s3DownloadInProgress = false; - public ?int $currentActivityId = null; - public function getListeners() { $userId = Auth::id(); @@ -271,7 +269,7 @@ public function runImport() 'container' => $this->container, 'serverId' => $this->server->id, ]); - $this->currentActivityId = $activity->id; + $this->dispatch('activityMonitor', $activity->id); } } catch (\Throwable $e) { return handleError($e, $this); @@ -411,8 +409,8 @@ public function downloadFromS3() $this->s3DownloadedFile = $downloadPath; $this->filename = $downloadPath; - $this->currentActivityId = $activity->id; + $this->dispatch('activityMonitor', $activity->id); $this->dispatch('info', 'Downloading file from S3. This may take a few minutes for large backups...'); } catch (\Throwable $e) { $this->s3DownloadInProgress = false; @@ -494,7 +492,7 @@ public function restoreFromS3() 's3DownloadedFile' => $this->s3DownloadedFile, 'resourceUuid' => $this->resource->uuid, ]); - $this->currentActivityId = $activity->id; + $this->dispatch('activityMonitor', $activity->id); } } catch (\Throwable $e) { return handleError($e, $this); @@ -524,7 +522,6 @@ public function cancelS3Download() // Reset S3 download state $this->s3DownloadedFile = null; $this->s3DownloadInProgress = false; - $this->currentActivityId = null; $this->filename = null; } } diff --git a/resources/views/livewire/project/database/import.blade.php b/resources/views/livewire/project/database/import.blade.php index 3568c85f7..9cec8f78e 100644 --- a/resources/views/livewire/project/database/import.blade.php +++ b/resources/views/livewire/project/database/import.blade.php @@ -8,8 +8,7 @@ s3DownloadedFile: $wire.entangle('s3DownloadedFile'), s3FileSize: $wire.entangle('s3FileSize'), s3StorageId: $wire.entangle('s3StorageId'), - s3Path: $wire.entangle('s3Path'), - importRunning: $wire.entangle('importRunning') + s3Path: $wire.entangle('s3Path') }"> @script @@ -148,23 +147,25 @@ -
-
Downloading from S3... This may take a few minutes for large - backups.
- -
- -
-
File downloaded successfully and ready for restore.
-
- - Restore Database from S3 - - - Cancel - + @if ($s3DownloadInProgress) +
+
Downloading from S3... This may take a few minutes for large + backups.
+
-
+ @elseif ($s3DownloadedFile) +
+
File downloaded successfully and ready for restore.
+
+ + Restore Database from S3 + + + Cancel + +
+
+ @endif
@endif @@ -173,9 +174,11 @@
Location: /
Restore Backup -
- -
+ @if ($importRunning) +
+ +
+ @endif @else
Database must be running to restore a backup.
@endif