From b7c36b8b3b8e93c94c0d300374db6189c9dd3ec8 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 12 Aug 2026 20:36:22 +0200 Subject: [PATCH] Compact recordings list rows to title plus one transcript preview line. --- app/Models/Recording.php | 22 +++++++++++++++ .../views/livewire/recordings/index.blade.php | 27 ++++++++++--------- tests/Feature/Recordings/IndexTest.php | 4 ++- 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/app/Models/Recording.php b/app/Models/Recording.php index 5b9a480..a088274 100644 --- a/app/Models/Recording.php +++ b/app/Models/Recording.php @@ -179,6 +179,28 @@ class Recording extends Model }); } + /** + * First line of the transcript, truncated for compact list rows. + */ + public function transcriptFirstLine(int $limit = 120): ?string + { + if (! filled($this->transcript)) { + return null; + } + + $firstLine = Str::of($this->transcript) + ->before("\n") + ->replaceMatches('/\s+/', ' ') + ->trim() + ->toString(); + + if ($firstLine === '') { + return null; + } + + return Str::limit($firstLine, $limit); + } + /** * Short transcript excerpt, optionally centered on a search hit. */ diff --git a/resources/views/livewire/recordings/index.blade.php b/resources/views/livewire/recordings/index.blade.php index 9bcc816..aa8824c 100644 --- a/resources/views/livewire/recordings/index.blade.php +++ b/resources/views/livewire/recordings/index.blade.php @@ -125,18 +125,21 @@ /> - - - {{ $recording->title }} - - @if ($recording->artist) - {{ $recording->artist }} - @endif - @if ($snippet = $recording->transcriptSnippet($search ?: null)) - - {{ $snippet }} - - @endif + +
+ + {{ $recording->title }} + + @if ($preview = $recording->transcriptFirstLine()) + + {{ $preview }} + + @endif +
{{ $recording->duration_formatted }} diff --git a/tests/Feature/Recordings/IndexTest.php b/tests/Feature/Recordings/IndexTest.php index 80494ad..c9adc1f 100644 --- a/tests/Feature/Recordings/IndexTest.php +++ b/tests/Feature/Recordings/IndexTest.php @@ -63,7 +63,7 @@ class IndexTest extends TestCase 'file_path' => 'recordings/office.mp3', 'file_size_bytes' => 100, 'transcription_status' => 'done', - 'transcript' => 'talking about the pocket recorder today', + 'transcript' => "talking about the pocket recorder today\nsecond line stays hidden", ]); Recording::query()->create([ @@ -79,6 +79,8 @@ class IndexTest extends TestCase Livewire::test(Index::class) ->set('search', 'pocket recorder') ->assertSee('Office chat') + ->assertSee('talking about the pocket recorder today') + ->assertDontSee('second line stays hidden') ->assertDontSee('Unrelated'); }