From e0bebc269fa6667922f5b9f8fe33f7a77a3636d3 Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Mon, 23 Nov 2026 16:51:40 +1030 Subject: [PATCH 1/3] Fix stars, reporting, deleting and polls on organization commits --- app/Devnull/Account.php | 26 ++++++++++++++++ app/Devnull/CommitMenu.php | 8 ++--- app/Devnull/Data/Commit.php | 3 +- app/Devnull/Data/CurrentUser.php | 5 +++ app/NativeComponents/CommitDetail.php | 2 +- .../Concerns/OpensCommitSheet.php | 3 +- .../Concerns/OpensStargazers.php | 3 +- .../Concerns/RefreshesInBackground.php | 4 +-- .../Concerns/ShowsCommits.php | 4 +-- app/NativeComponents/Onboarding.php | 4 +-- app/NativeComponents/ThisDevice.php | 4 +-- .../native/partials/commit-actions.blade.php | 2 +- tests/Feature/Screens/CommitDetailTest.php | 7 +++++ tests/Feature/Screens/CommitMenuTest.php | 31 +++++++++++++++++++ tests/Feature/Screens/PollVoteTest.php | 2 ++ tests/Feature/Screens/StargazersSheetTest.php | 26 ++++++++++++++++ tests/Pest.php | 22 +++++++++++++ 17 files changed, 136 insertions(+), 20 deletions(-) diff --git a/app/Devnull/Account.php b/app/Devnull/Account.php index d97f9944..77809058 100644 --- a/app/Devnull/Account.php +++ b/app/Devnull/Account.php @@ -2,6 +2,8 @@ namespace App\Devnull; +use App\Devnull\Data\Commit; +use App\Devnull\Data\CurrentUser; use App\Devnull\Data\Pasteis; use App\Devnull\Data\Profile; use App\Devnull\Data\Remotes; @@ -25,6 +27,8 @@ final class Account private const string ProfileKey = 'devnull.profile'; + private const string OrganizationsKey = 'devnull.organizations'; + private const string PinWarningKey = 'devnull.pin-warning-dismissed'; /** @@ -55,6 +59,27 @@ public function remember(User $user): void Cache::forever(self::CacheKey, $user->toArray()); } + /** + * Keeps you as a `GET /me` answer has you: who you are, your pastéis, your Remotes and your organizations. + */ + public function rememberCurrentUser(CurrentUser $current): void + { + $this->remember($current->user); + $this->rememberPasteis($current->pasteis()); + $this->rememberRemotes($current->remotes); + Cache::forever(self::OrganizationsKey, $current->organizationIds); + } + + /** + * Whether devnull counts the commit as yours, as the web does: you posted it, or an organization you're a member of did. + */ + public function owns(Commit $commit): bool + { + $user = $this->user(); + + return $user !== null && ($commit->author->id === $user->id || in_array($commit->author->id, (array) Cache::get(self::OrganizationsKey), true)); + } + /** * Your own profile as devnull last sent it (GET /users/{you}), kept for as * long as you're signed in rather than as long as the response cache keeps @@ -276,6 +301,7 @@ public function forget(): void Cache::forget(self::PasteisKey); Cache::forget(self::RemotesKey); Cache::forget(self::ProfileKey); + Cache::forget(self::OrganizationsKey); Cache::forget(self::PinWarningKey); Cache::forget(self::TimezoneKey); Cache::forget(self::GuildsKey); diff --git a/app/Devnull/CommitMenu.php b/app/Devnull/CommitMenu.php index 6fc7cacf..91dd594c 100644 --- a/app/Devnull/CommitMenu.php +++ b/app/Devnull/CommitMenu.php @@ -24,19 +24,19 @@ final class CommitMenu */ public static function items(Commit $commit, ?User $viewer): array { - $isOwn = $viewer !== null && $commit->author->id === $viewer->id; + $isAuthor = $viewer !== null && $commit->author->id === $viewer->id; $items = []; $items[] = self::item($commit, 'share', 'Share link', Lucide::Link, 'shareCommit'); - if ($isOwn && $commit->isApproved() && $commit->parentId === null && $commit->guild === null) { + if ($isAuthor && $commit->isApproved() && $commit->parentId === null && $commit->guild === null) { $items[] = self::item($commit, 'pin', $commit->isPinned ? 'Unpin from profile' : 'Pin to profile', Lucide::Pin, 'togglePin'); } - if ($viewer !== null && ! $isOwn && $commit->isApproved()) { + if ($viewer !== null && ! app(Account::class)->owns($commit) && $commit->isApproved()) { $items[] = NavAction::divider(); $items[] = self::item($commit, 'report', 'Report commit', Lucide::Flag, 'reportCommit'); - } elseif ($isOwn) { + } elseif (app(Account::class)->owns($commit)) { $items[] = NavAction::divider(); $items[] = self::item($commit, 'delete', 'Delete commit', Lucide::Trash2, 'confirmDelete', destructive: true); } diff --git a/app/Devnull/Data/Commit.php b/app/Devnull/Data/Commit.php index e7b87ada..12ffd48b 100644 --- a/app/Devnull/Data/Commit.php +++ b/app/Devnull/Data/Commit.php @@ -2,6 +2,7 @@ namespace App\Devnull\Data; +use App\Devnull\Account; use App\Devnull\Display; use App\Devnull\Lane; use Carbon\CarbonImmutable; @@ -359,7 +360,7 @@ public function canBeVotedOnBy(?User $viewer): bool return $viewer !== null && $this->poll !== null && $this->isApproved() - && $this->author->id !== $viewer->id + && ! app(Account::class)->owns($this) && $this->poll->closesAt !== null && ! $this->poll->hasVoted && ! $this->poll->showsResults() diff --git a/app/Devnull/Data/CurrentUser.php b/app/Devnull/Data/CurrentUser.php index 9fead8f8..f8926a4f 100644 --- a/app/Devnull/Data/CurrentUser.php +++ b/app/Devnull/Data/CurrentUser.php @@ -19,6 +19,8 @@ * And the terms: the version in force, which is the moment it took effect, when * you last accepted them, and whether that was this version. A devnull too old * to say leaves all three null. + * + * And the ids of the organizations you're a member of, whose commits are yours too. */ final readonly class CurrentUser { @@ -37,6 +39,8 @@ public function __construct( public ?string $termsVersion = null, public ?CarbonImmutable $termsAcceptedAt = null, public ?bool $termsAccepted = null, + /** @var list */ + public array $organizationIds = [], ) {} /** @@ -69,6 +73,7 @@ public static function fromArray(array $json): self termsVersion: is_string($data['terms_version'] ?? null) && $data['terms_version'] !== '' ? $data['terms_version'] : null, termsAcceptedAt: Commit::date($data['terms_accepted_at'] ?? null), termsAccepted: is_bool($data['terms_accepted'] ?? null) ? $data['terms_accepted'] : null, + organizationIds: array_values(array_filter(array_column(is_array($data['organizations'] ?? null) ? $data['organizations'] : [], 'id'), is_string(...))), ); } diff --git a/app/NativeComponents/CommitDetail.php b/app/NativeComponents/CommitDetail.php index f20c88a3..0836ea75 100644 --- a/app/NativeComponents/CommitDetail.php +++ b/app/NativeComponents/CommitDetail.php @@ -654,7 +654,7 @@ private function loadTombstoneReplies(string $id): void public function isOwn(): bool { - return $this->commit !== null && $this->commit->author->username === $this->me()?->username; + return $this->commit !== null && app(Account::class)->owns($this->commit); } public function render(): View diff --git a/app/NativeComponents/Concerns/OpensCommitSheet.php b/app/NativeComponents/Concerns/OpensCommitSheet.php index 9960b796..a1494dd3 100644 --- a/app/NativeComponents/Concerns/OpensCommitSheet.php +++ b/app/NativeComponents/Concerns/OpensCommitSheet.php @@ -2,6 +2,7 @@ namespace App\NativeComponents\Concerns; +use App\Devnull\Account; use App\Devnull\Client; use App\Devnull\Data\Commit; use App\Devnull\Data\Draft; @@ -583,7 +584,7 @@ private function canReport(Commit $commit): bool { $viewer = $this->me(); - return $viewer !== null && ! $commit->isDeleted() && $commit->isApproved() && $commit->author->id !== $viewer->id; + return $viewer !== null && ! $commit->isDeleted() && $commit->isApproved() && ! app(Account::class)->owns($commit); } /** diff --git a/app/NativeComponents/Concerns/OpensStargazers.php b/app/NativeComponents/Concerns/OpensStargazers.php index 84024cf4..372124a7 100644 --- a/app/NativeComponents/Concerns/OpensStargazers.php +++ b/app/NativeComponents/Concerns/OpensStargazers.php @@ -2,6 +2,7 @@ namespace App\NativeComponents\Concerns; +use App\Devnull\Account; use App\Devnull\Data\Page; use App\Devnull\Data\User; @@ -47,7 +48,7 @@ public function openStargazers(string $id): void { $commit = $this->shownCommit($id); - if ($commit === null || $commit->isDeleted() || $commit->starsCount === 0 || $commit->author->id !== $this->me()?->id) { + if ($commit === null || $commit->isDeleted() || $commit->starsCount === 0 || ! app(Account::class)->owns($commit)) { return; } diff --git a/app/NativeComponents/Concerns/RefreshesInBackground.php b/app/NativeComponents/Concerns/RefreshesInBackground.php index 1ac8fc84..562058ac 100644 --- a/app/NativeComponents/Concerns/RefreshesInBackground.php +++ b/app/NativeComponents/Concerns/RefreshesInBackground.php @@ -155,9 +155,7 @@ protected function refreshUnreadNotifications(): void $current = CurrentUser::fromArray($json); if ($current->user->username !== '') { - app(Account::class)->remember($current->user); - app(Account::class)->rememberPasteis($current->pasteis()); - app(Account::class)->rememberRemotes($current->remotes); + app(Account::class)->rememberCurrentUser($current); $this->takeTerms($current); } diff --git a/app/NativeComponents/Concerns/ShowsCommits.php b/app/NativeComponents/Concerns/ShowsCommits.php index b5c93c90..f13ef59a 100644 --- a/app/NativeComponents/Concerns/ShowsCommits.php +++ b/app/NativeComponents/Concerns/ShowsCommits.php @@ -545,7 +545,7 @@ private function pastelTurnedDown(string $id, ?ApiException $exception): void private function canReactTo(Commit $commit): bool { - return ! $commit->isDeleted() && $commit->isApproved() && $commit->author->id !== $this->me()?->id; + return ! $commit->isDeleted() && $commit->isApproved() && ! app(Account::class)->owns($commit); } private function canPin(Commit $commit): bool @@ -555,7 +555,7 @@ private function canPin(Commit $commit): bool private function canDelete(Commit $commit): bool { - return ! $commit->isDeleted() && ! $commit->isStaged() && $commit->author->id === $this->me()?->id; + return ! $commit->isDeleted() && ! $commit->isStaged() && app(Account::class)->owns($commit); } /** diff --git a/app/NativeComponents/Onboarding.php b/app/NativeComponents/Onboarding.php index 2b3cef0a..957494d7 100644 --- a/app/NativeComponents/Onboarding.php +++ b/app/NativeComponents/Onboarding.php @@ -268,10 +268,8 @@ private function signInWithExistingKey(): void return; } - app(Account::class)->remember($current->user); + app(Account::class)->rememberCurrentUser($current); app(Account::class)->rememberUnreadNotifications($current->unreadNotificationsCount); - app(Account::class)->rememberPasteis($current->pasteis()); - app(Account::class)->rememberRemotes($current->remotes); app(Account::class)->rememberTermsToAccept($current->termsToAccept()); $this->keepProfile($current->user); $this->replace($current->termsToAccept() === null ? '/log' : AcceptTerms::Path); diff --git a/app/NativeComponents/ThisDevice.php b/app/NativeComponents/ThisDevice.php index 25c2c46c..454813dd 100644 --- a/app/NativeComponents/ThisDevice.php +++ b/app/NativeComponents/ThisDevice.php @@ -985,10 +985,8 @@ private function takeMe(array $json): void return; } - app(Account::class)->remember($current->user); + app(Account::class)->rememberCurrentUser($current); app(Account::class)->rememberUnreadNotifications($current->unreadNotificationsCount); - app(Account::class)->rememberPasteis($current->pasteis()); - app(Account::class)->rememberRemotes($current->remotes); app(ResponseCache::class)->meChanged($json); $this->takeTerms($current); } diff --git a/resources/views/native/partials/commit-actions.blade.php b/resources/views/native/partials/commit-actions.blade.php index 00eb8bfe..e509420f 100644 --- a/resources/views/native/partials/commit-actions.blade.php +++ b/resources/views/native/partials/commit-actions.blade.php @@ -48,7 +48,7 @@ @php($stashed ??= []) @php($hasQuoteStash = in_array('quote-'.$commit->id, $stashed, true)) @php($hasReplyStash = in_array('reply-'.$commit->id, $stashed, true)) -@php($isOwn = $commit->author->id === $viewer?->id) +@php($isOwn = app(\App\Devnull\Account::class)->owns($commit)) @php($canQuote = $commit->isApproved() || $isOwn) @php($hasThread = $expandable && $commit->replyPreview !== null) @php($showsReplies = $withReplies && ! $hasThread && $repliesCount > 0) diff --git a/tests/Feature/Screens/CommitDetailTest.php b/tests/Feature/Screens/CommitDetailTest.php index fc0da284..509ce24a 100644 --- a/tests/Feature/Screens/CommitDetailTest.php +++ b/tests/Feature/Screens/CommitDetailTest.php @@ -810,3 +810,10 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): expect(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual(24 + 53 + 4 * 21 + 34); }); + +it("offers delete on a commit from an organization you're a member of", function () { + joinOrganizations('org-1'); + fakeThread(['author' => organizationAuthorJson('org-1', 'NativePHP')]); + + Native::visit('/log/commits/c2')->assertElement('top_bar_action', fn (array $node): bool => ($node['props']['id'] ?? null) === 'delete'); +}); diff --git a/tests/Feature/Screens/CommitMenuTest.php b/tests/Feature/Screens/CommitMenuTest.php index aedf1ae3..31e1d0e1 100644 --- a/tests/Feature/Screens/CommitMenuTest.php +++ b/tests/Feature/Screens/CommitMenuTest.php @@ -247,3 +247,34 @@ Http::assertNotSent(fn (Request $request): bool => str_ends_with($request->url(), '/pin')); }); + +it("leaves Report commit off a commit from an organization you're a member of, which devnull won't take", function () { + joinOrganizations('org-1'); + serveApi(fn () => Http::response(pageJson([commitJson(['id' => 'c1', 'author' => organizationAuthorJson('org-1', 'NativePHP')])]))); + + $screen = Native::visit('/log', platform: 'ios')->call('reportCommit', 'c1'); + + expect(array_column(array_filter(menuItems($screen, 'more-c1'), is_array(...)), 0))->not->toContain('report-c1') + ->and($screen->instance()->sheetOpen)->toBeFalse(); +}); + +it("deletes a commit from an organization you're a member of, as devnull lets you, without offering to pin it", function () { + joinOrganizations('org-1'); + fakeApi([ + 'GET /api/v1/log/following' => [pageJson([commitJson(['id' => 'c1', 'body' => 'Delete me', 'author' => organizationAuthorJson('org-1', 'NativePHP')])])], + 'DELETE /api/v1/commits/c1' => [null, 204], + ]); + + $screen = Native::visit('/log', platform: 'ios'); + + expect(menuItems($screen, 'more-c1'))->toBe([ + ['share-c1', 'Share link', 'custom:link'], + 'divider', + ['delete-c1', 'Delete commit', 'custom:trash-2'], + ]); + + $screen->tap('delete-c1') + ->emitNative(ButtonPressed::class, ['index' => 1, 'label' => 'Delete', 'id' => 'delete-commit']); + + Http::assertSent(fn (Request $request): bool => $request->method() === 'DELETE' && $request->url() === 'http://devnull.test/api/v1/commits/c1'); +}); diff --git a/tests/Feature/Screens/PollVoteTest.php b/tests/Feature/Screens/PollVoteTest.php index cbc8bc68..68555033 100644 --- a/tests/Feature/Screens/PollVoteTest.php +++ b/tests/Feature/Screens/PollVoteTest.php @@ -94,6 +94,7 @@ function pollOnLog(array $commit = [], ?array $answer = null): TestableComponent }); it('offers no vote where the web offers none', function (array $commit) { + joinOrganizations('org-1'); $screen = pollOnLog($commit)->call('choosePollOption', 'c1', 'o1'); expect(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'poll-vote-c1'))->toBeNull() @@ -105,6 +106,7 @@ function pollOnLog(array $commit = [], ?array $answer = null): TestableComponent Http::assertNotSent(fn (Request $request): bool => $request->method() === 'POST'); })->with([ 'your own poll' => [['author' => userJson()]], + "an organization's you're a member of, which someone else posted" => [['author' => organizationAuthorJson('org-1', 'NativePHP')]], 'one awaiting approval' => [['status' => 'pending', 'poll' => openPollJson(['closes_at' => null])]], 'a closed poll' => [['poll' => openPollJson(['closes_at' => '2026-10-19T11:59:00Z'])]], 'one you voted on' => [['poll' => openPollJson(results: true)]], diff --git a/tests/Feature/Screens/StargazersSheetTest.php b/tests/Feature/Screens/StargazersSheetTest.php index 0d37d788..e5f6e260 100644 --- a/tests/Feature/Screens/StargazersSheetTest.php +++ b/tests/Feature/Screens/StargazersSheetTest.php @@ -173,3 +173,29 @@ function ownStarredCommit(int $count, array $pages, string $platform = 'ios'): T expect(sentTo('GET', 'commits/c1/stars'))->toBe([]) ->and(sentTo('GET', 'commits/c2/stars'))->toBe([]); }); + +it('opens who starred a commit an organization you belong to posted, since devnull treats it as your commit', function (string $platform) { + $organization = fn (string $id, string $handle): array => userJson(['id' => $id, 'type' => 'organization', 'handle' => $handle, 'name' => $handle]); + + serveApi([ + 'GET /api/v1/me' => [['data' => [...userJson(), 'organizations' => [['role' => 'admin', ...$organization('org-1', 'NativePHP')]]]]], + 'GET /api/v1/log/following' => [pageJson([ + commitJson(['id' => 'c1', 'stars_count' => 3, 'author' => $organization('org-1', 'NativePHP')]), + commitJson(['id' => 'c2', 'stars_count' => 2, 'author' => $organization('org-2', 'laravel')]), + ])], + 'GET /api/v1/commits/c1/stars' => [pageJson([stargazerJson('grace', 'Grace Hopper')], path: 'http://devnull.test/api/v1/commits/c1/stars')], + ]); + + $screen = finishRefreshes(Native::visit('/log', platform: $platform)); + + expect(nodeByRef($screen, 'star-count-c1'))->type->toBe('pressable')->props->a11y_label->toBe('3 stars, show who starred') + ->and(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'star-c1'))->toBeNull() + ->and(nodeByRef($screen, 'star-c2'))->type->toBe('pressable'); + + finishRefreshes($screen->call('toggleStar', 'c1')); + + expect(sentTo('POST', 'commits/c1/star'))->toBe([]) + ->and(nodeByRef($screen, 'star-count-c1')['props']['a11y_label'])->toBe('3 stars, show who starred'); + + $screen->tap('star-count-c1')->assertSee('Starred by')->assertSee('Grace Hopper'); +})->with(['ios', 'android']); diff --git a/tests/Pest.php b/tests/Pest.php index 6eb917e7..0e63535c 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -2,6 +2,7 @@ use App\Devnull\Account; use App\Devnull\AppleSignIn; +use App\Devnull\Data\CurrentUser; use App\Devnull\Data\User; use App\Devnull\DeviceKey; use App\Devnull\ResponseCache; @@ -397,6 +398,27 @@ function signIn(array $user = []): FakeBridge return $bridge; } +/** + * Makes you a member of the given organizations, as `GET /me` lists them, so devnull counts their commits as yours. + */ +function joinOrganizations(string ...$ids): void +{ + app(Account::class)->rememberCurrentUser(CurrentUser::fromArray(['data' => [ + ...(app(Account::class)->user()?->toArray() ?? userJson()), + 'organizations' => array_map(fn (string $id): array => ['id' => $id], $ids), + ]])); +} + +/** + * An organization as the API sends one as a commit's author. + * + * @return array + */ +function organizationAuthorJson(string $id, string $handle): array +{ + return userJson(['id' => $id, 'type' => 'organization', 'handle' => $handle, 'name' => $handle]); +} + /** * A user as the API sends one to a signed request: a commit's author, a * notification's actor. Its links follow the username unless a test sends its own. From 693b253043c789641ad1ebb9af1210f4c01e3ce3 Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Mon, 23 Nov 2026 17:19:41 +1030 Subject: [PATCH 2/3] Fix organisation links in user bio and company fields --- app/Devnull/Data/Profile.php | 12 ++++++++++-- app/NativeComponents/Profile.php | 14 ++++++++++---- .../native/partials/github-text.blade.php | 2 +- .../native/partials/profile-header.blade.php | 4 ++-- tests/Feature/Screens/ProfileStandingTest.php | 19 ++++++++++++++++++- 5 files changed, 41 insertions(+), 10 deletions(-) diff --git a/app/Devnull/Data/Profile.php b/app/Devnull/Data/Profile.php index 946ccde7..8151953f 100644 --- a/app/Devnull/Data/Profile.php +++ b/app/Devnull/Data/Profile.php @@ -17,13 +17,20 @@ public function __construct( public bool $isMuting = false, public ?Achievements $achievements = null, public ?int $pasteisReceived = null, + /** + * The usernames (users or organizations) linked in this bio or company field that are on devnull, keyed by lowercase. + * + * @var array + */ + public array $bioProfiles = [], ) {} /** * Reads a `GET /users/{username}` response: the user and counts in `data`, * and alongside it whether you follow or mute them, their pinned commit, - * their streaks, their activity, their achievements and how many pastéis - * they have been given (null when devnull doesn't say). + * their streaks, their activity, their achievements, how many pastéis + * they have been given (null when devnull doesn't say), and any bio + * and company tags for devnull accounts, keyed by lowercase handle. * * @param array $json */ @@ -47,6 +54,7 @@ public static function fromArray(array $json): self isMuting: ($json['is_muting'] ?? $data['is_muting'] ?? false) === true, achievements: Achievements::fromArray($json['achievements'] ?? $data['achievements'] ?? null), pasteisReceived: is_int($received) ? max(0, $received) : null, + bioProfiles: array_filter(is_array($json['bio_profiles'] ?? null) ? $json['bio_profiles'] : [], is_string(...)), ); } diff --git a/app/NativeComponents/Profile.php b/app/NativeComponents/Profile.php index 0a03a1c7..4c91c1b5 100644 --- a/app/NativeComponents/Profile.php +++ b/app/NativeComponents/Profile.php @@ -609,11 +609,17 @@ public function openGitHubMention(string $username): void $user = $this->profile?->user; foreach (Mention::inText(($user?->bio ?? '')."\n".($user?->company ?? '')) as $mention) { - if ($mention->username === $username) { - Browser::inApp('https://github.com/'.rawurlencode($username)); - - return; + if ($mention->username !== $username) { + continue; } + + $handle = $this->profile->bioProfiles[mb_strtolower($username)] ?? null; + + $handle === null + ? Browser::inApp('https://github.com/'.rawurlencode($username)) + : $this->openInTab('/users/'.rawurlencode($handle)); + + return; } } diff --git a/resources/views/native/partials/github-text.blade.php b/resources/views/native/partials/github-text.blade.php index 54a224a6..1e4bb6e0 100644 --- a/resources/views/native/partials/github-text.blade.php +++ b/resources/views/native/partials/github-text.blade.php @@ -4,7 +4,7 @@ @if ($mention->offset > $position) @endif - + @php($position = $mention->offset + $mention->length) @endforeach @if ($position < mb_strlen($text)) diff --git a/resources/views/native/partials/profile-header.blade.php b/resources/views/native/partials/profile-header.blade.php index 78c88ffc..91b3bc24 100644 --- a/resources/views/native/partials/profile-header.blade.php +++ b/resources/views/native/partials/profile-header.blade.php @@ -78,7 +78,7 @@ @if ($user->bio) - @include('native.partials.github-text', ['text' => $user->bio, 'ref' => 'profile-bio', 'classes' => 'w-full text-[15px] leading-relaxed text-theme-ink', 'maxLines' => null]) + @include('native.partials.github-text', ['text' => $user->bio, 'profiles' => $profile->bioProfiles, 'ref' => 'profile-bio', 'classes' => 'w-full text-[15px] leading-relaxed text-theme-ink', 'maxLines' => null]) @endif {{-- @@ -87,7 +87,7 @@ --}} @if ($user->company) - @include('native.partials.profile-fact', ['key' => 'company', 'icon' => \App\Icons\Lucide::Building2, 'label' => $user->company, 'gitHubMentions' => true]) + @include('native.partials.profile-fact', ['key' => 'company', 'icon' => \App\Icons\Lucide::Building2, 'label' => $user->company, 'gitHubMentions' => true, 'profiles' => $profile->bioProfiles]) @endif @if ($user->location) @include('native.partials.profile-fact', ['key' => 'location', 'icon' => \App\Icons\Lucide::MapPin, 'label' => $user->location]) diff --git a/tests/Feature/Screens/ProfileStandingTest.php b/tests/Feature/Screens/ProfileStandingTest.php index f09af3f0..9276cb15 100644 --- a/tests/Feature/Screens/ProfileStandingTest.php +++ b/tests/Feature/Screens/ProfileStandingTest.php @@ -98,7 +98,7 @@ function standingJson(array $extra = []): array expect(childRefs($screen, 'sheet-badges'))->toBe(['sheet-badge-init', 'sheet-badge-stdout', 'sheet-badge-max_payload']); })->with(['earned' => [true, '+1 more'], 'none earned' => [false, 'View achievements']]); -it('opens tagged bio and company accounts on GitHub rather than as devnull users', function (string $ref, string $url) { +it("opens tagged bio and company accounts that aren't on devnull on GitHub", function (string $ref, string $url) { $json = standingJson(); $json['data']['bio'] = 'Builds @laravel with @nunomaduro.'; $json['data']['company'] = '@nativephp'; @@ -112,6 +112,23 @@ function standingJson(array $extra = []): array 'company' => ['profile-company-text-mention-0', 'https://github.com/nativephp'], ]); +it('opens tagged bio and company accounts that are on devnull here, as the web does', function (string $ref, string $label, string $path) { + $json = standingJson(); + $json['data']['bio'] = 'Builds @laravel with @grace.'; + $json['data']['company'] = '@nativephp'; + $json['bio_profiles'] = ['grace' => 'grace', 'nativephp' => 'NativePHP']; + fakeApi(['GET /api/v1/users/ada' => [$json], 'GET /api/v1/users/ada/commits' => [pageJson([])]]); + + $screen = Native::visit('/log/users/ada'); + + expect(nodeByRef($screen, $ref)['props']['a11y_label'])->toBe($label); + + $screen->tap($ref)->assertNativeNotCalled('Browser.OpenInApp')->assertNavigatedTo($path); +})->with([ + 'bio' => ['profile-bio-mention-21', '@grace', '/log/users/grace'], + 'company' => ['profile-company-text-mention-0', '@nativephp', '/log/users/NativePHP'], +]); + it('ignores profile mention actions for accounts that are not in the bio or company', function () { fakeApi(['GET /api/v1/users/ada' => [standingJson()], 'GET /api/v1/users/ada/commits' => [pageJson([])]]); Native::visit('/log/users/ada')->call('openGitHubMention', 'nobody')->assertNativeNotCalled('Browser.OpenInApp'); From b19c284ee5ae7077b1c35cddce57a83dd4c82728 Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Mon, 23 Nov 2026 18:10:06 +1030 Subject: [PATCH 3/3] Fix quoting an organization commit that's waiting for approval --- app/NativeComponents/Concerns/OpensCommitSheet.php | 2 +- tests/Feature/Screens/QuoteTest.php | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/NativeComponents/Concerns/OpensCommitSheet.php b/app/NativeComponents/Concerns/OpensCommitSheet.php index a1494dd3..e7075c53 100644 --- a/app/NativeComponents/Concerns/OpensCommitSheet.php +++ b/app/NativeComponents/Concerns/OpensCommitSheet.php @@ -577,7 +577,7 @@ private function canQuote(Commit $commit): bool { $viewer = $this->me(); - return $viewer !== null && ! $commit->isDeleted() && ! $commit->isStaged() && ($commit->isApproved() || $commit->author->id === $viewer->id); + return $viewer !== null && ! $commit->isDeleted() && ! $commit->isStaged() && ($commit->isApproved() || app(Account::class)->owns($commit)); } private function canReport(Commit $commit): bool diff --git a/tests/Feature/Screens/QuoteTest.php b/tests/Feature/Screens/QuoteTest.php index 3ce4a7b5..0bda5ebd 100644 --- a/tests/Feature/Screens/QuoteTest.php +++ b/tests/Feature/Screens/QuoteTest.php @@ -79,6 +79,15 @@ function quoteButtonDisabled(TestableComponent $screen): bool expect(nodeByRef($screen, 'sheet')['props']['visible'])->toBeFalse(); }); +it("quotes a commit from an organization you're a member of while it waits for approval, as devnull lets you", function () { + joinOrganizations('org-1'); + serveQuoteLog([commitJson(['id' => 'c1', 'status' => 'pending', 'author' => organizationAuthorJson('org-1', 'NativePHP')])]); + + $screen = Native::visit('/log', platform: 'ios')->tap('quote-c1'); + + expect(nodeByRef($screen, 'sheet')['props']['visible'])->toBeTrue(); +}); + it('opens a composer over the commit being quoted, drawn as the static quote card', function () { $screen = quoteSheetOnLog();