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.
*/
@@ -125,18 +125,21 @@
/>
</flux:button>
</flux:table.cell>
<flux:table.cell class="whitespace-normal">
<flux:link href="{{ route('recordings.show', $recording) }}" wire:navigate class="font-medium">
{{ $recording->title }}
</flux:link>
@if ($recording->artist)
<flux:text class="mt-0.5 text-xs">{{ $recording->artist }}</flux:text>
@endif
@if ($snippet = $recording->transcriptSnippet($search ?: null))
<flux:text class="mt-1 max-w-xl text-xs leading-relaxed">
{{ $snippet }}
</flux:text>
@endif
<flux:table.cell class="max-w-xl">
<div class="flex min-w-0 items-center gap-2">
<flux:link
href="{{ route('recordings.show', $recording) }}"
wire:navigate
class="shrink-0 font-medium"
>
{{ $recording->title }}
</flux:link>
@if ($preview = $recording->transcriptFirstLine())
<span class="min-w-0 truncate text-sm text-zinc-500 dark:text-zinc-400" title="{{ $preview }}">
{{ $preview }}
</span>
@endif
</div>
</flux:table.cell>
<flux:table.cell>{{ $recording->duration_formatted }}</flux:table.cell>
<flux:table.cell>
+3 -1
View File
@@ -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');
}