From a8616809f1272d071e01a384b8fbe10d5dce25b1 Mon Sep 17 00:00:00 2001 From: boban Date: Sun, 14 Jun 2026 20:58:48 +0200 Subject: [PATCH] fix(services): cap live journal at 200 rows in a scrollable, auto-sticking box --- app/Livewire/Services/Index.php | 2 +- app/Services/FleetService.php | 2 +- resources/views/livewire/services/index.blade.php | 7 ++++++- tests/Feature/ServicesJournalPollTest.php | 4 ++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/Livewire/Services/Index.php b/app/Livewire/Services/Index.php index 3d26b54..d7a859c 100644 --- a/app/Livewire/Services/Index.php +++ b/app/Livewire/Services/Index.php @@ -16,7 +16,7 @@ class Index extends Component use WithFleetContext; /** Cap on retained journal rows so the live poll never grows the payload unbounded. */ - private const JOURNAL_MAX = 300; + private const JOURNAL_MAX = 200; /** Active server name (from fleet context). */ public string $server = '—'; diff --git a/app/Services/FleetService.php b/app/Services/FleetService.php index a7d1d83..a30b063 100644 --- a/app/Services/FleetService.php +++ b/app/Services/FleetService.php @@ -358,7 +358,7 @@ class FleetService * * @return array{journal:array,cursor:?string} */ - public function journalSince(Server $server, ?string $cursor, int $tail = 300): array + public function journalSince(Server $server, ?string $cursor, int $tail = 200): array { // Journald cursors are `key=hex` segments joined by `;` — reject anything else // before it reaches the shell, then single-quote it. diff --git a/resources/views/livewire/services/index.blade.php b/resources/views/livewire/services/index.blade.php index ec528e8..640d239 100644 --- a/resources/views/livewire/services/index.blade.php +++ b/resources/views/livewire/services/index.blade.php @@ -93,7 +93,12 @@ {{ __('services.journal_live') }} -
+
@foreach ($journal as $line)
diff --git a/tests/Feature/ServicesJournalPollTest.php b/tests/Feature/ServicesJournalPollTest.php index 2bee76b..42f017f 100644 --- a/tests/Feature/ServicesJournalPollTest.php +++ b/tests/Feature/ServicesJournalPollTest.php @@ -42,7 +42,7 @@ class ServicesJournalPollTest extends TestCase $fleet = Mockery::mock(FleetService::class); $fleet->shouldReceive('journalSince') ->once() - ->with(Mockery::type(Server::class), 'cur-0', 300) + ->with(Mockery::type(Server::class), 'cur-0', 200) ->andReturn([ 'journal' => [['time' => '10:00:05', 'unit' => 'nginx', 'level' => 'info', 'text' => 'new line']], 'cursor' => 'cur-1', @@ -83,7 +83,7 @@ class ServicesJournalPollTest extends TestCase ->call('pollJournal'); $journal = $component->get('journal'); - $this->assertCount(300, $journal); + $this->assertCount(200, $journal); // The oldest row is evicted; the newest survives. $this->assertSame('n350', end($journal)['text']); $this->assertNotSame('oldest', $journal[0]['text']);