From 631c4fa3f89d5a1505ec61e81bfb4eff2862e2b4 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Sun, 22 Nov 2026 12:56:00 +0000 Subject: [PATCH 1/2] Show a compact link row under a commit's own images A YouTube link drew its full player card even when the commit had photos, so the post showed two big pictures. With photos attached, a video now gets the compact link row instead, and link rows drop their thumbnail. Co-Authored-By: Claude Opus 5.5 --- .../native/partials/commit-media.blade.php | 10 +++-- tests/Feature/Screens/CommitEmbedTest.php | 43 +++++++++++++++++++ 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/resources/views/native/partials/commit-media.blade.php b/resources/views/native/partials/commit-media.blade.php index 2e0851f7..1f8d6227 100644 --- a/resources/views/native/partials/commit-media.blade.php +++ b/resources/views/native/partials/commit-media.blade.php @@ -1,6 +1,7 @@ {{-- What hangs under a commit's body on the web: its images, its poll, the commit it quotes, then the link preview, or - for a YouTube link the player devnull offers (see partials/commit-embed). Other players keep the preview for now. + for a YouTube link the player devnull offers (see partials/commit-embed). Other players keep the preview for now, and + so does a video under the commit's own images, as a compact row with no picture of its own. A Nata Nu//ers high score has its card first, which the web doesn't draw (see partials/score-card). A reply in a thread shows only its images and link preview ($withEmbeds false), as the web's thread does. Images hold their space at their aspect ratio on a wash, so one that fails to load leaves the row as it was. Each is @@ -42,14 +43,15 @@ @include('native.partials.quoted-commit') @endif -@if ($commit->linkPreview?->embed?->isYouTube()) +@if ($images === [] && $commit->linkPreview?->embed?->isYouTube()) @include('native.partials.commit-embed', ['preview' => $commit->linkPreview]) @elseif ($commit->linkPreview?->isReady()) @php($preview = $commit->linkPreview) - {{-- A compact row, not a card: a small image, the mono site, then the title and description. --}} + {{-- A compact row, not a card: a small image, the mono site, then the title and description. Under the commit's own + images it has no image of its own, and a video is this row rather than its player. --}} - @if ($preview->imageUrl) + @if ($preview->imageUrl && $images === []) diff --git a/tests/Feature/Screens/CommitEmbedTest.php b/tests/Feature/Screens/CommitEmbedTest.php index 2f6d7416..864df33c 100644 --- a/tests/Feature/Screens/CommitEmbedTest.php +++ b/tests/Feature/Screens/CommitEmbedTest.php @@ -156,3 +156,46 @@ function imagesIn(array $node): array expect(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'embed-play-c1'))->toBeNull() ->and(nodeByRef($screen, 'link-preview-c1'))->not->toBeEmpty(); }); + +it("shows a video as a compact link row with no picture under the commit's own images", function () { + Http::fake(['www.youtube.com/oembed*' => Http::response(null, 404), 'devnull.test/*' => Http::response(pageJson([commitJson([ + 'id' => 'c1', + 'body' => 'Watch https://www.youtube.com/watch?v=E9Zx6rx0bWk', + 'images' => [['id' => 7, 'width' => 400, 'height' => 300, 'description' => null, 'url' => 'https://img.test/7']], + 'link_preview' => [ + 'url' => 'https://youtu.be/E9Zx6rx0bWk', + 'title' => 'The episode', + 'description' => null, + 'image_url' => 'https://i.ytimg.com/vi/E9Zx6rx0bWk/hqdefault.jpg', + 'site_name' => 'YouTube', + 'embed' => [ + 'provider' => 'YouTube', + 'kind' => 'video', + 'src' => 'https://www.youtube-nocookie.com/embed/E9Zx6rx0bWk?autoplay=1', + 'aspect_ratio' => '16 / 9', + 'height' => null, + 'poster' => 'https://i.ytimg.com/vi/E9Zx6rx0bWk/hqdefault.jpg', + ], + ], + ])]))]); + + $screen = Native::visit('/log')->assertSee('The episode'); + + $screen->assertMissingElement('pressable', fn (array $node): bool => ($node['ref'] ?? null) === 'embed-play-c1'); + + expect(imagesIn(nodeByRef($screen, 'link-preview-c1')))->toBe([]) + ->and(array_column(array_column(imagesIn(nodeByRef($screen, 'image-7')), 'props'), 'src'))->toHaveCount(1); +}); + +it("leaves a link preview's picture out under the commit's own images", function () { + Http::fake(['devnull.test/*' => Http::response(pageJson([commitJson([ + 'id' => 'c1', + 'body' => 'Read https://example.com/post', + 'images' => [['id' => 7, 'width' => 400, 'height' => 300, 'description' => null, 'url' => 'https://img.test/7']], + 'link_preview' => ['url' => 'https://example.com/post', 'title' => 'The post', 'description' => null, 'image_url' => 'https://example.com/og.png', 'site_name' => null], + ])]))]); + + $screen = Native::visit('/log')->assertSee('The post'); + + expect(imagesIn(nodeByRef($screen, 'link-preview-c1')))->toBe([]); +}); From cfcd248662ab137088f4dd5ad806abb5a4f38974 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Sun, 22 Nov 2026 14:40:44 +0000 Subject: [PATCH 2/2] Name the video and channel in a YouTube link's compact row Under a commit's own images a YouTube link shows the compact row, which used the scraped page title ("- YouTube") and YouTube's generic blurb. It now uses the same title and channel as the video card. Co-Authored-By: Claude Opus 5.5 --- .../native/partials/commit-media.blade.php | 19 +++++++++--- tests/Feature/Screens/CommitEmbedTest.php | 31 +++++++++++++++++++ 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/resources/views/native/partials/commit-media.blade.php b/resources/views/native/partials/commit-media.blade.php index 1f8d6227..fe6ea43e 100644 --- a/resources/views/native/partials/commit-media.blade.php +++ b/resources/views/native/partials/commit-media.blade.php @@ -48,8 +48,17 @@ @elseif ($commit->linkPreview?->isReady()) @php($preview = $commit->linkPreview) {{-- A compact row, not a card: a small image, the mono site, then the title and description. Under the commit's own - images it has no image of its own, and a video is this row rather than its player. --}} - + images it has no image of its own, and a video is this row rather than its player. A YouTube video's row names + the video and its channel, as its card does (see VideoDetails), rather than YouTube's own page title and blurb. --}} + @if ($preview->embed?->isYouTube()) + @php($card = \App\Devnull\VideoDetails::card($preview)) + @php($rowTitle = $card['title'] ?? $preview->title) + @php($rowDescription = $card['author']) + @else + @php($rowTitle = $preview->title) + @php($rowDescription = $preview->description) + @endif + @if ($preview->imageUrl && $images === []) @@ -58,9 +67,9 @@ @endif {{ $preview->site() }} - {{ $preview->title }} - @if ($preview->description) - {{ $preview->description }} + {{ $rowTitle }} + @if ($rowDescription) + {{ $rowDescription }} @endif diff --git a/tests/Feature/Screens/CommitEmbedTest.php b/tests/Feature/Screens/CommitEmbedTest.php index 864df33c..35515888 100644 --- a/tests/Feature/Screens/CommitEmbedTest.php +++ b/tests/Feature/Screens/CommitEmbedTest.php @@ -199,3 +199,34 @@ function imagesIn(array $node): array expect(imagesIn(nodeByRef($screen, 'link-preview-c1')))->toBe([]); }); + +it("names the video and its channel in the compact row under the commit's own images", function () { + VideoDetails::remember('https://youtu.be/bod7JDMeF-0', 'Side Projects Got Me Hired', 'Shruti Balasa'); + + Http::fake(['devnull.test/*' => Http::response(pageJson([commitJson([ + 'id' => 'c1', + 'body' => 'Watch https://youtu.be/bod7JDMeF-0', + 'images' => [['id' => 7, 'width' => 400, 'height' => 300, 'description' => null, 'url' => 'https://img.test/7']], + 'link_preview' => [ + 'url' => 'https://youtu.be/bod7JDMeF-0', + 'title' => '- YouTube', + 'description' => 'Enjoy the videos and music you love, upload original content.', + 'image_url' => null, + 'site_name' => 'YouTube', + 'embed' => [ + 'provider' => 'YouTube', + 'kind' => 'video', + 'src' => 'https://www.youtube-nocookie.com/embed/bod7JDMeF-0?autoplay=1', + 'aspect_ratio' => '16 / 9', + 'height' => null, + 'poster' => null, + ], + ], + ])]))]); + + Native::visit('/log') + ->assertSee('Side Projects Got Me Hired') + ->assertSee('Shruti Balasa') + ->assertDontSee('- YouTube') + ->assertDontSee('Enjoy the videos and music you love'); +});