From 62b6f411a88c5ff2d88bc4f46fbe2a91b3bb2917 Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Thu, 19 Nov 2026 01:13:53 +1030 Subject: [PATCH] When a handle isn't on /dev/null yet (404), say that instead of failing Tapping someone on GitHub who hasn't joined, such as a mention of @karpathy, hands their handle from the profile screen to the organization screen (#152). devnull has nothing by that handle, so the organization screen said "This organization's page didn't load here." That was wrong on both counts: they're not an organization, and nothing failed to load. A 404 for a handle with nothing on screen now says "@karpathy isn't on /dev/null yet." and offers "Follow them on the web for when they join", which opens their page on dev-null.sh. This also fixes "Open it on dev/null" to read "Open it on /dev/null" (added the leading slash to the app name). Fixes #156. --- app/NativeComponents/Organization.php | 26 ++++++++++++ resources/views/native/organization.blade.php | 17 ++++++-- .../partials/organization-page.blade.php | 2 +- tests/Feature/Screens/OrganizationTest.php | 40 ++++++++++++++++++- 4 files changed, 79 insertions(+), 6 deletions(-) diff --git a/app/NativeComponents/Organization.php b/app/NativeComponents/Organization.php index c2f3718c..2eb04846 100644 --- a/app/NativeComponents/Organization.php +++ b/app/NativeComponents/Organization.php @@ -8,6 +8,7 @@ use App\Devnull\Data\Mention; use App\Devnull\Data\Organization as OrganizationData; use App\Devnull\Data\Page; +use App\Devnull\Exceptions\ApiException; use App\Devnull\RowCache; use App\Devnull\SiteLink; use App\Devnull\Stash; @@ -88,6 +89,13 @@ class Organization extends NativeComponent */ public bool $commitsFailed = false; + /** + * devnull has no organization by this handle, nor a member, since a profile hands a handle no member has over to + * this screen. It's someone on GitHub who isn't on /dev/null yet, so the page says that rather than that it + * didn't load, and offers the web's page for them, where you can follow them for when they join. + */ + public bool $isNotOnDevnull = false; + /** * Each tab's rows from the last frame, so a render only builds the rows that changed, as on a profile. * @@ -272,6 +280,23 @@ protected function showsContent(): bool return $this->organization !== null; } + /** + * devnull has nothing by this handle, so the page says it isn't on /dev/null yet (see $isNotOnDevnull). Anything + * else that stops it loading, the page says didn't load. Only a page with no organization on it yet says so: once + * one is showing, what else devnull refuses, such as a thread's replies or its stargazers, keeps it showing. + */ + protected function refused(ApiException $exception): bool + { + if ($exception->status !== 404 || $this->organization !== null) { + return false; + } + + $this->isNotOnDevnull = true; + $this->error = null; + + return true; + } + /** * @return iterable */ @@ -358,6 +383,7 @@ private function takeOrganization(array $json): void // An answer with no organization in it, like a maintenance page, leaves what's showing alone. if ($organization->organization->username !== '') { $this->organization = $organization; + $this->isNotOnDevnull = false; } } diff --git a/resources/views/native/organization.blade.php b/resources/views/native/organization.blade.php index f36976c1..c0db5efb 100644 --- a/resources/views/native/organization.blade.php +++ b/resources/views/native/organization.blade.php @@ -43,13 +43,24 @@ class="w-full flex-1 bg-theme-surface" @else - {{-- devnull's error isn't printed: the page says itself when it didn't load, and offers the page on the web. --}} + {{-- + devnull's error isn't printed: the page says itself when it didn't load, and offers the page on the web. A + handle devnull has nothing by is someone who isn't on /dev/null yet, and you can follow them on the web's page + for when they join. + --}} - @if ($error) + @if ($isNotOnDevnull) + @include('native.partials.empty', [ + 'command' => '$ git log --grep=@'.$handle, + 'message' => "@{$handle} isn't on /dev/null yet.", + 'link' => 'Follow them on the web for when they join', + 'press' => 'openOnWeb', + ]) + @elseif ($error) @include('native.partials.empty', [ 'command' => '$ git log --grep=@'.$handle, 'message' => "This organization's page didn't load here.", - 'link' => 'Open it on dev/null', + 'link' => 'Open it on /dev/null', 'press' => 'openOnWeb', ]) @else diff --git a/resources/views/native/partials/organization-page.blade.php b/resources/views/native/partials/organization-page.blade.php index c97e6bee..234d444d 100644 --- a/resources/views/native/partials/organization-page.blade.php +++ b/resources/views/native/partials/organization-page.blade.php @@ -16,7 +16,7 @@ class="w-full flex-1 bg-theme-surface" @include('native.partials.empty', [ 'command' => $page['tab'] === 'mentions' ? '$ git log --grep='.$user->handle() : '$ git log --author='.$user->handle(), 'message' => $page['tab'] === 'mentions' ? "Its mentions didn't load here." : "Its commits didn't load here.", - 'link' => 'Open it on dev/null', + 'link' => 'Open it on /dev/null', 'press' => 'openOnWeb', ]) @elseif (! $page['loaded']) diff --git a/tests/Feature/Screens/OrganizationTest.php b/tests/Feature/Screens/OrganizationTest.php index 2a8fc540..55ad2060 100644 --- a/tests/Feature/Screens/OrganizationTest.php +++ b/tests/Feature/Screens/OrganizationTest.php @@ -154,12 +154,48 @@ function tapOrganizationTab(TestableComponent $screen, string $tab): TestableCom ->assertNavigatedTo('/log/users/nunomaduro'); }); +it("says a handle that's neither a member nor an organization isn't on /dev/null yet, and offers its page on the web, which looks it up", function () { + // A mention of someone who never joined lands here: their profile was missing too, so the profile handed over. + Http::fake(['devnull.test/api/v1/organizations/*' => Http::response(['message' => 'Not Found'], 404)]); + + $screen = finishRefreshes(Native::visit('/log/organizations/karpathy'))->assertNavTitle('karpathy'); + + $screen->assertSee("@karpathy isn't on /dev/null yet.") + ->assertSee('Follow them on the web for when they join') + ->assertDontSee("didn't load") + ->assertDontSee('Not Found'); + expect(findNode($screen->tree(), fn (array $node): bool => in_array($node['ref'] ?? null, ['error', 'organization-header'], true)))->toBeNull(); + + $screen->tap('empty-link') + ->assertNativeCalled('Browser.OpenInApp', fn (array $params): bool => $params['url'] === 'http://devnull.test/@karpathy'); +}); + +it("keeps an organization that's showing when devnull later has nothing by its handle", function () { + serveApi([ + 'GET /api/v1/organizations/laravel' => [organizationJson()], + 'GET /api/v1/organizations/laravel/commits' => [pageJson([])], + ]); + + $screen = finishRefreshes(Native::visit('/log/organizations/laravel')); + + serveApi([ + 'GET /api/v1/organizations/laravel' => [['message' => 'Not Found'], 404], + 'GET /api/v1/organizations/laravel/commits' => [pageJson([])], + ]); + + $screen = finishRefreshes($screen->call('load')) + ->assertSee('The PHP framework for web artisans.') + ->assertDontSee("isn't on /dev/null yet"); + + expect($screen->instance()->isNotOnDevnull)->toBeFalse(); +}); + it("says the page didn't load when devnull can't send the organization, and offers its page on the web", function () { - Http::fake(['devnull.test/api/v1/organizations/*' => Http::response(['message' => 'Not Found.'], 404)]); + Http::fake(['devnull.test/api/v1/organizations/*' => Http::response(['message' => 'Server Error'], 500)]); $screen = finishRefreshes(Native::visit('/log/organizations/nobody'))->assertNavTitle('nobody'); - $screen->assertSee("This organization's page didn't load here."); + $screen->assertSee("This organization's page didn't load here.")->assertSee('Open it on /dev/null')->assertDontSee('Server Error'); expect(findNode($screen->tree(), fn (array $node): bool => in_array($node['ref'] ?? null, ['error', 'organization-header'], true)))->toBeNull(); $screen->tap('empty-link')