Compact recordings list rows to title plus one transcript preview line.

This commit is contained in:
ben
2026-08-12 20:36:22 +02:00
parent 6bc5a20606
commit b7c36b8b3b
3 changed files with 40 additions and 13 deletions
+22
View File
@@ -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. * Short transcript excerpt, optionally centered on a search hit.
*/ */
@@ -125,18 +125,21 @@
/> />
</flux:button> </flux:button>
</flux:table.cell> </flux:table.cell>
<flux:table.cell class="whitespace-normal"> <flux:table.cell class="max-w-xl">
<flux:link href="{{ route('recordings.show', $recording) }}" wire:navigate class="font-medium"> <div class="flex min-w-0 items-center gap-2">
{{ $recording->title }} <flux:link
</flux:link> href="{{ route('recordings.show', $recording) }}"
@if ($recording->artist) wire:navigate
<flux:text class="mt-0.5 text-xs">{{ $recording->artist }}</flux:text> class="shrink-0 font-medium"
@endif >
@if ($snippet = $recording->transcriptSnippet($search ?: null)) {{ $recording->title }}
<flux:text class="mt-1 max-w-xl text-xs leading-relaxed"> </flux:link>
{{ $snippet }} @if ($preview = $recording->transcriptFirstLine())
</flux:text> <span class="min-w-0 truncate text-sm text-zinc-500 dark:text-zinc-400" title="{{ $preview }}">
@endif {{ $preview }}
</span>
@endif
</div>
</flux:table.cell> </flux:table.cell>
<flux:table.cell>{{ $recording->duration_formatted }}</flux:table.cell> <flux:table.cell>{{ $recording->duration_formatted }}</flux:table.cell>
<flux:table.cell> <flux:table.cell>
+3 -1
View File
@@ -63,7 +63,7 @@ class IndexTest extends TestCase
'file_path' => 'recordings/office.mp3', 'file_path' => 'recordings/office.mp3',
'file_size_bytes' => 100, 'file_size_bytes' => 100,
'transcription_status' => 'done', 'transcription_status' => 'done',
'transcript' => 'talking about the pocket recorder today', 'transcript' => "talking about the pocket recorder today\nsecond line stays hidden",
]); ]);
Recording::query()->create([ Recording::query()->create([
@@ -79,6 +79,8 @@ class IndexTest extends TestCase
Livewire::test(Index::class) Livewire::test(Index::class)
->set('search', 'pocket recorder') ->set('search', 'pocket recorder')
->assertSee('Office chat') ->assertSee('Office chat')
->assertSee('talking about the pocket recorder today')
->assertDontSee('second line stays hidden')
->assertDontSee('Unrelated'); ->assertDontSee('Unrelated');
} }