From 2640d25adff2567861d217f53c7f410441b8d2b7 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Tue, 20 Oct 2026 11:53:15 +0100 Subject: [PATCH] Keep skeleton rows still on the pages you can't see The Log and Profile pagers lay out the pages beside the one you're on, and their skeleton rows pulsed there forever. SwiftUI keeps redrawing a looping animation even off screen, and every so often it holds the main thread on its lock while it does. Only the page you're on pulses now. The pulsing column has a key that changes with it, so a page you swipe to gets a fresh view whose loop starts. Co-Authored-By: Claude Opus 5.5 --- .../views/native/partials/log-page.blade.php | 4 ++-- .../native/partials/profile-page.blade.php | 4 ++-- .../native/partials/rail-loading.blade.php | 7 ++++++- tests/Feature/Screens/LogCacheTest.php | 18 ++++++++++++++++++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/resources/views/native/partials/log-page.blade.php b/resources/views/native/partials/log-page.blade.php index 9dcfa7c1..337c7159 100644 --- a/resources/views/native/partials/log-page.blade.php +++ b/resources/views/native/partials/log-page.blade.php @@ -23,7 +23,7 @@ class="w-full flex-1 bg-theme-surface" @if (! $page['loaded'] && $page['error'] === null) @foreach (range(1, 3) as $skeleton) - @include('native.partials.rail-loading', ['ref' => 'loading-'.$skeleton, 'label' => 'Loading commits']) + @include('native.partials.rail-loading', ['ref' => 'loading-'.$skeleton, 'label' => 'Loading commits', 'pulse' => $page['showing']]) @endforeach @endif @@ -42,7 +42,7 @@ class="w-full flex-1 bg-theme-surface" @if ($page['lastCommit']) @if ($page['nextCursor'] !== null) - @include('native.partials.rail-loading') + @include('native.partials.rail-loading', ['pulse' => $page['showing']]) @else @include('native.partials.rail-end', ['lane' => $page['lastCommit']->lane(), 'message' => "That's the root commit. There's nothing before it."]) @endif diff --git a/resources/views/native/partials/profile-page.blade.php b/resources/views/native/partials/profile-page.blade.php index 253bf3c6..87006e8b 100644 --- a/resources/views/native/partials/profile-page.blade.php +++ b/resources/views/native/partials/profile-page.blade.php @@ -16,7 +16,7 @@ class="w-full flex-1 bg-theme-surface" > @if (! $page['loaded'] && $page['error'] === null) @foreach (range(1, 3) as $skeleton) - @include('native.partials.rail-loading', ['ref' => 'loading-'.$skeleton, 'label' => 'Loading commits']) + @include('native.partials.rail-loading', ['ref' => 'loading-'.$skeleton, 'label' => 'Loading commits', 'pulse' => $page['showing']]) @endforeach @endif @@ -46,7 +46,7 @@ class="w-full flex-1 bg-theme-surface" @if (! $page['isEmpty'] || $page['pinnedCommit']) @if ($page['nextCursor'] !== null) - @include('native.partials.rail-loading') + @include('native.partials.rail-loading', ['pulse' => $page['showing']]) @elseif ($page['tab'] === 'replies') @include('native.partials.rail-end', ['lane' => $user->lane(), 'message' => $isMe ? 'That was your first reply.' : "That's {$user->handle()}'s first reply."]) @else diff --git a/resources/views/native/partials/rail-loading.blade.php b/resources/views/native/partials/rail-loading.blade.php index 48ff0f38..f2807820 100644 --- a/resources/views/native/partials/rail-loading.blade.php +++ b/resources/views/native/partials/rail-loading.blade.php @@ -1,13 +1,18 @@ {{-- While the next page loads, a skeleton row stands in on a Rail Gray rail ending in its dot, as the web's CommitSkeleton. A list with nothing kept to show yet shows a few of them, the first time only. + It pulses only on the page you're on ($pulse). The pager lays out the pages beside it too, and a looping animation + there never stops: SwiftUI keeps redrawing it off screen, and the main thread keeps waiting on it while you scroll. + A loop only starts when its view appears, so the pulsing column gets a key of its own and comes in afresh, already + pulsing, when you swipe to its page. --}} @php($ref ??= 'loading-more') +@php($pulse ??= true) @php($label ??= 'Loading more commits') - + diff --git a/tests/Feature/Screens/LogCacheTest.php b/tests/Feature/Screens/LogCacheTest.php index 641417bc..72ec1bbc 100644 --- a/tests/Feature/Screens/LogCacheTest.php +++ b/tests/Feature/Screens/LogCacheTest.php @@ -77,6 +77,24 @@ function shownCommitIds(TestableComponent $screen): array $again->assertSee('Fresh commit'); }); +it('pulses skeleton rows only on the log you are on', function () { + holdRefreshes(); + fakeFreshLog([commitJson(['id' => 'c1', 'body' => 'Fresh commit'])]); + + $pulses = fn (array $list): bool => findNode($list, fn (array $node): bool => ($node['props']['animate-loop'] ?? false) === true) !== null; + + $screen = Native::visit('/log'); + + expect($pulses(showingLog($screen)))->toBeTrue() + ->and(showsLoading(nodeByRef($screen, 'log-latest')))->toBeTrue() + ->and($pulses(nodeByRef($screen, 'log-latest')))->toBeFalse(); + + $screen->call('showPage', 1); + + expect($pulses(showingLog($screen)))->toBeTrue() + ->and($pulses(nodeByRef($screen, 'log-following')))->toBeFalse(); +}); + it('holds new commits in a pill with the right count, and puts them on top without a request', function () { holdRefreshes(); keep('log/following', pageJson([commitJson(['id' => 'c1', 'body' => 'Seen before'])]));