diff --git a/app/Devnull/Account.php b/app/Devnull/Account.php index d97f9944..34a2ee73 100644 --- a/app/Devnull/Account.php +++ b/app/Devnull/Account.php @@ -36,6 +36,8 @@ final class Account private const string TermsKey = 'devnull.terms-to-accept'; + private const string OrganizationsKey = 'devnull.organizations'; + private const string GuildsKey = 'devnull.guilds-available'; /** @@ -259,9 +261,42 @@ public function rememberTermsToAccept(?string $version): void } /** - * Signs this phone out: who it was, the badges, its pastéis and Remotes, whether it has guilds and shows their - * tab, your timezone, the terms you owe, every answer, image and voice note kept for a quick start, and your unsent - * drafts and recordings. Signing out leaves the tabs for onboarding, so the next account's tabs are decided afresh. + * The GitHub organizations you can post as, as devnull last said, oldest membership first. None until it has. + * + * @return list + */ + public function organizations(): array + { + $kept = Cache::get(self::OrganizationsKey); + + return is_array($kept) ? array_values(array_map(User::fromArray(...), array_filter($kept, is_array(...)))) : []; + } + + /** + * Which commits are yours: your own and your organizations' (see Ownership). + */ + public function ownership(): Ownership + { + return Ownership::of($this->user(), $this->organizations()); + } + + /** + * Remembers the organizations you can post as. With null, from a devnull too old to say, it keeps what it had. + * + * @param list|null $organizations + */ + public function rememberOrganizations(?array $organizations): void + { + if ($organizations !== null) { + Cache::forever(self::OrganizationsKey, array_map(fn (User $organization): array => $organization->toArray(), $organizations)); + } + } + + /** + * Signs this phone out: who it was, the badges, its pastéis and Remotes, your organizations, whether it has guilds + * and shows their tab, your timezone, the terms you owe, every answer, image and voice note kept for a quick start, + * and your unsent drafts and recordings. Signing out leaves the tabs for onboarding, so the next account's tabs are + * decided afresh. */ public function forget(): void { @@ -280,6 +315,7 @@ public function forget(): void Cache::forget(self::TimezoneKey); Cache::forget(self::GuildsKey); Cache::forget(self::TermsKey); + Cache::forget(self::OrganizationsKey); self::forgetGuildsTabShown(); } } diff --git a/app/Devnull/Client.php b/app/Devnull/Client.php index b59aec0a..f85c4030 100644 --- a/app/Devnull/Client.php +++ b/app/Devnull/Client.php @@ -303,14 +303,16 @@ public function replies(string $id, ?string $cursor = null): Page /** * Commits, as a reply to $parentId or quoting $quotedCommitId, as the web's * composer, reply box and Quote do. devnull takes one or the other, not both. - * A new commit or a quote may start a poll (see PollDraft::payload()). - * A new commit can go straight to a guild's board ($guildHandle). + * A new commit or a quote may start a poll (see PollDraft::payload()). With + * $author, the handle of an organization you're a member of, it goes out as + * that organization, as the web's Post as picks (see PostAs). A new commit + * can go straight to a guild's board ($guildHandle). * * @param array{options: list, duration: int}|null $poll */ - public function createCommit(string $body, ?string $parentId = null, ?string $quotedCommitId = null, ?array $poll = null, ?string $guildHandle = null): Commit + public function createCommit(string $body, ?string $parentId = null, ?string $quotedCommitId = null, ?array $poll = null, ?string $author = null, ?string $guildHandle = null): Commit { - $commit = $this->data($this->send('POST', 'commits', payload: self::commitPayload($body, $parentId, $quotedCommitId, $poll, $guildHandle))); + $commit = $this->data($this->send('POST', 'commits', payload: self::commitPayload($body, $parentId, $quotedCommitId, $poll, $author, $guildHandle))); $this->cache->commitAdded($commit); return Commit::fromArray($commit); @@ -322,9 +324,9 @@ public function createCommit(string $body, ?string $parentId = null, ?string $qu * * @param array{options: list, duration: int}|null $poll */ - public function signedCommit(string $body, ?string $parentId = null, ?string $quotedCommitId = null, ?array $poll = null, ?string $guildHandle = null): SignedRequest + public function signedCommit(string $body, ?string $parentId = null, ?string $quotedCommitId = null, ?array $poll = null, ?string $author = null, ?string $guildHandle = null): SignedRequest { - return $this->signedWrite('POST', 'commits', self::commitPayload($body, $parentId, $quotedCommitId, $poll, $guildHandle)); + return $this->signedWrite('POST', 'commits', self::commitPayload($body, $parentId, $quotedCommitId, $poll, $author, $guildHandle)); } /** @@ -334,9 +336,9 @@ public function signedCommit(string $body, ?string $parentId = null, ?string $qu * * @param list $images */ - public function signedCommitWithImages(string $body, array $images, ?string $parentId = null, ?string $quotedCommitId = null, ?string $guildHandle = null): SignedRequest + public function signedCommitWithImages(string $body, array $images, ?string $parentId = null, ?string $quotedCommitId = null, ?string $author = null, ?string $guildHandle = null): SignedRequest { - return $this->signedWithImages('commits', self::commitPayload($body, $parentId, $quotedCommitId, guildHandle: $guildHandle), $images); + return $this->signedWithImages('commits', self::commitPayload($body, $parentId, $quotedCommitId, author: $author, guildHandle: $guildHandle), $images); } /** @@ -363,14 +365,16 @@ public function signedMessage(string $threadPath, string $body, string $clientId * Signs a commit to be submitted at $at, as the web's Schedule commit * does, for the background to send. Only you see it until then. With * photos it goes as multipart, as a commit with photos does, and a poll - * goes in its JSON. One for a guild's board says which ($guildHandle). + * goes in its JSON. With $author it goes out as that organization when it's + * due, as long as you're still in it then. One for a guild's board says + * which ($guildHandle). * * @param list $images * @param array|null $poll */ - public function signedScheduledCommit(string $body, CarbonInterface $at, array $images = [], ?array $poll = null, ?string $guildHandle = null): SignedRequest + public function signedScheduledCommit(string $body, CarbonInterface $at, array $images = [], ?array $poll = null, ?string $author = null, ?string $guildHandle = null): SignedRequest { - $payload = array_filter(['body' => $body, 'scheduled_at' => self::scheduleTime($at), 'poll' => $poll, 'guild_handle' => $guildHandle], fn (mixed $value): bool => $value !== null); + $payload = array_filter(['body' => $body, 'scheduled_at' => self::scheduleTime($at), 'poll' => $poll, 'author' => $author, 'guild_handle' => $guildHandle], fn (mixed $value): bool => $value !== null); return $images === [] ? $this->signedWrite('POST', self::ScheduledCommitsPath, $payload) @@ -1006,13 +1010,14 @@ private function send(string $method, string $path, array $query = [], ?array $p * @param array{options: list, duration: int}|null $poll * @return array */ - private static function commitPayload(string $body, ?string $parentId, ?string $quotedCommitId, ?array $poll = null, ?string $guildHandle = null): array + private static function commitPayload(string $body, ?string $parentId, ?string $quotedCommitId, ?array $poll = null, ?string $author = null, ?string $guildHandle = null): array { return array_filter([ 'body' => $body, 'parent_id' => $parentId, 'quoted_commit_id' => $quotedCommitId, 'poll' => $poll, + 'author' => $author, 'guild_handle' => $guildHandle, ], fn (mixed $value): bool => $value !== null); } diff --git a/app/Devnull/CommitMenu.php b/app/Devnull/CommitMenu.php index 6fc7cacf..491aeecf 100644 --- a/app/Devnull/CommitMenu.php +++ b/app/Devnull/CommitMenu.php @@ -3,7 +3,6 @@ namespace App\Devnull; use App\Devnull\Data\Commit; -use App\Devnull\Data\User; use App\Icons\Lucide; use Native\Mobile\Edge\Elements\TopBarAction; use Native\Mobile\Edge\Layouts\Builders\NavAction; @@ -14,26 +13,28 @@ * Unpin from profile on your own published commit, not a reply nor one posted * in a guild, which devnull won't pin to a profile; then, after a * divider, Report commit on someone else's published commit, or Delete commit - * on your own. Each item names the commit, so a tap never rebuilds anything - * from an attribute (see ShowsCommits). + * on yours. An organization's commit is yours while you're a member, whoever + * posted it (see Ownership), so every member gets Delete, as on the web. Only + * a person has a profile to pin to, so it never gets Pin. Each item names the + * commit, so a tap never rebuilds anything from an attribute (see ShowsCommits). */ final class CommitMenu { /** * @return list */ - public static function items(Commit $commit, ?User $viewer): array + public static function items(Commit $commit, Ownership $ownership): array { - $isOwn = $viewer !== null && $commit->author->id === $viewer->id; + $isOwn = $ownership->owns($commit); $items = []; $items[] = self::item($commit, 'share', 'Share link', Lucide::Link, 'shareCommit'); - if ($isOwn && $commit->isApproved() && $commit->parentId === null && $commit->guild === null) { + if ($ownership->isYourOwn($commit) && $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 ($ownership->isSignedIn() && ! $isOwn && $commit->isApproved()) { $items[] = NavAction::divider(); $items[] = self::item($commit, 'report', 'Report commit', Lucide::Flag, 'reportCommit'); } elseif ($isOwn) { diff --git a/app/Devnull/ComposerMenu.php b/app/Devnull/ComposerMenu.php index 71e5716e..533a0303 100644 --- a/app/Devnull/ComposerMenu.php +++ b/app/Devnull/ComposerMenu.php @@ -28,6 +28,20 @@ public static function items(bool $photosFull, bool $voiceNotesGoAlone, string $ ]; } + /** + * What the photo button in the reply bar on a commit's page opens: the photo library, or the camera, as the + * composer sheet's two photo buttons do. + * + * @return list + */ + public static function photoItems(): array + { + return [ + self::item('reply-pick-photos', 'Choose photos', Lucide::ImagePlus, 'pickPhotos'), + self::item('reply-take-photo', 'Take a photo', Lucide::Camera, 'takePhoto'), + ]; + } + private static function item(string $ref, string $label, Lucide $icon, string $method, bool $disabled = false): TopBarAction { return NavAction::make($ref) diff --git a/app/Devnull/ComposerSheet.php b/app/Devnull/ComposerSheet.php new file mode 100644 index 00000000..8f08c2b6 --- /dev/null +++ b/app/Devnull/ComposerSheet.php @@ -0,0 +1,151 @@ +fieldHeight); + $bottom = max(0.0, $caret->bottom()); + + return [ + 'bottom' => $field > 0 ? min($bottom, $field) : $bottom, + 'line_height' => max(0.0, $caret->height), + 'field_height' => $field, + ]; + } + + /** + * The caret to keep after the field reports a new one. While the field is shorter for the list, it reports + * itself at that height, scrolled to the caret, which says nothing about where the caret is at its full height, + * so the sheet keeps what it had. Any other report is the field at its full height. + * + * @param array{bottom: float, line_height: float, field_height: float}|null $kept + * @param int|null $shortened how tall the sheet has made the field, or null when it fills + * @return array{bottom: float, line_height: float, field_height: float} + */ + public static function reported(Caret $caret, ?array $kept, ?int $shortened): array + { + if ($kept !== null && $shortened !== null && abs($caret->fieldHeight - $shortened) <= 1) { + return $kept; + } + + return self::caret($caret); + } + + /** The mention list's height with all its rows showing, up to six: its padding, its heading, then its rows. */ + public static function mentionHeight(int $rows, bool $heading = false): int + { + return self::MentionPadding + + ($heading ? self::MentionHeadingHeight : 0) + + min(max($rows, 1), self::MentionRowsShown) * self::MentionRowHeight; + } + + /** + * Where the mention list goes, and how tall the field is while it shows. + * + * - `field`: the field's height, or null when it fills as usual. + * - `top`: the list's top. + * - `height`: the list's height, or null when it runs down to the toolbar. + * + * With room for the whole list (up to six rows) between the caret's line and the field's bottom, it floats there + * over the field and nothing moves. Without it, the field ends on the caret's line, shortened by as much as the + * list needs but never under two lines, and the list starts under it and runs to the toolbar, over anything + * under the field (which comes up with the field's bottom). So the list never covers the caret's line. + * + * The room is measured to the field's bottom, since nothing reports how tall what's under it is. + * + * @param array{bottom: float, line_height: float, field_height: float}|null $caret + * @return array{field: int|null, top: int, height: int|null} + */ + public static function mentionLayout(?array $caret, int $rows, bool $heading = false): array + { + if ($caret === null || $caret['field_height'] <= 0) { + $line = $caret === null ? self::FirstLineHeight : (int) ceil($caret['bottom']); + + return ['field' => null, 'top' => self::FieldTop + $line + self::MentionGap, 'height' => null]; + } + + $list = self::mentionHeight($rows, $heading); + $field = (int) floor($caret['field_height']); + $bottom = (int) ceil($caret['bottom']); + $room = $field - $bottom - self::MentionGap - self::MentionInset; + + if ($room >= $list) { + return ['field' => null, 'top' => self::FieldTop + $bottom + self::MentionGap, 'height' => $list]; + } + + $line = $caret['line_height'] > 0 ? (int) ceil($caret['line_height']) : self::FirstLineHeight; + $shortened = max(self::MinFieldLines * $line, $field - self::MentionGap - self::MentionInset - $list); + + if ($shortened >= $bottom) { + // The caret is in the field's first lines already: shortening it frees nothing, so the list takes what + // room there is under the caret, at least a row. + return [ + 'field' => null, + 'top' => self::FieldTop + $bottom + self::MentionGap, + 'height' => max($room, self::MentionPadding + self::MentionRowHeight), + ]; + } + + return ['field' => $shortened, 'top' => self::FieldTop + $shortened + self::MentionGap, 'height' => null]; + } + + /** Whether the sheet's mention list has the "People you follow" heading: a bare "@" in a new commit. */ + public static function mentionHeading(?array $mention, string $view): bool + { + return ($mention['query'] ?? null) === '' && $view === 'compose'; + } +} diff --git a/app/Devnull/Data/Commit.php b/app/Devnull/Data/Commit.php index e7b87ada..386c1110 100644 --- a/app/Devnull/Data/Commit.php +++ b/app/Devnull/Data/Commit.php @@ -4,6 +4,7 @@ use App\Devnull\Display; use App\Devnull\Lane; +use App\Devnull\Ownership; use Carbon\CarbonImmutable; use Closure; use Throwable; @@ -21,6 +22,9 @@ * A Nata Nu//ers high score carries its signed run in a fenced block, which * shows as a card ($scoreCard) instead of as code. * + * $continuationId is the reply that carries on a thread its author writes as + * replies to themselves, when devnull says which (see SelfThread). + * * A commit posted straight to a guild's board knows that guild ($guild), which * keeps it out of general logs. */ @@ -37,13 +41,6 @@ */ public const int CountFrom = 200; - /** - * A list shows a body longer than this, or longer than PreviewLines lines, as its start and "Show more". - */ - public const int PreviewLength = 280; - - public const int PreviewLines = 8; - /** * The status of a commit you made that devnull doesn't have yet, which * stands in for it on the screen (see PendingWrite::stagedCommit()). @@ -85,6 +82,7 @@ public function __construct( public ?ReplyPreview $replyPreview = null, public int $pasteisCount = 0, public ?ScoreCard $scoreCard = null, + public ?string $continuationId = null, public ?Guild $guild = null, ) {} @@ -153,6 +151,7 @@ public static function fromArray(array $data): self replyPreview: is_array($data['reply_preview'] ?? null) ? ReplyPreview::fromArray($data['reply_preview']) : null, pasteisCount: max(0, (int) ($data['pasteis_count'] ?? 0)), scoreCard: $scoreCard, + continuationId: is_string($data['continuation_id'] ?? null) && $data['continuation_id'] !== '' ? $data['continuation_id'] : null, guild: self::guild($data), ); } @@ -175,6 +174,14 @@ public function withMorePasteis(int $change): self return new self(...[...get_object_vars($this), 'pasteisCount' => max(0, $this->pasteisCount + $change)]); } + /** + * This commit with the count of replies its own page gives, for a copy that came without one. + */ + public function withRepliesCount(int $repliesCount): self + { + return new self(...[...get_object_vars($this), 'repliesCount' => max(0, $repliesCount)]); + } + public function withPinned(bool $isPinned): self { return new self(...[...get_object_vars($this), 'isPinned' => $isPinned]); @@ -216,18 +223,6 @@ public static function fits(string $body): bool && ! CommitBody::hasOversizedUrl($body); } - /** - * Whether a list would show only the start of a body, as the web's composer - * works it out: more than PreviewLength characters or PreviewLines lines, - * once blank lines in a run are counted as one. - */ - public static function isFoldedInLists(string $body): bool - { - $normalized = CommitBody::normalize($body); - - return mb_strlen($normalized) > self::PreviewLength || count(explode("\n", $normalized)) > self::PreviewLines; - } - /** * This commit with $update applied to the replies under it, as a feed draws them. * @@ -351,15 +346,15 @@ public function isApproved(): bool } /** - * Whether $viewer may vote on the commit's poll, as the web decides it: someone else's published commit, whose - * poll is open and hasn't had their vote yet. + * Whether you may vote on the commit's poll, as the web decides it: a published commit that isn't yours or your + * organization's (see Ownership), whose poll is open and hasn't had your vote yet. */ - public function canBeVotedOnBy(?User $viewer): bool + public function canBeVotedOnBy(Ownership $ownership): bool { - return $viewer !== null + return $ownership->isSignedIn() && $this->poll !== null && $this->isApproved() - && $this->author->id !== $viewer->id + && ! $ownership->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..32b1701d 100644 --- a/app/Devnull/Data/CurrentUser.php +++ b/app/Devnull/Data/CurrentUser.php @@ -19,9 +19,16 @@ * 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 GitHub organizations you're a member of, admin or not, oldest + * membership first, which you can post as, as the web's Post as menu lists + * them. A devnull too old to say leaves it null. */ final readonly class CurrentUser { + /** + * @param list|null $organizations + */ public function __construct( public User $user, public int $unreadNotificationsCount = 0, @@ -37,6 +44,7 @@ public function __construct( public ?string $termsVersion = null, public ?CarbonImmutable $termsAcceptedAt = null, public ?bool $termsAccepted = null, + public ?array $organizations = null, ) {} /** @@ -69,9 +77,23 @@ 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, + organizations: is_array($data['organizations'] ?? null) ? self::organizations($data['organizations']) : null, ); } + /** + * The organizations you can post as, each drawn as an organization whatever the answer said. + * + * @param array $organizations + * @return list + */ + private static function organizations(array $organizations): array + { + $users = array_map(fn (array $organization): User => User::fromArray([...$organization, 'type' => 'organization']), array_values(array_filter($organizations, is_array(...)))); + + return array_values(array_filter($users, fn (User $organization): bool => $organization->username !== '')); + } + /** * The version of the terms devnull is waiting for you to accept, exactly as it sent it, or null when you have. */ diff --git a/app/Devnull/Data/ScheduledCommit.php b/app/Devnull/Data/ScheduledCommit.php index 31280b98..dcdf0b0e 100644 --- a/app/Devnull/Data/ScheduledCommit.php +++ b/app/Devnull/Data/ScheduledCommit.php @@ -10,7 +10,8 @@ * page, which only you see. Until it's submitted it has its body, the options * of its poll, and how many images it carries. Once submitted, those are its * commit's, and its status is that commit's: pending review, approved, - * rejected, or deleted. + * rejected, or deleted. $author is the organization it goes out as, or null + * when it goes out as you. */ final readonly class ScheduledCommit { @@ -39,6 +40,7 @@ public function __construct( public CarbonImmutable $scheduledAt, public ?CarbonImmutable $submittedAt, public string $status, + public ?User $author = null, ) {} /** @@ -62,6 +64,7 @@ public static function fromArray(array $data): self scheduledAt: Commit::date($data['scheduled_at'] ?? null) ?? CarbonImmutable::now(), submittedAt: Commit::date($data['submitted_at'] ?? null), status: is_string($status) && ($status === 'scheduled' || array_key_exists($status, self::Labels)) ? $status : 'scheduled', + author: is_array($data['author'] ?? null) ? User::fromArray([...$data['author'], 'type' => 'organization']) : null, ); } diff --git a/app/Devnull/Display.php b/app/Devnull/Display.php index d64bf47b..765d915c 100644 --- a/app/Devnull/Display.php +++ b/app/Devnull/Display.php @@ -5,6 +5,9 @@ use App\Devnull\Data\CommitBody; use Carbon\CarbonImmutable; use Carbon\CarbonInterface; +use Native\Mobile\Edge\Elements\BottomBar; +use Native\Mobile\Facades\System; +use Native\Mobile\Platform; /** * How the machine prints things: relative times and short hashes, as the web does. @@ -12,21 +15,78 @@ final class Display { /** - * The commit page's reply bar with one line of draft: its hairline, the - * field and the padding around them, as drawn on an iPhone. + * How much a line of draft adds to a composer bar's field. */ - public const int ReplyBarHeight = 53; - public const int ReplyBarLineHeight = 21; public const int ReplyBarMaxLines = 5; - public const int ReplyBarCharactersPerLine = 34; + /** + * The photos on a reply's draft, above the field in the reply bar (see partials/composer-photos), and the + * description of one under them while it's open. + */ + public const int ReplyBarPhotosHeight = 88; + + public const int ReplyBarDescriptionHeight = 100; + + /** + * The people to mention above a field (see partials/mention-suggestions): a row's height, and how many rows show + * before the rest scroll inside the list. + */ + public const int MentionRowHeight = 44; + + public const int MentionRowsShown = 6; + + /** + * A bar holding partials/composer-box with one line of draft, as drawn on an iPhone: the bar's padding, then the + * field over the row of tools and the send button. + */ + public const int ComposerBoxBarHeight = 94; + + /** + * The fade over the foot of a screen, just above its composer bar (see partials/composer-fade). On iOS the glass + * under the bar fades in over the same height (see composerBarGlass()). + */ + public const int ComposerFadeHeight = 28; + + /** + * How much of the surface, in percent, tints the glass under a composer bar on iOS (see composerSurface()). + */ + public const int ComposerGlassTint = 40; + + /** + * How opaque, in percent, the glass under a composer bar gets on iOS once it has faded in (glass/N, see + * composerBarGlass()). Full glass over a dark screen reads as a heavy slab. + */ + public const int ComposerGlassOpacity = 80; + + /** + * The first iOS whose scroll views draw a scroll edge effect under a bar (see hasScrollEdge()). + */ + public const int ScrollEdgeIosVersion = 26; /** - * The row under the reply bar's field that marks a restored draft (see partials/stash-label) and counts its photos. + * Whether a composer's field and its row of tools sit in a rounded Liquid Glass box over the scroll edge effect, + * as in Messages (see composerInGlassBox()). Off, they sit straight on the effect. Only on iOS 26 and later. */ - public const int ReplyBarStashLabelHeight = 28; + public const bool ComposerInGlassBox = true; + + /** + * Which scroll edge effect iOS 26 and later draw under a composer bar (see composerEdgeBlur()): "soft", the + * progressive blur under the system's own toolbars, or "hard", an opaque fade. + */ + public const string ComposerEdgeBlur = 'soft'; + + /** + * A bar holding partials/composer-box in its glass box with one line of draft: ComposerBoxBarHeight, plus the + * box's own padding over and under what it holds (see composerBox()). + */ + public const int ComposerGlassBoxBarHeight = 100; + + /** + * About how many characters fit on a line of the box's field, which runs the width of the box. + */ + public const int ComposerBoxCharactersPerLine = 46; /** * The strip under the home indicator on Face ID iPhones. EDGE doesn't @@ -219,20 +279,187 @@ public static function maskedKey(string $openSsh): string * How far a commit page has to scroll past its last reply to clear the * reply bar. A pushed screen is drawn under its bottom bar and the home * indicator, with no inset for either, so the page pads its own end: the - * bar as the draft grows to its five lines, and the indicator below it. - * With the keyboard up the bar sits on the keyboard instead, which only - * leaves a little more room. A restored draft, or one with photos, adds - * the row under the field ($draftRow). + * fade over its foot (partials/composer-fade), the bar + * (partials/composer-box) as the draft grows to its five lines, and the + * indicator below it. With the keyboard up the bar sits on the keyboard + * instead, which only leaves a little more room. Photos on the draft add + * their row above the field ($hasPhotos), and an open description of one + * its box under them ($describing). A link too long for devnull adds the + * line that says so. */ - public static function replyBarClearance(string $draft, bool $draftRow = false): int + public static function replyBarClearance(string $draft, bool $hasPhotos = false, bool $describing = false): int { - return self::ReplyBarHeight - + (min(self::ReplyBarMaxLines, self::lineCount($draft, self::ReplyBarCharactersPerLine)) - 1) * self::ReplyBarLineHeight - + ($draftRow ? self::ReplyBarStashLabelHeight : 0) + return self::composerFadeHeight() + + self::composerBoxBarHeight() + + self::composerBoxGrowth($draft) + + ($hasPhotos ? self::ReplyBarPhotosHeight : 0) + + ($hasPhotos && $describing ? self::ReplyBarDescriptionHeight : 0) + (CommitBody::hasOversizedUrl($draft) ? 3 * self::ReplyBarLineHeight : 0) + self::HomeIndicatorHeight; } + /** + * How much taller a composer-box bar is than with one line, as the draft grows to its five lines. A screen pads + * its end by this on top of ComposerBoxBarHeight to keep its last row clear of the bar. + */ + public static function composerBoxGrowth(string $draft): int + { + return (min(self::ReplyBarMaxLines, self::lineCount($draft, self::ComposerBoxCharactersPerLine)) - 1) * self::ReplyBarLineHeight; + } + + /** + * The fade's classes (see partials/composer-fade): a gradient down from see-through to the bar's surface, where + * the bar's rows start. EDGE takes a gradient's stops as they are, without the dark companion a theme colour gets, + * so the stops are the surface of the appearance the phone is in now, and a screen with the fade draws again when + * that changes (see RedrawsOnAppearanceChange). + * + * On Android it climbs to 70% of the surface by halfway and ends solid, so what's under it has mostly faded before + * it reaches the bar. On iOS it ends at the glass's tint (composerSurface()), since the bar is glass there and the + * glass fades in under it over the same height. + */ + public static function composerFade(): string + { + $surface = strtolower((string) theme('surface', '#ffffff')); + + if (self::fadesInBar()) { + return "bg-gradient-to-b from-{$surface}/0 to-{$surface}/".self::ComposerGlassTint; + } + + return "bg-gradient-to-b from-{$surface}/0 via-{$surface}/70 to-{$surface}"; + } + + /** + * Whether the fade goes at the top of the composer bar itself, rather than over the foot of the screen above it. + * On iOS the screen runs on under its bottom bar, so a fade lying over the screen's foot would be under the bar, + * and the bar has to draw it. On Android the screen stops where the bar starts, so the fade lies over the screen. + */ + public static function fadesInBar(): bool + { + return Platform::isIos(); + } + + /** + * Whether the composer bars stand on iOS's own scroll edge effect: iOS 26 and later blur what scrolls under the + * bar, as under its own toolbars, from the bar's edge-blur attribute (see composerEdgeBlur()). That stands in for + * the fade and the tinted glass, so a bar there draws neither and lets the effect show. Older iOS keeps the fade + * over glass, and Android its fade over the surface. + * + * It needs a mobile-air that takes edge-blur on a bottom bar and says which iOS the phone runs + * (System::osVersion()). Without one this is false and every iOS keeps the fade. + */ + public static function hasScrollEdge(): bool + { + if (! Platform::isIos() + || ! method_exists(\Native\Mobile\System::class, 'osVersion') + || ! method_exists(BottomBar::class, 'edgeBlurStyle')) { + return false; + } + + return (int) System::osVersion() >= self::ScrollEdgeIosVersion; + } + + /** + * Whether a composer bar draws partials/composer-fade as its first row: on iOS, before the scroll edge effect. + */ + public static function fadeRowInBar(): bool + { + return self::fadesInBar() && ! self::hasScrollEdge(); + } + + /** + * Whether the composer's field and tools sit in a rounded Liquid Glass box on the bar (ComposerInGlassBox): on + * iOS 26 and later, over the scroll edge effect. Older iOS and Android draw them straight on the bar, as before. + */ + public static function composerInGlassBox(): bool + { + return self::ComposerInGlassBox && self::hasScrollEdge(); + } + + /** + * The classes for partials/composer-box's outer column. In the glass box it's rounded to match the send button + * inside it, which sits 8pt in from its right and bottom edges: the row of tools leaves 6pt at its end and 2pt + * under the button, and the box 2pt more under the row. + */ + public static function composerBox(): string + { + return self::composerInGlassBox() ? 'rounded-[24] glass pb-[2]' : ''; + } + + /** + * The padding over the field inside partials/composer-box. In the glass box the field sits as far under the + * box's top edge as the row of tools sits under the field, 16pt to the text either way. + */ + public static function composerFieldTop(): string + { + return self::composerInGlassBox() ? 'pt-2' : 'pt-1'; + } + + /** + * How tall a composer bar is with one line of draft (see ComposerBoxBarHeight and ComposerGlassBoxBarHeight). + */ + public static function composerBoxBarHeight(): int + { + return self::composerInGlassBox() ? self::ComposerGlassBoxBarHeight : self::ComposerBoxBarHeight; + } + + /** + * How tall the composer fade is where it's drawn: none where the scroll edge effect replaces it. + */ + public static function composerFadeHeight(): int + { + return self::hasScrollEdge() ? 0 : self::ComposerFadeHeight; + } + + /** + * The classes for a composer's native:bottom-bar. On iOS that's Liquid Glass: what scrolls under the bar shows + * through it, blurred. A patched mobile-air draws the glass behind the whole bar, under the home indicator too, + * and fades it in over the bar's top ComposerFadeHeight points, so it has no hard top edge. EDGE's own glass on + * an element can't be faded, and stops short of the home indicator. The glass stops at ComposerGlassOpacity + * percent (glass/N), so a little of the screen under the bar shows through. Android has no glass, so the bar + * stays the surface there. + * + * From iOS 26 the bar's edge-blur takes the glass's place (see composerEdgeBlur()). + */ + public static function composerBarGlass(): string + { + return self::fadesInBar() ? 'glass/'.self::ComposerGlassOpacity : ''; + } + + /** + * The edge-blur attribute for a composer's native:bottom-bar: on iOS, ComposerEdgeBlur, so iOS 26 and later draw + * the system's scroll edge effect under the bar, and mobile-air leaves the bar's glass out there. Older iOS ignores + * it and keeps the glass. Android has no such effect, so nothing is asked there. + */ + public static function composerEdgeBlur(): string + { + return self::fadesInBar() ? self::ComposerEdgeBlur : ''; + } + + /** + * The composer bar's own classes. On Android it's the surface. On iOS it has no background at all: mobile-air + * paints a bar's background colour behind the whole bar, which would cover the fade at its top, so the bar's + * rows carry the tint instead (composerSurface()). + */ + public static function composerBar(): string + { + return self::fadesInBar() ? '' : 'bg-theme-surface'; + } + + /** + * The classes for the rows of a composer bar, under its fade. On Android it's the surface. On iOS it's the + * surface at ComposerGlassTint percent, which tints the glass behind the bar to the screen's own colour, so in + * dark mode the bar doesn't come out lighter than the screen. A fill reaches under the home indicator, so the + * tint runs on there with the glass. + */ + public static function composerSurface(): string + { + if (self::hasScrollEdge()) { + return ''; + } + + return self::fadesInBar() ? 'bg-theme-surface/'.self::ComposerGlassTint : 'bg-theme-surface'; + } + /** * About how many lines some text wraps to where $perLine characters fit on one, counting each of its own lines. */ diff --git a/app/Devnull/DraftImages.php b/app/Devnull/DraftImages.php index cf3b3042..852eb88b 100644 --- a/app/Devnull/DraftImages.php +++ b/app/Devnull/DraftImages.php @@ -98,6 +98,10 @@ public function keep(string $path): DraftImage throw new InvalidDraftImage(self::Unreadable); } + // A moved file keeps its own time, which for a photo from the library can be years ago. Until the draft holds + // it, nothing does, so the next photo picked with it would prune it as long forgotten. + @touch($kept); + return new DraftImage($kept, self::Types[$info[2]], $info[0], $info[1]); } diff --git a/app/Devnull/LastVisit.php b/app/Devnull/LastVisit.php index f88e01b2..4a951c89 100644 --- a/app/Devnull/LastVisit.php +++ b/app/Devnull/LastVisit.php @@ -36,13 +36,13 @@ public function remember(string $userId, string $log, array $commits): void /** * The commit the marker goes above, or null for a first visit, when nothing is - * new, or when the only new commits are your own. + * new, or when the only new commits are yours or your organizations' (see Ownership). * * @param list $commits newest first */ - public static function firstSeenId(array $commits, ?string $seenAt, ?string $userId): ?string + public static function firstSeenId(array $commits, ?string $seenAt, Ownership $ownership): ?string { - if ($seenAt === null || $userId === null) { + if ($seenAt === null || ! $ownership->isSignedIn()) { return null; } @@ -58,7 +58,7 @@ public static function firstSeenId(array $commits, ?string $seenAt, ?string $use } foreach (array_slice($commits, 0, $index) as $newer) { - if ($newer->author->id !== $userId) { + if (! $ownership->owns($newer)) { return $commit->id; } } diff --git a/app/Devnull/Ownership.php b/app/Devnull/Ownership.php new file mode 100644 index 00000000..99f52478 --- /dev/null +++ b/app/Devnull/Ownership.php @@ -0,0 +1,72 @@ + $organizationIds + */ + public function __construct( + public ?string $userId = null, + public array $organizationIds = [], + ) {} + + /** + * @param list $organizations + */ + public static function of(?User $user, array $organizations = []): self + { + $userId = $user === null || $user->id === '' ? null : $user->id; + + if ($userId === null) { + return new self; + } + + return new self($userId, array_values(array_filter( + array_map(fn (User $organization): string => $organization->id, $organizations), + fn (string $id): bool => $id !== '' && $id !== $userId, + ))); + } + + public function isSignedIn(): bool + { + return $this->userId !== null; + } + + /** + * Whether the commit is yours: by you, or by an organization you're in. + */ + public function owns(Commit $commit): bool + { + $author = $commit->author->id; + + return $this->userId !== null && $author !== '' && ($author === $this->userId || in_array($author, $this->organizationIds, true)); + } + + /** + * Whether you made the commit as yourself, not as an organization. + */ + public function isYourOwn(Commit $commit): bool + { + return $this->userId !== null && $commit->author->id === $this->userId; + } +} diff --git a/app/Devnull/PostAs.php b/app/Devnull/PostAs.php new file mode 100644 index 00000000..26711721 --- /dev/null +++ b/app/Devnull/PostAs.php @@ -0,0 +1,124 @@ + + */ + public static function organizations(): array + { + return app(Account::class)->organizations(); + } + + /** + * The organization the commit goes out as, or null when it goes out as you. + */ + public static function author(?string $picked): ?User + { + if ($picked === null || $picked === '') { + return null; + } + + foreach (self::organizations() as $organization) { + if (strcasecmp($organization->username, $picked) === 0) { + return $organization; + } + } + + return null; + } + + /** + * Whether the composer shows whom it posts as: you're in an organization, or picked one you've left since. + */ + public static function offered(?string $picked): bool + { + return self::organizations() !== [] || ($picked !== null && $picked !== ''); + } + + /** + * The menu: you first, then your organizations, each with their avatar, round for you and a rounded square for + * an organization, as elsewhere in the app, and the one posting now ticked. Until an avatar loads, or if it + * can't, a person or building icon stands in. $method is called with the handle picked, or '' for you. + * + * Each row is the name with the handle under it, smaller, which screen readers read after the name. A core + * without NavAction::subtitle() (before NativePHP/mobile-air#740) gets one label, "Simon (@simon-hamp)", instead. + * + * @return list + */ + public static function menu(User $me, ?User $author, string $method): array + { + return array_map(function (User $identity) use ($author, $method): TopBarAction { + $icon = $identity->isOrganization ? Lucide::Building2 : Lucide::UserRound; + + $handle = '@'.$identity->username; + $subtitled = self::subtitles(); + + $row = NavAction::make('post-as-'.$identity->username) + ->label($subtitled ? $identity->name : $identity->name.' ('.$handle.')') + ->icon(ios: $icon->ios(), android: $icon->android()) + ->image(ImageCache::src($identity->avatarUrl)) + ->press($method."('".($identity->isOrganization ? $identity->username : '')."')"); + + if ($subtitled) { + $row->subtitle($handle); + } + + return $row->toElement() + ->setProp('image_shape', $identity->isOrganization ? 'rounded' : 'circle') + ->setProp('checked', self::posting($identity, $author)) + ->ref('post-as-'.$identity->username); + }, [$me, ...self::organizations()]); + } + + /** + * Whether the installed core can give a menu row a subtitle under its label. + */ + private static function subtitles(): bool + { + return method_exists(NavAction::class, 'subtitle'); + } + + /** + * What the composer's avatar says to a screen reader. + */ + public static function label(User $me, ?User $author): string + { + return 'Posting as @'.($author ?? $me)->username.'. Choose who to post as'; + } + + /** + * The lane the composer's main button is drawn in: yours, or the organization's. + */ + public static function colour(User $me, ?User $author): string + { + return Lane::token(($author ?? $me)->lane()); + } + + /** + * Whether the menu ticks this one: whoever posts now. + */ + private static function posting(User $identity, ?User $author): bool + { + return $author === null ? ! $identity->isOrganization : $identity->isOrganization && $identity->username === $author->username; + } +} diff --git a/app/Devnull/ResponseCache.php b/app/Devnull/ResponseCache.php index 3bc8e7be..a67e713d 100644 --- a/app/Devnull/ResponseCache.php +++ b/app/Devnull/ResponseCache.php @@ -400,10 +400,11 @@ public function pastelGiven(array $json): void /** * You committed. A commit goes on top of your logs and your profile; a reply - * goes under its parent and counts there, and on top of your replies. A - * post to a guild's board goes on top of that board alone, as it isn't in - * the logs or your profile's list, though devnull counts it among your - * commits. + * goes under its parent and counts there, and on top of your replies. One + * you posted as an organization is the organization's, so it stays off + * your profile and its counts, as devnull keeps it. A post to a guild's + * board goes on top of that board alone, as it isn't in the logs or your + * profile's list, though devnull counts it among your commits. * * @param array $commit */ @@ -416,18 +417,23 @@ public function commitAdded(array $commit): void } $parentId = is_string($commit['parent_id'] ?? null) ? $commit['parent_id'] : null; + $onYourProfile = ! self::isOrganizations($commit); $guild = Guild::fromArray(is_array($commit['guild'] ?? null) ? $commit['guild'] : ['handle' => $commit['guild_handle'] ?? null]); if ($parentId === null) { // Trending is ranked, so a new commit has no place at the top of it. - $paths = $guild === null ? ['log/following', 'log/latest', "users/{$me}/commits"] : ['guilds/'.rawurlencode($guild->handle)]; + $paths = $guild === null + ? ['log/following', 'log/latest', ...($onYourProfile ? ["users/{$me}/commits"] : [])] + : ['guilds/'.rawurlencode($guild->handle)]; foreach ($paths as $path) { $this->patch($path, [], fn (array $json): array => self::prepend($json, $commit)); } - $this->patch("users/{$me}", [], fn (array $json): array => self::count($json, 'commits_count', 1)); + if ($onYourProfile) { + $this->patch("users/{$me}", [], fn (array $json): array => self::count($json, 'commits_count', 1)); + } return; } @@ -436,7 +442,10 @@ public function commitAdded(array $commit): void $this->patch("commits/{$parentId}/replies", [], fn (array $json): array => ($json['meta']['next_cursor'] ?? null) === null ? [...$json, 'data' => [...self::without($json['data'] ?? [], $commit['id']), $commit]] : $json); - $this->patch("users/{$me}/commits", ['replies' => '1'], fn (array $json): array => self::prepend($json, $commit)); + if ($onYourProfile) { + $this->patch("users/{$me}/commits", ['replies' => '1'], fn (array $json): array => self::prepend($json, $commit)); + } + $this->patchCommit($parentId, fn (array $parent): array => self::withNewestReply([...$parent, 'replies_count' => (int) ($parent['replies_count'] ?? 0) + 1], $commit)); } @@ -461,11 +470,14 @@ private static function withNewestReply(array $parent, array $reply): array } /** - * You deleted a commit: it leaves every list, its page goes, and its parent counts one reply fewer. + * You deleted a commit: it leaves every list, its page goes, and its parent + * counts one reply fewer. Your profile counts one commit fewer, unless it + * was an organization's you're in (see Ownership). */ public function commitDeleted(string $id): void { - $parentId = $this->findCommit($id)['parent_id'] ?? null; + $found = $this->findCommit($id); + $parentId = $found['parent_id'] ?? null; $this->rememberDeletion($id); @@ -476,11 +488,21 @@ public function commitDeleted(string $id): void if (is_string($parentId) && $parentId !== '') { $this->patchCommit($parentId, fn (array $parent): array => [...$parent, 'replies_count' => max(0, (int) ($parent['replies_count'] ?? 0) - 1)]); - } elseif (($me = $this->username()) !== null) { + } elseif (($me = $this->username()) !== null && ($found === null || ! self::isOrganizations($found))) { $this->patch("users/{$me}", [], fn (array $json): array => self::count($json, 'commits_count', -1)); } } + /** + * Whether a kept commit is an organization's. + * + * @param array $commit + */ + private static function isOrganizations(array $commit): bool + { + return is_array($commit['author'] ?? null) && ($commit['author']['type'] ?? null) === 'organization'; + } + /** * You followed or unfollowed someone: their profile and your following * count change, and every list of people kept with whether you follow them. diff --git a/app/Devnull/RowInputs.php b/app/Devnull/RowInputs.php index 176756d1..d96cbca2 100644 --- a/app/Devnull/RowInputs.php +++ b/app/Devnull/RowInputs.php @@ -27,18 +27,21 @@ final class RowInputs public static function for(Commit $commit, array $scope): array { $viewer = $scope['viewer'] ?? app(Account::class)->user(); + $ownership = $scope['ownership'] ?? app(Account::class)->ownership(); return [ 'viewer' => $viewer?->id, + 'organizations' => $ownership->organizationIds, 'pasteis' => $scope['pasteis'] ?? app(Account::class)->pasteis(), 'stashed' => $scope['stashed'] ?? [], 'unfolded' => $scope['unfolded'] ?? [], 'expandable' => isset($scope['threads']), 'opened' => array_key_exists($commit->id, $scope['threads'] ?? []) && ! in_array($commit->id, $scope['closingThreads'] ?? [], true), 'faded' => in_array($commit->id, $scope['fadedRows'] ?? [], true), + // A reply whose replies, opened in place, showed its author carried it on gets "Show thread". + 'continued' => in_array($commit->id, $scope['threadsContinued'] ?? [], true), 'popping' => [$scope['popping']['star-'.$commit->id] ?? null, $scope['popping']['pastel-'.$commit->id] ?? null], 'tombstones' => $scope['tombstones'] ?? false, - 'tombstoneReplies' => array_key_exists($commit->id, $scope['tombstoneReplies'] ?? []), 'shown' => [self::changing($commit), $commit->quotedCommit === null ? null : self::changing($commit->quotedCommit)], 'poll' => [$scope['pollChoices'][$commit->id] ?? null, in_array($commit->id, $scope['voting'] ?? [], true)], 'selected' => ($scope['selectedCommit'] ?? null) === $commit->id, diff --git a/app/Devnull/SelfThread.php b/app/Devnull/SelfThread.php new file mode 100644 index 00000000..56278e10 --- /dev/null +++ b/app/Devnull/SelfThread.php @@ -0,0 +1,176 @@ + $parts The commits carrying the thread on below the commit, in order, at most the limit. + * @param bool $hasMore Whether another part follows the last of $parts. + * @param bool $hasEnded Whether it's known that no part follows the last of $parts. + * @param string|null $waiting The commit whose replies the walk needs to go on. + */ + public function __construct( + public array $parts = [], + public bool $hasMore = false, + public bool $hasEnded = false, + public ?string $waiting = null, + ) {} + + /** + * The reply among $replies that carries $commit's thread on, if it's one of them. + * + * @param iterable $replies + */ + public static function next(Commit $commit, iterable $replies): ?Commit + { + if ($commit->isDeleted() || $commit->isStaged() || $commit->author->id === '') { + return null; + } + + $earliest = null; + + foreach ($replies as $reply) { + if ($commit->continuationId !== null) { + if ($reply->id === $commit->continuationId) { + return $reply; + } + + continue; + } + + if ($reply->parentId !== $commit->id || $reply->isDeleted() || $reply->isStaged() || $reply->author->id !== $commit->author->id) { + continue; + } + + if ($earliest === null || self::isEarlier($reply, $earliest)) { + $earliest = $reply; + } + } + + return $earliest; + } + + /** + * $replies without the one that carries $commit's thread on, which shows as the next part of it instead. + * + * @param list $replies + * @return list + */ + public static function others(Commit $commit, array $replies): array + { + $next = self::next($commit, $replies); + + return $next === null ? $replies : array_values(array_filter($replies, fn (Commit $reply): bool => $reply->id !== $next->id)); + } + + /** + * Walks down from $commit through the parts that carry its thread on, as far as $limit and the replies that + * have come allow. + * + * @param Closure(Commit): (list|null) $repliesOf A commit's first page of replies, or null until it comes. + */ + public static function below(Commit $commit, Closure $repliesOf, int $limit = self::PerPage): self + { + $parts = []; + $above = $commit; + + while (true) { + $replies = $repliesOf($above); + + if ($replies === null) { + return new self($parts, waiting: $above->id); + } + + $next = self::next($above, $replies); + + if ($next === null || in_array($next, $parts, true) || $next->id === $commit->id) { + return new self($parts, hasEnded: true); + } + + if (count($parts) >= $limit) { + return new self($parts, hasMore: true); + } + + $parts[] = $next; + $above = $next; + } + } + + /** + * How many of the commits just above $commit, of $ancestors (oldest first), are earlier parts of its thread, + * and whose replies are needed to look further up. Only the author's own commits can be; each one is a part + * when its earliest reply from them is the one below it. + * + * @param list $ancestors + * @param Closure(Commit): (list|null) $repliesOf + * @return array{0: int, 1: string|null} + */ + public static function above(array $ancestors, Commit $commit, Closure $repliesOf): array + { + $count = 0; + $below = $commit; + + foreach (array_reverse($ancestors) as $ancestor) { + if ($below->isDeleted() || $ancestor->isDeleted() || $ancestor->author->id !== $below->author->id || $below->parentId !== $ancestor->id) { + break; + } + + $replies = $repliesOf($ancestor); + + if ($replies === null) { + return [$count, $ancestor->id]; + } + + if (self::next($ancestor, $replies)?->id !== $below->id) { + break; + } + + $count++; + $below = $ancestor; + } + + return [$count, null]; + } + + /** + * The place in its thread of the commit at $position, as the web's ThreadPositionBadge writes it: "3/7", with + * a "+" when more of the thread follows than has been read. Null for a commit that isn't part of one. + */ + public static function position(int $position, int $size, bool $isOpenEnded): ?string + { + return $size > 1 && $position >= 1 ? $position.'/'.$size.($isOpenEnded ? '+' : '') : null; + } + + private static function isEarlier(Commit $reply, Commit $than): bool + { + if ($reply->createdAt === null || $than->createdAt === null || $reply->createdAt->equalTo($than->createdAt)) { + return strcmp($reply->id, $than->id) < 0; + } + + return $reply->createdAt->lessThan($than->createdAt); + } +} diff --git a/app/Devnull/ThreadRows.php b/app/Devnull/ThreadRows.php index 337766d9..6d26c2b5 100644 --- a/app/Devnull/ThreadRows.php +++ b/app/Devnull/ThreadRows.php @@ -3,21 +3,36 @@ namespace App\Devnull; use App\Devnull\Data\Commit; +use Closure; /** - * The list rows of a commit's thread opened in a feed (see - * Concerns\ExpandsThreads), in order, each with what its partial draws. + * The rows of a commit's thread opened in place (see + * Concerns\ExpandsThreads), in order, each with what its partial draws: in a + * feed, and on a commit page under the commit and under the last part of its + * author's thread. * * Under the commit come its replies, each followed by its own replies when - * they're open, one step in, and "Show more" after the replies of a thread - * with more. Every row is a list row of its own, and the last one closes the - * commit's row with its hairline. + * they're open, and theirs, as deep as they go, with "Show more" after the + * replies of a thread with more. Every row is a row of its own, and in a feed + * the last one closes the commit's row with its hairline. On a commit page it + * does only when another commit's row follows the thread. * * The thread hangs off the rail in dashes, as on the web: the first reply on * an elbow from the commit's rail, each later one on a short link from the * line down from the reply above, which is in that reply's lane. A reply's - * own replies hang the same way off the line down from its avatar, which runs - * on past them ($spine) when another reply of the commit follows. + * own replies hang the same way off the line down from its avatar, one step + * in, and that line runs on past them ($spines) when another reply follows. + * + * The steps in stop at the web's depth (MaxIndentDepth). Replies at that + * depth each hang on an elbow of their own from the line of the reply they + * answer, as the web draws every reply, since their replies line up under + * them and a line down from one avatar to the next would run through those. + * Deeper replies are flattened: in the same column, with no lines, and a + * "↳ replying to @handle" line saying who they answer. + * + * In a feed only the commit's replies open theirs in place ($opensInPlace), + * and a reply's replies open their page. On a commit page every reply opens + * its replies in place. */ final class ThreadRows { @@ -35,67 +50,156 @@ final class ThreadRows */ public const int FirstReplyTop = 3; + /** + * How deep replies step in, as the web's maxIndentDepth: the commit's + * replies are 1, and deeper replies line up under those at this depth. + */ + public const int MaxIndentDepth = 3; + + /** + * How far in each step is, in points. + */ + public const int Step = 32; + /** * @param array> $threads Open threads, by the id of the commit or reply they answer. * @param array $cursors Where each open thread with more carries on. * @param array $shown How many of each open thread's replies show. * @param int|string|null $railLane The commit's rail running on past its thread, when its author's run carries on below. + * @param int $opensInPlace How deep a reply's replies button opens its replies in place rather than its page. + * @param bool $onPage On a commit page: replies muted, deleted ones open theirs in place, and no hairline under them by default. + * @param string|null $morePress What the commit's own "Show more" presses, when it isn't showMoreReplies. + * @param bool|null $hairline Whether the last row closes the thread with a hairline: in a feed it does, and on a + * commit page only when another commit's row comes next. * @return list, reply: Commit|null}> */ - public static function under(Commit $commit, array $threads, array $cursors, array $shown, int|string|null $railLane = null): array - { + public static function under( + Commit $commit, + array $threads, + array $cursors, + array $shown, + int|string|null $railLane = null, + int $opensInPlace = 1, + bool $onPage = false, + ?string $morePress = null, + ?bool $hairline = null, + ): array { $thread = fn (string $id): array => array_slice($threads[$id] ?? [], 0, $shown[$id] ?? null); $hasMore = fn (string $id): bool => isset($cursors[$id]) || count($thread($id)) < count($threads[$id] ?? []); - $replies = $thread($commit->id); - if ($replies === []) { + $rows = []; + self::branch($rows, $commit, 1, [], $thread, $hasMore, [ + 'railLane' => $railLane, + 'opensInPlace' => $opensInPlace, + 'onPage' => $onPage, + 'morePress' => $morePress, + 'hairline' => $hairline ?? ! $onPage, + ]); + + if ($rows === []) { return []; } - $rows = []; - $more = $hasMore($commit->id); + $last = array_key_last($rows); + $rows[$last]['data']['last'] = true; + + return $rows; + } + + /** + * How far in replies at $depth start, past the commit's text. + */ + public static function indent(int $depth): int + { + return (min($depth, self::MaxIndentDepth) - 1) * self::Step; + } + + /** + * The x of the line down from the avatars of replies at $depth, or the commit's rail above them all. + */ + private static function lineAt(int $depth): float + { + return $depth === 0 ? 31.5 : 75.5 + self::indent($depth); + } + + /** + * The rows of $parent's replies at $depth, and theirs under each. + * + * @param list> $rows + * @param list $spines Lines from further up running on past these rows. + * @param Closure(string): list $thread + * @param Closure(string): bool $hasMore + * @param array{railLane: int|string|null, opensInPlace: int, onPage: bool, morePress: string|null, hairline: bool} $options + */ + private static function branch(array &$rows, Commit $parent, int $depth, array $spines, Closure $thread, Closure $hasMore, array $options): void + { + $replies = $thread($parent->id); + + if ($replies === []) { + return; + } + + $more = $hasMore($parent->id); + $indent = self::indent($depth); + $hangs = $depth === self::MaxIndentDepth; + $flattened = $depth > self::MaxIndentDepth; + $parentLine = self::lineAt($depth - 1); + $onPage = $options['onPage']; foreach ($replies as $index => $reply) { - $nested = $reply->isDeleted() ? [] : $thread($reply->id); - $nestedMore = $nested !== [] && $hasMore($reply->id); + $nested = $reply->isDeleted() && ! $onPage ? [] : $thread($reply->id); $followed = $index < count($replies) - 1 || $more; + $top = ! $onPage && $depth === 1 && $index === 0 ? self::FirstReplyTop : 10; $rows[] = self::reply($reply, [ - 'lane' => $commit->lane(), - 'previousLane' => $index === 0 ? null : $replies[$index - 1]->lane(), - 'hasNext' => $followed || $nested !== [], - 'railLane' => $railLane, - 'thread' => $commit, - 'repliesInPlace' => true, - ...($index === 0 ? ['top' => self::FirstReplyTop] : []), + 'lane' => $parent->lane(), + 'previousLane' => $index === 0 || $hangs ? null : $replies[$index - 1]->lane(), + 'hasNext' => ! $hangs && ! $flattened && ($followed || $nested !== []), + 'links' => ! $flattened, + 'railLane' => $options['railLane'], + 'indent' => $indent, + 'top' => $top, + // At the deepest step the line of the reply answered runs on under the elbow to the next one. + 'spines' => [...$spines, ...($hangs && $followed ? [['left' => $parentLine, 'lane' => $parent->lane(), 'top' => $top + 12]] : [])], + 'replyingTo' => $flattened ? self::replyingTo($reply, $parent) : null, + 'repliesInPlace' => $depth <= $options['opensInPlace'], + 'muted' => $onPage, + 'tombstones' => $onPage, + 'hairline' => $options['hairline'], ]); - foreach ($nested as $nestedIndex => $nestedReply) { - $rows[] = self::reply($nestedReply, [ - 'lane' => $reply->lane(), - 'previousLane' => $nestedIndex === 0 ? null : $nested[$nestedIndex - 1]->lane(), - 'hasNext' => $nestedIndex < count($nested) - 1 || $nestedMore, - 'railLane' => $railLane, - 'indent' => 32, - 'spine' => $followed ? $reply->lane() : null, - 'thread' => $reply, - 'repliesInPlace' => false, - ]); - } - - if ($nestedMore) { - $rows[] = self::more($reply->id, $nested[array_key_last($nested)]->lane(), $railLane, 32, $followed ? $reply->lane() : null); - } + // The line that has to run on past this reply's own replies, to the next reply at this depth. + $through = match (true) { + ! $followed || $flattened => [], + $hangs => [['left' => $parentLine, 'lane' => $parent->lane()]], + default => [['left' => self::lineAt($depth), 'lane' => $reply->lane()]], + }; + + self::branch($rows, $reply, $depth + 1, [...$spines, ...$through], $thread, $hasMore, $options); } if ($more) { - $rows[] = self::more($commit->id, $replies[array_key_last($replies)]->lane(), $railLane); + $rows[] = self::more($parent, [ + 'lane' => $replies[array_key_last($replies)]->lane(), + 'parentLane' => $parent->lane(), + 'hangs' => $hangs, + 'links' => ! $flattened, + 'railLane' => $options['railLane'], + 'indent' => $indent, + 'spines' => $spines, + 'to' => $flattened && ! $parent->isDeleted() ? $parent->author->handle() : null, + 'hairline' => $options['hairline'], + ...($depth === 1 && $options['morePress'] !== null ? ['press' => $options['morePress']] : []), + ]); } + } - $last = array_key_last($rows); - $rows[$last]['data']['last'] = true; - - return $rows; + /** + * "replying to @handle", or "quoting" when the reply quotes what it answers, as the web marks a flattened reply. + */ + private static function replyingTo(Commit $reply, Commit $parent): string + { + return ($reply->quotedCommitId === $parent->id ? 'quoting ' : 'replying to ').($parent->isDeleted() ? '[deleted]' : $parent->author->handle()); } /** @@ -107,7 +211,7 @@ private static function reply(Commit $reply, array $data): array return [ 'key' => 'thread-reply-'.$reply->id, 'partial' => 'native.partials.thread-reply', - 'data' => ['reply' => $reply, 'indent' => 0, 'spine' => null, 'last' => false, 'fades' => true, ...$data], + 'data' => ['reply' => $reply, 'last' => false, 'fades' => true, ...$data], 'reply' => $reply, ]; } @@ -115,14 +219,15 @@ private static function reply(Commit $reply, array $data): array /** * "Show more" at the foot of a thread, on a line down in the lane of the reply above it. * + * @param array $data * @return array{key: string, partial: string, data: array, reply: null} */ - private static function more(string $threadId, int|string $lane, int|string|null $railLane, int $indent = 0, int|string|null $spine = null): array + private static function more(Commit $parent, array $data): array { return [ - 'key' => 'thread-more-'.$threadId, + 'key' => 'thread-more-'.$parent->id, 'partial' => 'native.partials.thread-more-row', - 'data' => ['threadId' => $threadId, 'lane' => $lane, 'railLane' => $railLane, 'indent' => $indent, 'spine' => $spine, 'last' => false], + 'data' => ['threadId' => $parent->id, 'last' => false, ...$data], 'reply' => null, ]; } diff --git a/app/Icons/Lucide.php b/app/Icons/Lucide.php index fd1780d8..7a5d7301 100644 --- a/app/Icons/Lucide.php +++ b/app/Icons/Lucide.php @@ -36,6 +36,7 @@ enum Lucide case ArrowUp; case Pin; case ListOrdered; + case ListTree; /** lucide-react 1.57 draws Building2 as building-complex, so that is the drawing in building-2.svg. */ case Building2; case MapPin; @@ -49,7 +50,6 @@ enum Lucide case UserPlus; case UserCheck; case AtSign; - case FoldVertical; case Award; case Ellipsis; case Flag; @@ -75,7 +75,6 @@ enum Lucide case Eye; case EyeOff; case Plus; - case Maximize2; case Vibrate; // The achievement badges, named as devnull names their icons (see forBadge()). @@ -180,6 +179,7 @@ public function custom(bool $filled = false): string self::ArrowUp => 'arrow-up', self::ChevronsUp => 'chevrons-up', self::ListOrdered => 'list-ordered', + self::ListTree => 'list-tree', self::Building2 => 'building-2', self::MapPin => 'map-pin', self::CalendarDays => 'calendar-days', @@ -190,7 +190,6 @@ public function custom(bool $filled = false): string self::UserPlus => 'user-plus', self::UserCheck => 'user-check', self::AtSign => 'at-sign', - self::FoldVertical => 'fold-vertical', self::Award => 'award', self::Ellipsis => 'ellipsis', self::Flag => 'flag', @@ -217,7 +216,6 @@ public function custom(bool $filled = false): string self::Eye => 'eye', self::EyeOff => 'eye-off', self::Plus => 'plus', - self::Maximize2 => 'maximize-2', self::Vibrate => 'vibrate', self::Terminal => 'terminal', self::FileCode => 'file-code', diff --git a/app/Models/PendingWrite.php b/app/Models/PendingWrite.php index 2a3ed5f5..d7a8030e 100644 --- a/app/Models/PendingWrite.php +++ b/app/Models/PendingWrite.php @@ -20,8 +20,9 @@ * $target is what it's about: the commit starred, or the Remotes thread a * message goes to. $payload is what's sent, and for a commit what the * composer needs to have it back: its body, what it replies to or quotes, - * its poll, its photos with their descriptions, and the draft it was - * stashed under, and the guild whose board it goes to, if any. + * its poll, its photos with their descriptions, the draft it was stashed + * under, the organization it goes out as, if not as you, and the guild whose + * board it goes to, if any. * * It's queued until it goes, sending while it's on its way, and failed once * devnull turned it down, when a commit stays for you to edit and a message @@ -133,6 +134,34 @@ public function quotedCommitId(): ?string return is_string($this->payload['quoted_commit_id'] ?? null) ? $this->payload['quoted_commit_id'] : null; } + /** + * The handle of the organization a commit goes out as, or null when it goes out as you. + */ + public function author(): ?string + { + return is_string($this->payload['author'] ?? null) && $this->payload['author'] !== '' ? $this->payload['author'] : null; + } + + /** + * The organization a commit goes out as, as the composer knew it, for the staged commit to show it, or null. + */ + public function authorProfile(): ?User + { + $profile = $this->payload['author_profile'] ?? null; + + return $this->author() !== null && is_array($profile) ? User::fromArray([...$profile, 'type' => 'organization']) : null; + } + + /** + * The payload's part for who a commit goes out as: nothing for you, and an organization's handle and profile. + * + * @return array{author?: string, author_profile?: array} + */ + public static function authorPayload(?User $organization): array + { + return $organization === null ? [] : ['author' => $organization->username, 'author_profile' => $organization->toArray()]; + } + /** * The commit's poll as devnull takes it, or null with none. * @@ -209,12 +238,15 @@ public static function imagePayload(array $images): array } /** - * The commit a commit on its way stands in as, by you, at once: what you - * wrote and its photos, marked staged, as the web's git words go, until - * devnull has it and the real one takes its place. + * The commit a commit on its way stands in as, at once: by you, or by the + * organization it goes out as, with what you wrote and its photos, marked + * staged, as the web's git words go, until devnull has it and the real one + * takes its place. */ - public function stagedCommit(User $author): Commit + public function stagedCommit(User $me): Commit { + $author = $this->authorProfile() ?? $me; + return new Commit( id: self::StagedPrefix.$this->client_id, body: $this->body(), diff --git a/app/NativeComponents/CommitDetail.php b/app/NativeComponents/CommitDetail.php index f1526969..bdf93ae8 100644 --- a/app/NativeComponents/CommitDetail.php +++ b/app/NativeComponents/CommitDetail.php @@ -3,6 +3,7 @@ namespace App\NativeComponents; use App\Devnull\Account; +use App\Devnull\Beat; use App\Devnull\Client; use App\Devnull\Data\Commit; use App\Devnull\Data\CommitThread; @@ -13,14 +14,20 @@ use App\Devnull\Display; use App\Devnull\DraftImages; use App\Devnull\Outbox; +use App\Devnull\PostAs; use App\Devnull\ResponseCache; use App\Devnull\RowCache; +use App\Devnull\SelfThread; use App\Devnull\Stash; +use App\Devnull\ThreadRows; use App\Devnull\Timeline; +use App\Devnull\Toasts; use App\Icons\Lucide; use App\Models\PendingWrite; +use App\NativeComponents\Concerns\ExpandsThreads; use App\NativeComponents\Concerns\OpensInTab; use App\NativeComponents\Concerns\OpensLiveStream; +use App\NativeComponents\Concerns\RedrawsOnAppearanceChange; use App\NativeComponents\Concerns\RefreshesInBackground; use App\NativeComponents\Concerns\ShowsCommits; use App\NativeComponents\Concerns\TalksToDevnull; @@ -41,37 +48,76 @@ * "› N replies", each opened in place. Opened from a "› N replies" button * ($data['replies']), its replies already show. They come ten at a time * (see Client::RepliesPerPage), and "Show more" under the last asks for the - * next ten, as it does under a deleted reply's replies opened in place. + * next ten. + * + * Each reply's own replies open in place under it, and theirs under them, as + * deep as they go, as the web's commit page does (see ExpandsThreads and + * App\Devnull\ThreadRows). So do the commits above the commit, less the one + * on the line down to it, which already shows (see ancestorThreads()). + * + * Tapping a commit in the tree, above the commit, below it or among the + * replies at any depth, moves this page to it rather than pushing another + * (see refocus()). Back still leaves the page. * * It opens on the commit as it was last time, or opened from a row, on what * the row knew of it, then asks devnull for the rest behind it and fills it in. * * The reply is stashed as you type, per commit, as on the web (see Stash), so * leaving the page keeps it, and it's in the reply bar again, marked as - * restored, when you come back to the commit. + * restored, when you come back to the commit. Drop throws it away whenever + * there's anything in it. + * + * The reply bar does everything the composer sheet did for a reply, so a + * reply never needs the sheet: presenting one takes the keyboard down and + * puts it back up on both platforms, however soon its field takes focus. + * Photos come from the library or the camera into the bar, above the field, + * each with its ✕ and ALT (see AttachesPhotos), and Preview shows the reply + * as it will look in the field's place (see toggleReplyPreview()). Reply in + * the bar sends them all. * - * The reply bar has no room for photos or a preview, so its expand button - * opens the reply in the composer sheet, which has them (see replyInSheet()). - * The draft goes with it, and back to the bar if the sheet closes unsent. - * Photos left in it show as a count under the bar's field, which opens the - * sheet on them, and Reply in the bar sends them with the text. + * Related commits wait under a header with their count, closed, and open + * in place when it's tapped (see toggleRelated()). * * A reply goes at once: the bar empties and the reply shows staged under the * commit while it goes to devnull from the outbox (see SyncsOutbox), then the - * real one takes its place. If devnull turns it down, it leaves, and what you + * real one takes its place. The page scrolls to it as it shows, and stays + * there when the real one comes (see scrollToRow()). If devnull turns it down, it leaves, and what you * wrote is back in the bar, or in the sheet with its photos. Edit, on the * toast of a reply or a quote turned down after you'd left, opens its commit * here with it ($data['edit']). + * + * A member of a GitHub organization can reply as it, from the avatar at the + * start of the bar's row, as the web's reply composer does (see PostAs). + * + * A thread its author wrote as replies to themselves reads in order, as on + * the web (see SelfThread): the parts after the commit follow it on its rail, + * each with its place in the thread, ten at a time with "Show more of this + * thread", and the next part isn't among the commit's replies. The replies of + * the last part show under it. The earlier parts are the ancestors above it, + * and wear their places too. Each step needs the replies of the commit above + * it, which are asked for one after another ($partReplies). */ class CommitDetail extends NativeComponent { + use ExpandsThreads { + toggleReplies as private toggleThread; + showMoreReplies as private showMoreThreadReplies; + } use OpensInTab; use OpensLiveStream; + use RedrawsOnAppearanceChange; use RefreshesInBackground; use ShowsCommits { + openCommit as private openCommitPage; + openReplies as private openRepliesPage; + replyTo as private replyOnPage; reopenFailedCommit as private reopenFailedCommitInSheet; editFailedCommit as private editFailedCommitInSheet; mentionFields as private sheetMentionFields; + attachedPhotos as private sheetPhotos; + photosChanged as private sheetPhotosChanged; + takesPhotos as private sheetTakesPhotos; + photoFailed as private sheetPhotoFailed; } use TalksToDevnull; @@ -87,6 +133,13 @@ class CommitDetail extends NativeComponent /** @var list */ public array $ancestors = []; + /** + * The commits above whose own page was asked for their count since the page last asked devnull again. + * + * @var list + */ + protected array $countedAncestors = []; + /** * The parts of its series after the commit, in order. * @@ -97,6 +150,26 @@ class CommitDetail extends NativeComponent /** @var list */ public array $replies = []; + /** + * The first page of replies of the commits around this one in its author's thread, by id, which say which + * reply carries it on (see SelfThread). + * + * @var array> + */ + public array $partReplies = []; + + /** + * The commits in $partReplies with more replies than their first page. + * + * @var list + */ + public array $partsWithMore = []; + + /** + * How many parts of the author's thread show after the commit. + */ + public int $threadLimit = SelfThread::PerPage; + public ?string $repliesCursor = null; /** @@ -107,23 +180,46 @@ class CommitDetail extends NativeComponent public array $related = []; /** - * Whether the replies have been kept or fetched. Until then they show as loading. + * Whether the reply bar shows the reply as it will look, in the field's place. */ - public bool $repliesLoaded = false; + public bool $replyPreviewing = false; /** - * The replies of deleted replies that were opened in place, by the deleted reply's id. + * What devnull sent back for the reply's body, with the body it was for under `draft`. * - * @var array> + * @var array|null */ - public array $tombstoneReplies = []; + public ?array $replyPreview = null; /** - * Where the next page of each deleted reply's replies starts, by the deleted reply's id, or null when they're all shown. - * - * @var array + * Whether the related commits show under their header. + */ + public bool $relatedShown = false; + + /** + * Whether the related commits are drawn see-through: about to fade in, or fading out on their way to closing. + */ + public bool $relatedFaded = false; + + /** + * Whether the related commits are fading out, still drawn until they have. + */ + public bool $relatedClosing = false; + + /** + * How long the related commits take to fade in or out, in milliseconds, as a Log thread's replies do. */ - public array $tombstoneCursors = []; + public const int RelatedFade = 220; + + /** + * How much later each related commit starts fading in than the one above it, in milliseconds. + */ + public const int RelatedStagger = 40; + + /** + * Whether the replies have been kept or fetched. Until then they show as loading. + */ + public bool $repliesLoaded = false; public string $reply = ''; @@ -134,6 +230,11 @@ class CommitDetail extends NativeComponent */ public array $replyImages = []; + /** + * The handle of the organization the reply bar posts as, or null for you (see PostAs). + */ + public ?string $replyAuthor = null; + /** * Whether the reply was stashed when the page opened, which the bar marks until you empty it or drop it. */ @@ -160,6 +261,30 @@ class CommitDetail extends NativeComponent */ public int $scrollKey = 0; + /** + * Which of the scroll view's rows it brings into view: the commit's, once tapping another commit in the tree + * moved the page to it (see refocus()), or the reply you just sent (see scrollToRow()). Null until one of those, + * so the page opens at the top as it always has. + */ + public ?int $scrollTarget = null; + + /** + * Counts the moves refocus() and scrollToRow() made. The scroll view takes it as its auto-scroll-token, so asking for the same row + * as last time (going back to the top twice) scrolls again rather than doing nothing. + */ + public int $scrollRequest = 0; + + /** + * The key of the row scrollToRow() brought into view last, so a reply you sent can be followed when devnull's + * takes its place (see showCommitWent()). + */ + private ?string $scrolledToRow = null; + + /** + * The commit the page opened on, before tapping others in its tree moved it (see refocus()). + */ + public string $openedId = ''; + /** * The replies from the last frame, so a render only builds the replies that changed, as the Log does its rows. */ @@ -194,6 +319,7 @@ public function applyConversationIntent(array $data): void public function mount(): void { + $this->openedId = $this->id; $this->focusReply = $this->data('reply', false) === true; $this->repliesShown = $this->embedded || $this->data('replies', false) === true; $draft = app(Stash::class)->get($this->me()?->id, $this->replyStashName()); @@ -247,26 +373,20 @@ public function load(): void protected function revalidate(): void { - $this->refresh($this->threadPath(), [], fn (array $json) => $this->takeThread($json)); + $this->countedAncestors = []; + $this->refresh($this->threadPath(), [], fn (array $json) => $this->takeCommitThread($json)); $this->refresh($this->threadPath().'/replies', [], fn (array $json) => $this->takeReplies($json)); $this->refresh($this->threadPath().'/related', [], fn (array $json) => $this->takeRelated($json), quiet: true, failed: function (): void { $this->related = []; app(ResponseCache::class)->forget($this->threadPath().'/related'); }); - foreach (array_keys($this->tombstoneReplies) as $id) { - $id = (string) $id; - - $this->refresh('commits/'.rawurlencode($id).'/replies', [], function (array $json) use ($id): void { - if (array_key_exists($id, $this->tombstoneReplies)) { - [$this->tombstoneReplies[$id], $this->tombstoneCursors[$id]] = self::withFirstPage( - $this->tombstoneReplies[$id], - $this->tombstoneCursors[$id] ?? null, - Page::fromArray($json, Commit::fromArray(...)), - ); - } - }); + foreach (array_keys($this->partReplies) as $id) { + $this->refreshPartReplies((string) $id); } + + $this->refreshThreads(); + $this->countAncestorReplies(); } protected function showsContent(): bool @@ -280,6 +400,7 @@ protected function showsContent(): bool public function showEarlier(): void { $this->earlierShown = true; + $this->countAncestorReplies(); } /** @@ -290,48 +411,393 @@ public function showEarlier(): void public function replyTapped(): void { $this->earlierShown = false; + $this->scrollTarget = null; $this->scrollKey++; } /** - * "› N replies" under the commit opens them in place, and "Hide replies" folds them away. + * A commit in the tree this page shows moves the page to it, rather than + * pushing another commit page (see refocus()). Anything else opens its page. + */ + public function openCommit(string $id): void + { + if (! $this->refocus($id)) { + $this->openCommitPage($id); + } + } + + /** + * "Show more" under the last part of a thread, or "› N replies" on a commit in the tree: the page moves to it with + * its replies showing. + */ + public function openReplies(string $id): void + { + if (! $this->refocus($id)) { + $this->openRepliesPage($id); + } + } + + /** + * Reply on a commit in the tree moves the page to it, with the reply bar answering it and its keyboard up. */ - public function toggleReplies(): void + public function replyTo(string $id): void { - $this->repliesShown = ! $this->repliesShown; + if ($id === $this->id) { + $this->focusReply = true; + + return; + } + + if ($this->refocus($id)) { + $this->focusReply = true; + + return; + } + + $this->replyOnPage($id); + } + + /** + * Moves the page to a commit already in its tree: an ancestor, a part of + * the author's thread or series, or a reply at any depth. It becomes the + * commit the page is about, with what's above it as its ancestors and its + * replies showing below, all from what the page already has, so nothing + * goes blank, and devnull is asked for the rest behind it. The commits + * above it start with their replies folded, showing only "› N replies", + * as when the page opens on a reply. Moving up, the commit the page was on + * keeps its replies, and so do the commits between, so the commit you + * move to shows the way back down to where you came from opened under it. + * + * The page stays one screen: Back still leaves it, as Simon asked, rather + * than stepping back through the commits it moved to. The scroll view + * brings the commit into view, with every ancestor showing above it. + * + * False, changing nothing, for a commit that isn't in the tree, or one + * that's staged or deleted, which has no page of its own. + */ + private function refocus(string $id): bool + { + if ($this->commit === null || $id === $this->id) { + return false; + } + + $target = $this->treeCommit($id); + $ancestors = $target === null || $target->isStaged() || $target->isDeleted() ? null : $this->ancestorsInTree($target); + + if ($ancestors === null) { + return false; + } + + $line = [...$this->ancestors, $this->commit]; + $below = array_slice($line, count($ancestors) + 1); + + // What the page was on keeps its replies, opened in place, when it ends up below the commit the page moves to. + if ($this->repliesShown && $this->repliesLoaded && $this->replies !== []) { + $this->threads[$this->id] = array_values(array_filter($this->replies, fn (Commit $reply): bool => ! $reply->isStaged())); + $this->keepCursor($this->id, $this->repliesCursor); + unset($this->threadShown[$this->id]); + } + + // Moving up, the commits between keep their replies open, so the one the page was on shows under them. + foreach ($below as $between) { + if ($between->id !== $this->id && ! array_key_exists($between->id, $this->threads) && ($kept = $this->cached('commits/'.rawurlencode($between->id).'/replies')) !== null) { + $this->takeThread($between->id, $kept); + } + } + + $this->id = $id; + $this->commit = $target; + $this->ancestors = $ancestors; + $this->series = []; + $this->related = []; + $this->relatedShown = false; + $this->threadLimit = SelfThread::PerPage; + $this->takeOwnReplies($id); + + // The commits above it fold their replies, the commit the page was on among them when the page moved down. + foreach ($this->ancestors as $ancestor) { + $this->closeThread($ancestor->id); + } + + if (($thread = $this->cached($this->threadPath())) !== null) { + $this->takeCommitThread($thread); + } + + $this->takeRelated($this->cached($this->threadPath().'/related') ?? []); + $this->repliesShown = true; + $this->earlierShown = true; + $this->takeReplyDraft(); + $this->error = null; + + // The commit's row is the one after its ancestors, whose replies are folded. A new token asks again even when + // that's the row the scroll view went to last time. The scroll view keeps its key, so its rows slide to their + // new places. Opening an ancestor's replies later leaves the target be, so it doesn't scroll. + $this->scrollTarget = count($this->ancestors); + $this->scrollRequest++; + $this->forgetRefreshes(); + $this->revalidate(); + $this->followThread(); + + return true; } /** - * A deleted reply has no page of its own, so its replies open in place below it. + * The commit's own replies, as the page knows them: opened in place, read for its author's thread, or kept from + * before. Until one of those, they show as loading. */ - public function toggleTombstone(string $id): void + private function takeOwnReplies(string $id): void { - if (array_key_exists($id, $this->tombstoneReplies)) { - unset($this->tombstoneReplies[$id], $this->tombstoneCursors[$id]); + $this->replies = []; + $this->repliesCursor = null; + $this->repliesLoaded = false; + + if (array_key_exists($id, $this->threads)) { + $this->replies = $this->threads[$id]; + $this->repliesCursor = $this->threadCursors[$id] ?? null; + $this->repliesLoaded = true; + unset($this->threads[$id], $this->threadCursors[$id], $this->threadShown[$id]); + $this->pagedThreads = array_values(array_diff($this->pagedThreads, [$id])); + } elseif (($kept = $this->cached($this->threadPath().'/replies')) !== null) { + $this->takeReplies($kept); return; + } elseif (array_key_exists($id, $this->partReplies)) { + $this->replies = $this->partReplies[$id]; + $this->repliesLoaded = true; } - $this->loadTombstoneReplies($id); + $this->keepStagedReplies(); } /** - * "Show more" under a deleted reply's replies: its next five, in place. + * The reply bar takes up the draft kept for the commit the page is on now. */ - public function loadMoreTombstoneReplies(string $id): void + private function takeReplyDraft(): void { - $cursor = $this->tombstoneCursors[$id] ?? null; + $draft = app(Stash::class)->get($this->me()?->id, $this->replyStashName()); + $this->reply = $draft->body; + $this->replyImages = $draft->images; + $this->replyRestored = ! $draft->isEmpty(); + $this->replyAuthor = null; + $this->replyPreviewing = false; + $this->replyPreview = null; + $this->focusReply = false; + } + + /** + * A commit the page draws in its tree, by id: around the commit, in its author's thread, or among the replies. + */ + private function treeCommit(string $id): ?Commit + { + $lastPart = $this->commit === null ? null : $this->selfThread()->parts; + $tree = [ + ...$this->ancestors, + ...$this->series, + ...($lastPart ?? []), + ...$this->replies, + ...$this->threadCommits(), + ...array_merge([], ...array_values($this->partReplies)), + ]; + + foreach ($tree as $commit) { + if ($commit->id === $id) { + return $commit; + } + } + + return null; + } + + /** + * What's above $target in the tree, in order: the page's line of ancestors as far as the one it hangs from, then + * the replies, parts or series between. Null when it doesn't hang from that line. + * + * @return list|null + */ + private function ancestorsInTree(Commit $target): ?array + { + $line = [...$this->ancestors, ...($this->commit === null ? [] : [$this->commit])]; + $lineIds = array_map(fn (Commit $commit): string => $commit->id, $line); + $at = array_search($target->id, $lineIds, true); + + if ($at !== false) { + return array_slice($line, 0, $at); + } + + $between = []; + $parentId = $target->parentId; + + while ($parentId !== null && ! in_array($parentId, $lineIds, true)) { + $parent = $this->treeCommit($parentId); + + if ($parent === null || in_array($parent, $between, true)) { + return null; + } + + array_unshift($between, $parent); + $parentId = $parent->parentId; + } + + if ($parentId === null) { + return null; + } + + return [...array_slice($line, 0, array_search($parentId, $lineIds, true) + 1), ...$between]; + } + + /** + * The replies of each commit above the commit, as its "› N replies" opens them in place under it, the same as a + * reply's (see ExpandsThreads), and how many that button counts. The commit under it on the page, when that's + * one of its replies, is left out of both: it's already showing, on the line down to the commit. The web leaves + * out only the part of a self-thread that carries it on (see SelfThread), so there the rest of the line would + * show twice. devnull's count already leaves that part out. + * + * @param list $above + * @return array, reply: Commit|null}>}> + */ + private function ancestorThreads(array $above): array + { + if ($this->commit === null) { + return []; + } + + $line = [...$above, $this->commit]; + $threads = []; + + foreach ($above as $index => $ancestor) { + $next = $line[$index + 1]; + $onLine = $next->parentId === $ancestor->id && $ancestor->continuationId !== $next->id; + $replies = array_values(array_filter($this->threads[$ancestor->id] ?? [], fn (Commit $reply): bool => $reply->id !== $next->id)); + + $threads[$ancestor->id] = [ + 'count' => max(0, $ancestor->repliesCount - ($onLine ? 1 : 0)), + 'rows' => $ancestor->isDeleted() || $replies === [] ? [] : ThreadRows::under( + $ancestor, + [...$this->threads, $ancestor->id => $replies], + $this->threadCursors, + $this->threadShown, + $ancestor->lane(), + opensInPlace: PHP_INT_MAX, + onPage: true, + // The next commit on the line follows them, so they end on the hairline the ancestor's row gave up. + hairline: true, + ), + ]; + } + + return $threads; + } + + /** + * The commits on the page's line, above the commit and the commit itself, draw rows of their own, so closing the + * replies they're among leaves their own replies open. + */ + protected function drawsOnItsOwn(string $id): bool + { + return $id === $this->id || in_array($id, array_map(fn (Commit $ancestor): string => $ancestor->id, $this->ancestors), true); + } + + /** + * "› N replies" under the commit opens them in place, and "Hide replies" folds them away. Under a reply, at any + * depth, or a commit above the commit, it opens that one's replies in place under it (see ExpandsThreads). + */ + public function toggleReplies(string $id = ''): void + { + if ($id === '' || $id === $this->id) { + $this->repliesShown = ! $this->repliesShown; - if ($cursor === null) { return; } - $page = $this->attempt(fn ($devnull) => $devnull->replies($id, $cursor)); + $this->toggleThread($id); + } + + /** + * "Show more" under a reply's replies opened in place. The commit's own go on from loadMoreReplies(). + */ + public function showMoreReplies(string $id): void + { + if ($id === $this->id) { + $this->loadMoreReplies(); - if ($page !== null && array_key_exists($id, $this->tombstoneReplies)) { - $this->tombstoneReplies[$id] = [...$this->tombstoneReplies[$id], ...$page->items]; - $this->tombstoneCursors[$id] = $page->nextCursor; + return; } + + $this->showMoreThreadReplies($id); + } + + /** + * "Show more of this thread": the next ten parts of the author's thread, as on the web. + */ + public function showMoreThread(): void + { + $this->threadLimit += SelfThread::PerPage; + $this->followThread(); + } + + /** + * The web's preview toggle, in the reply bar: the reply shows as it will + * look in the field's place, at once, and devnull is asked for its body, + * with its code and mentions, unless it already said for this one. The + * keyboard goes down with the field. Pressed again, the field comes back + * with the keyboard. + */ + public function toggleReplyPreview(): void + { + $this->replyPreviewing = ! $this->replyPreviewing; + $this->describing = null; + + if (! $this->replyPreviewing) { + $this->focusReply = true; + + return; + } + + $body = trim($this->reply); + + if ($body === '' || ($this->replyPreview['draft'] ?? null) === $body) { + return; + } + + $this->writeInBackground('POST', Client::PreviewPath, ['body' => $body], function (array $json) use ($body): void { + if (is_array($json['data'] ?? null)) { + $this->replyPreview = [...$json['data'], 'draft' => $body]; + } + }, fn (): null => null); + } + + /** + * The related commits' header opens them, and closes them again. EDGE + * can't animate a node coming into the page or leaving it, so they're + * drawn see-through first and shown once a Beat comes back, which each + * row fades and slides to, a little after the one above. Closing fades + * them out the same way, then takes them out. + */ + public function toggleRelated(): void + { + if ($this->relatedClosing) { + return; + } + + if (! $this->relatedShown) { + $this->relatedShown = true; + $this->relatedFaded = true; + $shown = fn () => $this->relatedFaded = false; + + Beat::dispatch(Beat::Step)->finished($shown)->failed($shown); + + return; + } + + $this->relatedFaded = true; + $this->relatedClosing = true; + $closed = function (): void { + $this->relatedShown = false; + $this->relatedFaded = false; + $this->relatedClosing = false; + }; + + Beat::dispatch(self::RelatedFade)->finished($closed)->failed($closed); } public function loadMoreReplies(): void @@ -349,6 +815,7 @@ public function loadMoreReplies(): void $this->replies = [...array_values(array_filter($this->replies, fn (Commit $reply): bool => ! isset($loaded[$reply->id]))), ...$page->items]; $this->repliesCursor = $page->nextCursor; $this->keepStagedReplies(); + $this->followThread(); } } @@ -372,6 +839,7 @@ public function sendReply(): void 'images' => PendingWrite::imagePayload($this->replyImages), 'stash' => $this->replyStashName(), 'composer' => 'bar', + ...PendingWrite::authorPayload(PostAs::author($this->replyAuthor)), ]); if ($write === null) { @@ -380,13 +848,24 @@ public function sendReply(): void $this->reply = ''; $this->replyImages = []; + $this->replyPreviewing = false; + $this->replyPreview = null; $this->forgetMention('reply'); $this->updatedReply(); $this->repliesShown = true; $this->keepStagedReplies(); + $this->scrollToRow('thread-reply-'.PendingWrite::stagedId($write->client_id)); $this->sendFromOutbox($write); } + /** + * Post as, from the reply bar's avatar: an organization's handle, or '' for you. + */ + public function postAsInReply(string $handle = ''): void + { + $this->replyAuthor = PostAs::author($handle)?->username; + } + /** * The reply bar suggests whom devnull suggests for a reply to this commit, the people in its thread first, as * the web's reply composer asks, and so does the composer sheet over it (see SuggestsMentions). @@ -413,13 +892,17 @@ public function updatedReply(): void } /** - * The web's drop, beside a restored reply: it's thrown away, photos too, and the field starts again empty. + * The web's drop, beside the reply while there's anything in it: it's thrown away, photos too, and the field + * starts again empty. */ public function dropReplyStash(): void { app(DraftImages::class)->discard($this->replyImages); $this->reply = ''; $this->replyImages = []; + $this->replyPreviewing = false; + $this->replyPreview = null; + $this->describing = null; $this->updatedReply(); } @@ -437,6 +920,7 @@ protected function showCommitted(Commit $commit): void $this->replyRestored = false; $this->repliesShown = true; $this->keepStagedReplies(); + $this->scrollToRow('thread-reply-'.$commit->id); } /** @@ -447,6 +931,32 @@ protected function showCommitWent(PendingWrite $write, Commit $commit): void $staged = PendingWrite::stagedId($write->client_id); $this->replies = array_map(fn (Commit $reply): Commit => $reply->id === $staged ? $commit : $reply, $this->replies); + $this->followThread(); + $this->followSentReply('thread-reply-'.$staged, $commit); + } + + /** + * The page scrolled to a reply you sent, staged, and devnull's reply has taken its place. That's the same row, + * so the scroll view is left be. Only when the reply has moved, as the next part of your thread below the + * commit's replies, does the page follow it there. + */ + private function followSentReply(string $stagedKey, Commit $commit): void + { + if ($this->scrolledToRow !== $stagedKey) { + return; + } + + $keys = array_column($this->pageRows($this->viewData()), 'key'); + $at = array_search('thread-reply-'.$commit->id, $keys, true); + $at = $at === false ? array_search('commit-'.$commit->id, $keys, true) : $at; + + if ($at === false || $at === $this->scrollTarget) { + $this->scrolledToRow = null; + + return; + } + + $this->scrollToRow($keys[$at]); } /** @@ -497,6 +1007,57 @@ protected function editFailedCommit(PendingWrite $write): void $this->takeFailedReply($write); } + /** + * The photos on the draft being written: the sheet's while it's up, otherwise the reply bar's. + * + * @return list + */ + protected function attachedPhotos(): array + { + return $this->sheetOpen ? $this->sheetPhotos() : $this->replyImages; + } + + /** + * Photos added in the reply bar, or taken off it, go in the reply's stash with its text. + * + * @param list $photos + */ + protected function photosChanged(array $photos): void + { + if ($this->sheetOpen) { + $this->sheetPhotosChanged($photos); + + return; + } + + $this->replyImages = $photos; + $this->updatedReply(); + } + + /** + * A reply can have photos, as on the web, unless its commit has gone. + */ + protected function takesPhotos(): bool + { + return $this->sheetOpen ? $this->sheetTakesPhotos() : $this->commit !== null && ! $this->commit->isDeleted(); + } + + /** + * Why a photo won't do comes as a toast, from the top, clear of the reply bar, as it does in Remotes. + */ + protected function photoFailed(?string $error): void + { + if ($this->sheetOpen) { + $this->sheetPhotoFailed($error); + + return; + } + + if ($error !== null) { + Toasts::failed($error); + } + } + /** * The reply bar takes back the draft it handed the sheet, as it was left there, photos too. */ @@ -516,6 +1077,16 @@ protected function commitSheetGone(string $view): void */ protected function showDeleted(string $id): void { + // The page moved here from a commit above it, so it goes back there rather than leaving. + $parent = $this->ancestors === [] ? null : end($this->ancestors); + + if ($id === $this->id && $id !== $this->openedId && $parent !== null && $this->refocus($parent->id)) { + $this->threads = array_map(fn (array $replies): array => array_values(array_filter($replies, fn (Commit $reply): bool => $reply->id !== $id)), $this->threads); + $this->replies = array_values(array_filter($this->replies, fn (Commit $reply): bool => $reply->id !== $id)); + + return; + } + if ($id === $this->id) { $this->back(); @@ -531,8 +1102,9 @@ protected function updateShownCommits(Closure $update): void $this->ancestors = array_map($update, $this->ancestors); $this->series = array_map($update, $this->series); $this->replies = array_map($update, $this->replies); + $this->partReplies = array_map(fn (array $replies): array => array_map($update, $replies), $this->partReplies); $this->related = array_map($update, $this->related); - $this->tombstoneReplies = array_map(fn (array $replies): array => array_map($update, $replies), $this->tombstoneReplies); + $this->threads = array_map(fn (array $replies): array => array_map($update, $replies), $this->threads); } /** @@ -540,7 +1112,7 @@ protected function updateShownCommits(Closure $update): void */ protected function shownCommits(): iterable { - return [...($this->commit === null ? [] : [$this->commit]), ...$this->ancestors, ...$this->series, ...$this->replies, ...$this->related, ...array_merge([], ...array_values($this->tombstoneReplies))]; + return [...($this->commit === null ? [] : [$this->commit]), ...$this->ancestors, ...$this->series, ...$this->replies, ...array_merge([], ...array_values($this->partReplies)), ...$this->related, ...$this->threadCommits()]; } /** @@ -563,6 +1135,7 @@ private function takeFailedReply(PendingWrite $write): void { $this->reply = $write->body(); $this->replyImages = $write->images(); + $this->replyAuthor = $write->author(); $this->replyRestored = true; $this->focusReply = true; $this->updatedReply(); @@ -590,7 +1163,7 @@ private function keepStagedReplies(): void private function showKept(): void { if (($thread = $this->cached($this->threadPath())) !== null) { - $this->takeThread($thread); + $this->takeCommitThread($thread); } elseif ($this->commit === null && ($commit = $this->data('commit')) instanceof Commit && $commit->id === $this->id) { $this->commit = $commit; $this->ancestors = $commit->parent === null ? [] : [$commit->parent]; @@ -602,6 +1175,7 @@ private function showKept(): void $this->takeRelated($this->cached($this->threadPath().'/related') ?? []); $this->keepStagedReplies(); + $this->followThread(); } /** @@ -615,13 +1189,66 @@ private function takeRelated(array $json): void /** * @param array $json */ - private function takeThread(array $json): void + private function takeCommitThread(array $json): void { $thread = CommitThread::fromArray($json); $this->commit = $thread->commit; $this->ancestors = $thread->ancestors; $this->series = $thread->series; + $this->countAncestorReplies(); + $this->followThread(); + } + + /** + * The commits above the commit that show: its parent, or every one once "↑ N earlier commits" opened them. + * + * @return list + */ + private function shownAncestors(): array + { + return $this->earlierShown ? $this->ancestors : array_slice($this->ancestors, -1); + } + + /** + * devnull sends the commits above the commit without their counts, so on their own a commit above never shows + * its "› N replies". Each one showing takes its count from its own page instead: kept from before at once, and + * asked for behind. That also keeps its page, so tapping it moves there with nothing blank. + */ + private function countAncestorReplies(): void + { + foreach ($this->shownAncestors() as $ancestor) { + if ($ancestor->isStaged() || $ancestor->isDeleted()) { + continue; + } + + $id = $ancestor->id; + $path = 'commits/'.rawurlencode($id); + + if (($kept = $this->cached($path)) !== null) { + $this->takeAncestorCount($id, $kept); + } + + // The commit's page landing draws its ancestors again, and they were asked for once already. + if (! in_array($id, $this->countedAncestors, true)) { + $this->countedAncestors[] = $id; + $this->refresh($path, [], fn (array $json) => $this->takeAncestorCount($id, $json), quiet: true); + } + } + } + + /** + * @param array $json + */ + private function takeAncestorCount(string $id, array $json): void + { + $page = CommitThread::fromArray($json)->commit; + + if ($page->id !== $id) { + return; + } + + $this->ancestors = array_map(fn (Commit $ancestor): Commit => $ancestor->id === $id ? $ancestor->withRepliesCount($page->repliesCount) : $ancestor, $this->ancestors); } /** @@ -634,6 +1261,74 @@ private function takeReplies(array $json): void [$this->replies, $this->repliesCursor] = self::withFirstPage($this->replies, $this->repliesCursor, Page::fromArray($json, Commit::fromArray(...))); $this->repliesLoaded = true; $this->keepStagedReplies(); + $this->followThread(); + } + + /** + * Asks for the replies the author's thread needs next, above the commit and below it, each when the one + * before has come (see SelfThread). A page kept from before shows at once and refreshes behind. + */ + private function followThread(): void + { + if ($this->commit === null) { + return; + } + + $waiting = [ + $this->selfThread()->waiting, + SelfThread::above($this->ancestors, $this->commit, $this->repliesOf())[1], + ]; + + foreach (array_unique(array_filter($waiting, fn (?string $id): bool => $id !== null && $id !== $this->id)) as $id) { + $kept = $this->cached('commits/'.rawurlencode($id).'/replies'); + $this->refreshPartReplies($id); + + if ($kept !== null) { + $this->takePartReplies($id, $kept); + } + } + } + + private function refreshPartReplies(string $id): void + { + $this->refresh('commits/'.rawurlencode($id).'/replies', [], fn (array $json) => $this->takePartReplies($id, $json)); + } + + /** + * @param array $json + */ + private function takePartReplies(string $id, array $json): void + { + $page = Page::fromArray($json, Commit::fromArray(...)); + $this->partReplies[$id] = $page->items; + $this->partsWithMore = array_values(array_diff($this->partsWithMore, [$id])); + + if ($page->hasMore()) { + $this->partsWithMore[] = $id; + } + + $this->followThread(); + } + + /** + * The first page of a commit's replies as far as the page has them, or null until they come. The commit's + * own are the ones showing, less any still on their way. + * + * @return Closure(Commit): (list|null) + */ + private function repliesOf(): Closure + { + return fn (Commit $commit): ?array => $commit->id === $this->id + ? ($this->repliesLoaded ? array_values(array_filter($this->replies, fn (Commit $reply): bool => ! $reply->isStaged())) : null) + : ($this->partReplies[$commit->id] ?? null); + } + + /** + * The parts of the author's thread after the commit, as far as they've been read. + */ + private function selfThread(): SelfThread + { + return $this->commit === null ? new SelfThread : SelfThread::below($this->commit, $this->repliesOf(), $this->threadLimit); } /** @@ -670,43 +1365,177 @@ private function threadPath(): string return 'commits/'.rawurlencode($this->id); } - private function loadTombstoneReplies(string $id): void + /** + * Whether the commit is yours, or an organization's you're in, which puts Delete in the nav bar (see Ownership). + */ + public function isOwn(): bool { - $page = $this->attempt(fn ($devnull) => $devnull->replies($id)); - - if ($page !== null) { - $this->tombstoneReplies[$id] = $page->items; - $this->tombstoneCursors[$id] = $page->nextCursor; - } + return $this->commit !== null && $this->ownership()->owns($this->commit); } - public function isOwn(): bool + public function render(): View { - return $this->commit !== null && $this->commit->author->username === $this->me()?->username; + $this->replyRows ??= new RowCache; + $this->replyRows->startFrame(); + $data = $this->viewData(); + + return view('native.commit-detail', [...$data, 'replyRows' => $this->replyRows, 'pageRows' => $this->pageRows($data)]); } - public function render(): View + /** + * What the page's view draws from, besides the component's own properties. + * + * @return array + */ + private function viewData(): array { $earlier = $this->earlierShown ? [] : array_slice($this->ancestors, 0, -1); - $above = $this->earlierShown ? $this->ancestors : array_slice($this->ancestors, -1); + $above = $this->shownAncestors(); $viewer = $this->me(); - $this->replyRows ??= new RowCache; - $this->replyRows->startFrame(); + $thread = $this->selfThread(); + $parts = $thread->parts; + $partsAbove = $this->commit === null ? 0 : SelfThread::above($this->ancestors, $this->commit, $this->repliesOf())[0]; + $lastPart = $thread->hasEnded && $parts !== [] ? end($parts) : null; + $replies = $this->commit === null ? $this->replies : SelfThread::others($this->commit, $this->replies); - return view('native.commit-detail', [ - 'replyRows' => $this->replyRows, + return [ 'myColour' => $this->myColour(), 'viewer' => $viewer, + 'ownership' => $this->ownership(), 'stashed' => app(Stash::class)->names($viewer?->id), 'pasteis' => app(Account::class)->pasteis(), 'rows' => $this->commit === null ? [] : Timeline::thread( - [...$above, $this->commit, ...$this->series], + [...$above, $this->commit, ...$this->series, ...$parts], laneAbove: $earlier === [] ? null : end($earlier)->lane(), ), 'relatedRows' => Timeline::thread($this->related), + 'ancestorThreads' => $this->ancestorThreads($above), 'earlierCount' => $this->commit === null ? 0 : count($earlier), 'earlierLane' => $earlier === [] ? null : end($earlier)->lane(), - 'replyCount' => max($this->commit->repliesCount ?? 0, count($this->replies)), - ]); + 'replyCount' => max($this->commit->repliesCount ?? 0, count($replies)), + 'replies' => $replies, + 'threadParts' => array_map(fn (Commit $part): string => $part->id, $parts), + 'threadMore' => $thread->hasMore, + 'threadPositions' => $this->threadPositions($thread, $partsAbove), + 'lastPart' => $lastPart, + 'lastPartReplies' => $lastPart === null ? [] : array_slice($this->partReplies[$lastPart->id] ?? [], 0, Client::RepliesPerPage), + 'lastPartMore' => $lastPart !== null && (count($this->partReplies[$lastPart->id] ?? []) > Client::RepliesPerPage || in_array($lastPart->id, $this->partsWithMore, true)), + ]; + } + + /** + * The scroll view's rows from the top down to the end of the thread, in the order the view draws them, each one + * child of the scroll view: "↑ N earlier commits", then each commit with what hangs under it, its replies opened + * in place and theirs (see App\Devnull\ThreadRows). The view draws exactly these, so a row's place here is its + * place among the scroll view's children, which auto-scroll-to counts in (see scrollToRow()). What comes after + * the thread, the related commits and the room for the reply bar, the view draws on its own. + * + * @param array $data What viewData() gave. + * @return list, reply: Commit|null}> + */ + private function pageRows(array $data): array + { + $commit = $this->commit; + $rows = $data['rows']; + $replies = $data['replies']; + $lastPart = $data['lastPart']; + $noReplies = $commit !== null && $data['replyCount'] === 0 && $this->repliesLoaded && $this->series === [] && $data['threadParts'] === []; + $relatedBelow = $commit !== null && $this->related !== [] && ! $noReplies; + $pageRows = []; + + if ($data['earlierCount'] > 0) { + $pageRows[] = ['key' => 'earlier-commits', 'partial' => 'native.partials.earlier-commits', 'data' => ['count' => $data['earlierCount'], 'lane' => $data['earlierLane']], 'reply' => null]; + } + + foreach ($rows as $index => $row) { + $last = $index === array_key_last($rows); + $isFocused = $row->commit->id === $commit?->id; + $isLastPart = $lastPart !== null && $row->commit->id === $lastPart->id; + $hasThread = $isFocused && $this->repliesShown && $replies !== []; + $partThread = $isLastPart && $data['lastPartReplies'] !== []; + $aboveThread = $data['ancestorThreads'][$row->commit->id] ?? null; + $aboveOpen = ($aboveThread['rows'] ?? []) !== []; + + $pageRows[] = ['key' => 'commit-'.$row->commit->id, 'partial' => 'native.partials.commit-row', 'reply' => null, 'data' => [ + 'commit' => $row->commit, + 'previousLane' => $row->previousLane, + 'continuesRun' => $row->continuesRun, + 'continuesNext' => $isFocused || $aboveOpen ? ! $last : null, + 'threadBelow' => $hasThread || $partThread || $aboveOpen, + 'repliesBelow' => $partThread, + 'focused' => $isFocused, + 'muted' => ! $isFocused, + 'seriesExpanded' => true, + 'withTail' => ! $last || $data['threadMore'], + 'hairline' => ! ($last && $relatedBelow && ! $data['threadMore']), + 'threadPosition' => $data['threadPositions'][$row->commit->id] ?? null, + 'showsThread' => false, + 'expandable' => $aboveThread !== null, + 'repliesCount' => $aboveThread['count'] ?? null, + ]]; + + if ($isFocused && $this->repliesShown && $replies === [] && ! $this->repliesLoaded && $this->error === null) { + $pageRows[] = ['key' => 'loading-replies', 'partial' => null, 'data' => [], 'reply' => null]; + } + + // The replies, and theirs opened in place under them as deep as they go. A commit above the commit opens + // its replies in place under it too, all but the one on the line down to the commit, which already shows + // (see ancestorThreads()). Replies with another commit's row after them end on the hairline the row above + // them gave up; at the foot of the page they end on none. + array_push($pageRows, ...match (true) { + $aboveThread !== null => $aboveThread['rows'], + $hasThread => ThreadRows::under($commit, [...$this->threads, $commit->id => $replies], array_filter([...$this->threadCursors, $commit->id => $this->repliesCursor]), $this->threadShown, $last ? null : $commit->lane(), opensInPlace: PHP_INT_MAX, onPage: true, morePress: 'loadMoreReplies', hairline: ! $last), + $partThread => ThreadRows::under($lastPart, [...$this->threads, $lastPart->id => $data['lastPartReplies']], array_filter([...$this->threadCursors, $lastPart->id => $data['lastPartMore'] ? 'more' : null]), $this->threadShown, opensInPlace: PHP_INT_MAX, onPage: true, morePress: "openReplies('{$lastPart->id}')"), + default => [], + }); + } + + return $pageRows; + } + + /** + * Brings the row keyed $key into view, animated, under a new token so it goes even when that's the row it went to + * last time. Nothing happens for a row the page doesn't draw. + */ + private function scrollToRow(string $key): void + { + $at = array_search($key, array_column($this->pageRows($this->viewData()), 'key'), true); + + if ($at === false) { + return; + } + + $this->scrollTarget = $at; + $this->scrollRequest++; + $this->scrolledToRow = $key; + } + + /** + * Each commit's place in its author's thread, by id, as the web marks them: the earlier parts above the + * commit, the commit, and the parts after it. None when the commit isn't part of a thread. + * + * A part known to follow the last one read counts, and a thread not read to its end gets the web's "+". + * + * @return array + */ + private function threadPositions(SelfThread $below, int $partsAbove): array + { + if ($this->commit === null) { + return []; + } + + $thread = [...array_slice($this->ancestors, count($this->ancestors) - $partsAbove, $partsAbove), $this->commit, ...$below->parts]; + $size = count($thread) + ($below->hasMore ? 1 : 0); + $positions = []; + + foreach ($thread as $index => $commit) { + $label = SelfThread::position($index + 1, $size, ! $below->hasEnded); + + if ($label !== null) { + $positions[$commit->id] = $label; + } + } + + return $positions; } } diff --git a/app/NativeComponents/Concerns/ExpandsThreads.php b/app/NativeComponents/Concerns/ExpandsThreads.php index bee2b638..cbd8830d 100644 --- a/app/NativeComponents/Concerns/ExpandsThreads.php +++ b/app/NativeComponents/Concerns/ExpandsThreads.php @@ -6,6 +6,7 @@ use App\Devnull\Client; use App\Devnull\Data\Commit; use App\Devnull\Data\Page; +use App\Devnull\SelfThread; use App\Devnull\ThreadRows; /** @@ -18,9 +19,11 @@ * asked for once they're all showing. * * A reply opened in place has the same button under its own actions, which - * opens its replies in place too, one step in. A reply that deep opens its - * replies on its page. Every thread is kept by the id of the commit or reply - * it answers, so a reply's replies sit in $threads beside its commit's. + * opens its replies in place too, one step in. In a feed a reply that deep + * opens its replies on its page. On a commit page every reply opens its + * replies in place, as deep as they go (see CommitDetail and + * App\Devnull\ThreadRows). Every thread is kept by the id of the commit or + * reply it answers, so a reply's replies sit in $threads beside its commit's. * * EDGE can't animate a row coming into a list or going out of it, so replies * fade: a page that opens is drawn see-through ($fadedRows) and drawn again @@ -28,6 +31,11 @@ * animates to. Closing fades its rows out the same way, then takes them out. * * A thread opened before opens at once from the cache, and refreshes behind. + * + * The reply that carries on a thread its author wrote as replies to + * themselves isn't one of the replies, as on the web: it's the next part of + * that thread, which the commit's "Show thread" opens (see SelfThread). + * devnull's count of the replies already leaves it out. */ trait ExpandsThreads { @@ -75,6 +83,13 @@ trait ExpandsThreads */ public array $closingThreads = []; + /** + * Commits whose replies, opened, showed that their author carried them on as a thread, so they show "Show thread". + * + * @var list + */ + public array $threadsContinued = []; + public function toggleReplies(string $id): void { if (array_key_exists($id, $this->threads)) { @@ -215,6 +230,8 @@ private function takeThread(string $id, array $json): void */ private function openThread(string $id, Page $page): void { + $page = $this->withoutContinuation($id, $page); + // A thread whose last reply went closes, so its commit gets its hairline back. if ($page->items === []) { $this->closeThread($id); @@ -250,7 +267,9 @@ private function keepCursor(string $id, ?string $cursor): void private function closeThread(string $id): void { foreach ($this->threads[$id] ?? [] as $reply) { - $this->closeThread($reply->id); + if (! $this->drawsOnItsOwn($reply->id)) { + $this->closeThread($reply->id); + } } unset($this->threads[$id], $this->threadCursors[$id], $this->threadShown[$id]); @@ -297,6 +316,28 @@ private function fadeOut(string $id): void Beat::dispatch(ThreadRows::Fade)->finished($closed)->failed($closed); } + /** + * The page without the reply that carries the commit's thread on, which marks the commit as carried on instead. + * + * @param Page $page + * @return Page + */ + private function withoutContinuation(string $id, Page $page): Page + { + $commit = $this->shownCommit($id); + $next = $commit === null ? null : SelfThread::next($commit, $page->items); + + if ($next === null) { + return $page; + } + + if (! in_array($id, $this->threadsContinued, true)) { + $this->threadsContinued[] = $id; + } + + return new Page(SelfThread::others($commit, $page->items), $page->nextCursor); + } + /** * The rows of $replies in a thread, and its "Show more" when it has more. * @@ -321,7 +362,7 @@ private function rowsInside(string $id): array $rows = $this->rowsOf($id, $this->shownReplies($id)); foreach ($this->shownReplies($id) as $reply) { - if (array_key_exists($reply->id, $this->threads)) { + if (array_key_exists($reply->id, $this->threads) && ! $this->drawsOnItsOwn($reply->id)) { $rows = [...$rows, ...$this->rowsInside($reply->id)]; } } @@ -329,6 +370,15 @@ private function rowsInside(string $id): array return $rows; } + /** + * Whether the screen draws a reply in a row of its own rather than in the thread it's in, so its own replies + * stay open when that thread closes. A commit page draws the commits on its line that way (see CommitDetail). + */ + protected function drawsOnItsOwn(string $id): bool + { + return false; + } + /** * @return list */ diff --git a/app/NativeComponents/Concerns/OpensCommitSheet.php b/app/NativeComponents/Concerns/OpensCommitSheet.php index fb5e7ff8..9f771335 100644 --- a/app/NativeComponents/Concerns/OpensCommitSheet.php +++ b/app/NativeComponents/Concerns/OpensCommitSheet.php @@ -3,12 +3,14 @@ namespace App\NativeComponents\Concerns; use App\Devnull\Client; +use App\Devnull\ComposerSheet; use App\Devnull\Data\Commit; use App\Devnull\Data\Draft; use App\Devnull\Data\PollDraft; use App\Devnull\Data\StashedDraft; use App\Devnull\DraftImages; use App\Devnull\Outbox; +use App\Devnull\PostAs; use App\Devnull\ReportReason; use App\Devnull\ResponseCache; use App\Devnull\SignedRequest; @@ -20,6 +22,7 @@ use Carbon\CarbonImmutable; use Closure; use Native\Mobile\Facades\System; +use Native\Mobile\UI\Caret; /** * The sheet under a commit (see partials/commit-sheet). Report commit, in the @@ -63,6 +66,11 @@ * web's does: devnull's people for a new commit, a reply or a quote (see * SuggestsMentions). * + * A member of a GitHub organization can post as it instead, from the avatar + * over the field, as the web's Post as menu does, in a new commit, a quote or + * a reply (see PostAs). It starts as you each time, as the web's does, and + * the commit shows staged as the organization while it goes. + * * The sheet keeps its commit while it slides away, so it doesn't empty on the * way down, and lets go of it once iOS says it's gone, however it was closed. */ @@ -116,6 +124,19 @@ trait OpensCommitSheet */ public string $sheetBody = ''; + /** + * Where the sheet's field last said its caret is drawn at its full height, for the mention list to go under (see + * ComposerSheet). Null until it has said, and again once the sheet is gone. + * + * @var array{bottom: float, line_height: float, field_height: float}|null + */ + public ?array $sheetCaret = null; + + /** + * The handle of the organization the sheet posts as, or null for you (see PostAs). + */ + public ?string $sheetAuthor = null; + /** * Whether the sheet opened on a stashed draft, which it marks until you empty it or drop it. */ @@ -261,6 +282,15 @@ public function composeInSheet(): void $this->restoreSheetDraft(); } + /** + * Post as, from the sheet's avatar: an organization's handle, or '' for you. + */ + public function postAsInSheet(string $handle = ''): void + { + $this->sheetAuthor = PostAs::author($handle)?->username; + $this->sheetError = null; + } + /** * A new commit in the sheet for the board of the guild $handle, under its own draft. */ @@ -308,6 +338,33 @@ public function openScheduledCommits(): void $this->sheetOpen = false; } + /** + * The sheet's field drew its caret somewhere else: it moved, the text wrapped differently, or the field scrolled. + */ + public function sheetCaretMoved(Caret $caret): void + { + $this->sheetCaret = ComposerSheet::reported($caret, $this->sheetCaret, $this->sheetMentionLayout()['field'] ?? null); + } + + /** + * Where the sheet's mention list goes and how tall its field is meanwhile (see ComposerSheet::mentionLayout()), or + * null while there's no list. + * + * @return array{field: int|null, top: int, height: int|null}|null + */ + public function sheetMentionLayout(): ?array + { + if (($this->mention['field'] ?? null) !== 'sheetBody' || ($this->mentionPeople === [] && $this->mentionOrganizations === [])) { + return null; + } + + return ComposerSheet::mentionLayout( + $this->sheetCaret, + count($this->mentionPeople) + count($this->mentionOrganizations), + ComposerSheet::mentionHeading($this->mention, $this->sheetView), + ); + } + /** * Stashes the draft as it changes (see stashSheetDraft()). */ @@ -359,6 +416,7 @@ public function commitFromSheet(): void 'images' => PendingWrite::imagePayload($this->sheetImages), 'stash' => $stashName, 'composer' => $this->sheetView, + ...PendingWrite::authorPayload(PostAs::author($this->sheetAuthor)), ...($this->sheetGuild === null ? [] : ['guild_handle' => $this->sheetGuild]), ]); @@ -515,6 +573,7 @@ private function closeCommitSheet(): void { $this->sheetClosing = $this->sheetClosing || ($this->sheetOpen && System::isIos()); $this->sheetOpen = false; + $this->sheetCaret = null; $this->forgetMention('sheetBody'); } @@ -577,18 +636,24 @@ private function openFailedCommit(PendingWrite $write): bool return $this->sheetOpen && $this->sheetStashName() === $write->stashName(); } + /** + * A published commit, or one of yours still waiting for approval, as the web's Quote shows. + */ private function canQuote(Commit $commit): bool { - $viewer = $this->me(); + $ownership = $this->ownership(); - return $viewer !== null && ! $commit->isDeleted() && ! $commit->isStaged() && ($commit->isApproved() || $commit->author->id === $viewer->id); + return $ownership->isSignedIn() && ! $commit->isDeleted() && ! $commit->isStaged() && ($commit->isApproved() || $ownership->owns($commit)); } + /** + * Someone else's published commit: never yours or an organization's you're in, which devnull won't take a report of. + */ private function canReport(Commit $commit): bool { - $viewer = $this->me(); + $ownership = $this->ownership(); - return $viewer !== null && ! $commit->isDeleted() && $commit->isApproved() && $commit->author->id !== $viewer->id; + return $ownership->isSignedIn() && ! $commit->isDeleted() && $commit->isApproved() && ! $ownership->owns($commit); } /** @@ -607,11 +672,12 @@ private function scheduleFromSheet(string $body, string $stashName): void $images = $this->sheetImages; $poll = $this->sheetPollPayload(); + $author = PostAs::author($this->sheetAuthor)?->username; $guild = $this->sheetGuild; $this->sendingSchedule = true; $this->sheetError = null; - $this->sendInBackground(fn (Client $devnull): SignedRequest => $devnull->signedScheduledCommit($body, $at, $images, $poll, $guild), function () use ($me, $stashName, $images): void { + $this->sendInBackground(fn (Client $devnull): SignedRequest => $devnull->signedScheduledCommit($body, $at, $images, $poll, $author, $guild), function () use ($me, $stashName, $images): void { $this->sendingSchedule = false; app(ResponseCache::class)->forget(Client::ScheduledCommitsPath); app(Stash::class)->put($me->id, $stashName, new StashedDraft); @@ -619,9 +685,13 @@ private function scheduleFromSheet(string $body, string $stashName): void $this->sheetImages = []; $this->closeCommitSheet(); Toasts::say(self::Scheduled); - }, function (string $message): void { + }, function (string $message) use ($author): void { $this->sendingSchedule = false; $this->sheetError = $message; + + if ($author !== null && method_exists($this, 'refreshUnreadNotifications')) { + $this->refreshUnreadNotifications(); + } }, timeout: $images === [] ? 30 : 120); } @@ -634,6 +704,8 @@ private function forgetCommitSheet(): void $this->reportReason = ''; $this->reportDetails = ''; $this->sheetBody = ''; + $this->sheetCaret = null; + $this->sheetAuthor = null; $this->sheetRestored = false; $this->sheetError = null; $this->forgetMention('sheetBody'); @@ -681,9 +753,10 @@ protected function stashSheetDraft(): void } /** - * The sheet starts from its stashed draft, with its photos and poll. A - * commit devnull turned down that was written under it comes back whole, - * and leaves the outbox: from here it's a draft again. + * The sheet starts from its stashed draft, with its photos and poll, as + * you. A commit devnull turned down that was written under it comes back + * whole, as the organization it was to go out as, and leaves the outbox: + * from here it's a draft again. */ private function restoreSheetDraft(): void { @@ -691,6 +764,7 @@ private function restoreSheetDraft(): void $failed = $name === null ? null : app(Outbox::class)->failedDraft($name); if ($failed !== null) { + $this->sheetAuthor = $failed->author(); $this->takeFailedCommit($failed); } diff --git a/app/NativeComponents/Concerns/OpensStargazers.php b/app/NativeComponents/Concerns/OpensStargazers.php index 84024cf4..5ec6fe7f 100644 --- a/app/NativeComponents/Concerns/OpensStargazers.php +++ b/app/NativeComponents/Concerns/OpensStargazers.php @@ -12,6 +12,11 @@ * opening their profile. As on the web, only you see who starred your * commits, and it asks devnull again each time it opens, so stars given in * the meantime show. + * + * An organization's commit is every member's (see Ownership), so its star + * opens the sheet too. The web lists who starred it to any member, but the + * API only to the member who posted it, and to anyone else it says the list + * isn't there. The sheet says so then, rather than offering Try again. */ trait OpensStargazers { @@ -37,6 +42,11 @@ trait OpensStargazers */ public bool $stargazersFailed = false; + /** + * Whether devnull only shows who starred this organization's commit to the member who posted it. + */ + public bool $stargazersForPoster = false; + /** * The load the sheet is waiting for. An answer to an earlier one, sent * before the sheet closed or opened again, is left alone. @@ -47,7 +57,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 || ! $this->ownership()->owns($commit)) { return; } @@ -81,10 +91,11 @@ public function loadStargazers(): void $this->stargazers = [...$this->stargazers, ...$page->items]; $this->stargazersCursor = $page->nextCursor; $this->loadingStargazers = false; - }, again: true, quiet: true, failed: function () use ($load): void { + }, again: true, quiet: true, failed: function (int $status = 0) use ($load): void { if ($load === $this->stargazersLoad) { $this->loadingStargazers = false; - $this->stargazersFailed = true; + $this->stargazersForPoster = $status === 404 && $this->shownCommit((string) $this->stargazersOf)?->author->isOrganization === true; + $this->stargazersFailed = ! $this->stargazersForPoster; } }); } @@ -113,5 +124,6 @@ public function stargazersClosed(): void $this->stargazersCursor = null; $this->loadingStargazers = false; $this->stargazersFailed = false; + $this->stargazersForPoster = false; } } diff --git a/app/NativeComponents/Concerns/RedrawsOnAppearanceChange.php b/app/NativeComponents/Concerns/RedrawsOnAppearanceChange.php new file mode 100644 index 00000000..0a003add --- /dev/null +++ b/app/NativeComponents/Concerns/RedrawsOnAppearanceChange.php @@ -0,0 +1,19 @@ +remember($current->user); app(Account::class)->rememberPasteis($current->pasteis()); app(Account::class)->rememberRemotes($current->remotes); + app(Account::class)->rememberOrganizations($current->organizations); $this->takeTerms($current); } diff --git a/app/NativeComponents/Concerns/ShowsCommits.php b/app/NativeComponents/Concerns/ShowsCommits.php index 6caef1e6..67b47706 100644 --- a/app/NativeComponents/Concerns/ShowsCommits.php +++ b/app/NativeComponents/Concerns/ShowsCommits.php @@ -39,6 +39,9 @@ * * A commit can be tapped where a row nests it too: the commit a row quotes, * and the replies a feed shows under a commit. + * + * A commit is yours when you made it or an organization you're in did, as + * devnull decides it (see Ownership). */ trait ShowsCommits { @@ -182,8 +185,8 @@ public function showTime(string $id): void * star goes to devnull from the outbox (see SyncsOutbox). The commit takes * the count devnull sends back, or the star comes back off it if devnull * says no. Like the web, only someone else's published commit can be - * starred, as devnull turns down a star on your own (whose star opens who - * starred it instead, see OpensStargazers). + * starred, as devnull turns down a star on your own or your organization's + * (whose star opens who starred it instead, see OpensStargazers). */ public function toggleStar(string $id): void { @@ -204,8 +207,8 @@ public function toggleStar(string $id): void /** * Gives the commit a pastel, as the web's pastel button does in pastéis * mode: one per tap, from the ten you get each day, on someone else's - * published commit, never an organization's (they can't receive them). - * The pastel's count goes up and your allowance down at once, + * published commit, never an organization's, which has no pastel at all, + * as on the web. Its count goes up and your allowance down at once, * and the pastel goes from the background, so you can keep tapping. When * devnull turns one down, it comes back, and a toast says why in the web's * words. With none left, the toast says so without asking devnull. @@ -215,7 +218,7 @@ public function givePastel(string $id): void $commit = $this->shownCommit($id); $pasteis = app(Account::class)->pasteis(); - if ($commit === null || $pasteis === null || $commit->author->isOrganization || ! $this->canReactTo($commit)) { + if ($commit === null || $pasteis === null || ! $this->canGivePastel($commit)) { return; } @@ -236,8 +239,9 @@ public function givePastel(string $id): void /** * Pin to profile or Unpin from profile, in your own published commit's - * More menu. Once devnull answers, a toast says so in the web's words, and - * a pin takes the place of the one before (see showPinned()). + * More menu. Not an organization's: devnull pins to its author's profile, + * which only a person has. Once devnull answers, a toast says so in the + * web's words, and a pin takes the place of the one before (see showPinned()). */ public function togglePin(string $id): void { @@ -340,7 +344,8 @@ public function shareCommit(string $id): void } /** - * Delete commit, in your own commit's More menu, asks first, as the web does. + * Delete commit, in the More menu of your own commit or an organization's + * you're in, asks first, as the web does. */ public function confirmDelete(string $id): void { @@ -415,6 +420,11 @@ private function pastelGiven(string $id, array $json): void /** * Deletes your commit on devnull, which takes it out of every list kept on * this phone, then the screen lets it go (see showDeleted()). + * + * An organization's commit is only yours while you're in it. When devnull + * turns its delete down, the screen says why in devnull's words, and asks + * GET /me which organizations you're still in, so the commit stops + * offering Delete if you've left. */ public function deleteCommit(string $id): void { @@ -437,6 +447,8 @@ public function deleteCommit(string $id): void } else { $this->showDeleted($id); } + } elseif ($this->error !== null && $commit->author->isOrganization && method_exists($this, 'refreshUnreadNotifications')) { + $this->refreshUnreadNotifications(); } } @@ -484,17 +496,22 @@ 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() && ! $this->ownership()->owns($commit); + } + + private function canGivePastel(Commit $commit): bool + { + return $this->canReactTo($commit) && ! $commit->author->isOrganization; } private function canPin(Commit $commit): bool { - return ! $commit->isDeleted() && $commit->isApproved() && $commit->parentId === null && $commit->guild === null && $commit->author->id === $this->me()?->id; + return ! $commit->isDeleted() && $commit->isApproved() && $commit->parentId === null && $commit->guild === null && $this->ownership()->isYourOwn($commit); } private function canDelete(Commit $commit): bool { - return ! $commit->isDeleted() && ! $commit->isStaged() && $commit->author->id === $this->me()?->id; + return ! $commit->isDeleted() && ! $commit->isStaged() && $this->ownership()->owns($commit); } /** diff --git a/app/NativeComponents/Concerns/SuggestsMentions.php b/app/NativeComponents/Concerns/SuggestsMentions.php index 9166bcf4..4dd2f05e 100644 --- a/app/NativeComponents/Concerns/SuggestsMentions.php +++ b/app/NativeComponents/Concerns/SuggestsMentions.php @@ -31,8 +31,6 @@ trait SuggestsMentions */ public const string MentionBeforeCaret = '/(?:^|[^\p{L}\p{N}_.\/@-])@([A-Za-z0-9][A-Za-z0-9-]{0,38}|)$/u'; - public const int MaxMentionSuggestions = 6; - /** * The "@handle" the caret is after: the field it's in, where its "@" is, in code points, what follows it, and the * field's text when the caret was there. Null while there's none. @@ -199,7 +197,8 @@ private static function mentionEnd(array $mention, string $text): ?int } /** - * An org's members to suggest for what's typed after the "@", best first. + * An org's members to suggest for what's typed after the "@", best first. All of them: past six the list scrolls + * (see partials/mention-suggestions), as the reply bar's does. * * @param list $members * @return list @@ -236,6 +235,6 @@ private static function rankMembers(array $members, string $query, ?User $viewer usort($ranked, fn (array $a, array $b): int => [$a['tier'], ! $a['followed'], $a['user']->username] <=> [$b['tier'], ! $b['followed'], $b['user']->username]); - return array_column(array_slice($ranked, 0, self::MaxMentionSuggestions), 'user'); + return array_column($ranked, 'user'); } } diff --git a/app/NativeComponents/Concerns/SyncsOutbox.php b/app/NativeComponents/Concerns/SyncsOutbox.php index faf6ae4e..71dea56e 100644 --- a/app/NativeComponents/Concerns/SyncsOutbox.php +++ b/app/NativeComponents/Concerns/SyncsOutbox.php @@ -45,11 +45,11 @@ * - A star comes back off the commit, here and in every kept copy, and the * toast offers Retry. * - A commit or a reply leaves the screen, and its draft goes back where you - * wrote it: the text in its stash, and the photos and poll with the failed - * write in the outbox, for the composer to take when it opens. The screen - * that owns the composer opens it again with the lot. Anywhere else the - * toast offers Edit, which opens it here when it can, or the commit the - * reply or quote was for. + * wrote it: the text in its stash, and the photos, poll and organization + * it was to go out as with the failed write in the outbox, for the + * composer to take when it opens. The screen that owns the composer opens + * it again with the lot. Anywhere else the toast offers Edit, which opens + * it here when it can, or the commit the reply or quote was for. * - A message stays in its thread as rejected, with its Retry, and the toast * offers Retry too. Its photos or voice note stay on the phone with it * until it goes. @@ -333,6 +333,7 @@ private function turnDownCommit(PendingWrite $write, string $error, bool $reopen } $this->broadcastOutboxChange('commit-rejected', $write); + $this->checkOrganizations($write); $recovered = $reopen && ($this->nativeParentComponent instanceof FeedWorkspace ? $this->nativeParentComponent->recoverOutboxDraft($write) @@ -400,6 +401,18 @@ public function applyPendingStar(string $id, bool $starred): void $this->showStar($id, $starred); } + /** + * A commit that was to go out as an organization asks devnull which ones + * you're still in, since leaving it is a reason devnull turns one down. Its + * composer then posts as you, as the web's does (see PostAs). + */ + private function checkOrganizations(PendingWrite $write): void + { + if ($write->author() !== null && method_exists($this, 'refreshUnreadNotifications')) { + $this->refreshUnreadNotifications(); + } + } + /** * Signs a write as devnull takes it, here on the UI thread. */ @@ -413,8 +426,8 @@ private function signWrite(PendingWrite $write): SignedRequest PendingWrite::Unstar => $devnull->signedWrite('DELETE', $commit), PendingWrite::Message => $devnull->signedMessage((string) $write->target, $write->body(), $write->client_id, $write->replyToId(), $write->images(), $write->voice()), default => $write->images() === [] - ? $devnull->signedCommit($write->body(), $write->parentId(), $write->quotedCommitId(), $write->poll(), $write->guildHandle()) - : $devnull->signedCommitWithImages($write->body(), $write->images(), $write->parentId(), $write->quotedCommitId(), $write->guildHandle()), + ? $devnull->signedCommit($write->body(), $write->parentId(), $write->quotedCommitId(), $write->poll(), $write->author(), $write->guildHandle()) + : $devnull->signedCommitWithImages($write->body(), $write->images(), $write->parentId(), $write->quotedCommitId(), $write->author(), $write->guildHandle()), }; } diff --git a/app/NativeComponents/Concerns/TalksToDevnull.php b/app/NativeComponents/Concerns/TalksToDevnull.php index 246acbde..43d3b6a5 100644 --- a/app/NativeComponents/Concerns/TalksToDevnull.php +++ b/app/NativeComponents/Concerns/TalksToDevnull.php @@ -9,6 +9,7 @@ use App\Devnull\Exceptions\KeychainUnavailable; use App\Devnull\Exceptions\Unauthenticated; use App\Devnull\Lane; +use App\Devnull\Ownership; use Closure; /** @@ -62,6 +63,14 @@ protected function me(): ?User return app(Account::class)->user(); } + /** + * Which commits are yours: your own and your organizations' (see Ownership). + */ + protected function ownership(): Ownership + { + return app(Account::class)->ownership(); + } + /** * The theme token for your lane, which the main buttons and the pager tab * underlines are drawn in. diff --git a/app/NativeComponents/Concerns/VotesOnPolls.php b/app/NativeComponents/Concerns/VotesOnPolls.php index 0d6e38a9..d9c78538 100644 --- a/app/NativeComponents/Concerns/VotesOnPolls.php +++ b/app/NativeComponents/Concerns/VotesOnPolls.php @@ -35,7 +35,7 @@ public function choosePollOption(string $id, string $optionId): void { $commit = $this->shownCommit($id); - if ($commit === null || ! $commit->canBeVotedOnBy($this->me()) || ! in_array($optionId, array_map(fn ($option): string => $option->id, $commit->poll?->options ?? []), true)) { + if ($commit === null || ! $commit->canBeVotedOnBy($this->ownership()) || ! in_array($optionId, array_map(fn ($option): string => $option->id, $commit->poll?->options ?? []), true)) { return; } @@ -47,7 +47,7 @@ public function voteOnPoll(string $id): void $commit = $this->shownCommit($id); $choice = $this->pollChoices[$id] ?? null; - if ($commit === null || $choice === null || in_array($id, $this->voting, true) || ! $commit->canBeVotedOnBy($this->me())) { + if ($commit === null || $choice === null || in_array($id, $this->voting, true) || ! $commit->canBeVotedOnBy($this->ownership())) { return; } diff --git a/app/NativeComponents/Conversation.php b/app/NativeComponents/Conversation.php index ad5ccdf8..ce1cb605 100644 --- a/app/NativeComponents/Conversation.php +++ b/app/NativeComponents/Conversation.php @@ -28,6 +28,7 @@ use App\NativeComponents\Concerns\OpensInTab; use App\NativeComponents\Concerns\PlaysVoiceNotes; use App\NativeComponents\Concerns\RecordsVoiceNotes; +use App\NativeComponents\Concerns\RedrawsOnAppearanceChange; use App\NativeComponents\Concerns\RefreshesInBackground; use App\NativeComponents\Concerns\ShowsImageViewer; use App\NativeComponents\Concerns\SuggestsMentions; @@ -110,6 +111,7 @@ class Conversation extends NativeComponent use OpensInTab; use PlaysVoiceNotes; use RecordsVoiceNotes; + use RedrawsOnAppearanceChange; use RefreshesInBackground; use ShowsImageViewer; use SuggestsMentions; @@ -246,10 +248,10 @@ class Conversation extends NativeComponent public bool $composing = false; /** - * The composer bar's height with one line in its field, the same as the reply bar on a commit's page: its top - * line, then the field, its tools and Push with 8 points above and below. + * The composer bar's height with one line in its field: the field over the + and Push (see partials/composer-box), + * with 8 points above and below. */ - public const int ComposerBarHeight = Display::ReplyBarHeight; + public const int ComposerBarHeight = Display::ComposerBoxBarHeight; /** * The "Replying to …" bar above the field. @@ -1847,15 +1849,14 @@ private function longPins(): array } /** - * How far the thread pads its end to clear the composer bar: the bar with one line in its field, the lines the - * draft has grown by, the reply bar while replying, the photos and an open description, and a little room. The - * scroll view adds the home indicator itself while the keyboard is down, so this is the same either way. + * How far the thread pads its end to clear the composer bar: the fade above it, the bar with one line in its + * field, the lines the draft has grown by, the reply bar while replying, the photos and an open description, and + * a little room. The scroll view adds the home indicator itself while the keyboard is down, so this is the same + * either way. */ private static function composerClearance(string $draft, bool $replying, bool $hasPhotos, bool $describing): int { - $grownBy = Display::replyBarClearance($draft) - Display::ReplyBarHeight - Display::HomeIndicatorHeight; - - return self::ComposerBarHeight + $grownBy + return Display::composerFadeHeight() + Display::composerBoxBarHeight() + Display::composerBoxGrowth($draft) + ($replying ? self::ReplyingBarHeight : 0) + ($hasPhotos ? self::PhotosHeight : 0) + ($hasPhotos && $describing ? self::DescriptionHeight : 0) diff --git a/app/NativeComponents/Log.php b/app/NativeComponents/Log.php index 319747e7..2ef269c0 100644 --- a/app/NativeComponents/Log.php +++ b/app/NativeComponents/Log.php @@ -6,9 +6,9 @@ use App\Devnull\Data\Commit; use App\Devnull\Data\Page; use App\Devnull\Data\TimelineRow; -use App\Devnull\Data\User; use App\Devnull\Display; use App\Devnull\LastVisit; +use App\Devnull\Ownership; use App\Devnull\ResponseCache; use App\Devnull\RowCache; use App\Devnull\RowWindow; @@ -1200,6 +1200,7 @@ public function render(): Element private function frame(): View { $viewer = $this->me(); + $ownership = $this->ownership(); foreach (self::Logs as $log) { $this->rowCache($log)->startFrame(); @@ -1215,14 +1216,15 @@ private function frame(): View 'loaded' => $this->loaded, 'lastVisitAt' => $this->lastVisitAt, 'error' => $this->error, - ], $viewer, $this->listKey) - : $this->page($log, $this->previewState($log), $viewer, $this->listKeys[$log] ?? 0), self::Logs); + ], $ownership, $this->listKey) + : $this->page($log, $this->previewState($log), $ownership, $this->listKeys[$log] ?? 0), self::Logs); $showing = $pages[array_search($this->log, self::Logs, true)]; return view('native.log', [ 'myColour' => $this->myColour(), 'viewer' => $viewer, + 'ownership' => $ownership, 'pasteis' => app(Account::class)->pasteis(), 'stashed' => app(Stash::class)->names($viewer?->id), 'newCommitsLabel' => $this->newCommitsLabel(), @@ -1239,7 +1241,7 @@ private function frame(): View * @param array $state * @return array */ - private function page(string $log, array $state, ?User $viewer, int $listKey): array + private function page(string $log, array $state, Ownership $ownership, int $listKey): array { /** @var list $commits */ $commits = $state['commits']; @@ -1247,7 +1249,7 @@ private function page(string $log, array $state, ?User $viewer, int $listKey): a $latestCommits = $state['latestCommits']; // Only the log you're on has who to follow: the others show their first few commits. $showsWhoToFollow = $log === $this->log && $this->showsWhoToFollow(); - $rows = $this->timeline($log, $latestCommits, $commits, $log === self::Ranked ? null : LastVisit::firstSeenId($commits, $state['lastVisitAt'], $viewer?->id), $showsWhoToFollow); + $rows = $this->timeline($log, $latestCommits, $commits, $log === self::Ranked ? null : LastVisit::firstSeenId($commits, $state['lastVisitAt'], $ownership), $showsWhoToFollow); return [ 'log' => $log, diff --git a/app/NativeComponents/Notifications.php b/app/NativeComponents/Notifications.php index 58b7dd7b..f22944de 100644 --- a/app/NativeComponents/Notifications.php +++ b/app/NativeComponents/Notifications.php @@ -270,13 +270,16 @@ public function open(string $id): void $commitId = $notification->commitToOpen(); - $this->openInTab($commitId !== null - ? '/commits/'.$commitId - : '/users/'.$notification->actor->username); + $this->openInTab(match (true) { + $commitId !== null => '/commits/'.$commitId, + $notification->actor->isOrganization => '/organizations/'.rawurlencode($notification->actor->username), + default => '/users/'.$notification->actor->username, + }); } /** - * Names and avatars open their profile independently of the notification's commit. + * Names and avatars open their profile independently of the notification's commit: an organization's page for + * one that replied, quoted or mentioned you. */ public function openActor(string $username): void { @@ -287,7 +290,9 @@ public function openActor(string $username): void foreach ([$notification->actor, ...$notification->actors] as $actor) { if ($username !== '' && $actor->username === $username) { - $this->openInTab('/users/'.$actor->username, ['user' => $actor]); + $actor->isOrganization + ? $this->openInTab('/organizations/'.rawurlencode($actor->username)) + : $this->openInTab('/users/'.$actor->username, ['user' => $actor]); return; } diff --git a/app/NativeComponents/Onboarding.php b/app/NativeComponents/Onboarding.php index 2b3cef0a..77914150 100644 --- a/app/NativeComponents/Onboarding.php +++ b/app/NativeComponents/Onboarding.php @@ -272,6 +272,7 @@ private function signInWithExistingKey(): void app(Account::class)->rememberUnreadNotifications($current->unreadNotificationsCount); app(Account::class)->rememberPasteis($current->pasteis()); app(Account::class)->rememberRemotes($current->remotes); + app(Account::class)->rememberOrganizations($current->organizations); app(Account::class)->rememberTermsToAccept($current->termsToAccept()); $this->keepProfile($current->user); $this->replace($current->termsToAccept() === null ? '/log' : AcceptTerms::Path); diff --git a/app/NativeComponents/Organization.php b/app/NativeComponents/Organization.php index c8e3ac24..78bf193d 100644 --- a/app/NativeComponents/Organization.php +++ b/app/NativeComponents/Organization.php @@ -279,6 +279,7 @@ public function render(): View 'myColour' => $this->myColour(), 'newCommitsLabel' => $this->newCommitsLabel(), 'viewer' => $this->me(), + 'ownership' => $this->ownership(), 'stashed' => app(Stash::class)->names($this->me()?->id), 'pages' => $pages, 'pageIndex' => array_search($this->tab, self::Tabs, true), diff --git a/app/NativeComponents/Profile.php b/app/NativeComponents/Profile.php index 64fbc07f..f9ad023b 100644 --- a/app/NativeComponents/Profile.php +++ b/app/NativeComponents/Profile.php @@ -943,6 +943,7 @@ public function render(): View 'canRemote' => $this->canRemote(), 'newCommitsLabel' => $this->newCommitsLabel(), 'viewer' => $this->me(), + 'ownership' => $this->ownership(), 'stashed' => app(Stash::class)->names($this->me()?->id), 'pages' => $pages, 'pageIndex' => array_search($this->tab, self::Tabs, true), diff --git a/app/NativeComponents/Search.php b/app/NativeComponents/Search.php index 86b9e3f1..afbc04dd 100644 --- a/app/NativeComponents/Search.php +++ b/app/NativeComponents/Search.php @@ -289,6 +289,7 @@ public function render(): View 'searchesCommits' => $this->searchesCommits($term), 'rowCache' => $this->rowCache, 'viewer' => $viewer, + 'ownership' => $this->ownership(), 'stashed' => app(Stash::class)->names($viewer?->id), 'myColour' => $this->myColour(), 'rows' => Timeline::ranked([], $this->commits), diff --git a/app/NativeComponents/Starred.php b/app/NativeComponents/Starred.php index fb69e42c..98fd4021 100644 --- a/app/NativeComponents/Starred.php +++ b/app/NativeComponents/Starred.php @@ -265,6 +265,7 @@ public function render(): View return view('native.starred', [ 'rowCache' => $this->rowCache, 'viewer' => $viewer, + 'ownership' => $this->ownership(), 'stashed' => app(Stash::class)->names($viewer?->id), 'myColour' => $this->myColour(), 'rows' => Timeline::feed($this->commits), diff --git a/app/NativeComponents/ThisDevice.php b/app/NativeComponents/ThisDevice.php index 25c2c46c..dd17af64 100644 --- a/app/NativeComponents/ThisDevice.php +++ b/app/NativeComponents/ThisDevice.php @@ -989,6 +989,7 @@ private function takeMe(array $json): void app(Account::class)->rememberUnreadNotifications($current->unreadNotificationsCount); app(Account::class)->rememberPasteis($current->pasteis()); app(Account::class)->rememberRemotes($current->remotes); + app(Account::class)->rememberOrganizations($current->organizations); app(ResponseCache::class)->meChanged($json); $this->takeTerms($current); } diff --git a/composer.lock b/composer.lock index 1aa88999..2c9e81e3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8da614573009c041da1206198f293c72", + "content-hash": "9db9066376d7ad3b55e1afbfba7018e9", "packages": [ { "name": "bacon/bacon-qr-code", @@ -59,7 +59,8 @@ "issues": "https://github.com/Bacon/BaconQrCode/issues", "source": "https://github.com/Bacon/BaconQrCode/tree/v3.1.1" }, - "time": "2026-04-05T21:06:35+00:00" + "time": "2026-04-05T21:06:35+00:00", + "published-time": "2026-04-05T21:07:28+00:00" }, { "name": "brick/math", @@ -119,7 +120,8 @@ "type": "github" } ], - "time": "2026-09-12T10:28:18+00:00" + "time": "2026-09-12T10:28:18+00:00", + "published-time": "2026-09-12T12:23:30+00:00" }, { "name": "carbonphp/carbon-doctrine-types", @@ -193,7 +195,8 @@ "type": "tidelift" } ], - "time": "2026-09-06T14:11:38+00:00" + "time": "2026-09-06T14:11:38+00:00", + "published-time": "2026-09-06T14:15:00+00:00" }, { "name": "codingwithrk/nativephp-social-auth", @@ -262,7 +265,8 @@ "issues": "https://github.com/codingwithrk/nativephp-social-auth/issues", "source": "https://github.com/codingwithrk/nativephp-social-auth/tree/v1.0.0" }, - "time": "2026-09-12T10:32:53+00:00" + "time": "2026-09-12T10:32:53+00:00", + "published-time": "2026-09-12T10:35:30+00:00" }, { "name": "composer/semver", @@ -339,7 +343,8 @@ "type": "github" } ], - "time": "2026-10-29T09:13:34+00:00" + "time": "2026-10-29T09:13:34+00:00", + "published-time": "2026-10-29T09:14:11+00:00" }, { "name": "dasprid/enum", @@ -389,7 +394,8 @@ "issues": "https://github.com/DASPRiD/Enum/issues", "source": "https://github.com/DASPRiD/Enum/tree/1.0.7" }, - "time": "2025-09-16T12:23:56+00:00" + "time": "2025-09-16T12:23:56+00:00", + "published-time": "2025-09-16T12:25:04+00:00" }, { "name": "devnull/adaptive-layout", @@ -573,7 +579,8 @@ "issues": "https://github.com/dflydev/dflydev-dot-access-data/issues", "source": "https://github.com/dflydev/dflydev-dot-access-data/tree/v3.0.3" }, - "time": "2024-07-08T12:26:09+00:00" + "time": "2024-07-08T12:26:09+00:00", + "published-time": "2024-07-08T12:27:13+00:00" }, { "name": "doctrine/inflector", @@ -663,7 +670,8 @@ "type": "tidelift" } ], - "time": "2026-10-26T08:14:14+00:00" + "time": "2026-10-26T08:14:14+00:00", + "published-time": "2026-10-26T20:06:59+00:00" }, { "name": "doctrine/lexer", @@ -738,7 +746,8 @@ "type": "tidelift" } ], - "time": "2026-10-01T06:59:29+00:00" + "time": "2026-10-01T06:59:29+00:00", + "published-time": "2026-10-01T07:01:28+00:00" }, { "name": "dragonmantank/cron-expression", @@ -802,30 +811,31 @@ "type": "github" } ], - "time": "2026-10-19T17:53:57+00:00" + "time": "2026-10-19T17:53:57+00:00", + "published-time": "2026-10-19T17:54:31+00:00" }, { "name": "egulias/email-validator", - "version": "4.0.4", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/egulias/EmailValidator.git", - "reference": "d42c8731f0624ad6bdc8d3e5e9a4524f68801cfa" + "reference": "9bef884e12278a7b89b64adbfb9379c021d3c102" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/d42c8731f0624ad6bdc8d3e5e9a4524f68801cfa", - "reference": "d42c8731f0624ad6bdc8d3e5e9a4524f68801cfa", + "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/9bef884e12278a7b89b64adbfb9379c021d3c102", + "reference": "9bef884e12278a7b89b64adbfb9379c021d3c102", "shasum": "" }, "require": { - "doctrine/lexer": "^2.0 || ^3.0", + "doctrine/lexer": "^3.0.3", "php": ">=8.1", - "symfony/polyfill-intl-idn": "^1.26" + "symfony/polyfill-intl-idn": "^1.43" }, "require-dev": { - "phpunit/phpunit": "^10.2", - "vimeo/psalm": "^5.12" + "phpunit/phpunit": "^10.5.67", + "vimeo/psalm": "^5.26.1" }, "suggest": { "ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation" @@ -861,7 +871,7 @@ ], "support": { "issues": "https://github.com/egulias/EmailValidator/issues", - "source": "https://github.com/egulias/EmailValidator/tree/4.0.4" + "source": "https://github.com/egulias/EmailValidator/tree/4.0.5" }, "funding": [ { @@ -869,7 +879,8 @@ "type": "github" } ], - "time": "2025-03-06T22:45:56+00:00" + "time": "2026-11-22T16:52:20+00:00", + "published-time": "2026-11-22T22:05:57+00:00" }, { "name": "endroid/qr-code", @@ -941,7 +952,8 @@ "type": "github" } ], - "time": "2026-02-05T07:01:58+00:00" + "time": "2026-02-05T07:01:58+00:00", + "published-time": "2026-02-05T07:02:58+00:00" }, { "name": "evenement/evenement", @@ -988,7 +1000,8 @@ "issues": "https://github.com/igorw/evenement/issues", "source": "https://github.com/igorw/evenement/tree/v3.0.2" }, - "time": "2023-08-08T05:53:35+00:00" + "time": "2023-08-08T05:53:35+00:00", + "published-time": "2023-08-08T08:34:49+00:00" }, { "name": "fruitcake/php-cors", @@ -1059,7 +1072,8 @@ "type": "github" } ], - "time": "2025-12-03T09:33:47+00:00" + "time": "2025-12-03T09:33:47+00:00", + "published-time": "2025-12-03T09:37:01+00:00" }, { "name": "graham-campbell/result-type", @@ -1121,29 +1135,31 @@ "type": "tidelift" } ], - "time": "2026-08-24T09:06:52+00:00" + "time": "2026-08-24T09:06:52+00:00", + "published-time": "2026-08-24T09:07:57+00:00" }, { "name": "guzzlehttp/guzzle", - "version": "8.3.1", + "version": "8.6.0", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "7d9b1f430bb65ac664e120af227bf9a795ad6333" + "reference": "ba6574fd975ab16f87dc356729a36777c03851e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/7d9b1f430bb65ac664e120af227bf9a795ad6333", - "reference": "7d9b1f430bb65ac664e120af227bf9a795ad6333", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/ba6574fd975ab16f87dc356729a36777c03851e8", + "reference": "ba6574fd975ab16f87dc356729a36777c03851e8", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^3.1", - "guzzlehttp/psr7": "^3.2", + "guzzlehttp/promises": "^3.2", + "guzzlehttp/psr7": "^3.6", "php": "^7.4 || ^8.0", "psr/http-client": "^1.0", "psr/http-factory": "^1.0", + "symfony/deprecation-contracts": "^2.5 || ^3.0", "symfony/polyfill-php80": "^1.25", "symfony/polyfill-php82": "^1.27" }, @@ -1231,7 +1247,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/8.3.1" + "source": "https://github.com/guzzle/guzzle/tree/8.6.0" }, "funding": [ { @@ -1247,20 +1263,21 @@ "type": "tidelift" } ], - "time": "2026-10-25T21:35:34+00:00" + "time": "2026-11-22T16:48:13+00:00", + "published-time": "2026-11-22T16:50:37+00:00" }, { "name": "guzzlehttp/promises", - "version": "3.1.0", + "version": "3.2.0", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "094d0ec418eb3b1411ea271a180ec95cae6ae933" + "reference": "a201cc78db93065f891278f86eaeaa1c97c5a158" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/094d0ec418eb3b1411ea271a180ec95cae6ae933", - "reference": "094d0ec418eb3b1411ea271a180ec95cae6ae933", + "url": "https://api.github.com/repos/guzzle/promises/zipball/a201cc78db93065f891278f86eaeaa1c97c5a158", + "reference": "a201cc78db93065f891278f86eaeaa1c97c5a158", "shasum": "" }, "require": { @@ -1315,7 +1332,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/3.1.0" + "source": "https://github.com/guzzle/promises/tree/3.2.0" }, "funding": [ { @@ -1331,26 +1348,28 @@ "type": "tidelift" } ], - "time": "2026-10-18T12:48:16+00:00" + "time": "2026-11-21T03:48:02+00:00", + "published-time": "2026-11-21T03:48:27+00:00" }, { "name": "guzzlehttp/psr7", - "version": "3.2.0", + "version": "3.6.0", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "cdc139396207a5eba10c242d241fb014cb098390" + "reference": "1fa0f8319c046b7dec80030460254283d851388e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/cdc139396207a5eba10c242d241fb014cb098390", - "reference": "cdc139396207a5eba10c242d241fb014cb098390", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/1fa0f8319c046b7dec80030460254283d851388e", + "reference": "1fa0f8319c046b7dec80030460254283d851388e", "shasum": "" }, "require": { "php": "^7.4 || ^8.0", "psr/http-factory": "^1.1", "psr/http-message": "^2.0", + "symfony/deprecation-contracts": "^2.5 || ^3.0", "symfony/polyfill-php80": "^1.25", "symfony/polyfill-php82": "^1.27" }, @@ -1366,6 +1385,7 @@ "phpunit/phpunit": "^9.6.34" }, "suggest": { + "ext-intl": "Convert internationalized hosts with Idna", "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" }, "type": "library", @@ -1434,7 +1454,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/3.2.0" + "source": "https://github.com/guzzle/psr7/tree/3.6.0" }, "funding": [ { @@ -1450,7 +1470,8 @@ "type": "tidelift" } ], - "time": "2026-10-17T23:57:19+00:00" + "time": "2026-11-22T00:00:35+00:00", + "published-time": "2026-11-22T00:01:04+00:00" }, { "name": "guzzlehttp/uri-template", @@ -1536,20 +1557,21 @@ "type": "tidelift" } ], - "time": "2026-08-24T17:13:02+00:00" + "time": "2026-08-24T17:13:02+00:00", + "published-time": "2026-08-24T17:13:22+00:00" }, { "name": "laravel/boost", - "version": "v2.10.3", + "version": "v2.10.4", "source": { "type": "git", "url": "https://github.com/laravel/boost.git", - "reference": "75c269a8a53e931c7252e7cd562e1a209356a7c6" + "reference": "9cd5e7d81300b5dee4c8b1619ec4b36f4a6367fd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/boost/zipball/75c269a8a53e931c7252e7cd562e1a209356a7c6", - "reference": "75c269a8a53e931c7252e7cd562e1a209356a7c6", + "url": "https://api.github.com/repos/laravel/boost/zipball/9cd5e7d81300b5dee4c8b1619ec4b36f4a6367fd", + "reference": "9cd5e7d81300b5dee4c8b1619ec4b36f4a6367fd", "shasum": "" }, "require": { @@ -1568,7 +1590,7 @@ "laravel/pint": "^1.27.0", "mockery/mockery": "^1.6.12", "orchestra/testbench": "^9.15.0|^10.6|^11.0", - "pestphp/pest": "^2.36.0|^3.8.4|^4.1.5", + "pestphp/pest": "^2.36.0|^3.8.4|^4.1.5|^5.3.3", "phpstan/phpstan": "^2.1.27", "rector/rector": "^2.1" }, @@ -1603,20 +1625,21 @@ "issues": "https://github.com/laravel/boost/issues", "source": "https://github.com/laravel/boost" }, - "time": "2026-10-07T19:07:19+00:00" + "time": "2026-10-29T18:31:16+00:00", + "published-time": "2026-10-29T18:32:20+00:00" }, { "name": "laravel/framework", - "version": "v13.40.0", + "version": "v13.44.1", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "1449bf241017087fbd38c118ecaabef3f6797fdc" + "reference": "8a8c4a84852869e13190d89f9da873cd9a70f14c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/1449bf241017087fbd38c118ecaabef3f6797fdc", - "reference": "1449bf241017087fbd38c118ecaabef3f6797fdc", + "url": "https://api.github.com/repos/laravel/framework/zipball/8a8c4a84852869e13190d89f9da873cd9a70f14c", + "reference": "8a8c4a84852869e13190d89f9da873cd9a70f14c", "shasum": "" }, "require": { @@ -1642,7 +1665,7 @@ "league/commonmark": "^2.8.1", "league/flysystem": "^3.25.1", "league/flysystem-local": "^3.25.1", - "league/uri": "^7.5.1", + "league/uri": "^7.6", "monolog/monolog": "^3.10", "nesbot/carbon": "^3.8.4", "nunomaduro/termwind": "^2.0", @@ -1671,6 +1694,7 @@ "voku/portable-ascii": "^2.0.2" }, "conflict": { + "laravel/horizon": "<5.47.0", "tightenco/collect": "<5.5.33" }, "provide": { @@ -1719,11 +1743,12 @@ "spatie/once": "*" }, "require-dev": { - "ably/ably-php": "^1.0", + "ably/pubsub-server": "^1.0|^2.0", "aws/aws-sdk-php": "^3.322.9", "ext-gmp": "*", "fakerphp/faker": "^1.24", "intervention/image": "^4.2", + "jasonmccreary/double": "^1.2.1", "laravel/pint": "^1.18", "league/flysystem-aws-s3-v3": "^3.25.1", "league/flysystem-ftp": "^3.25.1", @@ -1735,7 +1760,7 @@ "orchestra/testbench-core": "^11.6.0", "pda/pheanstalk": "^7.0.0 || ^8.0.0", "php-http/discovery": "^1.15", - "phpstan/phpstan": "2.3.1", + "phpstan/phpstan": "2.3.5", "phpunit/phpunit": "^11.5.50 || ^12.5.8 || ^13.0.3", "predis/predis": "^2.3 || ^3.0", "rector/rector": "2.6.3", @@ -1748,7 +1773,7 @@ "web-token/jwt-library": "^4.1" }, "suggest": { - "ably/ably-php": "Required to use the Ably broadcast driver (^1.0).", + "ably/pubsub-server": "Required to use the Ably broadcast driver (^1.0|^2.0).", "aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage, and SES mail driver (^3.322.9).", "brianium/paratest": "Required to run tests in parallel (^7.0 || ^8.0).", "ext-apcu": "Required to use the APC cache driver.", @@ -1834,40 +1859,41 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2026-11-03T15:07:18+00:00" + "time": "2026-11-24T16:10:06+00:00", + "published-time": "2026-11-24T16:10:17+00:00" }, { "name": "laravel/mcp", - "version": "v1.1.2", + "version": "v1.2.1", "source": { "type": "git", "url": "https://github.com/laravel/mcp.git", - "reference": "ab9238ce6c89095679651dd3d19d67641d73a436" + "reference": "a8057f222549e42384d49482042d762a547aaf2a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/mcp/zipball/ab9238ce6c89095679651dd3d19d67641d73a436", - "reference": "ab9238ce6c89095679651dd3d19d67641d73a436", + "url": "https://api.github.com/repos/laravel/mcp/zipball/a8057f222549e42384d49482042d762a547aaf2a", + "reference": "a8057f222549e42384d49482042d762a547aaf2a", "shasum": "" }, "require": { "ext-json": "*", "ext-mbstring": "*", - "illuminate/console": "^11.45.3|^12.41.1|^13.0", - "illuminate/container": "^11.45.3|^12.41.1|^13.0", - "illuminate/contracts": "^11.45.3|^12.41.1|^13.0", - "illuminate/http": "^11.45.3|^12.41.1|^13.0", + "illuminate/console": "^12.41.1|^13.0", + "illuminate/container": "^12.41.1|^13.0", + "illuminate/contracts": "^12.41.1|^13.0", + "illuminate/http": "^12.41.1|^13.0", "illuminate/json-schema": "^12.41.1|^13.0", - "illuminate/routing": "^11.45.3|^12.41.1|^13.0", - "illuminate/support": "^11.45.3|^12.41.1|^13.0", - "illuminate/validation": "^11.45.3|^12.41.1|^13.0", + "illuminate/routing": "^12.41.1|^13.0", + "illuminate/support": "^12.41.1|^13.0", + "illuminate/validation": "^12.41.1|^13.0", "php": "^8.2", "symfony/process": "^7.4.5|^8.0.5" }, "require-dev": { "jasonmccreary/double": "^1.0", - "laravel/pint": "^1.20", - "orchestra/testbench": "^9.15|^10.8|^11.0", + "laravel/pint": "^1.20,!=1.32.2", + "orchestra/testbench": "^10.8|^11.0", "pestphp/pest": "^3.8.5|^4.3.2", "phpstan/phpstan": "^2.1.27", "rector/rector": "^2.2.4" @@ -1909,20 +1935,21 @@ "issues": "https://github.com/laravel/mcp/issues", "source": "https://github.com/laravel/mcp" }, - "time": "2026-10-26T17:48:48+00:00" + "time": "2026-11-17T16:36:18+00:00", + "published-time": "2026-11-17T18:52:14+00:00" }, { "name": "laravel/prompts", - "version": "v0.3.26", + "version": "v0.3.28", "source": { "type": "git", "url": "https://github.com/laravel/prompts.git", - "reference": "2d1e9bf6bab8d3f383c254db7f2b4ea8816d55e0" + "reference": "72247703c4d4ac1d6122955c90433aa9429bd236" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/2d1e9bf6bab8d3f383c254db7f2b4ea8816d55e0", - "reference": "2d1e9bf6bab8d3f383c254db7f2b4ea8816d55e0", + "url": "https://api.github.com/repos/laravel/prompts/zipball/72247703c4d4ac1d6122955c90433aa9429bd236", + "reference": "72247703c4d4ac1d6122955c90433aa9429bd236", "shasum": "" }, "require": { @@ -1965,9 +1992,10 @@ ], "description": "Add beautiful and user-friendly forms to your command-line applications.", "support": { - "source": "https://github.com/laravel/prompts/tree/v0.3.26" + "source": "https://github.com/laravel/prompts/tree/v0.3.28" }, - "time": "2026-10-09T14:45:13+00:00" + "time": "2026-11-23T14:41:10+00:00", + "published-time": "2026-11-24T16:27:03+00:00" }, { "name": "laravel/roster", @@ -2029,20 +2057,21 @@ "issues": "https://github.com/laravel/roster/issues", "source": "https://github.com/laravel/roster" }, - "time": "2026-07-18T17:53:15+00:00" + "time": "2026-07-18T17:53:15+00:00", + "published-time": "2026-07-20T09:14:35+00:00" }, { "name": "laravel/serializable-closure", - "version": "v2.1.0", + "version": "v2.2.0", "source": { "type": "git", "url": "https://github.com/laravel/serializable-closure.git", - "reference": "2d5869a838bbcf37e0d8b0568fc41914e81374b5" + "reference": "2bfb44e8af009b553ed2c060c94b0bc3c67b4769" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/2d5869a838bbcf37e0d8b0568fc41914e81374b5", - "reference": "2d5869a838bbcf37e0d8b0568fc41914e81374b5", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/2bfb44e8af009b553ed2c060c94b0bc3c67b4769", + "reference": "2bfb44e8af009b553ed2c060c94b0bc3c67b4769", "shasum": "" }, "require": { @@ -2090,37 +2119,37 @@ "issues": "https://github.com/laravel/serializable-closure/issues", "source": "https://github.com/laravel/serializable-closure" }, - "time": "2026-09-22T14:32:34+00:00" + "time": "2026-10-14T21:20:29+00:00", + "published-time": "2026-11-10T16:11:08+00:00" }, { "name": "laravel/tinker", - "version": "v3.0.2", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/laravel/tinker.git", - "reference": "4faba77764bd33411735936acdf30446d058c78b" + "reference": "0630f3d4dc64d7800e7f5dded22ea3362ed52adb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/tinker/zipball/4faba77764bd33411735936acdf30446d058c78b", - "reference": "4faba77764bd33411735936acdf30446d058c78b", + "url": "https://api.github.com/repos/laravel/tinker/zipball/0630f3d4dc64d7800e7f5dded22ea3362ed52adb", + "reference": "0630f3d4dc64d7800e7f5dded22ea3362ed52adb", "shasum": "" }, "require": { - "illuminate/console": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0", - "illuminate/contracts": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0", - "illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0", - "php": "^8.1", - "psy/psysh": "^0.12.0", - "symfony/var-dumper": "^5.4|^6.0|^7.0|^8.0" + "illuminate/console": "^12.0|^13.0", + "illuminate/contracts": "^12.0|^13.0", + "illuminate/support": "^12.0|^13.0", + "php": "^8.2", + "psy/psysh": "^0.12.19", + "symfony/var-dumper": "^7.0|^8.0" }, "require-dev": { - "mockery/mockery": "~1.3.3|^1.4.2", "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^10.5|^11.5" + "phpunit/phpunit": "^10.5|^11.5|^12.5|^13.4" }, "suggest": { - "illuminate/database": "The Illuminate Database package (^8.0|^9.0|^10.0|^11.0|^12.0|^13.0)." + "illuminate/database": "The Illuminate Database package (^12.0|^13.0)." }, "type": "library", "extra": { @@ -2157,22 +2186,23 @@ ], "support": { "issues": "https://github.com/laravel/tinker/issues", - "source": "https://github.com/laravel/tinker/tree/v3.0.2" + "source": "https://github.com/laravel/tinker/tree/v3.2.0" }, - "time": "2026-03-17T14:54:13+00:00" + "time": "2026-11-11T14:11:46+00:00", + "published-time": "2026-11-17T15:22:49+00:00" }, { "name": "league/commonmark", - "version": "2.10.7", + "version": "2.10.8", "source": { "type": "git", "url": "https://github.com/thephpleague/commonmark.git", - "reference": "8eb53e906fd60c67038d22f1f1cab420ed58b8be" + "reference": "681e662a40c805c567f52d603b64d55282ea356c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/8eb53e906fd60c67038d22f1f1cab420ed58b8be", - "reference": "8eb53e906fd60c67038d22f1f1cab420ed58b8be", + "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/681e662a40c805c567f52d603b64d55282ea356c", + "reference": "681e662a40c805c567f52d603b64d55282ea356c", "shasum": "" }, "require": { @@ -2266,7 +2296,8 @@ "type": "tidelift" } ], - "time": "2026-10-31T13:35:37+00:00" + "time": "2026-11-24T15:44:47+00:00", + "published-time": "2026-11-24T15:45:01+00:00" }, { "name": "league/config", @@ -2348,7 +2379,8 @@ "type": "github" } ], - "time": "2022-12-11T20:36:23+00:00" + "time": "2022-12-11T20:36:23+00:00", + "published-time": "2022-12-11T20:36:45+00:00" }, { "name": "league/flysystem", @@ -2431,7 +2463,8 @@ "issues": "https://github.com/thephpleague/flysystem/issues", "source": "https://github.com/thephpleague/flysystem/tree/3.36.0" }, - "time": "2026-09-02T08:00:27+00:00" + "time": "2026-09-02T08:00:27+00:00", + "published-time": "2026-09-02T08:01:40+00:00" }, { "name": "league/flysystem-local", @@ -2480,7 +2513,8 @@ "support": { "source": "https://github.com/thephpleague/flysystem-local/tree/3.35.3" }, - "time": "2026-08-12T13:29:21+00:00" + "time": "2026-08-12T13:29:21+00:00", + "published-time": "2026-08-22T12:57:18+00:00" }, { "name": "league/mime-type-detection", @@ -2536,25 +2570,26 @@ "type": "tidelift" } ], - "time": "2026-07-09T11:49:27+00:00" + "time": "2026-07-09T11:49:27+00:00", + "published-time": "2026-07-09T11:50:09+00:00" }, { "name": "league/uri", - "version": "7.9.1", + "version": "7.10.0", "source": { "type": "git", "url": "https://github.com/thephpleague/uri.git", - "reference": "40403f5c3141457a61f7f1aba6706e8fa4a0ece5" + "reference": "be89e2382e37acdef232259071ade5180821397b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri/zipball/40403f5c3141457a61f7f1aba6706e8fa4a0ece5", - "reference": "40403f5c3141457a61f7f1aba6706e8fa4a0ece5", + "url": "https://api.github.com/repos/thephpleague/uri/zipball/be89e2382e37acdef232259071ade5180821397b", + "reference": "be89e2382e37acdef232259071ade5180821397b", "shasum": "" }, "require": { "ext-mbstring": "*", - "league/uri-interfaces": "^7.9.1", + "league/uri-interfaces": "^7.10.0", "php": "^8.1", "psr/http-factory": "^1" }, @@ -2627,7 +2662,7 @@ "docs": "https://uri.thephpleague.com", "forum": "https://thephpleague.slack.com", "issues": "https://github.com/thephpleague/uri-src/issues", - "source": "https://github.com/thephpleague/uri/tree/7.9.1" + "source": "https://github.com/thephpleague/uri/tree/7.10.0" }, "funding": [ { @@ -2635,20 +2670,21 @@ "type": "github" } ], - "time": "2026-10-27T07:14:23+00:00" + "time": "2026-11-04T12:45:07+00:00", + "published-time": "2026-11-04T13:02:21+00:00" }, { "name": "league/uri-interfaces", - "version": "7.9.1", + "version": "7.10.0", "source": { "type": "git", "url": "https://github.com/thephpleague/uri-interfaces.git", - "reference": "994300a79e17f179112dc259f8df0c4de982f736" + "reference": "ea66240cff4ae9a56ce85d577a04d038b771e51c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/994300a79e17f179112dc259f8df0c4de982f736", - "reference": "994300a79e17f179112dc259f8df0c4de982f736", + "url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/ea66240cff4ae9a56ce85d577a04d038b771e51c", + "reference": "ea66240cff4ae9a56ce85d577a04d038b771e51c", "shasum": "" }, "require": { @@ -2711,7 +2747,7 @@ "docs": "https://uri.thephpleague.com", "forum": "https://thephpleague.slack.com", "issues": "https://github.com/thephpleague/uri-src/issues", - "source": "https://github.com/thephpleague/uri-interfaces/tree/7.9.1" + "source": "https://github.com/thephpleague/uri-interfaces/tree/7.10.0" }, "funding": [ { @@ -2719,20 +2755,21 @@ "type": "github" } ], - "time": "2026-10-27T07:14:23+00:00" + "time": "2026-11-04T12:45:07+00:00", + "published-time": "2026-11-04T13:02:27+00:00" }, { "name": "monolog/monolog", - "version": "3.12.1", + "version": "3.13.0", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "d7059e4c691d05ea1222b5124bed0f961be46e15" + "reference": "1f5f55bb4a9a230ff6d8a4ceccea31d10b0142ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/d7059e4c691d05ea1222b5124bed0f961be46e15", - "reference": "d7059e4c691d05ea1222b5124bed0f961be46e15", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/1f5f55bb4a9a230ff6d8a4ceccea31d10b0142ac", + "reference": "1f5f55bb4a9a230ff6d8a4ceccea31d10b0142ac", "shasum": "" }, "require": { @@ -2812,7 +2849,7 @@ ], "support": { "issues": "https://github.com/Seldaek/monolog/issues", - "source": "https://github.com/Seldaek/monolog/tree/3.12.1" + "source": "https://github.com/Seldaek/monolog/tree/3.13.0" }, "funding": [ { @@ -2824,7 +2861,8 @@ "type": "tidelift" } ], - "time": "2026-09-29T19:21:12+00:00" + "time": "2026-11-16T10:43:05+00:00", + "published-time": "2026-11-16T10:45:37+00:00" }, { "name": "nativephp/mobile", @@ -2832,12 +2870,12 @@ "source": { "type": "git", "url": "https://github.com/NativePHP/mobile-air.git", - "reference": "db7d5db8a2870dc0badbf958377872cd4e3826fc" + "reference": "a9fd09f5b998b46cf70d50e29035b882d459f482" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/NativePHP/mobile-air/zipball/db7d5db8a2870dc0badbf958377872cd4e3826fc", - "reference": "db7d5db8a2870dc0badbf958377872cd4e3826fc", + "url": "https://api.github.com/repos/NativePHP/mobile-air/zipball/a9fd09f5b998b46cf70d50e29035b882d459f482", + "reference": "a9fd09f5b998b46cf70d50e29035b882d459f482", "shasum": "" }, "require": { @@ -2887,40 +2925,14 @@ } }, "autoload": { - "psr-4": { - "Native\\Mobile\\": "src/" - }, "files": [ "src/helpers.php" - ] - }, - "autoload-dev": { + ], "psr-4": { - "Tests\\": "tests/" + "Native\\Mobile\\": "src/" } }, - "scripts": { - "qa": [ - "@composer format", - "@composer analyse", - "@composer test" - ], - "post-autoload-dump": [ - "@php ./vendor/bin/testbench package:discover --ansi" - ], - "analyse": [ - "vendor/bin/phpstan analyse" - ], - "test": [ - "vendor/bin/pest" - ], - "test-coverage": [ - "vendor/bin/pest --coverage" - ], - "format": [ - "vendor/bin/pint" - ] - }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -2945,10 +2957,11 @@ "nativephp" ], "support": { - "source": "https://github.com/NativePHP/mobile-air/tree/main", - "issues": "https://github.com/NativePHP/mobile-air/issues" + "issues": "https://github.com/NativePHP/mobile-air/issues", + "source": "https://github.com/NativePHP/mobile-air/tree/main" }, - "time": "2026-11-20T17:55:04+00:00" + "time": "2026-11-24T09:54:26+00:00", + "published-time": "2026-11-24T09:54:33+00:00" }, { "name": "nativephp/mobile-browser", @@ -3003,7 +3016,8 @@ "issues": "https://github.com/NativePHP/mobile-browser/issues", "source": "https://github.com/NativePHP/mobile-browser/tree/1.2.1" }, - "time": "2026-10-22T19:51:21+00:00" + "time": "2026-10-22T19:51:21+00:00", + "published-time": "2026-10-22T19:52:31+00:00" }, { "name": "nativephp/mobile-camera", @@ -3058,7 +3072,8 @@ "issues": "https://github.com/NativePHP/mobile-camera/issues", "source": "https://github.com/NativePHP/mobile-camera/tree/1.1.0" }, - "time": "2026-10-22T15:11:58+00:00" + "time": "2026-10-22T15:11:58+00:00", + "published-time": "2026-10-22T15:14:50+00:00" }, { "name": "nativephp/mobile-clipboard", @@ -3113,7 +3128,8 @@ "issues": "https://github.com/NativePHP/mobile-clipboard/issues", "source": "https://github.com/NativePHP/mobile-clipboard/tree/1.0.0" }, - "time": "2026-07-19T02:38:14+00:00" + "time": "2026-07-19T02:38:14+00:00", + "published-time": "2026-07-19T02:38:45+00:00" }, { "name": "nativephp/mobile-firebase", @@ -3224,7 +3240,8 @@ "issues": "https://github.com/NativePHP/mobile-media-player/issues", "source": "https://github.com/NativePHP/mobile-media-player/tree/1.1.0" }, - "time": "2026-10-29T09:15:16+00:00" + "time": "2026-10-29T09:15:16+00:00", + "published-time": "2026-10-29T09:19:23+00:00" }, { "name": "nativephp/mobile-microphone", @@ -3279,7 +3296,8 @@ "issues": "https://github.com/NativePHP/mobile-microphone/issues", "source": "https://github.com/NativePHP/mobile-microphone/tree/1.2.0" }, - "time": "2026-10-29T09:22:03+00:00" + "time": "2026-10-29T09:22:03+00:00", + "published-time": "2026-10-29T09:22:40+00:00" }, { "name": "nativephp/mobile-secure-storage", @@ -3338,16 +3356,16 @@ }, { "name": "nativephp/mobile-share", - "version": "1.1.0", + "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/NativePHP/mobile-share.git", - "reference": "217a556ee7863010187a527752b8cef46057f2f5" + "reference": "cc30896ae0751e181c07ce290c05ac37253ae11b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/NativePHP/mobile-share/zipball/217a556ee7863010187a527752b8cef46057f2f5", - "reference": "217a556ee7863010187a527752b8cef46057f2f5", + "url": "https://api.github.com/repos/NativePHP/mobile-share/zipball/cc30896ae0751e181c07ce290c05ac37253ae11b", + "reference": "cc30896ae0751e181c07ce290c05ac37253ae11b", "shasum": "" }, "require": { @@ -3387,18 +3405,19 @@ "description": "Native share sheet plugin for NativePHP Mobile", "support": { "issues": "https://github.com/NativePHP/mobile-share/issues", - "source": "https://github.com/NativePHP/mobile-share/tree/1.1.0" + "source": "https://github.com/NativePHP/mobile-share/tree/1.1.1" }, - "time": "2026-09-03T18:26:20+00:00" + "time": "2026-11-04T12:56:41+00:00", + "published-time": "2026-11-04T12:58:17+00:00" }, { "name": "nativephp/mobile-skia", - "version": "1.0.0", + "version": "1.1.0", "dist": { "type": "zip", - "url": "https://plugins.nativephp.com/dist/nativephp/mobile-skia/nativephp-mobile-skia-ffc7fa9101c1e5183497773ea47cd16fdfbbc72d-zip-f04ec9.zip", - "reference": "ffc7fa9101c1e5183497773ea47cd16fdfbbc72d", - "shasum": "c468d6182ad2ca8e66c7d8827bff9e75499067b8" + "url": "https://plugins.nativephp.com/dist/nativephp/mobile-skia/nativephp-mobile-skia-17820ca291c9a00c5a882b3f083f861054e57407-zip-6b0370.zip", + "reference": "17820ca291c9a00c5a882b3f083f861054e57407", + "shasum": "2dd1514acf47112e11c1ba8f0b7accba38d707c1" }, "require": { "nativephp/mobile": "^4.5.1", @@ -3433,7 +3452,7 @@ ] }, "license": [ - "MIT" + "proprietary" ], "authors": [ { @@ -3451,7 +3470,7 @@ "nativephp", "skia" ], - "time": "2026-10-07T13:32:43+00:00" + "time": "2026-11-02T18:10:45+00:00" }, { "name": "nativephp/mobile-ui", @@ -3459,12 +3478,12 @@ "source": { "type": "git", "url": "https://github.com/NativePHP/mobile-ui.git", - "reference": "3a6096d7c7d1e7e81ab6c5ba1cd6c81bfedc3901" + "reference": "633ebed65ddcb204d343245a8b92196fec1d4185" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/NativePHP/mobile-ui/zipball/3a6096d7c7d1e7e81ab6c5ba1cd6c81bfedc3901", - "reference": "3a6096d7c7d1e7e81ab6c5ba1cd6c81bfedc3901", + "url": "https://api.github.com/repos/NativePHP/mobile-ui/zipball/633ebed65ddcb204d343245a8b92196fec1d4185", + "reference": "633ebed65ddcb204d343245a8b92196fec1d4185", "shasum": "" }, "require": { @@ -3524,7 +3543,7 @@ "url": "https://nativephp.com/sponsor" } ], - "time": "2026-11-19T22:21:34+00:00" + "time": "2026-11-24T10:20:57+00:00" }, { "name": "nesbot/carbon", @@ -3630,7 +3649,8 @@ "type": "tidelift" } ], - "time": "2026-10-25T14:32:48+00:00" + "time": "2026-10-25T14:32:48+00:00", + "published-time": "2026-10-25T14:41:05+00:00" }, { "name": "nette/schema", @@ -3697,7 +3717,8 @@ "issues": "https://github.com/nette/schema/issues", "source": "https://github.com/nette/schema/tree/v1.4.0" }, - "time": "2026-10-22T02:12:50+00:00" + "time": "2026-10-22T02:12:50+00:00", + "published-time": "2026-10-22T02:14:45+00:00" }, { "name": "nette/utils", @@ -3788,7 +3809,8 @@ "issues": "https://github.com/nette/utils/issues", "source": "https://github.com/nette/utils/tree/v4.1.6" }, - "time": "2026-10-20T17:07:56+00:00" + "time": "2026-10-20T17:07:56+00:00", + "published-time": "2026-10-20T17:48:30+00:00" }, { "name": "nikic/php-parser", @@ -3845,35 +3867,36 @@ "issues": "https://github.com/nikic/PHP-Parser/issues", "source": "https://github.com/nikic/PHP-Parser/tree/v5.9.0" }, - "time": "2026-09-13T18:51:52+00:00" + "time": "2026-09-13T18:51:52+00:00", + "published-time": "2026-09-13T18:53:16+00:00" }, { "name": "nunomaduro/termwind", - "version": "v2.4.0", + "version": "v2.4.1", "source": { "type": "git", "url": "https://github.com/nunomaduro/termwind.git", - "reference": "712a31b768f5daea284c2169a7d227031001b9a8" + "reference": "9b85ae4d802403bfc004ea633ce542bc262ee5c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/712a31b768f5daea284c2169a7d227031001b9a8", - "reference": "712a31b768f5daea284c2169a7d227031001b9a8", + "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/9b85ae4d802403bfc004ea633ce542bc262ee5c3", + "reference": "9b85ae4d802403bfc004ea633ce542bc262ee5c3", "shasum": "" }, "require": { "ext-mbstring": "*", "php": "^8.2", - "symfony/console": "^7.4.4 || ^8.0.4" + "symfony/console": "^7.4.23 || ^8.1.11" }, "require-dev": { - "illuminate/console": "^11.47.0", - "laravel/pint": "^1.27.1", - "mockery/mockery": "^1.6.12", - "pestphp/pest": "^2.36.0 || ^3.8.4 || ^4.3.2", - "phpstan/phpstan": "^1.12.32", + "illuminate/console": "^11.51 || ^12.70 || ^13.40", + "laravel/pint": "^1.30.4", + "mockery/mockery": "^1.6.15", + "pestphp/pest": "^2.36.1 || ^3.8.7 || ^4.7.8 || ^5.3.5", + "phpstan/phpstan": "^1.12.34", "phpstan/phpstan-strict-rules": "^1.6.2", - "symfony/var-dumper": "^7.3.5 || ^8.0.4", + "symfony/var-dumper": "^7.4.22 || ^8.1.10", "thecodingmachine/phpstan-strict-rules": "^1.0.0" }, "type": "library", @@ -3916,7 +3939,7 @@ ], "support": { "issues": "https://github.com/nunomaduro/termwind/issues", - "source": "https://github.com/nunomaduro/termwind/tree/v2.4.0" + "source": "https://github.com/nunomaduro/termwind/tree/v2.4.1" }, "funding": [ { @@ -3932,7 +3955,8 @@ "type": "github" } ], - "time": "2026-02-16T23:10:27+00:00" + "time": "2026-11-07T03:57:16+00:00", + "published-time": "2026-11-07T04:01:24+00:00" }, { "name": "phpoption/phpoption", @@ -4007,7 +4031,8 @@ "type": "tidelift" } ], - "time": "2026-08-24T00:54:40+00:00" + "time": "2026-08-24T00:54:40+00:00", + "published-time": "2026-08-24T01:09:05+00:00" }, { "name": "psr/clock", @@ -4055,7 +4080,8 @@ "issues": "https://github.com/php-fig/clock/issues", "source": "https://github.com/php-fig/clock/tree/1.0.0" }, - "time": "2022-11-25T14:36:26+00:00" + "time": "2022-11-25T14:36:26+00:00", + "published-time": "2022-11-25T14:59:22+00:00" }, { "name": "psr/container", @@ -4108,7 +4134,8 @@ "issues": "https://github.com/php-fig/container/issues", "source": "https://github.com/php-fig/container/tree/2.0.2" }, - "time": "2021-11-05T16:47:00+00:00" + "time": "2021-11-05T16:47:00+00:00", + "published-time": "2021-11-05T16:53:27+00:00" }, { "name": "psr/event-dispatcher", @@ -4158,7 +4185,8 @@ "issues": "https://github.com/php-fig/event-dispatcher/issues", "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0" }, - "time": "2019-01-08T18:20:26+00:00" + "time": "2019-01-08T18:20:26+00:00", + "published-time": "2019-03-25T15:31:44+00:00" }, { "name": "psr/http-client", @@ -4210,7 +4238,8 @@ "support": { "source": "https://github.com/php-fig/http-client" }, - "time": "2023-09-23T14:17:50+00:00" + "time": "2023-09-23T14:17:50+00:00", + "published-time": "2023-09-23T14:18:12+00:00" }, { "name": "psr/http-factory", @@ -4265,7 +4294,8 @@ "support": { "source": "https://github.com/php-fig/http-factory" }, - "time": "2024-04-15T12:06:14+00:00" + "time": "2024-04-15T12:06:14+00:00", + "published-time": "2024-05-10T07:32:19+00:00" }, { "name": "psr/http-message", @@ -4318,7 +4348,8 @@ "support": { "source": "https://github.com/php-fig/http-message/tree/2.0" }, - "time": "2023-04-04T09:54:51+00:00" + "time": "2023-04-04T09:54:51+00:00", + "published-time": "2023-04-04T09:55:35+00:00" }, { "name": "psr/log", @@ -4368,7 +4399,8 @@ "support": { "source": "https://github.com/php-fig/log/tree/3.0.2" }, - "time": "2024-09-11T13:17:53+00:00" + "time": "2024-09-11T13:17:53+00:00", + "published-time": "2024-09-11T13:21:14+00:00" }, { "name": "psr/simple-cache", @@ -4419,7 +4451,8 @@ "support": { "source": "https://github.com/php-fig/simple-cache/tree/3.0.0" }, - "time": "2021-10-29T13:26:27+00:00" + "time": "2021-10-29T13:26:27+00:00", + "published-time": "2021-10-29T13:27:19+00:00" }, { "name": "psy/psysh", @@ -4498,7 +4531,8 @@ "issues": "https://github.com/bobthecow/psysh/issues", "source": "https://github.com/bobthecow/psysh/tree/v0.12.24" }, - "time": "2026-06-29T15:41:09+00:00" + "time": "2026-06-29T15:41:09+00:00", + "published-time": "2026-06-29T15:41:53+00:00" }, { "name": "ramsey/collection", @@ -4574,20 +4608,21 @@ "issues": "https://github.com/ramsey/collection/issues", "source": "https://github.com/ramsey/collection/tree/2.1.1" }, - "time": "2025-03-22T05:38:12+00:00" + "time": "2025-03-22T05:38:12+00:00", + "published-time": "2025-03-22T05:39:22+00:00" }, { "name": "ramsey/uuid", - "version": "4.9.4", + "version": "4.10.0", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "75d73f48d02797c2c285a7e9f348fadc0102ffe2" + "reference": "f9aa3efc8015fcbc013d84d699583b268ccb593a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/75d73f48d02797c2c285a7e9f348fadc0102ffe2", - "reference": "75d73f48d02797c2c285a7e9f348fadc0102ffe2", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/f9aa3efc8015fcbc013d84d699583b268ccb593a", + "reference": "f9aa3efc8015fcbc013d84d699583b268ccb593a", "shasum": "" }, "require": { @@ -4599,23 +4634,22 @@ "rhumsaa/uuid": "self.version" }, "require-dev": { - "captainhook/captainhook": "^5.25", - "captainhook/plugin-composer": "^5.3", - "dealerdirect/phpcodesniffer-composer-installer": "^1.0", - "ergebnis/composer-normalize": "^2.47", - "mockery/mockery": "^1.6", - "paragonie/random-lib": "^2", - "php-mock/php-mock": "^2.6", - "php-mock/php-mock-mockery": "^1.5", + "captainhook/captainhook": "^5.29.3", + "captainhook/plugin-composer": "^5.3.3", + "dealerdirect/phpcodesniffer-composer-installer": "^1.2.1", + "mockery/mockery": "^1.6.15", + "paragonie/random-lib": "^2.0.3", + "php-mock/php-mock": "^2.7.0", + "php-mock/php-mock-mockery": "^1.5.0", "php-parallel-lint/php-parallel-lint": "^1.4.0", "phpbench/phpbench": "^1.2.14", - "phpstan/extension-installer": "^1.4", - "phpstan/phpstan": "^2.1", - "phpstan/phpstan-mockery": "^2.0", - "phpstan/phpstan-phpunit": "^2.0", - "phpunit/phpunit": "^9.6", - "slevomat/coding-standard": "^8.18", - "squizlabs/php_codesniffer": "^3.13" + "phpstan/extension-installer": "^1.4.3", + "phpstan/phpstan": "^2.3.5", + "phpstan/phpstan-mockery": "^2.0.0", + "phpstan/phpstan-phpunit": "^2.1.2", + "phpunit/phpunit": "^9.6.39", + "slevomat/coding-standard": "^8.31.3", + "squizlabs/php_codesniffer": "^4.0.4" }, "suggest": { "ext-bcmath": "Enables faster math with arbitrary-precision integers using BCMath.", @@ -4650,9 +4684,10 @@ ], "support": { "issues": "https://github.com/ramsey/uuid/issues", - "source": "https://github.com/ramsey/uuid/tree/4.9.4" + "source": "https://github.com/ramsey/uuid/tree/4.10.0" }, - "time": "2026-09-16T11:39:30+00:00" + "time": "2026-11-14T23:23:20+00:00", + "published-time": "2026-11-14T23:35:39+00:00" }, { "name": "react/cache", @@ -4724,7 +4759,8 @@ "type": "open_collective" } ], - "time": "2022-11-30T15:59:55+00:00" + "time": "2022-11-30T15:59:55+00:00", + "published-time": "2022-11-30T16:03:35+00:00" }, { "name": "react/datagram", @@ -4805,7 +4841,8 @@ "type": "open_collective" } ], - "time": "2024-09-06T11:22:35+00:00" + "time": "2024-09-06T11:22:35+00:00", + "published-time": "2024-09-06T11:49:15+00:00" }, { "name": "react/dns", @@ -4881,7 +4918,8 @@ "type": "open_collective" } ], - "time": "2025-11-18T19:34:28+00:00" + "time": "2025-11-18T19:34:28+00:00", + "published-time": "2025-11-18T19:35:06+00:00" }, { "name": "react/event-loop", @@ -4953,7 +4991,8 @@ "type": "open_collective" } ], - "time": "2025-11-17T20:46:25+00:00" + "time": "2025-11-17T20:46:25+00:00", + "published-time": "2025-11-17T20:47:32+00:00" }, { "name": "react/promise", @@ -5026,7 +5065,8 @@ "type": "open_collective" } ], - "time": "2025-08-19T18:57:03+00:00" + "time": "2025-08-19T18:57:03+00:00", + "published-time": "2025-08-19T19:13:36+00:00" }, { "name": "s2br/nativephp-mobile-splashscreen", @@ -5084,7 +5124,8 @@ "issues": "https://github.com/S2BR/nativephp-mobile-splashscreen/issues", "source": "https://github.com/S2BR/nativephp-mobile-splashscreen/tree/v1.4.0" }, - "time": "2026-07-21T13:52:18+00:00" + "time": "2026-07-21T13:52:18+00:00", + "published-time": "2026-07-21T13:54:32+00:00" }, { "name": "spatie/laravel-package-tools", @@ -5145,7 +5186,8 @@ "type": "github" } ], - "time": "2026-09-28T07:16:50+00:00" + "time": "2026-09-28T07:16:50+00:00", + "published-time": "2026-09-28T07:17:01+00:00" }, { "name": "symfony/clock", @@ -5222,20 +5264,21 @@ "type": "tidelift" } ], - "time": "2026-10-12T14:32:04+00:00" + "time": "2026-10-12T14:32:04+00:00", + "published-time": "2026-10-14T06:48:32+00:00" }, { "name": "symfony/console", - "version": "v8.1.10", + "version": "v8.1.11", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "5b6d9b127ec27bc6db59bf65e2e37b6fe5b00083" + "reference": "5a315b092b81f3e920e9daea1a2ae4c66ed298b9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/5b6d9b127ec27bc6db59bf65e2e37b6fe5b00083", - "reference": "5b6d9b127ec27bc6db59bf65e2e37b6fe5b00083", + "url": "https://api.github.com/repos/symfony/console/zipball/5a315b092b81f3e920e9daea1a2ae4c66ed298b9", + "reference": "5a315b092b81f3e920e9daea1a2ae4c66ed298b9", "shasum": "" }, "require": { @@ -5302,7 +5345,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v8.1.10" + "source": "https://github.com/symfony/console/tree/v8.1.11" }, "funding": [ { @@ -5322,7 +5365,8 @@ "type": "tidelift" } ], - "time": "2026-10-28T11:16:19+00:00" + "time": "2026-11-04T07:07:11+00:00", + "published-time": "2026-11-04T11:31:39+00:00" }, { "name": "symfony/css-selector", @@ -5391,20 +5435,21 @@ "type": "tidelift" } ], - "time": "2026-10-18T14:56:39+00:00" + "time": "2026-10-18T14:56:39+00:00", + "published-time": "2026-10-28T18:24:46+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v3.7.1", + "version": "v3.8.1", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "f3202fa1b5097b0af062dc978b32ecf63404e31d" + "reference": "feb1edf4e546af3b85c5caebe8359a20db230ca3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/f3202fa1b5097b0af062dc978b32ecf63404e31d", - "reference": "f3202fa1b5097b0af062dc978b32ecf63404e31d", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/feb1edf4e546af3b85c5caebe8359a20db230ca3", + "reference": "feb1edf4e546af3b85c5caebe8359a20db230ca3", "shasum": "" }, "require": { @@ -5417,7 +5462,7 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.7-dev" + "dev-main": "3.8-dev" } }, "autoload": { @@ -5442,7 +5487,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.7.1" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.8.1" }, "funding": [ { @@ -5462,7 +5507,8 @@ "type": "tidelift" } ], - "time": "2026-06-05T06:23:12+00:00" + "time": "2026-09-16T14:15:10+00:00", + "published-time": "2026-11-04T11:25:34+00:00" }, { "name": "symfony/error-handler", @@ -5543,7 +5589,8 @@ "type": "tidelift" } ], - "time": "2026-10-25T14:40:25+00:00" + "time": "2026-10-25T14:40:25+00:00", + "published-time": "2026-10-28T18:24:13+00:00" }, { "name": "symfony/event-dispatcher", @@ -5629,20 +5676,21 @@ "type": "tidelift" } ], - "time": "2026-08-21T17:47:34+00:00" + "time": "2026-08-21T17:47:34+00:00", + "published-time": "2026-08-22T13:46:58+00:00" }, { "name": "symfony/event-dispatcher-contracts", - "version": "v3.7.1", + "version": "v3.8.1", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "c7de7a00ffb67842132da02ea92988a39ccd9f4e" + "reference": "658e29751424da3ef4758c60f769e59d1b2981eb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/c7de7a00ffb67842132da02ea92988a39ccd9f4e", - "reference": "c7de7a00ffb67842132da02ea92988a39ccd9f4e", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/658e29751424da3ef4758c60f769e59d1b2981eb", + "reference": "658e29751424da3ef4758c60f769e59d1b2981eb", "shasum": "" }, "require": { @@ -5656,7 +5704,7 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.7-dev" + "dev-main": "3.8-dev" } }, "autoload": { @@ -5689,7 +5737,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.7.1" + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.8.1" }, "funding": [ { @@ -5709,20 +5757,21 @@ "type": "tidelift" } ], - "time": "2026-06-05T06:23:12+00:00" + "time": "2026-09-16T14:15:10+00:00", + "published-time": "2026-11-04T11:25:36+00:00" }, { "name": "symfony/finder", - "version": "v8.1.10", + "version": "v8.1.11", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "2f4c0f26106520d82e1b71759d2fb8d32d8b7a43" + "reference": "a2902e479ba5691d20d51d100a715ea19ad2c837" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/2f4c0f26106520d82e1b71759d2fb8d32d8b7a43", - "reference": "2f4c0f26106520d82e1b71759d2fb8d32d8b7a43", + "url": "https://api.github.com/repos/symfony/finder/zipball/a2902e479ba5691d20d51d100a715ea19ad2c837", + "reference": "a2902e479ba5691d20d51d100a715ea19ad2c837", "shasum": "" }, "require": { @@ -5757,7 +5806,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v8.1.10" + "source": "https://github.com/symfony/finder/tree/v8.1.11" }, "funding": [ { @@ -5777,20 +5826,21 @@ "type": "tidelift" } ], - "time": "2026-10-19T17:00:07+00:00" + "time": "2026-11-02T10:58:30+00:00", + "published-time": "2026-11-04T11:31:20+00:00" }, { "name": "symfony/http-foundation", - "version": "v8.1.10", + "version": "v8.1.11", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "79325f87c3a2acc7564ddce9f457046e980e7255" + "reference": "30fa3efe6e736b0d06f5331cc6abe813582c0a26" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/79325f87c3a2acc7564ddce9f457046e980e7255", - "reference": "79325f87c3a2acc7564ddce9f457046e980e7255", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/30fa3efe6e736b0d06f5331cc6abe813582c0a26", + "reference": "30fa3efe6e736b0d06f5331cc6abe813582c0a26", "shasum": "" }, "require": { @@ -5838,7 +5888,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v8.1.10" + "source": "https://github.com/symfony/http-foundation/tree/v8.1.11" }, "funding": [ { @@ -5858,20 +5908,21 @@ "type": "tidelift" } ], - "time": "2026-10-27T12:24:10+00:00" + "time": "2026-11-04T08:39:20+00:00", + "published-time": "2026-11-04T11:31:54+00:00" }, { "name": "symfony/http-kernel", - "version": "v8.1.10", + "version": "v8.1.11", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "924974dbdcdf4cc40d7bb2c65ae83bb6dc67cff1" + "reference": "460658504e26a2794aa614b4fbe6cf9bac2076fe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/924974dbdcdf4cc40d7bb2c65ae83bb6dc67cff1", - "reference": "924974dbdcdf4cc40d7bb2c65ae83bb6dc67cff1", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/460658504e26a2794aa614b4fbe6cf9bac2076fe", + "reference": "460658504e26a2794aa614b4fbe6cf9bac2076fe", "shasum": "" }, "require": { @@ -5948,7 +5999,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v8.1.10" + "source": "https://github.com/symfony/http-kernel/tree/v8.1.11" }, "funding": [ { @@ -5968,7 +6019,8 @@ "type": "tidelift" } ], - "time": "2026-10-28T18:22:19+00:00" + "time": "2026-11-04T11:29:46+00:00", + "published-time": "2026-11-04T11:32:19+00:00" }, { "name": "symfony/mailer", @@ -6048,7 +6100,8 @@ "type": "tidelift" } ], - "time": "2026-10-23T17:06:53+00:00" + "time": "2026-10-23T17:06:53+00:00", + "published-time": "2026-10-28T18:23:52+00:00" }, { "name": "symfony/mime", @@ -6134,7 +6187,8 @@ "type": "tidelift" } ], - "time": "2026-10-28T17:58:38+00:00" + "time": "2026-10-28T17:58:38+00:00", + "published-time": "2026-10-28T18:23:55+00:00" }, { "name": "symfony/polyfill-ctype", @@ -6217,7 +6271,8 @@ "type": "tidelift" } ], - "time": "2026-04-10T16:19:22+00:00" + "time": "2026-04-10T16:19:22+00:00", + "published-time": "2026-04-26T14:44:50+00:00" }, { "name": "symfony/polyfill-intl-grapheme", @@ -6299,7 +6354,8 @@ "type": "tidelift" } ], - "time": "2026-10-15T09:18:53+00:00" + "time": "2026-10-15T09:18:53+00:00", + "published-time": "2026-10-28T10:07:44+00:00" }, { "name": "symfony/polyfill-intl-idn", @@ -6386,7 +6442,8 @@ "type": "tidelift" } ], - "time": "2026-09-23T14:40:04+00:00" + "time": "2026-09-23T14:40:04+00:00", + "published-time": "2026-09-30T10:23:39+00:00" }, { "name": "symfony/polyfill-intl-normalizer", @@ -6471,7 +6528,8 @@ "type": "tidelift" } ], - "time": "2026-09-23T22:02:09+00:00" + "time": "2026-09-23T22:02:09+00:00", + "published-time": "2026-09-30T10:23:47+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -6556,7 +6614,8 @@ "type": "tidelift" } ], - "time": "2026-10-28T09:35:49+00:00" + "time": "2026-10-28T09:35:49+00:00", + "published-time": "2026-10-28T10:07:45+00:00" }, { "name": "symfony/polyfill-php80", @@ -6640,7 +6699,8 @@ "type": "tidelift" } ], - "time": "2026-09-25T15:50:05+00:00" + "time": "2026-09-25T15:50:05+00:00", + "published-time": "2026-09-30T10:23:35+00:00" }, { "name": "symfony/polyfill-php82", @@ -6720,7 +6780,8 @@ "type": "tidelift" } ], - "time": "2026-09-25T15:50:05+00:00" + "time": "2026-09-25T15:50:05+00:00", + "published-time": "2026-09-30T10:23:32+00:00" }, { "name": "symfony/polyfill-php84", @@ -6800,20 +6861,21 @@ "type": "tidelift" } ], - "time": "2026-09-23T22:01:09+00:00" + "time": "2026-09-23T22:01:09+00:00", + "published-time": "2026-09-30T10:23:33+00:00" }, { "name": "symfony/polyfill-php85", - "version": "v1.43.0", + "version": "v1.44.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php85.git", - "reference": "86a42cbcc07adc331481a5ab310a4024bfc227f6" + "reference": "94c794cb5ba51784bc259f11e9f128593297d8dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php85/zipball/86a42cbcc07adc331481a5ab310a4024bfc227f6", - "reference": "86a42cbcc07adc331481a5ab310a4024bfc227f6", + "url": "https://api.github.com/repos/symfony/polyfill-php85/zipball/94c794cb5ba51784bc259f11e9f128593297d8dc", + "reference": "94c794cb5ba51784bc259f11e9f128593297d8dc", "shasum": "" }, "require": { @@ -6860,7 +6922,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php85/tree/v1.43.0" + "source": "https://github.com/symfony/polyfill-php85/tree/v1.44.0" }, "funding": [ { @@ -6880,7 +6942,8 @@ "type": "tidelift" } ], - "time": "2026-09-25T15:46:47+00:00" + "time": "2026-10-30T15:20:09+00:00", + "published-time": "2026-11-15T14:20:22+00:00" }, { "name": "symfony/polyfill-php86", @@ -6960,7 +7023,8 @@ "type": "tidelift" } ], - "time": "2026-09-25T15:46:47+00:00" + "time": "2026-09-25T15:46:47+00:00", + "published-time": "2026-09-30T10:23:43+00:00" }, { "name": "symfony/polyfill-time", @@ -7043,7 +7107,8 @@ "type": "tidelift" } ], - "time": "2026-08-07T13:08:13+00:00" + "time": "2026-08-07T13:08:13+00:00", + "published-time": "2026-08-24T11:45:15+00:00" }, { "name": "symfony/polyfill-uuid", @@ -7126,7 +7191,8 @@ "type": "tidelift" } ], - "time": "2026-09-24T05:20:52+00:00" + "time": "2026-09-24T05:20:52+00:00", + "published-time": "2026-09-30T10:23:49+00:00" }, { "name": "symfony/process", @@ -7191,20 +7257,21 @@ "type": "tidelift" } ], - "time": "2026-10-25T14:40:25+00:00" + "time": "2026-10-25T14:40:25+00:00", + "published-time": "2026-10-28T18:25:20+00:00" }, { "name": "symfony/routing", - "version": "v8.1.10", + "version": "v8.1.11", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "41b32d2c5d907abe2c3ffaa7a112dd7492353822" + "reference": "f3fefc6cad3748d538be970ca81b71f06d7aa8b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/41b32d2c5d907abe2c3ffaa7a112dd7492353822", - "reference": "41b32d2c5d907abe2c3ffaa7a112dd7492353822", + "url": "https://api.github.com/repos/symfony/routing/zipball/f3fefc6cad3748d538be970ca81b71f06d7aa8b3", + "reference": "f3fefc6cad3748d538be970ca81b71f06d7aa8b3", "shasum": "" }, "require": { @@ -7251,7 +7318,7 @@ "url" ], "support": { - "source": "https://github.com/symfony/routing/tree/v8.1.10" + "source": "https://github.com/symfony/routing/tree/v8.1.11" }, "funding": [ { @@ -7271,20 +7338,21 @@ "type": "tidelift" } ], - "time": "2026-10-26T21:55:04+00:00" + "time": "2026-11-04T08:39:20+00:00", + "published-time": "2026-11-04T11:30:59+00:00" }, { "name": "symfony/service-contracts", - "version": "v3.7.3", + "version": "v3.8.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "15e6a07ec2a2c75ceb1b21dd98105ee8456d2257" + "reference": "052852a96fd5e5ebdb617dba22031e41a3300fb5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/15e6a07ec2a2c75ceb1b21dd98105ee8456d2257", - "reference": "15e6a07ec2a2c75ceb1b21dd98105ee8456d2257", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/052852a96fd5e5ebdb617dba22031e41a3300fb5", + "reference": "052852a96fd5e5ebdb617dba22031e41a3300fb5", "shasum": "" }, "require": { @@ -7302,7 +7370,7 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.7-dev" + "dev-main": "3.8-dev" } }, "autoload": { @@ -7338,7 +7406,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.7.3" + "source": "https://github.com/symfony/service-contracts/tree/v3.8.1" }, "funding": [ { @@ -7358,7 +7426,8 @@ "type": "tidelift" } ], - "time": "2026-07-27T15:39:01+00:00" + "time": "2026-10-20T17:38:25+00:00", + "published-time": "2026-11-04T11:25:33+00:00" }, { "name": "symfony/string", @@ -7448,20 +7517,21 @@ "type": "tidelift" } ], - "time": "2026-10-23T17:06:53+00:00" + "time": "2026-10-23T17:06:53+00:00", + "published-time": "2026-10-28T18:24:27+00:00" }, { "name": "symfony/translation", - "version": "v8.1.10", + "version": "v8.1.11", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "8fbbb32f4bbbece5079acb01ab648fd20583fc93" + "reference": "d065adf56e5508293e80d7c140b0a9e043b63e9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/8fbbb32f4bbbece5079acb01ab648fd20583fc93", - "reference": "8fbbb32f4bbbece5079acb01ab648fd20583fc93", + "url": "https://api.github.com/repos/symfony/translation/zipball/d065adf56e5508293e80d7c140b0a9e043b63e9c", + "reference": "d065adf56e5508293e80d7c140b0a9e043b63e9c", "shasum": "" }, "require": { @@ -7521,7 +7591,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v8.1.10" + "source": "https://github.com/symfony/translation/tree/v8.1.11" }, "funding": [ { @@ -7541,20 +7611,21 @@ "type": "tidelift" } ], - "time": "2026-10-25T14:40:25+00:00" + "time": "2026-11-01T22:27:46+00:00", + "published-time": "2026-11-04T11:31:54+00:00" }, { "name": "symfony/translation-contracts", - "version": "v3.7.1", + "version": "v3.8.1", "source": { "type": "git", "url": "https://github.com/symfony/translation-contracts.git", - "reference": "ccb206b98faccc511ebae8e5fad50f2dc0b30621" + "reference": "0a3ae917402632fcba2aeddae9c98332f3d7dd05" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/ccb206b98faccc511ebae8e5fad50f2dc0b30621", - "reference": "ccb206b98faccc511ebae8e5fad50f2dc0b30621", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/0a3ae917402632fcba2aeddae9c98332f3d7dd05", + "reference": "0a3ae917402632fcba2aeddae9c98332f3d7dd05", "shasum": "" }, "require": { @@ -7567,7 +7638,7 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.7-dev" + "dev-main": "3.8-dev" } }, "autoload": { @@ -7603,7 +7674,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/translation-contracts/tree/v3.7.1" + "source": "https://github.com/symfony/translation-contracts/tree/v3.8.1" }, "funding": [ { @@ -7623,7 +7694,8 @@ "type": "tidelift" } ], - "time": "2026-06-05T06:23:12+00:00" + "time": "2026-10-03T08:17:19+00:00", + "published-time": "2026-11-04T11:25:31+00:00" }, { "name": "symfony/uid", @@ -7701,7 +7773,8 @@ "type": "tidelift" } ], - "time": "2026-10-12T14:32:04+00:00" + "time": "2026-10-12T14:32:04+00:00", + "published-time": "2026-10-14T06:48:53+00:00" }, { "name": "symfony/var-dumper", @@ -7788,20 +7861,21 @@ "type": "tidelift" } ], - "time": "2026-10-26T21:55:04+00:00" + "time": "2026-10-26T21:55:04+00:00", + "published-time": "2026-10-28T18:25:26+00:00" }, { "name": "symfony/yaml", - "version": "v8.1.10", + "version": "v8.1.11", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "9de4ff9874dd18b738b9f248398c3e36ef15a1d2" + "reference": "e8266f55160f674f290a5f567cb55e11e21f921b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/9de4ff9874dd18b738b9f248398c3e36ef15a1d2", - "reference": "9de4ff9874dd18b738b9f248398c3e36ef15a1d2", + "url": "https://api.github.com/repos/symfony/yaml/zipball/e8266f55160f674f290a5f567cb55e11e21f921b", + "reference": "e8266f55160f674f290a5f567cb55e11e21f921b", "shasum": "" }, "require": { @@ -7844,7 +7918,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v8.1.10" + "source": "https://github.com/symfony/yaml/tree/v8.1.11" }, "funding": [ { @@ -7864,7 +7938,8 @@ "type": "tidelift" } ], - "time": "2026-10-18T14:56:39+00:00" + "time": "2026-11-04T08:39:20+00:00", + "published-time": "2026-11-04T11:31:03+00:00" }, { "name": "tijsverkoyen/css-to-inline-styles", @@ -7919,7 +7994,8 @@ "issues": "https://github.com/tijsverkoyen/CssToInlineStyles/issues", "source": "https://github.com/tijsverkoyen/CssToInlineStyles/tree/v2.4.0" }, - "time": "2025-12-02T11:56:42+00:00" + "time": "2025-12-02T11:56:42+00:00", + "published-time": "2025-12-11T21:29:16+00:00" }, { "name": "victorycodedev/toastkit", @@ -7988,16 +8064,16 @@ }, { "name": "vlucas/phpdotenv", - "version": "v5.8.0", + "version": "v5.8.1", "source": { "type": "git", "url": "https://github.com/phpdotenv/phpdotenv.git", - "reference": "96149103e62ac67e915f6d2ef59b72dee2e011e0" + "reference": "ba37876e98122ca15151247ce1187d20ee8bf4e0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpdotenv/phpdotenv/zipball/96149103e62ac67e915f6d2ef59b72dee2e011e0", - "reference": "96149103e62ac67e915f6d2ef59b72dee2e011e0", + "url": "https://api.github.com/repos/phpdotenv/phpdotenv/zipball/ba37876e98122ca15151247ce1187d20ee8bf4e0", + "reference": "ba37876e98122ca15151247ce1187d20ee8bf4e0", "shasum": "" }, "require": { @@ -8056,7 +8132,7 @@ ], "support": { "issues": "https://github.com/phpdotenv/phpdotenv/issues", - "source": "https://github.com/phpdotenv/phpdotenv/tree/v5.8.0" + "source": "https://github.com/phpdotenv/phpdotenv/tree/v5.8.1" }, "funding": [ { @@ -8068,7 +8144,8 @@ "type": "tidelift" } ], - "time": "2026-10-25T16:26:19+00:00" + "time": "2026-11-23T00:53:11+00:00", + "published-time": "2026-11-23T00:53:39+00:00" }, { "name": "voku/portable-ascii", @@ -8142,20 +8219,21 @@ "type": "tidelift" } ], - "time": "2026-04-26T05:33:54+00:00" + "time": "2026-04-26T05:33:54+00:00", + "published-time": "2026-04-26T05:43:38+00:00" }, { "name": "workerman/workerman", - "version": "v4.2.1", + "version": "v4.2.2", "source": { "type": "git", "url": "https://github.com/walkor/workerman.git", - "reference": "cafb5a43d93d7d30a16b32a57948581cca993562" + "reference": "5cc996a38944282da2746d6c44b5a4c2997ac66a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/walkor/workerman/zipball/cafb5a43d93d7d30a16b32a57948581cca993562", - "reference": "cafb5a43d93d7d30a16b32a57948581cca993562", + "url": "https://api.github.com/repos/walkor/workerman/zipball/5cc996a38944282da2746d6c44b5a4c2997ac66a", + "reference": "5cc996a38944282da2746d6c44b5a4c2997ac66a", "shasum": "" }, "require": { @@ -8205,7 +8283,8 @@ "type": "patreon" } ], - "time": "2024-11-24T11:45:37+00:00" + "time": "2026-11-13T11:24:40+00:00", + "published-time": "2026-11-13T11:59:53+00:00" } ], "packages-dev": [ @@ -8300,7 +8379,8 @@ "type": "paypal" } ], - "time": "2026-03-29T15:46:14+00:00" + "time": "2026-03-29T15:46:14+00:00", + "published-time": "2026-03-29T15:46:42+00:00" }, { "name": "composer/pcre", @@ -8376,7 +8456,8 @@ "type": "github" } ], - "time": "2026-06-07T11:47:49+00:00" + "time": "2026-06-07T11:47:49+00:00", + "published-time": "2026-06-11T12:12:37+00:00" }, { "name": "composer/xdebug-handler", @@ -8442,24 +8523,25 @@ "type": "tidelift" } ], - "time": "2024-05-06T16:37:16+00:00" + "time": "2024-05-06T16:37:16+00:00", + "published-time": "2024-05-06T17:01:42+00:00" }, { "name": "doctrine/deprecations", - "version": "1.1.6", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "d4fe3e6fd9bb9e72557a19674f44d8ac7db4c6ca" + "reference": "d2e16653a734c8784c1851ad68b02f997b53ca82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/d4fe3e6fd9bb9e72557a19674f44d8ac7db4c6ca", - "reference": "d4fe3e6fd9bb9e72557a19674f44d8ac7db4c6ca", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/d2e16653a734c8784c1851ad68b02f997b53ca82", + "reference": "d2e16653a734c8784c1851ad68b02f997b53ca82", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0" + "php": "^7.4 || ^8.0" }, "conflict": { "phpunit/phpunit": "<=7.5 || >=14" @@ -8488,9 +8570,10 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/1.1.6" + "source": "https://github.com/doctrine/deprecations/tree/1.2.0" }, - "time": "2026-02-07T07:09:04+00:00" + "time": "2026-11-11T10:04:49+00:00", + "published-time": "2026-11-11T10:12:24+00:00" }, { "name": "fakerphp/faker", @@ -8553,7 +8636,8 @@ "issues": "https://github.com/FakerPHP/Faker/issues", "source": "https://github.com/FakerPHP/Faker/tree/v1.24.1" }, - "time": "2024-11-21T13:46:39+00:00" + "time": "2024-11-21T13:46:39+00:00", + "published-time": "2024-11-21T13:47:18+00:00" }, { "name": "fidry/cpu-core-counter", @@ -8615,20 +8699,21 @@ "type": "github" } ], - "time": "2026-09-29T22:11:39+00:00" + "time": "2026-09-29T22:11:39+00:00", + "published-time": "2026-09-29T22:12:43+00:00" }, { "name": "filp/whoops", - "version": "2.18.7", + "version": "2.19.3", "source": { "type": "git", "url": "https://github.com/filp/whoops.git", - "reference": "50670ba239926c50f2073e868f6672f775cd57ec" + "reference": "d5480d53f10069dc4620a39f87e38e8945d47322" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filp/whoops/zipball/50670ba239926c50f2073e868f6672f775cd57ec", - "reference": "50670ba239926c50f2073e868f6672f775cd57ec", + "url": "https://api.github.com/repos/filp/whoops/zipball/d5480d53f10069dc4620a39f87e38e8945d47322", + "reference": "d5480d53f10069dc4620a39f87e38e8945d47322", "shasum": "" }, "require": { @@ -8678,7 +8763,7 @@ ], "support": { "issues": "https://github.com/filp/whoops/issues", - "source": "https://github.com/filp/whoops/tree/2.18.7" + "source": "https://github.com/filp/whoops/tree/2.19.3" }, "funding": [ { @@ -8686,7 +8771,8 @@ "type": "github" } ], - "time": "2026-10-18T13:17:38+00:00" + "time": "2026-11-09T23:30:17+00:00", + "published-time": "2026-11-09T23:32:45+00:00" }, { "name": "hamcrest/hamcrest-php", @@ -8741,7 +8827,8 @@ "issues": "https://github.com/hamcrest/hamcrest-php/issues", "source": "https://github.com/hamcrest/hamcrest-php/tree/v3.0.0" }, - "time": "2026-03-17T11:56:53+00:00" + "time": "2026-03-17T11:56:53+00:00", + "published-time": "2026-06-16T10:52:40+00:00" }, { "name": "jean85/pretty-package-versions", @@ -8801,42 +8888,43 @@ "issues": "https://github.com/Jean85/pretty-package-versions/issues", "source": "https://github.com/Jean85/pretty-package-versions/tree/2.1.1" }, - "time": "2025-03-19T14:43:43+00:00" + "time": "2025-03-19T14:43:43+00:00", + "published-time": "2025-03-19T14:50:06+00:00" }, { "name": "laravel/pail", - "version": "v1.2.7", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/laravel/pail.git", - "reference": "2f7d27dada8effc48b8c424445a69cca7007daaa" + "reference": "72d615ff1104717c1317c6d5d7eab679e43a0408" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pail/zipball/2f7d27dada8effc48b8c424445a69cca7007daaa", - "reference": "2f7d27dada8effc48b8c424445a69cca7007daaa", + "url": "https://api.github.com/repos/laravel/pail/zipball/72d615ff1104717c1317c6d5d7eab679e43a0408", + "reference": "72d615ff1104717c1317c6d5d7eab679e43a0408", "shasum": "" }, "require": { "ext-mbstring": "*", - "illuminate/console": "^10.24|^11.0|^12.0|^13.0", - "illuminate/contracts": "^10.24|^11.0|^12.0|^13.0", - "illuminate/log": "^10.24|^11.0|^12.0|^13.0", - "illuminate/process": "^10.24|^11.0|^12.0|^13.0", - "illuminate/support": "^10.24|^11.0|^12.0|^13.0", - "nunomaduro/termwind": "^1.15|^2.0", + "illuminate/console": "^12.0|^13.0", + "illuminate/contracts": "^12.0|^13.0", + "illuminate/log": "^12.0|^13.0", + "illuminate/process": "^12.0|^13.0", + "illuminate/support": "^12.0|^13.0", + "nunomaduro/termwind": "^2.0", "php": "^8.2", - "symfony/console": "^6.0|^7.0|^8.0" + "symfony/console": "^7.0|^8.0" }, "require-dev": { - "laravel/framework": "^10.24|^11.0|^12.0|^13.0", + "laravel/framework": "^12.69|^13.30", "laravel/pint": "^1.13", - "orchestra/testbench-core": "^8.13|^9.17|^10.8|^11.0", - "pestphp/pest": "^2.20|^3.0|^4.0", - "pestphp/pest-plugin-type-coverage": "^2.3|^3.0|^4.0", + "orchestra/testbench-core": "^10.8|^11.0", + "pestphp/pest": "^3.0|^4.0", + "pestphp/pest-plugin-type-coverage": "^3.0|^4.0", "phpstan/phpstan": "^1.12.27", - "symfony/var-dumper": "^6.3|^7.0|^8.0", - "symfony/yaml": "^6.3|^7.0|^8.0" + "symfony/var-dumper": "^7.0|^8.0", + "symfony/yaml": "^7.0|^8.0" }, "type": "library", "extra": { @@ -8881,20 +8969,21 @@ "issues": "https://github.com/laravel/pail/issues", "source": "https://github.com/laravel/pail" }, - "time": "2026-05-20T22:24:57+00:00" + "time": "2026-11-09T14:56:19+00:00", + "published-time": "2026-11-10T16:07:50+00:00" }, { "name": "laravel/pint", - "version": "v1.32.1", + "version": "v1.32.3", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "006bd7825eb01daf92959d060b89cd9514fe4253" + "reference": "1cf8e0320bed4b3c6e51df92039a5636c3887728" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/006bd7825eb01daf92959d060b89cd9514fe4253", - "reference": "006bd7825eb01daf92959d060b89cd9514fe4253", + "url": "https://api.github.com/repos/laravel/pint/zipball/1cf8e0320bed4b3c6e51df92039a5636c3887728", + "reference": "1cf8e0320bed4b3c6e51df92039a5636c3887728", "shasum": "" }, "require": { @@ -8905,15 +8994,15 @@ "php": "^8.3.0" }, "require-dev": { - "composer/semver": "^3.4.4", - "friendsofphp/php-cs-fixer": "^3.95.25", - "illuminate/view": "^13.31.0", - "larastan/larastan": "^3.11.0", + "composer/semver": "^3.6.0", + "friendsofphp/php-cs-fixer": "^3.95.30", + "illuminate/view": "^13.42.0", + "larastan/larastan": "^3.15.0", "laravel-zero/framework": "^13.0.0", - "laravel/agent-detector": "^2.0.2", - "laravel/prompts": "^0.3.24", + "laravel/agent-detector": "^2.0.5", + "laravel/prompts": "^0.3.27", "mockery/mockery": "^1.6.15", - "nunomaduro/termwind": "^2.4.0", + "nunomaduro/termwind": "^2.4.1", "pestphp/pest": "^4.7.8" }, "bin": [ @@ -8951,32 +9040,33 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2026-09-10T10:47:55+00:00" + "time": "2026-11-11T16:45:13+00:00", + "published-time": "2026-11-11T16:45:39+00:00" }, { "name": "laravel/sail", - "version": "v1.69.0", + "version": "v1.71.0", "source": { "type": "git", "url": "https://github.com/laravel/sail.git", - "reference": "3587ac9d68e8f2eaf36bd9fb003a4555861dca9d" + "reference": "6b56b4f316d1e8048fac6840819b49eaef00cda1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/sail/zipball/3587ac9d68e8f2eaf36bd9fb003a4555861dca9d", - "reference": "3587ac9d68e8f2eaf36bd9fb003a4555861dca9d", + "url": "https://api.github.com/repos/laravel/sail/zipball/6b56b4f316d1e8048fac6840819b49eaef00cda1", + "reference": "6b56b4f316d1e8048fac6840819b49eaef00cda1", "shasum": "" }, "require": { - "illuminate/console": "^9.52.16|^10.0|^11.0|^12.0|^13.0", - "illuminate/contracts": "^9.52.16|^10.0|^11.0|^12.0|^13.0", - "illuminate/support": "^9.52.16|^10.0|^11.0|^12.0|^13.0", - "php": "^8.0", - "symfony/console": "^6.0|^7.0|^8.0", - "symfony/yaml": "^6.0|^7.0|^8.0" + "illuminate/console": "^12.0|^13.0", + "illuminate/contracts": "^12.0|^13.0", + "illuminate/support": "^12.0|^13.0", + "php": "^8.2", + "symfony/console": "^7.0|^8.0", + "symfony/yaml": "^7.0|^8.0" }, "require-dev": { - "orchestra/testbench": "^7.0|^8.0|^9.0|^10.0|^11.0", + "orchestra/testbench": "^10.0|^11.0", "phpstan/phpstan": "^2.0" }, "bin": [ @@ -9014,7 +9104,8 @@ "issues": "https://github.com/laravel/sail/issues", "source": "https://github.com/laravel/sail" }, - "time": "2026-10-08T20:06:52+00:00" + "time": "2026-11-11T14:19:59+00:00", + "published-time": "2026-11-17T15:19:48+00:00" }, { "name": "mockery/mockery", @@ -9096,7 +9187,8 @@ "security": "https://github.com/mockery/mockery/security/advisories", "source": "https://github.com/mockery/mockery" }, - "time": "2026-08-19T19:37:52+00:00" + "time": "2026-08-19T19:37:52+00:00", + "published-time": "2026-08-19T19:38:57+00:00" }, { "name": "myclabs/deep-copy", @@ -9156,40 +9248,41 @@ "type": "github" } ], - "time": "2026-08-11T10:17:44+00:00" + "time": "2026-08-11T10:17:44+00:00", + "published-time": "2026-08-11T10:29:20+00:00" }, { "name": "nunomaduro/collision", - "version": "v8.9.5", + "version": "v8.9.6", "source": { "type": "git", "url": "https://github.com/nunomaduro/collision.git", - "reference": "fb53eacd509a1d303858e2d20cfebf2d630254ec" + "reference": "68806f9257968f23775bee62970cb90925b79d51" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/collision/zipball/fb53eacd509a1d303858e2d20cfebf2d630254ec", - "reference": "fb53eacd509a1d303858e2d20cfebf2d630254ec", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/68806f9257968f23775bee62970cb90925b79d51", + "reference": "68806f9257968f23775bee62970cb90925b79d51", "shasum": "" }, "require": { - "filp/whoops": "^2.18.4", - "nunomaduro/termwind": "^2.4.0", + "filp/whoops": "^2.19.3", + "nunomaduro/termwind": "^2.4.1", "php": "^8.2.0", - "symfony/console": "^7.4.14 || ^8.1.1" + "symfony/console": "^7.4.23 || ^8.1.11" }, "conflict": { "laravel/framework": "<11.48.0 || >=14.0.0", "phpunit/phpunit": "<11.5.50 || >=14.0.0" }, "require-dev": { - "brianium/paratest": "^7.8.5", - "larastan/larastan": "^3.10.0", - "laravel/framework": "^11.48.0 || ^12.56.0 || ^13.20.0", - "laravel/pint": "^1.29.3", - "orchestra/testbench-core": "^9.12.0 || ^10.12.1 || ^11.3.5", - "pestphp/pest": "^3.8.5 || ^4.7.5 || ^5.0.0", - "sebastian/environment": "^7.2.1 || ^8.1.2 || ^9.3.2" + "brianium/paratest": "^7.8.6", + "larastan/larastan": "^3.14.0", + "laravel/framework": "^11.57.1 || ^12.72.0 || ^13.40.0", + "laravel/pint": "^1.30.4", + "orchestra/testbench-core": "^9.24.0 || ^10.16.0 || ^11.6.0", + "pestphp/pest": "^3.8.7 || ^4.7.8 || ^5.3.5", + "sebastian/environment": "^7.2.1 || ^8.1.2 || ^9.3.3" }, "type": "library", "extra": { @@ -9252,7 +9345,8 @@ "type": "patreon" } ], - "time": "2026-07-15T19:09:14+00:00" + "time": "2026-11-10T17:06:52+00:00", + "published-time": "2026-11-10T17:23:22+00:00" }, { "name": "pestphp/pest", @@ -9370,7 +9464,8 @@ "type": "github" } ], - "time": "2026-08-03T20:49:44+00:00" + "time": "2026-08-03T20:49:44+00:00", + "published-time": "2026-08-03T20:50:30+00:00" }, { "name": "pestphp/pest-plugin", @@ -9440,7 +9535,8 @@ "type": "patreon" } ], - "time": "2025-08-20T12:35:58+00:00" + "time": "2025-08-20T12:35:58+00:00", + "published-time": "2025-08-20T12:36:18+00:00" }, { "name": "pestphp/pest-plugin-arch", @@ -9510,7 +9606,8 @@ "type": "github" } ], - "time": "2026-04-10T17:20:19+00:00" + "time": "2026-04-10T17:20:19+00:00", + "published-time": "2026-04-10T17:20:32+00:00" }, { "name": "pestphp/pest-plugin-laravel", @@ -9584,7 +9681,8 @@ "type": "github" } ], - "time": "2026-02-21T00:29:45+00:00" + "time": "2026-02-21T00:29:45+00:00", + "published-time": "2026-02-21T00:30:05+00:00" }, { "name": "pestphp/pest-plugin-mutate", @@ -9660,7 +9758,8 @@ "type": "github" } ], - "time": "2025-08-21T20:19:25+00:00" + "time": "2025-08-21T20:19:25+00:00", + "published-time": "2025-08-21T20:29:53+00:00" }, { "name": "pestphp/pest-plugin-profanity", @@ -9716,7 +9815,8 @@ "support": { "source": "https://github.com/pestphp/pest-plugin-profanity/tree/v4.2.1" }, - "time": "2025-12-08T00:13:17+00:00" + "time": "2025-12-08T00:13:17+00:00", + "published-time": "2025-12-08T00:14:31+00:00" }, { "name": "phar-io/manifest", @@ -9783,7 +9883,8 @@ "type": "github" } ], - "time": "2024-03-03T12:33:53+00:00" + "time": "2024-03-03T12:33:53+00:00", + "published-time": "2024-03-03T12:39:44+00:00" }, { "name": "phar-io/version", @@ -9834,7 +9935,8 @@ "issues": "https://github.com/phar-io/version/issues", "source": "https://github.com/phar-io/version/tree/3.2.1" }, - "time": "2022-02-21T01:04:05+00:00" + "time": "2022-02-21T01:04:05+00:00", + "published-time": "2022-02-21T01:04:30+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -9892,7 +9994,8 @@ "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.2.1" }, - "time": "2025-11-10T21:21:55+00:00" + "time": "2025-11-10T21:21:55+00:00", + "published-time": "2026-09-27T10:14:49+00:00" }, { "name": "phpdocumentor/reflection-docblock", @@ -9957,7 +10060,8 @@ "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/6.0.3" }, - "time": "2026-03-18T20:49:53+00:00" + "time": "2026-03-18T20:49:53+00:00", + "published-time": "2026-03-18T20:51:16+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -10015,20 +10119,21 @@ "issues": "https://github.com/phpDocumentor/TypeResolver/issues", "source": "https://github.com/phpDocumentor/TypeResolver/tree/2.1.0" }, - "time": "2026-09-27T19:32:54+00:00" + "time": "2026-09-27T19:32:54+00:00", + "published-time": "2026-09-28T18:39:55+00:00" }, { "name": "phpstan/phpdoc-parser", - "version": "2.4.0", + "version": "2.4.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "e3647094ed8f0f1f67393d812b793a5143e25af3" + "reference": "af8e840551031d254cfdb3a18a62c3470a309c10" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/e3647094ed8f0f1f67393d812b793a5143e25af3", - "reference": "e3647094ed8f0f1f67393d812b793a5143e25af3", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/af8e840551031d254cfdb3a18a62c3470a309c10", + "reference": "af8e840551031d254cfdb3a18a62c3470a309c10", "shasum": "" }, "require": { @@ -10060,9 +10165,10 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/2.4.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/2.4.1" }, - "time": "2026-10-28T20:28:58+00:00" + "time": "2026-10-30T19:36:28+00:00", + "published-time": "2026-10-30T19:37:11+00:00" }, { "name": "phpunit/php-code-coverage", @@ -10150,7 +10256,8 @@ "type": "tidelift" } ], - "time": "2026-10-03T14:03:50+00:00" + "time": "2026-10-03T14:03:50+00:00", + "published-time": "2026-10-03T14:04:33+00:00" }, { "name": "phpunit/php-file-iterator", @@ -10223,7 +10330,8 @@ "type": "tidelift" } ], - "time": "2026-08-25T14:40:53+00:00" + "time": "2026-08-25T14:40:53+00:00", + "published-time": "2026-08-25T14:41:57+00:00" }, { "name": "phpunit/php-invoker", @@ -10287,7 +10395,8 @@ "type": "github" } ], - "time": "2025-02-07T04:58:58+00:00" + "time": "2025-02-07T04:58:58+00:00", + "published-time": "2025-02-07T04:59:09+00:00" }, { "name": "phpunit/php-text-template", @@ -10359,7 +10468,8 @@ "type": "tidelift" } ], - "time": "2026-10-03T04:51:29+00:00" + "time": "2026-10-03T04:51:29+00:00", + "published-time": "2026-10-03T04:54:39+00:00" }, { "name": "phpunit/php-timer", @@ -10419,7 +10529,8 @@ "type": "github" } ], - "time": "2025-02-07T04:59:38+00:00" + "time": "2025-02-07T04:59:38+00:00", + "published-time": "2025-02-07T04:59:52+00:00" }, { "name": "phpunit/phpunit", @@ -10509,7 +10620,8 @@ "type": "other" } ], - "time": "2026-07-28T13:58:09+00:00" + "time": "2026-07-28T13:58:09+00:00", + "published-time": "2026-07-28T14:01:28+00:00" }, { "name": "sebastian/cli-parser", @@ -10578,7 +10690,8 @@ "type": "tidelift" } ], - "time": "2026-05-17T05:29:34+00:00" + "time": "2026-05-17T05:29:34+00:00", + "published-time": "2026-05-17T05:30:34+00:00" }, { "name": "sebastian/comparator", @@ -10670,7 +10783,8 @@ "type": "tidelift" } ], - "time": "2026-05-21T04:45:25+00:00" + "time": "2026-05-21T04:45:25+00:00", + "published-time": "2026-05-21T04:45:36+00:00" }, { "name": "sebastian/complexity", @@ -10728,7 +10842,8 @@ "type": "github" } ], - "time": "2025-02-07T04:55:25+00:00" + "time": "2025-02-07T04:55:25+00:00", + "published-time": "2025-02-07T04:55:36+00:00" }, { "name": "sebastian/diff", @@ -10807,7 +10922,8 @@ "type": "tidelift" } ], - "time": "2026-08-25T15:35:54+00:00" + "time": "2026-08-25T15:35:54+00:00", + "published-time": "2026-08-25T15:37:16+00:00" }, { "name": "sebastian/environment", @@ -10883,7 +10999,8 @@ "type": "tidelift" } ], - "time": "2026-05-25T13:40:20+00:00" + "time": "2026-05-25T13:40:20+00:00", + "published-time": "2026-05-25T13:40:39+00:00" }, { "name": "sebastian/exporter", @@ -10973,7 +11090,8 @@ "type": "tidelift" } ], - "time": "2026-05-20T04:37:17+00:00" + "time": "2026-05-20T04:37:17+00:00", + "published-time": "2026-05-20T04:37:31+00:00" }, { "name": "sebastian/global-state", @@ -11047,7 +11165,8 @@ "type": "tidelift" } ], - "time": "2026-06-01T15:10:33+00:00" + "time": "2026-06-01T15:10:33+00:00", + "published-time": "2026-06-01T15:20:45+00:00" }, { "name": "sebastian/lines-of-code", @@ -11117,7 +11236,8 @@ "type": "tidelift" } ], - "time": "2026-05-19T16:22:07+00:00" + "time": "2026-05-19T16:22:07+00:00", + "published-time": "2026-05-19T16:22:47+00:00" }, { "name": "sebastian/object-enumerator", @@ -11175,7 +11295,8 @@ "type": "github" } ], - "time": "2025-02-07T04:57:48+00:00" + "time": "2025-02-07T04:57:48+00:00", + "published-time": "2025-02-07T04:58:08+00:00" }, { "name": "sebastian/object-reflector", @@ -11231,7 +11352,8 @@ "type": "github" } ], - "time": "2025-02-07T04:58:17+00:00" + "time": "2025-02-07T04:58:17+00:00", + "published-time": "2025-02-07T04:58:28+00:00" }, { "name": "sebastian/recursion-context", @@ -11307,7 +11429,8 @@ "type": "tidelift" } ], - "time": "2025-08-13T04:44:59+00:00" + "time": "2025-08-13T04:44:59+00:00", + "published-time": "2025-08-13T04:45:10+00:00" }, { "name": "sebastian/type", @@ -11376,20 +11499,21 @@ "type": "tidelift" } ], - "time": "2026-05-20T06:45:45+00:00" + "time": "2026-05-20T06:45:45+00:00", + "published-time": "2026-05-20T06:50:13+00:00" }, { "name": "sebastian/version", - "version": "6.0.1", + "version": "6.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "9e935a16187e14f39b0e79910dabd614972cdb26" + "reference": "a8b6643a19ba6c8125a473623e45fb8cbb0e4159" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/9e935a16187e14f39b0e79910dabd614972cdb26", - "reference": "9e935a16187e14f39b0e79910dabd614972cdb26", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/a8b6643a19ba6c8125a473623e45fb8cbb0e4159", + "reference": "a8b6643a19ba6c8125a473623e45fb8cbb0e4159", "shasum": "" }, "require": { @@ -11422,7 +11546,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/version/issues", "security": "https://github.com/sebastianbergmann/version/security/policy", - "source": "https://github.com/sebastianbergmann/version/tree/6.0.1" + "source": "https://github.com/sebastianbergmann/version/tree/6.0.2" }, "funding": [ { @@ -11442,7 +11566,8 @@ "type": "tidelift" } ], - "time": "2026-10-04T05:50:08+00:00" + "time": "2026-11-09T06:30:55+00:00", + "published-time": "2026-11-09T06:31:20+00:00" }, { "name": "staabm/side-effects-detector", @@ -11494,7 +11619,8 @@ "type": "github" } ], - "time": "2024-10-20T05:08:20+00:00" + "time": "2024-10-20T05:08:20+00:00", + "published-time": "2024-10-20T05:09:39+00:00" }, { "name": "ta-tikoma/phpunit-architecture-test", @@ -11553,7 +11679,8 @@ "issues": "https://github.com/ta-tikoma/phpunit-architecture-test/issues", "source": "https://github.com/ta-tikoma/phpunit-architecture-test/tree/0.8.7" }, - "time": "2026-02-17T17:25:14+00:00" + "time": "2026-02-17T17:25:14+00:00", + "published-time": "2026-02-17T17:26:32+00:00" }, { "name": "theseer/tokenizer", @@ -11603,20 +11730,21 @@ "type": "github" } ], - "time": "2025-12-08T11:19:18+00:00" + "time": "2025-12-08T11:19:18+00:00", + "published-time": "2025-12-08T11:19:39+00:00" }, { "name": "webmozart/assert", - "version": "2.5.0", + "version": "2.5.1", "source": { "type": "git", "url": "https://github.com/webmozarts/assert.git", - "reference": "8a163706bbcac613733dba03f51e13b5eb1bb819" + "reference": "e578132c01bd0c64108386ab20d8217cd175ddec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/8a163706bbcac613733dba03f51e13b5eb1bb819", - "reference": "8a163706bbcac613733dba03f51e13b5eb1bb819", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/e578132c01bd0c64108386ab20d8217cd175ddec", + "reference": "e578132c01bd0c64108386ab20d8217cd175ddec", "shasum": "" }, "require": { @@ -11667,9 +11795,10 @@ ], "support": { "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/2.5.0" + "source": "https://github.com/webmozarts/assert/tree/2.5.1" }, - "time": "2026-10-05T23:14:19+00:00" + "time": "2026-11-15T13:41:13+00:00", + "published-time": "2026-11-15T13:41:42+00:00" } ], "aliases": [ diff --git a/resources/icons/fold-vertical.svg b/resources/icons/fold-vertical.svg deleted file mode 100644 index f24194ca..00000000 --- a/resources/icons/fold-vertical.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/resources/icons/list-tree.svg b/resources/icons/list-tree.svg new file mode 100644 index 00000000..27294fa1 --- /dev/null +++ b/resources/icons/list-tree.svg @@ -0,0 +1 @@ + diff --git a/resources/icons/maximize-2.svg b/resources/icons/maximize-2.svg deleted file mode 100644 index 12b88ce8..00000000 --- a/resources/icons/maximize-2.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/resources/views/native/commit-detail.blade.php b/resources/views/native/commit-detail.blade.php index 9e65131b..d5f4c550 100644 --- a/resources/views/native/commit-detail.blade.php +++ b/resources/views/native/commit-detail.blade.php @@ -5,178 +5,180 @@ @include('native.partials.live-stream-sheet') @include('native.partials.stargazers-sheet') - - - - @if (! $commit && $error === null) - - - - @endif + {{-- + The stack around the page holds the fade over its foot, just above the reply bar (see partials/composer-fade). + Pushed on a wide display, the stack is the readable column, centred in the surface. The rows stay the scroll + view's own children, so auto-scroll-to can still reach them. The workspace's pane is narrow enough already. + --}} + + + {{-- + Each row is a child of the scroll view itself, so it can bring one into view: the commit the page is on, after + tapping another commit in the tree moves the page to it (see CommitDetail::refocus() and $scrollTarget). Every + move animates (auto-scroll-animated), and $scrollRequest as the token makes asking for the same row again scroll + again. With animate-layout the rows the page keeps slide to their new places, and the ones it adds or drops + fade. That needs the scroll view's key, and each row's, to stay the same across the move: the focused commit + is keyed commit-, as the commits above it are. These need NativePHP/mobile-air#736 and + NativePHP/mobile-ui#225; without them the move jumps and a repeat of the same row doesn't scroll. + --}} + + @if (! $commit && $error === null) + + + + @endif - {{-- - The commit is the main thing, near the top: larger, in full ink, with its git date and its replies behind - a toggle in its action row. The commit it replies to shows above it, and what that replies to waits - behind "↑ N earlier commits", since EDGE can't open the page scrolled down to the commit. Opened, the - ancestors, the commit and the rest of its series share one rail, so someone replying to themselves shows - their avatar once. The replies hang under it on the thread's dashed lines, with the rail ending in a dot - above them, ten at a time with "Show more" under the last. A part of a series with more parts after it - has its replies right under it, beside the rail running on, and the later parts follow. Everything - around the commit is muted, and still opens its own page. A deleted reply's own replies open in place, - one level in, ten at a time too, since a deleted commit has no page. - --}} - @if ($earlierCount > 0) - @include('native.partials.earlier-commits', ['count' => $earlierCount, 'lane' => $earlierLane]) - @endif + {{-- + The commit is the main thing, near the top: larger, in full ink, with its git date and its replies behind + a toggle in its action row. The commit it replies to shows above it, and what that replies to waits + behind "↑ N earlier commits", since EDGE can't open the page scrolled down to the commit. Opened, the + ancestors, the commit and the rest of its series share one rail, so someone replying to themselves shows + their avatar once. The replies hang under it on the thread's dashed lines, with the rail ending in a dot + above them, ten at a time with "Show more" under the last. A part of a series with more parts after it + has its replies right under it, beside the rail running on, and the later parts follow. Everything + around the commit is muted, and the commits above it open their other replies in place under them, as the + commit does, from their "N replies", which starts folded, even after the page moves. Tapping any commit in the tree moves the page to it rather than pushing + another (see CommitDetail::refocus()). Every reply's own replies open in place under + it, ten at a time too, as deep as they go, as on the web: they step in up to the web's depth and line up + under the deepest step past it, saying who they answer (see App\Devnull\ThreadRows). - @foreach ($rows as $row) - @php($isFocused = $row->commit->id === $commit?->id) - @php($hasThread = $isFocused && $repliesShown && $replies !== []) - @include('native.partials.commit-row', [ - 'commit' => $row->commit, - 'previousLane' => $row->previousLane, - 'continuesRun' => $row->continuesRun, - 'continuesNext' => $isFocused ? ! $loop->last : null, - 'threadBelow' => $hasThread, - 'focused' => $isFocused, - 'muted' => ! $isFocused, - 'seriesExpanded' => true, - 'withTail' => ! $loop->last, - ]) - @if ($isFocused && $repliesShown && $replies === [] && ! $repliesLoaded && $error === null) - - - - @endif - @if ($hasThread) - @php($railLane = $loop->last ? null : $commit->lane()) - @foreach ($replies as $index => $threadReply) - @php($nested = $tombstoneReplies[$threadReply->id] ?? []) - @php($nestedMore = ($tombstoneCursors[$threadReply->id] ?? null) !== null) - @php($hasNext = ! $loop->last || $repliesCursor !== null) - @php($replyRow = [ - 'reply' => $threadReply, - 'lane' => $commit->lane(), - 'previousLane' => $index === 0 ? null : $replies[$index - 1]->lane(), - 'hasNext' => $hasNext, - 'railLane' => $railLane, - 'tombstones' => true, - 'muted' => true, - 'thread' => $commit, - 'more' => $loop->last && $nested === [] && $repliesCursor !== null ? 'loadMoreReplies' : null, - 'last' => $loop->last && $nested === [], - ]) - @php($rowScope = array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1])) - @php($replyRows->include('reply-'.$threadReply->id, \App\Devnull\RowInputs::for($threadReply, $rowScope), 'native.partials.thread-reply', $replyRow, $rowScope)) - @foreach ($nested as $nestedIndex => $nestedReply) - @php($nestedRow = [ - 'reply' => $nestedReply, - 'lane' => \App\Devnull\Lane::Rail, - 'previousLane' => $nestedIndex === 0 ? null : $nested[$nestedIndex - 1]->lane(), - 'hasNext' => ! $loop->last || $nestedMore, - 'railLane' => $railLane, - 'indent' => 32, - 'spine' => $hasNext ? $threadReply->lane() : null, - 'muted' => true, - 'thread' => $nestedMore ? $threadReply : $commit, - 'more' => match (true) { - ! $loop->last => null, - $nestedMore => "loadMoreTombstoneReplies('{$threadReply->id}')", - $loop->parent->last && $repliesCursor !== null => 'loadMoreReplies', - default => null, - }, - 'last' => $loop->last && $loop->parent->last, - ]) - @php($rowScope = array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1])) - @php($replyRows->include('reply-'.$nestedReply->id, \App\Devnull\RowInputs::for($nestedReply, $rowScope), 'native.partials.thread-reply', $nestedRow, $rowScope)) - @endforeach - @endforeach - @endif - @endforeach + A thread its author wrote as replies to themselves carries on below the commit, on the same rail, as + the web reads it (see SelfThread): each part wears its place ("2/5"), ten show at a time with "Show + more of this thread" under them, and the replies of the last part hang under it as the commit's do. + --}} + {{-- + The rows down to the end of the thread come from CommitDetail::pageRows(), each one child of the scroll + view, in the order it lists them, so the place it gives a row is the row auto-scroll-to brings into + view: the reply you just sent, say (see CommitDetail::scrollToRow()). A row drawn here and not there + would put every row below it one out. Related commits start with a full-width line of their own (see + partials/related-commits), so the last row above them leaves out its hairline, which runs from the + text's edge, and the two don't stack up into a line and a half. Replies end with no hairline on a + commit page, and "No replies yet" keeps the commit's. + --}} + @php($noReplies = $commit && $replyCount === 0 && $repliesLoaded && $series === [] && $threadParts === []) - @if ($commit && $replyCount === 0 && $repliesLoaded && $series === []) - - No replies yet. - + @foreach ($pageRows as $pageRow) + @if ($pageRow['key'] === 'loading-replies') + + + + @elseif ($pageRow['reply'] === null) + @include($pageRow['partial'], $pageRow['data']) + @else + @php($rowScope = array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1])) + @php($replyRows->include('reply-'.$pageRow['reply']->id, \App\Devnull\RowInputs::for($pageRow['reply'], $rowScope), $pageRow['partial'], $pageRow['data'], $rowScope)) @endif + @endforeach - @if ($commit && $related !== []) - @include('native.partials.related-commits') - @endif + @if ($threadMore && $threadParts !== []) + @include('native.partials.thread-continues', ['lane' => $rows[array_key_last($rows)]->commit->lane()]) + @endif - {{-- - A pushed screen clears its overlaid reply bar itself (see Display::replyBarClearance). - The embedded workspace reserves the actual bar height natively, so it only needs the final gap. - --}} - @if ($commit) - - @endif - - + @if ($noReplies) + + No replies yet. + + @endif + + @if ($commit && $related !== []) + @include('native.partials.related-commits') + @endif + + {{-- + A pushed screen runs under its bottom bar, so the page clears the reply bar itself (see + Display::replyBarClearance): the last reply and its actions end above the fade and the bar, keyboard + up or down. The embedded workspace reserves the actual bar height natively, so it only needs the final + gap. + --}} + @if ($commit) + + @endif + @if ($commit && ! \App\Devnull\Display::fadesInBar()) + @include('native.partials.composer-fade', ['ref' => 'reply-fade']) + @endif + + + @if ($commit) {{-- - The bar is painted from its first child's background: native:bottom-bar takes no classes of its own, so - the surface and the hairline above it belong to this column, or the replies show through. On iOS the bar - is bare and the field is a Liquid Glass plate instead, the way the HIG floats controls over content; the - hairline stays as a clear 1pt so the bar keeps the height Display::ReplyBarHeight counts on. + The reply bar, drawn as the Remotes composer is: the field across the top and a row under it with the + tools on the left and the round send button on the right (see partials/composer-box), with the page fading + out above it (see partials/composer-fade). On iOS the bar is Liquid Glass, faded in at the top, so the page + shows through it blurred (see Display::composerBarGlass()). From iOS 26 the system's scroll edge effect + blurs the page under the bar instead, with no fade or glass (see Display::composerEdgeBlur()), and the + field and tools sit in a rounded glass box on it (Display::composerInGlassBox()). On Android it's the + surface, painted from this column. Either fills the strip under the home indicator. + + The bar does everything the composer sheet did for a reply, so a reply never needs the sheet, whose + presenting takes the keyboard down and back up on both platforms. The photo button adds photos from the + library or the camera, which show above the field with their ✕ and ALT. Preview shows the reply as it will + look in the field's place, and pressed again brings the field back. Beside the send button, drop throws + the draft away whenever there's anything in it, after the web's stash@{0} when the draft came back from + the stash, then how long the reply is near the limit. - The expand button opens the reply in the composer sheet, which has the photos and preview the bar has no - room for. It sits where partials/composer-plate puts a composer's tools: inside the plate on iOS, ahead of - the field on Android. + A member of a GitHub organization has the web's Post as at the start of the row, as composer-box's $lead: + the avatar of whoever the reply goes out as, lined up with the field's text, which opens the menu (see + PostAs). The send button is then filled with that one's lane. --}} - - - + @php($replyPostingMe = app(\App\Devnull\Account::class)->user()) + @php($replyPostsAs = $replyPostingMe !== null && \App\Devnull\PostAs::offered($replyAuthor)) + + + @if (\App\Devnull\Display::fadeRowInBar()) + @include('native.partials.composer-fade', ['ref' => 'reply-fade', 'inBar' => true]) + @endif + {{-- - The readable width goes on a child: Android seats the bar's root at the leading edge of a - full-width box, so the root stays full width and centres this. + The rows keep the tint full width. The readable width goes on a child, which they centre, as + Android seats the bar's root at the leading edge of a full-width box. --}} - + {{-- - The people to mention keep a slot above the field, empty and no height when there's no one, so the - field's row never moves. Android rebuilds a row that moves among its siblings, field and all, which - drops the keyboard. + The people to mention and the photos on the reply keep a slot each above the field, empty and + 0.1pt tall when there's nothing in it, so the field's row never moves. Android rebuilds a row that + moves among its siblings, field and all, which drops the keyboard. On iOS an empty slot would + otherwise take 10pt of the bar, and EDGE drops a height of 0. --}} @php($mentioning = ($mention['field'] ?? null) === 'reply' && ($mentionPeople !== [] || $mentionOrganizations !== [])) - + @include('native.partials.mention-suggestions', ['field' => 'reply', 'label' => 'Mention a developer']) - - @include('native.partials.composer-plate', [ + @php($showsPhotos = $replyImages !== [] && ! $replyPreviewing) + + @if ($showsPhotos) + @include('native.partials.composer-photos', ['photos' => $replyImages, 'photoRef' => 'reply-photo']) + @endif + + + @php($hasDraft = trim($reply) !== '' || $replyImages !== []) + @php($photosFull = count($replyImages) >= \App\Devnull\DraftImages::MaxImages) + @include('native.partials.composer-box', [ 'ref' => 'reply', - 'field' => 'native.partials.reply-field', - 'tools' => [['ref' => 'reply-expand', 'icon' => \App\Icons\Lucide::Maximize2, 'label' => 'Reply with photos or a preview', 'press' => "replyInSheet('{$commit->id}')"]], + 'field' => $replyPreviewing ? 'native.partials.reply-preview' : 'native.partials.reply-field', + 'lead' => $replyPostsAs ? [['native.partials.post-as', ['ref' => 'reply-post-as', 'me' => $replyPostingMe, 'picked' => $replyAuthor, 'method' => 'postAsInReply', 'size' => 28, 'inset' => 'pl-3']]] : [], + 'tools' => [ + ['ref' => 'reply-add-photos', 'icon' => \App\Icons\Lucide::ImagePlus, 'label' => $photosFull ? 'A reply can have up to 3 photos' : 'Add photos', 'menu' => $photosFull ? null : \App\Devnull\ComposerMenu::photoItems(), 'disabled' => $photosFull], + ['ref' => 'reply-preview', 'icon' => \App\Icons\Lucide::Eye, 'label' => $replyPreviewing ? 'Edit' : 'Preview', 'press' => 'toggleReplyPreview', 'active' => $replyPreviewing], + ], + 'trail' => [ + ...($hasDraft ? [['native.partials.stash-label', ['ref' => 'reply-stash', 'drop' => 'dropReplyStash', 'size' => 'text-xs', 'restored' => $replyRestored]]] : []), + ['native.partials.body-counter', ['body' => $reply, 'ref' => 'reply-budget']], + ], + 'send' => [ + 'ref' => 'send-reply', + 'label' => 'Reply', + 'press' => 'sendReply', + 'disabled' => ! \App\Devnull\Data\Draft::canCommit($reply, $replyImages), + 'colour' => $replyPostingMe === null ? $myColour : \App\Devnull\PostAs::colour($replyPostingMe, \App\Devnull\PostAs::author($replyAuthor)), + ], ]) - @include('native.partials.body-counter', ['body' => $reply, 'ref' => 'reply-budget']) - Reply @if (\App\Devnull\Data\CommitBody::hasOversizedUrl($reply)) Each link must not be greater than {{ \App\Devnull\Data\BodyLink::MaxLength }} characters. @endif - {{-- - A reply stashed when you left the commit comes back with the web's stash@{0} and drop under it. - Photos attached in the sheet show as a count on the left, which opens the sheet on them, and Reply - sends them. - --}} - @if ($replyRestored || $replyImages !== []) - - @if ($replyImages !== []) - @php($photoCount = \App\Devnull\Display::count(count($replyImages), 'photo', 'photos')) - - - - {{ $photoCount }} - - - - @endif - @if ($replyRestored) - @include('native.partials.stash-label', ['ref' => 'reply-stash', 'drop' => 'dropReplyStash', 'size' => 'text-xs']) - @endif - - @endif + diff --git a/resources/views/native/conversation.blade.php b/resources/views/native/conversation.blade.php index 51519304..07f45bf8 100644 --- a/resources/views/native/conversation.blade.php +++ b/resources/views/native/conversation.blade.php @@ -69,29 +69,44 @@ @if ($pinned !== []) @include('native.partials.pinned-bar') @endif + + {{-- The thread fades out above the composer instead of meeting it at a hard edge. On iOS the bar draws the fade. --}} + @if ($loaded && ! \App\Devnull\Display::fadesInBar()) + @include('native.partials.composer-fade', ['ref' => 'composer-fade']) + @endif @if ($loaded) {{-- - The composer, drawn as the reply bar on a commit's page is (see partials/composer-plate): on iOS the bar is - bare and the field is a Liquid Glass plate with the tools inside it, on Android the bar is the surface with - a hairline and the tools lead it. The web's tools, photos, the microphone and Ping, open from one + here. Above the field - sit what you're replying to and the photos on the draft, on glass of their own on iOS. While the thread - can't take a message, the bar is solid on both, with why in the field's place. + The composer: the field over a row holding the + and the round send button (see partials/composer-box), + with the thread fading out above it (see partials/composer-fade) rather than meeting a line. On iOS the bar + is Liquid Glass, faded in at the top, so the thread shows through it blurred (see + Display::composerBarGlass()). From iOS 26 the system's scroll edge effect blurs the thread under the bar + instead, with no fade or glass (see Display::composerEdgeBlur()), and the field and tools sit in a rounded + glass box on it (Display::composerInGlassBox()). On Android it's the surface. Either fills the strip under + the home indicator. + The web's tools, photos, the microphone and Ping, open from the one +. Above the field sit the people to + mention, what you're replying to and the photos on the draft. While the thread can't take a message, why + goes in the field's place. --}} - - - + + + @if (\App\Devnull\Display::fadeRowInBar()) + @include('native.partials.composer-fade', ['ref' => 'composer-fade', 'inBar' => true]) + @endif + @if ($canPush) {{-- The members to mention, what you're replying to and the photos on the draft each keep a slot, empty and no height when there's nothing in it, so the field's row never moves. Android rebuilds - a row that moves among its siblings, field and all, which drops the keyboard. + a row that moves among its siblings, field and all, which drops the keyboard. An empty slot is + h-[0.1]: on iOS an empty one otherwise takes 10 points of the bar, and EDGE drops a height of 0. --}} - + @php($mentioning = ($mention['field'] ?? null) === 'draft' && ($mentionPeople !== [] || $mentionOrganizations !== [])) + @include('native.partials.mention-suggestions', ['field' => 'draft', 'heading' => ($mention['query'] ?? null) === '' ? 'Members' : null]) - + @if ($replyTo) @@ -105,30 +120,28 @@ @endif - + @include('native.partials.composer-photos', ['photos' => $photos, 'photoRef' => 'photo', 'describeClass' => 'ios:glass']) - {{-- The same room above and below the field, so the bar sits evenly on the keyboard. --}} - - {{-- - The web's tools, photos, a voice note and Ping, are one + here, which opens them in a menu (see - ComposerMenu), so the field keeps its room. A voice note takes the field's place, and the +'s, - while it's recorded and waits to be pushed. - --}} - @include('native.partials.composer-plate', [ + {{-- + The box keeps its row, and the row its place among the bar's, so the field inside never moves. + A voice note takes the field's place, and the +'s, while it's recorded and waits to be pushed. + --}} + + @include('native.partials.composer-box', [ 'ref' => 'message', 'field' => $recorder === null ? 'native.partials.message-field' : 'native.partials.voice-recorder', 'tools' => $recorder !== null ? [] : [ ['ref' => 'composer-tools', 'icon' => \App\Icons\Lucide::Plus, 'label' => 'Photos, a voice note or a ping', 'menu' => \App\Devnull\ComposerMenu::items(count($photos) >= \App\Devnull\DraftImages::MaxImages, trim($draft) !== '' || $photos !== [], $pingLabel)], ], + 'trail' => [['native.partials.message-length']], + 'send' => [ + 'ref' => 'push', + 'label' => 'Push', + 'press' => 'send', + 'disabled' => $recorder === null ? trim($draft) === '' && $photos === [] : $recorder === 'stopping' || ($recorder === 'recording' && ! $recordingStarted), + ], ]) - @php($length = mb_strlen($draft)) - @if ($length >= 1600) - {{ number_format($length) }}/2,000 - @endif - - Push - @else @@ -153,6 +166,7 @@ @endif @endif + @endif diff --git a/resources/views/native/partials/body-counter.blade.php b/resources/views/native/partials/body-counter.blade.php index 0c50a5c2..327a2a86 100644 --- a/resources/views/native/partials/body-counter.blade.php +++ b/resources/views/native/partials/body-counter.blade.php @@ -1,11 +1,8 @@ {{-- The web's BodyCounter, next to Commit or Reply: nothing until 200 characters are left, then the count in mono, amber - from 20 and Rm Red at none. Before that, a body long enough to be folded in lists shows the fold icon instead. + from 20 and Rm Red at none. --}} @php($remaining = \App\Devnull\Data\Commit::MaxLength - (($literal ?? false) ? mb_strlen(\App\Devnull\Data\CommitBody::normalize($body)) : \App\Devnull\Data\CommitBody::characterCount($body))) -@php($isCounting = $remaining <= \App\Devnull\Data\Commit::CountFrom) -@if ($isCounting) +@if ($remaining <= \App\Devnull\Data\Commit::CountFrom) {{ $remaining }} -@elseif (\App\Devnull\Data\Commit::isFoldedInLists($body)) - @endif diff --git a/resources/views/native/partials/commit-actions.blade.php b/resources/views/native/partials/commit-actions.blade.php index 4ca38578..b8371dc7 100644 --- a/resources/views/native/partials/commit-actions.blade.php +++ b/resources/views/native/partials/commit-actions.blade.php @@ -10,14 +10,15 @@ in place, as on the web (see Concerns\ExpandsThreads); elsewhere it opens the commit with its replies showing. Like the web, someone else's commit that isn't approved gets no star or Quote. devnull doesn't let you star your own commits, so on those the star is the count, which opens who starred it (see OpensStargazers), or a faint star until - there are any, as on the web. + there are any, as on the web. An organization's commit is yours while you're a member of it, whoever posted it + ($ownership, see Ownership). Quote opens a sheet to write the quote in, over the commit being quoted (see commit-sheet). The pastel is the web's: the pastel de nata and how many the commit was given, always, even 0. On someone else's published commit it gives one more per tap; on your own, or one that isn't published, it's just the count. It - only shows in pastéis mode ($pasteis), and never on an organization's commit, since organizations can't be given - pastéis. + only shows in pastéis mode ($pasteis), and never on an organization's commit, which takes no pastéis, as the web + leaves it off. A star you give and a pastel pop as they do on the web (see PopsReactions). A commit with a quote or a reply you started and didn't send marks that button, as the web does with stash@{0} beside its label. That doesn't fit the row, so here it's a dot after the label, inside the button. @@ -52,10 +53,11 @@ @php($iconSize = $compact ? 14 : 16) @php($labelSize = $compact ? 'text-xs' : 'text-[13px]') @php($viewer ??= app(\App\Devnull\Account::class)->user()) +@php($ownership ??= app(\App\Devnull\Account::class)->ownership()) @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 = $ownership->owns($commit)) @php($canQuote = $commit->isApproved() || $isOwn) @php($showsReplies = $withReplies && ! $commit->isDeleted() && $repliesCount > 0) @php($endDot ??= null) @@ -120,7 +122,7 @@ - + diff --git a/resources/views/native/partials/commit-poll.blade.php b/resources/views/native/partials/commit-poll.blade.php index 4e8f5242..262ecb71 100644 --- a/resources/views/native/partials/commit-poll.blade.php +++ b/resources/views/native/partials/commit-poll.blade.php @@ -4,14 +4,14 @@ its percentage in mono on the right, and "4 votes · 3h left" under them all. Without results, the options are plain boxes over the time left. - On someone else's published commit whose poll is open and has no vote of yours yet, you vote as on the web: tap an - option to pick it, its box in Commit Blue on Blue Wash with its radio filled, then Vote, beside the time left, - since votes are final (see VotesOnPolls). Vote spins while it goes, and the poll then shows its results. $static - is the quote card's copy, which never votes. + On a published commit that isn't yours or your organization's, whose poll is open and has no vote of yours yet, you + vote as on the web: tap an option to pick it, its box in Commit Blue on Blue Wash with its radio filled, then Vote, + beside the time left, since votes are final (see VotesOnPolls). Vote spins while it goes, and the poll then shows + its results. $static is the quote card's copy, which never votes. --}} @php($poll = $commit->poll) @php($static ??= false) -@php($canVote = ! $static && $commit->canBeVotedOnBy($viewer ?? app(\App\Devnull\Account::class)->user())) +@php($canVote = ! $static && $commit->canBeVotedOnBy($ownership ?? app(\App\Devnull\Account::class)->ownership())) @php($choice = $pollChoices[$commit->id] ?? null) @php($isVoting = in_array($commit->id, $voting ?? [], true)) diff --git a/resources/views/native/partials/commit-row-content.blade.php b/resources/views/native/partials/commit-row-content.blade.php index cb47a630..347af90b 100644 --- a/resources/views/native/partials/commit-row-content.blade.php +++ b/resources/views/native/partials/commit-row-content.blade.php @@ -11,9 +11,13 @@ row is fixed here, so they meet it on both platforms. On a commit page the commit it's about ($focused) is the main thing: a larger name and body in full ink, its time, - which tapped says when in your timezone, its hash, and its replies behind a toggle in its action row. The commits around it ($muted) step back: + which tapped says when in your timezone, its hash at the top right, and its replies behind a toggle in its action row. The commits around it ($muted) step back: smaller and in muted ink, with a smaller avatar and action row. They still open their own pages. + A commit in a thread its author wrote as replies to themselves wears its place in it ($threadPosition, "2/5"), and + one its author carried on that way links to that thread ($showsThread), as the web's "Show thread" does (see + SelfThread). $repliesBelow says its replies show under the row, so its action row leaves out "› N replies". + A commit posted straight to a guild's board says so under its header (see guild-badge), except in search. A commit you just made that devnull doesn't have yet is staged: dimmed, with the staged chip and no actions, until @@ -37,6 +41,9 @@ @php($withTail ??= ! $focused) @php($continuesNext ??= null) @php($threadBelow ??= false) +@php($threadPosition ??= null) +@php($showsThread ??= $commit->continuationId !== null) +@php($repliesBelow ??= false) @php($inFeed = $continuesNext !== null) @php($endsWithDot = $inFeed && ! $continuesRun && ! $continuesNext) @php($laterParts = $seriesExpanded ? 0 : $commit->laterSeriesParts()) @@ -45,7 +52,7 @@ {{-- The action row's 36pt reaches 6pt into the inset below it, as its buttons are taller than their icons. --}} @php($bottom = $threadBelow && $focused ? 0 : $inset - 6 + ($hairline ? 1 : 0)) @php($padding = 'pt-['.$inset.']'.($bottom > 0 ? ' pb-['.$bottom.']' : '')) -@php($repliesLine = ! $commit->isStaged() && ! $commit->isDeleted() && ($focused ? ($replyCount ?? $commit->repliesCount) : $commit->repliesCount) > 0 ? 40 : 0) +@php($repliesLine = ! $commit->isStaged() && ! $commit->isDeleted() && ($focused || ! $repliesBelow) && ($focused ? ($replyCount ?? $commit->repliesCount) : $commit->repliesCount) > 0 ? 40 : 0) @php($dotInActions = $endsWithDot && ! $commit->isStaged()) @php($metaSize = $muted ? 'text-xs' : 'text-[13px]') @@ -64,9 +71,17 @@ @if ($commit->isSeriesPart()) @include('native.partials.series-position') @endif + @if ($threadPosition !== null) + @include('native.partials.thread-position') + @endif @unless ($commit->isApproved()) @include('native.partials.status-chip', ['status' => $commit->status]) @endunless + @if ($focused) + {{-- Its short hash, at the top right of the row, as the web has it at the right of the page's header. --}} + + {{ $commit->shortHash }} + @endif @if ($commit->guild !== null && ! ($hidesGuildBadge ?? false)) @@ -95,8 +110,8 @@ @endif - @if ($focused) - {{ $commit->shortHash }} + @if ($showsThread && ! $focused) + @include('native.partials.show-thread') @endif @if ($commit->isStaged()) @@ -109,7 +124,7 @@ 'endDot' => $dotInActions ? $commit->lane() : null, ]) @else - @include('native.partials.commit-actions', ['compact' => $muted, 'endDot' => $dotInActions ? $commit->lane() : null]) + @include('native.partials.commit-actions', ['compact' => $muted, 'withReplies' => ! $repliesBelow, 'endDot' => $dotInActions ? $commit->lane() : null]) @endif diff --git a/resources/views/native/partials/commit-row.blade.php b/resources/views/native/partials/commit-row.blade.php index a5782409..1ba0640e 100644 --- a/resources/views/native/partials/commit-row.blade.php +++ b/resources/views/native/partials/commit-row.blade.php @@ -15,7 +15,7 @@ @if ($commit->isDeleted()) @include('native.partials.commit-tombstone') @elseif ($focused) - + @include('native.partials.commit-row-content') @else diff --git a/resources/views/native/partials/commit-sheet.blade.php b/resources/views/native/partials/commit-sheet.blade.php index 8fa3ebd3..67e43903 100644 --- a/resources/views/native/partials/commit-sheet.blade.php +++ b/resources/views/native/partials/commit-sheet.blade.php @@ -21,14 +21,24 @@ field, its placeholder in it, and Open issue (the same check) in Commit's place in the bar. Opened, the sheet says so, with View issue and Done. + A member of a GitHub organization sees who the commit goes out as above the field, as the web's composer shows its + avatar: theirs, or the organization's, with its name and handle. A tap opens Post as (see PostAs). Commit is then + filled with the organization's lane. An issue always comes from you, so it hides there. + A commit's page opens its reply here too, as "Reply to @handle", with the commit being answered as a static card over the field, for the photos and the preview its reply bar has no room for. Commit says Reply there. - While the caret is after an "@handle", the people to mention show right under the field, as the web's composer lists - them (see SuggestsMentions): for a bare "@" in a new commit, the people you follow, under that heading. The field - keeps the keyboard up through presses in the sheet (keep-focus), so picking someone leaves you typing after them. + While the caret is after an "@handle", the people to mention show as the web's composer lists them (see + SuggestsMentions): for a bare "@" in a new commit, the people you follow, under that heading. They float over the + field just under the caret's line, which the field reports (@caretChange), as tall as their rows, up to six. When + that doesn't fit above the field's bottom, the field gets shorter instead, ending on the caret's line, and the + list goes under it, down to the toolbar and over a quoted commit or poll (see ComposerSheet). The field fills + again once they're gone, and both moves are animated. The field keeps the keyboard up through presses in the sheet + (keep-focus), so picking someone leaves you typing after them. - Under what's being written come its photos and the poll editor. A toolbar is pinned to the bottom of the sheet, so + The sheet doesn't scroll. The field fills the space between the author row and the toolbar, less what's under it: + the photos as a strip of 80pt squares, the poll editor, the commit being quoted, or "Submit at", each at its own + height, with 12pt clear of the toolbar, as the field leaves under "Replying to". Only the field scrolls its text. A toolbar is pinned to the bottom of the sheet, so it stays just above the keyboard: the tools on the left, photos, the camera, a poll (not on a reply) and the preview, which shows the draft as the commit it would become in place of the field (see AttachesToCommits), and stash@{0} and the counter on the right. An issue draft has no tools, as on the web. With photos, Commit spins while @@ -53,6 +63,8 @@ @php($quoting = $sheetView === 'quote') @php($replying = $sheetView === 'reply') @php($issueCommand = $sheetIssue === null ? null : \App\Devnull\IssueCommand::from($sheetIssue)) + @php($postingMe = app(\App\Devnull\Account::class)->user()) + @php($postsAs = $postingMe !== null && ! $issueCommand && \App\Devnull\PostAs::offered($sheetAuthor)) @php($canCommit = \App\Devnull\Data\Draft::canCommit($sheetBody, $sheetImages, $replying ? null : $sheetPoll)) @@ -62,62 +74,99 @@ @include('native.partials.sheet-bar-button', ['ref' => 'sheet-open-issue', 'icon' => \App\Icons\Lucide::Check, 'label' => 'Open issue', 'main' => true, 'loading' => $openingIssue, 'press' => $openingIssue || ! \App\Devnull\IssueCommand::fits($sheetBody) ? null : 'openIssueFromSheet']) @else @php($schedulingThis = $scheduling && $sheetView === 'compose') - @include('native.partials.sheet-bar-button', ['ref' => 'sheet-commit', 'icon' => \App\Icons\Lucide::Check, 'label' => match (true) { $schedulingThis => 'Schedule commit', $replying => 'Reply', default => 'Commit' }, 'main' => true, 'loading' => $sendingSchedule, 'press' => $sendingSchedule || ! $canCommit || ($schedulingThis && ! $hasScheduledTime) ? null : 'commitFromSheet']) + @include('native.partials.sheet-bar-button', ['ref' => 'sheet-commit', 'icon' => \App\Icons\Lucide::Check, 'label' => match (true) { $schedulingThis => 'Schedule commit', $replying => 'Reply', default => 'Commit' }, 'main' => true, 'mainColour' => $postingMe === null ? $myColour : \App\Devnull\PostAs::colour($postingMe, \App\Devnull\PostAs::author($sheetAuthor)), 'loading' => $sendingSchedule, 'press' => $sendingSchedule || ! $canCommit || ($schedulingThis && ! $hasScheduledTime) ? null : 'commitFromSheet']) @endif - - - @if ($sheetError) - {{ $sheetError }} - @endif + {{-- + Nothing here scrolls but the field (or the preview in its place). What's over the field and under + it take their own height, and the field (h-full in a flex-1 slot) takes what's left between them + and the toolbar. Each part has a keyed slot that's always drawn, empty or not, so the field never + moves among its siblings: Android rebuilds a node that does, and the keyboard goes down with it. + --}} + @php($sheetLayout = \App\Devnull\ComposerSheet::class) + @php($linkTooLong = ! $issueCommand && \App\Devnull\Data\CommitBody::hasOversizedUrl($sheetBody)) + @php($pollShown = $sheetPoll !== null && ! $replying) + @php($guildHint = $sheetGuild !== null && $sheetView === 'compose') + @php($offersIssues = ! $quoting && ! $scheduling && ! $replying && ! $issueCommand && $sheetGuild === null) + @php($issueCommands = $offersIssues && $sheetTyped ? \App\Devnull\IssueCommand::suggested($sheetBody) : []) + @php($issueHint = $offersIssues && ! $issueHintsDismissed ? \App\Devnull\IssueCommand::hinted($sheetBody) : null) + @php($hasAbove = $postsAs || $sheetError || $issueCommand || $replying) + + @if ($postsAs) + + @include('native.partials.post-as', ['ref' => 'sheet-post-as', 'me' => $postingMe, 'picked' => $sheetAuthor, 'method' => 'postAsInSheet', 'size' => 36, 'withName' => true]) + + @endif - @if ($issueCommand) - @include('native.partials.issue-badge', ['command' => $issueCommand]) - @endif + @if ($sheetError) + {{ $sheetError }} + @endif - @if ($replying) - @include('native.partials.quoted-commit', ['quoted' => $sheetCommit, 'static' => true, 'label' => 'Replying to']) - @endif + @if ($issueCommand) + @include('native.partials.issue-badge', ['command' => $issueCommand]) + @endif - @if ($previewing) - @include('native.partials.composer-preview') - @else + @if ($replying) + @include('native.partials.quoted-commit', ['quoted' => $sheetCommit, 'static' => true, 'label' => 'Replying to']) + @endif + + @php($sheetMentionsShown = ! $previewing && ($mention['field'] ?? null) === 'sheetBody' && ($mentionPeople !== [] || $mentionOrganizations !== [])) + @php($sheetMentions = $sheetMentionsShown ? $sheetLayout::mentionLayout($sheetCaret, count($mentionPeople) + count($mentionOrganizations), $sheetLayout::mentionHeading($mention, $sheetView)) : null) + {{-- + animate-layout: when the mention list comes or goes (or photos, the poll, the preview), the field + slot's new height and the parts under it slide into place rather than jump. The parts keep their + keys, so they're matched from one frame to the next. + --}} + + @if ($previewing) + + + @include('native.partials.composer-preview', [ + 'ref' => 'sheet-draft', + 'body' => $sheetBody, + 'preview' => $sheetPreview, + 'images' => $sheetImages, + 'poll' => $replying ? null : $sheetPoll, + 'pollLength' => $sheetPollLength, + 'quoted' => $quoting ? $sheetCommit : null, + ]) + + + @else + {{-- Shorter while the mention list needs the room under it (see ComposerSheet::mentionLayout()), the slot keeps its key and place, so the field stays the same view. --}} + - - @include('native.partials.mention-suggestions', [ - 'field' => 'sheetBody', - 'heading' => ($mention['query'] ?? null) === '' && $sheetView === 'compose' ? 'People you follow' : null, - 'label' => 'Mention a developer', - 'class' => 'w-full py-1 rounded-md border border-theme-hairline bg-theme-surface', - ]) - - @if ($sheetGuild !== null && $sheetView === 'compose') + + @php($hasBelow = $guildHint || $linkTooLong || $sheetImages !== [] || $pollShown || $quoting || $scheduling || $issueCommands !== [] || $issueHint !== null) + + @if ($guildHint) Posted to this guild, not your profile log. @endif - @if (! $issueCommand && \App\Devnull\Data\CommitBody::hasOversizedUrl($sheetBody)) + @if ($linkTooLong) Each link must not be greater than {{ \App\Devnull\Data\BodyLink::MaxLength }} characters. @endif @include('native.partials.composer-photos') - @if ($sheetPoll !== null && ! $replying) + @if ($pollShown) @include('native.partials.poll-editor') @endif @@ -125,17 +174,39 @@ class="w-full text-theme-ink" @include('native.partials.quoted-commit', ['quoted' => $sheetCommit, 'static' => true]) @elseif ($scheduling) @include('native.partials.schedule-picker') - @elseif (! $replying && ! $issueCommand && $sheetGuild === null) - @include('native.partials.issue-suggestions', [ - 'suggestions' => $sheetTyped ? \App\Devnull\IssueCommand::suggested($sheetBody) : [], - 'hint' => $issueHintsDismissed ? null : \App\Devnull\IssueCommand::hinted($sheetBody), - ]) + @elseif ($offersIssues) + @include('native.partials.issue-suggestions', ['suggestions' => $issueCommands, 'hint' => $issueHint]) @endif - @endif + - - - {{-- Pinned under the scroll view, so it rides just above the keyboard, and above the home indicator without it. --}} + {{-- + The people to mention, out of the layout so nothing moves when they come and go unless the + field has to make room for them: just under the caret's line, as tall as their rows, or + under the shortened field down to the toolbar (see ComposerSheet::mentionLayout()). They + scroll inside past six rows, or when even the shortened field leaves less room. On Liquid + Glass on iOS, like the reply bar's, and on a raised surface on Android. + --}} + @if ($sheetMentions !== null) + + + @include('native.partials.mention-suggestions', [ + 'field' => 'sheetBody', + 'heading' => $sheetLayout::mentionHeading($mention, $sheetView) ? 'People you follow' : null, + 'label' => 'Mention a developer', + 'class' => 'w-full py-1', + // This scroll view scrolls them; the partial's own six-row one would be a second. + 'scrolls' => false, + ]) + + + @endif + @endif + + {{-- Pinned under the field and what's around it, so it rides just above the keyboard, and above the home indicator without it. --}} @unless ($issueCommand) diff --git a/resources/views/native/partials/composer-box.blade.php b/resources/views/native/partials/composer-box.blade.php new file mode 100644 index 00000000..fb84f564 --- /dev/null +++ b/resources/views/native/partials/composer-box.blade.php @@ -0,0 +1,39 @@ +{{-- + A composer bar's field, tools and send button, laid out the way the Claude and Messages apps lay theirs out: the + field across the top, growing to its five lines, and under it a row with the tools on the left and a round send + button in your colour on the right. The same on both platforms. Before iOS 26 nothing is drawn around them: they sit + straight on the bar, which is glass on iOS and the surface on Android, under the fade at its top (see + partials/composer-fade). From iOS 26 they sit in a rounded Liquid Glass box over the system's scroll edge effect, + unless Display::ComposerInGlassBox is off (see Display::composerBox()). + + $ref names the box ("{$ref}-box", also its key, so the field keeps its place as rows above it come and go) and its + rows ("{$ref}-field-row", "{$ref}-actions"). $field is the partial that draws the field, keyed itself, so it stays + the same view while the tools and everything else in the row under it change. $tools are composer-tool's, in the + web's order. $lead and $trail, when there are any, are partials with their data ([view, data]) for the start of the + row, ahead of the tools, and for the end, left of the send button, such as the count of a long draft. $send is + send-button's: its ref, label, method, and whether it can send yet. + + The field's text lines up with the tools' icons under it. The field sits a little nearer the fade above it than + the row under it: the row around the box has no top padding, and the field row leaves 8pt under the field. In the + glass box the field sits as far under the box's edge as above the tools (Display::composerFieldTop()). +--}} +@php($lead ??= []) +@php($trail ??= []) + + + @include($field) + + + @foreach ($lead as $part) + @include($part[0], $part[1] ?? []) + @endforeach + @foreach ($tools as $tool) + @include('native.partials.composer-tool', $tool) + @endforeach + + @foreach ($trail as $part) + @include($part[0], $part[1] ?? []) + @endforeach + @include('native.partials.send-button', $send) + + diff --git a/resources/views/native/partials/composer-fade.blade.php b/resources/views/native/partials/composer-fade.blade.php new file mode 100644 index 00000000..023b2a87 --- /dev/null +++ b/resources/views/native/partials/composer-fade.blade.php @@ -0,0 +1,13 @@ +{{-- + The soft edge between a screen and its composer bar: a gradient from see-through at the top to the bar's surface at + the bottom, where the bar's rows start, so whatever scrolls down to the bar fades out instead of meeting a hard + line. Its colours come from Display::composerFade(). + + Where it goes depends on the platform (Display::fadesInBar()). On iOS the screen runs on under the bar, so the fade + is the bar's first row ($inBar), over what runs under it, and the bar's glass fades in under it over the same + height (see Display::composerBarGlass()). On Android the screen stops at the bar, so the fade lies over the foot of + the screen's scroll view, at the bottom of the stack around it. From iOS 26 there's no fade at all: the system's + scroll edge effect blurs what runs under the bar (Display::fadeRowInBar()). $ref names it. +--}} +@php($inBar ??= false) + diff --git a/resources/views/native/partials/composer-plate.blade.php b/resources/views/native/partials/composer-plate.blade.php deleted file mode 100644 index d5ec3f0f..00000000 --- a/resources/views/native/partials/composer-plate.blade.php +++ /dev/null @@ -1,24 +0,0 @@ -{{-- - A composer bar's field and its tools, as the reply bar on a commit's page and a Remotes thread's message bar draw - them, for the row that holds them with what follows (a counter, the send button). On iOS the field is a Liquid - Glass plate and the tools sit inside it at its trailing edge, where iOS puts a field's own controls, staying at the - bottom as the draft grows. On Android the tools lead the row, ahead of the field, and the row starts closer to the - edge for them (ios:pl-4 android:pl-2). - - $ref names the plate ("{$ref}-plate", also its key, so the field keeps its place as rows above it come and go), - $field is the partial that draws the field, and $tools are composer-tool's, in the web's order. ---}} -@php($toolsInField = \Native\Mobile\Platform::isIos()) -@unless ($toolsInField) - @foreach ($tools as $tool) - @include('native.partials.composer-tool', $tool) - @endforeach -@endunless - - @include($field) - @if ($toolsInField) - @foreach ($tools as $tool) - @include('native.partials.composer-tool', $tool) - @endforeach - @endif - diff --git a/resources/views/native/partials/composer-preview.blade.php b/resources/views/native/partials/composer-preview.blade.php index 7959f818..b061d41a 100644 --- a/resources/views/native/partials/composer-preview.blade.php +++ b/resources/views/native/partials/composer-preview.blade.php @@ -1,23 +1,27 @@ {{-- - The draft in the composer as the commit it would become, in place of the field, as the web's ComposerPreviewBody: - its body as devnull would keep it, with its code and mentions once devnull has said, then its photos, its poll's - options and how long it runs once published, and the commit it quotes. With nothing to show yet, it says so. + A draft as the commit it would become, in place of the field, as the web's ComposerPreviewBody: its body as devnull + would keep it, with its code and mentions once devnull has said, then its photos, its poll's options and how long it + runs once published, and the commit it quotes. With nothing to show yet, it says so. + + The composer sheet and the reply bar on a commit's page both show one. $ref names it ("{$ref}-preview", and + "{$ref}-poll" for the poll), $body is the draft, $preview what devnull said of it (see AttachesToCommits), $images + its photos, $poll its options or null, $pollLength how long the poll runs, and $quoted the commit it quotes or null. --}} -@php($draftCommit = \App\Devnull\Data\Draft::asCommit($me ?? app(\App\Devnull\Account::class)->user() ?? \App\Devnull\Data\User::fromArray([]), $sheetBody, $sheetPreview, $sheetImages, $sheetView === 'reply' ? null : $sheetPoll, $sheetView === 'quote' ? $sheetCommit : null)) - - @if (trim($sheetBody) === '' && $sheetImages === [] && $sheetPoll === null) +@php($draftCommit = \App\Devnull\Data\Draft::asCommit($me ?? app(\App\Devnull\Account::class)->user() ?? \App\Devnull\Data\User::fromArray([]), $body, $preview, $images, $poll, $quoted)) + + @if (trim($body) === '' && $images === [] && $poll === null) Nothing to preview yet. @else @include('native.partials.commit-body', ['commit' => $draftCommit, 'focused' => true, 'static' => true]) @include('native.partials.commit-media', ['commit' => $draftCommit, 'withEmbeds' => false, 'scoreAction' => false]) @if ($draftCommit->poll) - + @foreach ($draftCommit->poll->options as $option) {{ $option->label }} @endforeach - {{ \App\Devnull\Data\PollDraft::runs($sheetPollLength) }} + {{ \App\Devnull\Data\PollDraft::runs($pollLength) }} @endif @if ($draftCommit->quotedCommit) diff --git a/resources/views/native/partials/composer-tool.blade.php b/resources/views/native/partials/composer-tool.blade.php index 92027763..6ae256f4 100644 --- a/resources/views/native/partials/composer-tool.blade.php +++ b/resources/views/native/partials/composer-tool.blade.php @@ -1,11 +1,13 @@ {{-- One of the composer's tools, as the web's ghost icon buttons: a 44pt target with the icon in muted ink, on Blue Wash in Commit Blue while it's on ($active). While it can't be used ($disabled), it's faded, with nothing to press. - With $menu (TopBarAction items), a tap opens that menu instead of pressing. + With $menu (TopBarAction items), a tap opens that menu instead of pressing. With $text, the icon is smaller and the + words follow it in muted ink, as the reply box counts the photos on its draft. --}} @php($active ??= false) @php($disabled ??= false) @php($menu ??= null) +@php($text ??= null) @if ($menu !== null) {{-- iOS's menu reads its icon to VoiceOver rather than the pressable's label, so the icon carries it too. --}} @@ -17,6 +19,13 @@ +@elseif ($text !== null) + + + + {{ $text }} + + @else diff --git a/resources/views/native/partials/dashed-ring.blade.php b/resources/views/native/partials/dashed-ring.blade.php index 97d43a19..67e9bf36 100644 --- a/resources/views/native/partials/dashed-ring.blade.php +++ b/resources/views/native/partials/dashed-ring.blade.php @@ -1,4 +1,6 @@ {{-- - A 2pt ring in dashes of $lane's colour, as the web's `border-2 border-dashed rounded-full`, $size across. + A 2pt ring in dashes of $lane's colour, as the web's `border-2 border-dashed rounded-full`, $size across. $rounded + makes it a rounded square instead, around an organization. --}} - +@php($rounded ??= 'rounded-full') + diff --git a/resources/views/native/partials/feed.blade.php b/resources/views/native/partials/feed.blade.php index 74d9e1da..5a9ebb31 100644 --- a/resources/views/native/partials/feed.blade.php +++ b/resources/views/native/partials/feed.blade.php @@ -3,7 +3,8 @@ partials/who-to-follow) and commits on the rail. A commit's replies stay hidden until its replies button opens them in place (see Concerns\ExpandsThreads). Then its thread hangs under it, inside its row's hairline, a page at a time with "Show more" under the last, and a reply's own replies opened under it one step in (see App\Devnull\ThreadRows). - The commit's rail runs on past them when its author's run goes on below. + The commit's rail runs on past them when its author's run goes on below. A commit its author carried on in replies to + themselves shows "Show thread". Given a $rowCache (see App\Devnull\RowCache), commits and replies that haven't changed since the last frame are drawn from it rather than built again. Given a $rowWindow (see App\Devnull\RowWindow), rows far from the screen @@ -50,6 +51,7 @@ 'continuesRun' => $row->continuesRun, 'continuesNext' => $row->continuesNext, 'threadBelow' => $threadRows !== [], + 'showsThread' => $feedCommit->continuationId !== null || in_array($feedCommit->id, $threadsContinued ?? [], true), ]; @endphp @if (! $feedDraws) diff --git a/resources/views/native/partials/mention-suggestions.blade.php b/resources/views/native/partials/mention-suggestions.blade.php index 1f0a4e29..93dbf174 100644 --- a/resources/views/native/partials/mention-suggestions.blade.php +++ b/resources/views/native/partials/mention-suggestions.blade.php @@ -4,15 +4,27 @@ colour. $heading, when there is one, heads them: Members for a bare "@" in an org thread. A tap puts "@handle " in the field in place of what was typed. Above a bar's field on iOS they sit on glass of their own, like the reply strip; $class says otherwise. + + At most six rows show (Display::MentionRowsShown). Past that the rows scroll inside a list that tall, so the list + never pushes the field and the bar's buttons down under the keyboard. Fewer, and it's only as tall as its rows. + Each row is then exactly a row's height (Display::MentionRowHeight), so six fill the list. The rows sit inside the + list's own column, so the slot around it, and the field's row beside that, stay where they are. A caller that + scrolls the list itself (the composer sheet sizes and scrolls its own) passes 'scrolls' => false, and every row is + drawn as tall as it is, with no scroll view inside. --}} @if (($mention['field'] ?? null) === $field && ($mentionPeople !== [] || $mentionOrganizations !== [])) @if ($heading ?? null) {{ $heading }} @endif - @foreach ([...array_map(fn ($user) => [$user, true], $mentionPeople), ...array_map(fn ($user) => [$user, false], $mentionOrganizations)] as [$user, $person]) + @php($mentionRows = [...array_map(fn ($user) => [$user, true], $mentionPeople), ...array_map(fn ($user) => [$user, false], $mentionOrganizations)]) + @php($mentionScrolls = ($scrolls ?? true) && count($mentionRows) > \App\Devnull\Display::MentionRowsShown) + @if ($mentionScrolls) + + @endif + @foreach ($mentionRows as [$user, $person]) - + @include('native.partials.avatar', ['user' => $user, 'size' => 28]) {{ $user->name }} @@ -26,5 +38,8 @@ @endforeach + @if ($mentionScrolls) + + @endif @endif diff --git a/resources/views/native/partials/message-field.blade.php b/resources/views/native/partials/message-field.blade.php index 339424b9..f990d826 100644 --- a/resources/views/native/partials/message-field.blade.php +++ b/resources/views/native/partials/message-field.blade.php @@ -1,12 +1,12 @@ {{-- - A Remotes thread's message field (see partials/composer-plate). It keeps the keyboard up through presses elsewhere - in the thread (keep-focus), as the web keeps its field focused through Reply and Push, and its column is keyed, so - the reply strip or photos coming and going above it never rebuild it. It mounts afresh only to take focus + A Remotes thread's message field, across the top of partials/composer-box. It keeps the keyboard up through presses + elsewhere in the thread (keep-focus), as the web keeps its field focused through Reply and Push, and its column is + keyed, so the reply strip or photos coming and going above it never rebuild it. It mounts afresh only to take focus ($composerKey): replying while the field is idle, or attaching photos. EDGE sends no focus event, so a press into the field tells the thread it's in use. Where the caret is goes to the thread as it moves, for the "@" suggestions in an org (see SuggestsMentions), and a picked mention comes back with where the caret goes, after it. --}} - + = 1600) + {{ number_format($length) }}/{{ number_format(\App\Devnull\Data\Message::MaxLength) }} +@endif diff --git a/resources/views/native/partials/post-as.blade.php b/resources/views/native/partials/post-as.blade.php new file mode 100644 index 00000000..b22f86a8 --- /dev/null +++ b/resources/views/native/partials/post-as.blade.php @@ -0,0 +1,30 @@ +{{-- + Who a composer posts as (see PostAs): the avatar of whoever it is now, round for you and a rounded square for an + organization, with a small chevron on its corner, as the web's Post as button draws it. A tap opens the menu of you + and your organizations, which calls $method with the handle picked, or '' for you. With $withName, their name and + handle follow the avatar, for the sheet, which has the room. $inset pads it inside its tap target, so a bar can line + the avatar up with its field. + + $picked is the handle the composer holds. An organization you've left since posts as you, so your avatar shows. +--}} +@php($size ??= 32) +@php($withName ??= false) +@php($inset ??= '') +@php($author = \App\Devnull\PostAs::author($picked)) +@php($identity = $author ?? $me) + + + + @include('native.partials.avatar', ['user' => $identity, 'size' => $size]) + + + + + @if ($withName) + + {{ $identity->name }} + {{ $identity->handle() }} + + @endif + + diff --git a/resources/views/native/partials/rail-avatar.blade.php b/resources/views/native/partials/rail-avatar.blade.php index e5055af0..d000bc54 100644 --- a/resources/views/native/partials/rail-avatar.blade.php +++ b/resources/views/native/partials/rail-avatar.blade.php @@ -13,8 +13,8 @@ @php($position ??= '') @php($live = ! $staged && $user->isLive()) @if ($staged) - - @include('native.partials.dashed-ring', ['size' => 48, 'lane' => $lane]) + + @include('native.partials.dashed-ring', ['size' => 48, 'lane' => $lane, 'rounded' => $user->isOrganization ? 'rounded-lg' : 'rounded-full']) @include('native.partials.avatar', ['user' => $user, 'size' => 40]) diff --git a/resources/views/native/partials/related-commits.blade.php b/resources/views/native/partials/related-commits.blade.php index a7398456..af215186 100644 --- a/resources/views/native/partials/related-commits.blade.php +++ b/resources/views/native/partials/related-commits.blade.php @@ -1,19 +1,36 @@ -{{-- Other threads, in relevance order, on a fresh rail below this thread as on the web. --}} +{{-- + Other threads, in relevance order, on a fresh rail below this thread as on the web. They start closed under a + header with their count, which opens them in place and closes them again, its chevron turning as they do (see + CommitDetail::toggleRelated()). Each commit fades and slides into place a little after the one above it, and fades + out together as they close. The header is the whole row, so it's an easy target at the foot of the page. +--}} +@php($relatedOpen = $relatedShown && ! $relatedClosing) +@php($relatedLabel = \App\Devnull\Display::count(count($relatedRows), 'related commit', 'related commits')) - - Related commits - - @foreach ($relatedRows as $relatedRow) - @include('native.partials.commit-row', [ - 'commit' => $relatedRow->commit, - 'previousLane' => $relatedRow->previousLane, - 'continuesRun' => $relatedRow->continuesRun, - 'continuesNext' => null, - 'focused' => false, - 'muted' => false, - 'seriesExpanded' => false, - 'threadBelow' => false, - 'withTail' => ! $loop->last, - ]) - @endforeach + + + Related commits + {{ count($relatedRows) }} + + + + + @if ($relatedShown) + @foreach ($relatedRows as $relatedRow) + + @include('native.partials.commit-row', [ + 'commit' => $relatedRow->commit, + 'previousLane' => $relatedRow->previousLane, + 'continuesRun' => $relatedRow->continuesRun, + 'continuesNext' => null, + 'focused' => false, + 'muted' => false, + 'seriesExpanded' => false, + 'threadBelow' => false, + 'withTail' => ! $loop->last, + 'expandable' => false, + ]) + + @endforeach + @endif diff --git a/resources/views/native/partials/reply-field.blade.php b/resources/views/native/partials/reply-field.blade.php index 04f37457..1879f43a 100644 --- a/resources/views/native/partials/reply-field.blade.php +++ b/resources/views/native/partials/reply-field.blade.php @@ -1,11 +1,12 @@ {{-- - The reply bar's field on a commit's page (see partials/composer-plate). EDGE sends no focus event, so a press on the - field is how the page learns you're replying. The expand button is beside it rather than in it, so pressing it + The reply bar's field on a commit's page, across the top of partials/composer-box. EDGE sends no focus event, so a + press on the field is how the page learns you're replying. The tools are in the row under it, so pressing them doesn't count. Where the caret is goes to the page as it moves, for the "@" suggestions above the bar (see SuggestsMentions). It keeps the keyboard up through presses elsewhere on the page (keep-focus), as the Remotes - field does, so picking someone to mention leaves you typing after them. + field does, so picking someone to mention leaves you typing after them. It grows with the reply to five lines and + then scrolls, sized by the field itself, not by the page. --}} - + diff --git a/resources/views/native/partials/reply-preview.blade.php b/resources/views/native/partials/reply-preview.blade.php new file mode 100644 index 00000000..31ba70ad --- /dev/null +++ b/resources/views/native/partials/reply-preview.blade.php @@ -0,0 +1,19 @@ +{{-- + The reply as it will look, in the reply bar's field's place, while Preview is on (see CommitDetail::toggleReplyPreview()): + its body as devnull keeps it, with its photos. Held to about half a screen, and scrolls past that, so a long reply + doesn't push the commit off the top. +--}} + + + @include('native.partials.composer-preview', [ + 'ref' => 'reply-draft', + 'body' => $reply, + 'preview' => $replyPreview, + 'images' => $replyImages, + 'poll' => null, + 'pollLength' => \App\Devnull\Data\PollDraft::DefaultLength, + 'quoted' => null, + 'me' => $viewer, + ]) + + diff --git a/resources/views/native/partials/send-button.blade.php b/resources/views/native/partials/send-button.blade.php new file mode 100644 index 00000000..d38068c1 --- /dev/null +++ b/resources/views/native/partials/send-button.blade.php @@ -0,0 +1,25 @@ +{{-- + A composer's send button: a 32pt circle in your colour with an up arrow, as the Claude and Messages apps send. + It names what it does for screen readers ($label: Push, Reply). While there's nothing to send ($disabled) it's a + muted circle, and not a button, as a disabled button would be. Its 36pt tap target fits the composer-tool row. + $colour fills it with another lane than yours, such as the organization a reply goes out as (see PostAs). +--}} +@php($disabled ??= false) +@php($colour ??= $myColour) +@php($circle = 'rounded-full '.($disabled ? 'bg-theme-surface-variant' : 'bg-theme-'.$colour)) +@php($arrow = $disabled ? 'text-theme-ink-muted' : 'text-theme-on-'.$colour) +@if ($disabled) + + + + + +@else + + + + + + + +@endif diff --git a/resources/views/native/partials/sheet-bar-button.blade.php b/resources/views/native/partials/sheet-bar-button.blade.php index 2d645dfc..8823f5ba 100644 --- a/resources/views/native/partials/sheet-bar-button.blade.php +++ b/resources/views/native/partials/sheet-bar-button.blade.php @@ -1,16 +1,18 @@ {{-- A round button in a sheet's bar, as Apple draws a sheet's cross and check: the same 44pt circle on both platforms. - It's glass on iOS and a tonal circle on Android, or filled with your colour as the bar's main button ($main). + It's glass on iOS and a tonal circle on Android, or filled with your colour as the bar's main button ($main), or + with $mainColour's, the lane of the organization a composer posts as. Without $press it's drawn muted, and not as a button, as a disabled button would be. Its action checks again anyway. $loading swaps the icon for a spinner in the same circle. --}} @php($main ??= false) +@php($mainColour ??= $myColour) @php($loading ??= false) @php($hint ??= null) @php($filled = $main && ($press !== null || $loading)) -@php($circle = 'rounded-full '.($filled ? 'bg-theme-'.$myColour : 'android:bg-theme-surface-variant ios:glass'.($press === null ? '' : ':interactive'))) -@php($iconColour = $filled ? 'text-theme-on-'.$myColour : ($press === null ? 'text-theme-ink-muted' : 'text-theme-ink')) +@php($circle = 'rounded-full '.($filled ? 'bg-theme-'.$mainColour : 'android:bg-theme-surface-variant ios:glass'.($press === null ? '' : ':interactive'))) +@php($iconColour = $filled ? 'text-theme-on-'.$mainColour : ($press === null ? 'text-theme-ink-muted' : 'text-theme-ink')) @if ($press !== null) diff --git a/resources/views/native/partials/show-thread.blade.php b/resources/views/native/partials/show-thread.blade.php new file mode 100644 index 00000000..6a3e4aa6 --- /dev/null +++ b/resources/views/native/partials/show-thread.blade.php @@ -0,0 +1,8 @@ +{{-- + "Show thread" under a commit its author carried on in replies to themselves, as the web's ShowThreadLink: it opens + the commit's page, where the thread reads in order (see SelfThread). +--}} + + + Show thread + diff --git a/resources/views/native/partials/stargazers-sheet.blade.php b/resources/views/native/partials/stargazers-sheet.blade.php index f20394b8..1d3d9253 100644 --- a/resources/views/native/partials/stargazers-sheet.blade.php +++ b/resources/views/native/partials/stargazers-sheet.blade.php @@ -3,6 +3,9 @@ then each of them, newest first, with their avatar, name and handle. A tap opens them. While a page loads, skeleton rows stand in for up to three of them. When one doesn't load, the web's line says so, with Try again, and while there are more, Show more. Nothing is drawn until the sheet opens. + + On an organization's commit that a different member posted, devnull's API won't list who starred it, though the + web does, so the sheet says that instead ($stargazersForPoster). --}} @if ($stargazersOf !== null) @@ -34,7 +37,9 @@ @endif - @if ($stargazersFailed) + @if ($stargazersForPoster) + Only the member who posted this commit can see who starred it here. + @elseif ($stargazersFailed) fatal: could not load stars Try again diff --git a/resources/views/native/partials/stash-label.blade.php b/resources/views/native/partials/stash-label.blade.php index b455da5c..a91815bb 100644 --- a/resources/views/native/partials/stash-label.blade.php +++ b/resources/views/native/partials/stash-label.blade.php @@ -1,11 +1,15 @@ {{-- The web's StashLabel, beside a draft that was stashed and has come back: stash@{0} in mono, then drop, which throws - the draft away. $drop is what drop presses, and drop is a full 44pt target. + the draft away. $drop is what drop presses, and drop is a full 44pt target. With $restored false, the draft is one + you're writing now, so there's no stash@{0}, only drop. --}} @php($size ??= 'text-[13px]') +@php($restored ??= true) - {{ 'stash@{0}' }} - + @if ($restored) + {{ 'stash@{0}' }} + @endif + drop diff --git a/resources/views/native/partials/thread-continues.blade.php b/resources/views/native/partials/thread-continues.blade.php new file mode 100644 index 00000000..efe83068 --- /dev/null +++ b/resources/views/native/partials/thread-continues.blade.php @@ -0,0 +1,24 @@ +{{-- + "Show more of this thread" under the last part of an author's thread a commit page shows, as the web's: a tap shows + the next ten parts (see SelfThread). It mirrors "↑ N earlier commits" above the commit: the last part's rail comes + down solid to a hollow node in its lane, and a dashed Rail Gray line runs on below it to what's still to come. +--}} +@php($colour = 'bg-theme-'.\App\Devnull\Lane::token($lane)) + + + + + + + Show more of this thread + + + + + + + @include('native.partials.rail-node', ['lane' => $lane, 'filled' => false]) + + @include('native.partials.dashed-line', ['position' => 'top-[31] bottom-0', 'left' => 31.5, 'lane' => \App\Devnull\Lane::Rail]) + + diff --git a/resources/views/native/partials/thread-links.blade.php b/resources/views/native/partials/thread-links.blade.php index 8f2c9084..9f547262 100644 --- a/resources/views/native/partials/thread-links.blade.php +++ b/resources/views/native/partials/thread-links.blade.php @@ -1,23 +1,28 @@ {{-- - The lines beside a reply in a feed's thread (see thread-reply), drawn last in its row so they sit on top: the - commit's rail running on past, the elbow or the link from the reply above, and the line on down to the next one. + The lines beside a reply in a thread (see thread-reply and App\Devnull\ThreadRows), drawn last in its row so they + sit on top: the commit's rail running on past, the lines from further up running on past ($spines, each from its + `top` or the row's top), the elbow or the link from the reply above, and the line on down to the next one. A + flattened reply, past the web's depth, has no links of its own ($links). --}} +@php($spines ??= []) +@php($links ??= true) @if ($railLane !== null) @include('native.partials.rail', ['previous' => $railLane]) @endif -@if ($spine !== null) - @include('native.partials.dashed-line', ['position' => 'top-0 bottom-0', 'left' => 75.5, 'lane' => $spine]) -@endif +@foreach ($spines as $spineLine) + @include('native.partials.dashed-line', ['position' => (isset($spineLine['top']) ? 'top-['.$spineLine['top'].']' : 'top-0').' bottom-0', 'left' => $spineLine['left'], 'lane' => $spineLine['lane']]) +@endforeach -@if ($previousLane === null) - @include('native.partials.thread-elbow', ['lane' => $lane, 'from' => $indent > 0 ? 75.5 : 31.5, 'to' => 64 + $indent, 'level' => $top + 12]) -@else - @include('native.partials.dashed-line', ['position' => 'top-0 h-['.($top - 4).']', 'left' => $avatarLine - 0.5, 'lane' => $previousLane]) -@endif +@if ($links) + @if ($previousLane === null) + @include('native.partials.thread-elbow', ['lane' => $lane, 'from' => $indent > 0 ? 43.5 + $indent : 31.5, 'to' => 64 + $indent, 'level' => $top + 12]) + @else + @include('native.partials.dashed-line', ['position' => 'top-0 h-['.($top - 4).']', 'left' => $avatarLine - 0.5, 'lane' => $previousLane]) + @endif -@if ($hasNext) - {{-- From 4pt under the avatar down to the next reply, or to the top of Show more's dot: 12pt under it, its padding - and the hairline below. --}} - @include('native.partials.dashed-line', ['position' => 'top-['.($top + 28).'] '.($more !== null ? 'bottom-[34]' : 'bottom-0'), 'left' => $avatarLine - 0.5, 'lane' => $reply->lane()]) + @if ($hasNext) + {{-- From 4pt under the avatar down to the next row, which carries it on. --}} + @include('native.partials.dashed-line', ['position' => 'top-['.($top + 28).'] bottom-0', 'left' => $avatarLine - 0.5, 'lane' => $reply->lane()]) + @endif @endif diff --git a/resources/views/native/partials/thread-more-row.blade.php b/resources/views/native/partials/thread-more-row.blade.php index d35dc8f2..4b77ced3 100644 --- a/resources/views/native/partials/thread-more-row.blade.php +++ b/resources/views/native/partials/thread-more-row.blade.php @@ -1,18 +1,28 @@ {{-- - "Show more" at the foot of a thread opened in a feed (see App\Devnull\ThreadRows), as a list row of its own: a muted - rail dot where the next avatar would be, on the dashed line down from the reply above ($lane), and the words. - Tapped, the thread's next page opens under what's showing. $indent puts it one step in, under a reply's own replies. + "Show more" at the foot of a thread opened in place (see App\Devnull\ThreadRows), as a row of its own: a muted rail + dot where the next avatar would be, on the dashed line down from the reply above ($lane), and the words. Tapped, + the thread's next page opens under what's showing, or whatever $press says. $indent puts it as far in as the + replies above it, and $spines carry the lines from further up on past it. + + At the web's deepest step the dot hangs on an elbow from the line of the reply the thread answers ($hangs, in + $parentLane), as those replies do. Past it there are no lines ($links), and it says whose replies these are ($to). It's 44pt tall, as tall as the list's shortest row, so the list never pads it out under its hairline. The dot sits - in its middle, so the line from above stops at the top of the dot, 13pt down. + in its middle, so the line from above stops at the top of the dot, 13pt down. In a feed the $last closes the + commit's row with its hairline; on a commit page ($hairline false) nothing does. --}} @php($indent ??= 0) -@php($spine ??= null) +@php($spines ??= []) @php($railLane ??= null) +@php($hangs ??= false) +@php($links ??= true) +@php($to ??= null) +@php($hairline ??= true) +@php($press ??= "showMoreReplies('{$threadId}')") @php($faded = in_array('more-'.$threadId, $fadedRows ?? [], true)) - + - + @@ -20,14 +30,22 @@ - Show more + @if ($to === null) + Show more + @else + Show more to {{ $to }} + @endif @if ($railLane !== null) @include('native.partials.rail', ['previous' => $railLane]) @endif - @if ($spine !== null) - @include('native.partials.dashed-line', ['position' => 'top-0 bottom-0', 'left' => 75.5, 'lane' => $spine]) + @foreach ($spines as $spineLine) + @include('native.partials.dashed-line', ['position' => (isset($spineLine['top']) ? 'top-['.$spineLine['top'].']' : 'top-0').' bottom-0', 'left' => $spineLine['left'], 'lane' => $spineLine['lane']]) + @endforeach + @if ($links && $hangs) + @include('native.partials.thread-elbow', ['lane' => $parentLane, 'from' => 43.5 + $indent, 'to' => 64 + $indent, 'level' => 22]) + @elseif ($links) + @include('native.partials.dashed-line', ['position' => 'top-0 h-[13]', 'left' => 75.5 + $indent, 'lane' => $lane]) @endif - @include('native.partials.dashed-line', ['position' => 'top-0 h-[13]', 'left' => 75.5 + $indent, 'lane' => $lane]) diff --git a/resources/views/native/partials/thread-more.blade.php b/resources/views/native/partials/thread-more.blade.php deleted file mode 100644 index 6ed4afba..00000000 --- a/resources/views/native/partials/thread-more.blade.php +++ /dev/null @@ -1,17 +0,0 @@ -{{-- - "Show more" at the foot of a thread, as the web's: a muted rail dot where the next avatar would be, and the words. - It sits inside the last reply's row, under the reply, so the rail beside it never breaks: a row of its own is - shorter than the list's shortest, and the list pads it out under its hairline. ---}} - - - - - - - - - - Show more - - diff --git a/resources/views/native/partials/thread-position.blade.php b/resources/views/native/partials/thread-position.blade.php new file mode 100644 index 00000000..0a9bb7dd --- /dev/null +++ b/resources/views/native/partials/thread-position.blade.php @@ -0,0 +1,4 @@ +{{-- A commit's place in its author's thread, like the web's ThreadPositionBadge: "2/5" in mono on a muted wash. --}} + + {{ $threadPosition }} + diff --git a/resources/views/native/partials/thread-reply.blade.php b/resources/views/native/partials/thread-reply.blade.php index 406df615..58c08bce 100644 --- a/resources/views/native/partials/thread-reply.blade.php +++ b/resources/views/native/partials/thread-reply.blade.php @@ -1,49 +1,56 @@ {{-- - A reply in the thread under a commit in a feed, like a reply in the web's thread: a 24pt avatar lined up with the - commit's text, the name and time, the body and its actions. The thread hangs off the rail in dashes of each - author's lane, as upstream's #121 draws it: the first reply on an elbow from the rail ($lane is the commit's), each - later one on a short link from the reply above ($previousLane), and a line on down from its avatar when another - reply, or "Show more", follows ($hasNext). $railLane runs the commit's own rail on past, solid, when its author's - run goes on below the thread. A deleted reply keeps its place with a dashed ring. In a feed the $last closes the - commit's row with its hairline. On a commit page nothing follows the thread, so there's no hairline. + A reply in a thread opened in place (see App\Devnull\ThreadRows), like a reply in the web's thread: a 24pt avatar + lined up with the commit's text, or $indent further in, the name and time, the body and its actions. The thread + hangs off the rail in dashes of each author's lane, as upstream's #121 draws it: the first reply on an elbow from + the line of what it answers ($lane is that one's), each later one on a short link from the reply above + ($previousLane), and a line on down from its avatar when another reply, its own replies, or "Show more", follows + ($hasNext). $spines carry lines from further up on past it, and $railLane runs the commit's own rail on past, + solid, when its author's run goes on below the thread (see thread-links). A deleted reply keeps its place with a + dashed ring. In a feed the $last closes the commit's row with its hairline. On a commit page it has one only when + another commit's row comes next ($hairline): under the replies of a commit above the commit, say, but not at the + foot of the page. - On a commit page a deleted reply's own replies open in place ($tombstones), since it has no page of their own, - one level in ($indent 32), hanging off a dashed spine from its ring as the web nests them. $spine carries the - thread's line on past a nested reply when the deleted one has another reply after it. + Past the web's depth a reply is flattened: it lines up under the reply it answers, with no lines of its own + ($links), and says who it answers on a line under its name ($replyingTo), as the web does. - The last reply carries the thread's "Show more" when there's more ($more, what it presses), with the line from its - avatar running down to it. + On a commit page a deleted reply's own replies open in place too ($tombstones), with "N replies" under its ring. $top is the space above the avatar, 10pt, less for the first reply in a feed, which sits under the commit row's bottom padding (see ThreadRows::FirstReplyTop). The lines beside it are placed from the avatar, so they move with it. A commit page draws its replies $muted, smaller and in muted ink, so the commit they answer stays the main thing. + A reply its author carried on in replies to themselves links to that thread, as on the web (see show-thread): when + devnull says so, or once its replies opened in place showed it ($threadsContinued, see Concerns\ExpandsThreads). + A reply you just sent that devnull doesn't have yet is staged: dimmed, with the staged chip and no actions. - In a feed a reply's replies button opens them under it ($repliesInPlace, see App\Devnull\ThreadRows); deeper in, - or on a commit page, it opens the reply's page. A feed's thread rows fade in as they open and out as they close - ($fades): drawn see-through and nudged up while they're in $fadedRows (see Concerns\ExpandsThreads), and eased - to where they belong. Only what's beside the rail fades, so the commit's rail running past never blinks. + A reply's replies button opens them under it ($repliesInPlace): on a commit page at every depth, in a feed only for + the commit's own replies, and a reply's replies there open its page. Tapping the reply itself opens its page. The + rows fade in as they open and out as they close ($fades): drawn see-through and nudged up while they're in + $fadedRows (see Concerns\ExpandsThreads), and eased to where they belong. Only what's beside the rail fades, so + the commit's rail running past never blinks. --}} @php($previousLane ??= null) @php($muted ??= false) +@php($hairline ??= ! $muted) @php($railLane ??= null) @php($indent ??= 0) -@php($spine ??= null) +@php($spines ??= []) +@php($links ??= true) +@php($replyingTo ??= null) @php($tombstones ??= false) -@php($more ??= null) @php($avatarLine = 76 + $indent) @php($repliesInPlace ??= false) @php($fades ??= false) @php($top ??= 10) @php($faded = $fades && in_array($reply->id, $fadedRows ?? [], true)) @if ($reply->isDeleted()) - @php($opened = $tombstones && array_key_exists($reply->id, $tombstoneReplies ?? [])) + @php($opened = $tombstones && array_key_exists($reply->id, $threads ?? []) && ! in_array($reply->id, $closingThreads ?? [], true)) - + @include('native.partials.dashed-ring', ['size' => 24, 'lane' => \App\Devnull\Lane::Rail]) @@ -52,7 +59,7 @@ [deleted] This commit was deleted. @if ($tombstones && $reply->repliesCount > 0) - + {{ $opened ? 'Hide replies' : \App\Devnull\Display::count($reply->repliesCount, 'reply', 'replies') }} @@ -61,18 +68,11 @@ @endif - @if ($more !== null) - @include('native.partials.thread-more', ['commit' => $thread ?? $reply]) - @endif - @if ($last && ! $muted) + @if ($last && $hairline) @endif @include('native.partials.thread-links') - @if ($opened && ($tombstoneReplies[$reply->id] ?? []) !== []) - {{-- The spine its own replies hang off, down from its ring. --}} - @include('native.partials.dashed-line', ['position' => 'top-['.($top + 28).'] bottom-0', 'left' => $avatarLine - 0.5, 'lane' => \App\Devnull\Lane::Rail]) - @endif @else @php($commit = $reply) @@ -80,7 +80,7 @@ - + @include('native.partials.rail-avatar', ['user' => $reply->author, 'lane' => $reply->lane(), 'size' => 24, 'staged' => false]) @@ -93,17 +93,23 @@ @include('native.partials.status-chip', ['status' => $reply->status]) @endunless + @if ($replyingTo !== null) + + + {{ $replyingTo }} + + @endif @include('native.partials.commit-body', ['size' => $muted ? 'text-sm' : 'text-[15px]']) @include('native.partials.commit-media', ['withEmbeds' => false]) + @if ($reply->continuationId !== null || in_array($reply->id, $threadsContinued ?? [], true)) + @include('native.partials.show-thread') + @endif @unless ($reply->isStaged()) @include('native.partials.commit-actions', ['expandable' => $repliesInPlace, 'withQuote' => false, 'compact' => $muted]) @endunless - @if ($more !== null) - @include('native.partials.thread-more', ['commit' => $thread ?? $reply]) - @endif - @if ($last && ! $muted) + @if ($last && $hairline) @endif diff --git a/resources/views/native/partials/voice-recorder.blade.php b/resources/views/native/partials/voice-recorder.blade.php index 3c19a267..989ecc54 100644 --- a/resources/views/native/partials/voice-recorder.blade.php +++ b/resources/views/native/partials/voice-recorder.blade.php @@ -1,5 +1,5 @@ {{-- - The voice note in the composer, in the field's place (see partials/composer-plate), as the web's recorder draws + The voice note in the composer, in the field's place (see partials/composer-box), as the web's recorder draws it: the trash, then "opening microphone…" until it records, then a pulsing dot, the microphone's level coming in on the right, and the clock counting to the minute, amber in the last ten seconds, with Stop; then the recording itself, to listen to before Push sends it. The same height as the field with one line, so the bar doesn't move. @@ -7,9 +7,9 @@ While it records, the thread renders five times a second for the meter (RecordsVoiceNotes::MeterInterval). --}} @if ($recorder === 'recording') - + @else - + @endif diff --git a/resources/views/native/scheduled-commits.blade.php b/resources/views/native/scheduled-commits.blade.php index 64fa03c7..710d20b4 100644 --- a/resources/views/native/scheduled-commits.blade.php +++ b/resources/views/native/scheduled-commits.blade.php @@ -47,6 +47,13 @@ {{ $item->label($now) }} {{ Display::scheduleTime($item->scheduledAt, $timezone) }} + @if ($item->author) + {{-- The organization it goes out as, as the web's list shows it under the time. --}} + + @include('native.partials.avatar', ['user' => $item->author, 'size' => 16]) + As {{ $item->author->handle() }} + + @endif @if ($item->isWaiting()) @php($when = Display::scheduleTime($item->scheduledAt, $timezone)) diff --git a/tests/Feature/Devnull/ComposerScrollEdgeTest.php b/tests/Feature/Devnull/ComposerScrollEdgeTest.php new file mode 100644 index 00000000..c56f3556 --- /dev/null +++ b/tests/Feature/Devnull/ComposerScrollEdgeTest.php @@ -0,0 +1,59 @@ +toBe($edge) + ->and(Display::fadeRowInBar())->toBe($platform === 'ios' && ! $edge) + ->and(Display::composerFadeHeight())->toBe($edge ? 0 : Display::ComposerFadeHeight) + ->and(Display::composerSurface() === '')->toBe($edge) + ->and(Display::composerInGlassBox())->toBe($edge && Display::ComposerInGlassBox) + ->and(Display::composerBoxBarHeight())->toBe($edge && Display::ComposerInGlassBox ? Display::ComposerGlassBoxBarHeight : Display::ComposerBoxBarHeight) + ->and(Display::composerBox() === '')->toBe(! ($edge && Display::ComposerInGlassBox)); + } finally { + System::rememberPlatform(null); + } + }); +})->with([ + 'iOS 18' => ['ios', '18.5', false], + 'iOS 26' => ['ios', '26.0', true], + 'iOS 26.1' => ['ios', '26.1', true], + 'iOS 27' => ['ios', '27.0.1', true], + 'Android 16' => ['android', '16', false], + 'Android 26' => ['android', '26', false], +]); + +it('asks iOS for the composer edge blur on the bar, over glass for older iOS, and Android for neither', function () { + System::rememberPlatform('ios'); + + try { + expect(Display::composerBarGlass())->toBe('glass/'.Display::ComposerGlassOpacity) + ->and(Display::composerEdgeBlur())->toBe(Display::ComposerEdgeBlur); + } finally { + System::rememberPlatform(null); + } + + System::rememberPlatform('android'); + + try { + expect(Display::composerBarGlass())->toBe('') + ->and(Display::composerEdgeBlur())->toBe(''); + } finally { + System::rememberPlatform(null); + } +}); + +it('asks for an edge blur mobile-air takes', function () { + expect(Display::ComposerEdgeBlur)->toBeIn(['soft', 'hard']); +}); + +it('keeps the glass box as tall as the bar it replaces, plus its own padding', function () { + // The field's padding over it grows from 4 to 8, and the box adds 2 under the row of tools. + expect(Display::ComposerGlassBoxBarHeight)->toBe(Display::ComposerBoxBarHeight + 4 + 2); +}); diff --git a/tests/Feature/Screens/CommitDetailCacheTest.php b/tests/Feature/Screens/CommitDetailCacheTest.php index 145eaedf..afc3e075 100644 --- a/tests/Feature/Screens/CommitDetailCacheTest.php +++ b/tests/Feature/Screens/CommitDetailCacheTest.php @@ -48,7 +48,8 @@ function serveThread(): void finishRefreshes($screen)->assertSee('A compiler'); - expect(count(Http::recorded()))->toBe(3); + // The commit, its replies, what's related, and c0's own page for how many replies it has. + expect(count(Http::recorded()))->toBe(4); }); it('opens from a row on what the row knew, then fills in the replies and what it replies to', function () { @@ -140,7 +141,7 @@ function serveThread(): void 'GET /api/v1/commits/d1/replies' => [pageJson([replyJson(['id' => 'r9', 'parent_id' => 'd1', 'body' => 'Under a deleted reply'])])], ]); - $screen = Native::visit('/log/commits/c1')->tap('replies-c1')->call('toggleTombstone', 'd1')->assertSee('Under a deleted reply'); + $screen = Native::visit('/log/commits/c1')->tap('replies-c1')->call('toggleReplies', 'd1')->assertSee('Under a deleted reply'); $screen->call('load'); diff --git a/tests/Feature/Screens/CommitDetailTest.php b/tests/Feature/Screens/CommitDetailTest.php index edea66a8..e429ab2b 100644 --- a/tests/Feature/Screens/CommitDetailTest.php +++ b/tests/Feature/Screens/CommitDetailTest.php @@ -1,6 +1,7 @@ 'http://devnull.test']); @@ -51,19 +54,19 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): ->assertSee('Reply to @local_dev'); // The commit comes after the one it replies to, and the row standing in for what that replies to. - expect(childRefs($screen, 'thread-page'))->toBe(['earlier-commits', 'commit-c1', 'focused-commit', 'reply-bar-clearance']); + expect(childRefs($screen, 'thread-scroll'))->toBe(['earlier-commits', 'commit-c1', 'focused-commit', 'reply-bar-clearance']); $screen->tap('earlier-commits') ->assertSee('The root commit') ->assertDontSee('1 earlier commit'); - expect(childRefs($screen, 'thread-page'))->toBe(['commit-c0', 'commit-c1', 'focused-commit', 'reply-bar-clearance']); + expect(childRefs($screen, 'thread-scroll'))->toBe(['commit-c0', 'commit-c1', 'focused-commit', 'reply-bar-clearance']); $screen->tap('replies-c2') ->assertSee('First reply') ->assertSee('Hide replies'); - expect(childRefs($screen, 'thread-page'))->toBe(['commit-c0', 'commit-c1', 'focused-commit', 'thread-reply-r1', 'reply-bar-clearance']); + expect(childRefs($screen, 'thread-scroll'))->toBe(['commit-c0', 'commit-c1', 'focused-commit', 'thread-reply-r1', 'reply-bar-clearance']); $screen->tap('replies-c2') ->assertDontSee('First reply') @@ -84,7 +87,7 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): ->assertSee('The parent commit') ->assertDontSee('The root commit'); - expect(childRefs($screen, 'thread-page'))->toBe(['earlier-commits', 'commit-c1', 'focused-commit', 'reply-bar-clearance']) + expect(childRefs($screen, 'thread-scroll'))->toBe(['earlier-commits', 'commit-c1', 'focused-commit', 'reply-bar-clearance']) ->and(nodeByRef($screen, 'thread-scroll')['id'])->not->toBe($before); }); @@ -108,17 +111,114 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): ->and(idsDownTo($screen->tree(), 'reply-input'))->toBe($field); }); -it('puts the expand button inside the reply field on iOS, and ahead of it on Android', function (string $platform, array $row, array $plate) { +it('draws the reply bar with the field over the photo and preview buttons and a round Reply, on both platforms', function (string $platform) { fakeThread(); $screen = Native::visit('/log/commits/c2', platform: $platform); + $actions = childRefs($screen, 'reply-actions'); - expect(childRefs($screen, 'reply-row'))->toBe($row) - ->and(childRefs($screen, 'reply-plate'))->toBe($plate); -})->with([ - 'iOS' => ['ios', ['reply-plate', 'send-reply'], ['reply-field', 'reply-expand']], - 'Android' => ['android', ['reply-expand', 'reply-plate', 'send-reply'], ['reply-field']], -]); + expect(childRefs($screen, 'reply-row'))->toBe(['reply-box']) + ->and(childRefs($screen, 'reply-box'))->toBe(['reply-field-row', 'reply-actions']) + ->and(childRefs($screen, 'reply-field-row'))->toBe(['reply-field']) + ->and(array_slice($actions, 0, 2))->toBe(['reply-add-photos', 'reply-preview']) + ->and(end($actions))->toBe('send-reply') + ->and(array_column(menuItems($screen, 'reply-add-photos'), 0))->toBe(['reply-pick-photos', 'reply-take-photo']) + ->and(nodeByRef($screen, 'send-reply')['props']['a11y_label'] ?? nodeByRef($screen, 'send-reply')['a11y_label'] ?? null)->toBe('Reply') + ->and(rendersRef($screen, 'reply-expand'))->toBeFalse() + ->and(canSend($screen, 'send-reply'))->toBeFalse(); + + $screen->input('reply-input', 'Ready'); + + expect(canSend($screen, 'send-reply'))->toBeTrue(); +})->with(['ios', 'android']); + +it('keeps the same field, up to five lines and then scrolling, however long the reply grows', function (string $platform) { + fakeThread(); + + $screen = Native::visit('/log/commits/c2', platform: $platform)->input('reply-input', 'A short one'); + $field = idsDownTo($screen->tree(), 'reply-input'); + + $screen->input('reply-input', str_repeat("A line of a long reply\n", 12)); + + // The field sizes itself: the page only says how many lines it can take, which never changes as you type. + expect(idsDownTo($screen->tree(), 'reply-input'))->toBe($field) + ->and(nodeByRef($screen, 'reply-input')['props']['max_lines'])->toBe(Display::ReplyBarMaxLines) + ->and(nodeByRef($screen, 'reply-input')['props']['min_lines'] ?? null)->toBeNull() + ->and(nodeByRef($screen, 'sheet')['props']['visible'] ?? false)->toBeFalse(); +})->with(['ios', 'android']); + +it('previews the reply in the field\'s place, with the body devnull keeps, and brings the field back with the keyboard', function () { + fakeThread(extra: ['POST /api/v1/commits/preview' => [['data' => [ + 'body' => 'Shipped 🚀 with @ada', + 'body_segments' => [['type' => 'text', 'text' => 'Shipped 🚀 with @ada']], + 'preview_segments' => null, + 'mentions' => [['handle' => 'ada', 'offset' => 15, 'length' => 4]], + ]]]]); + $screen = Native::visit('/log/commits/c2')->input('reply-input', 'Shipped :rocket: with @ada'); + holdRefreshes(); + $screen->tap('reply-preview'); + + // At once, the reply as written, in the field's place, while devnull is asked. The sheet never opens. + expect(rendersRef($screen, 'reply-input'))->toBeFalse() + ->and(childRefs($screen, 'reply-field-row'))->toBe(['reply-preview-pane']) + ->and(nodeByRef($screen, 'reply-preview')['props']['a11y_label'])->toBe('Edit') + ->and(treeShows(nodeByRef($screen, 'reply-draft-preview'), 'Shipped :rocket: with @ada'))->toBeTrue() + ->and(nodeByRef($screen, 'sheet')['props']['visible'] ?? false)->toBeFalse(); + + finishRefreshes($screen); + + expect(treeShows(nodeByRef($screen, 'reply-draft-preview'), 'Shipped 🚀 with '))->toBeTrue() + ->and(canSend($screen, 'send-reply'))->toBeTrue(); + + Http::assertSent(fn (Request $request): bool => str_ends_with($request->url(), '/api/v1/commits/preview') + && $request->body() === '{"body":"Shipped :rocket: with @ada"}'); + + $screen->tap('reply-preview'); + + expect(nodeByRef($screen, 'reply-input')['props'])->toMatchArray(['value' => 'Shipped :rocket: with @ada', 'autofocus' => true]) + ->and(nodeByRef($screen, 'reply-preview')['props']['a11y_label'])->toBe('Preview'); +}); + +it('shows a drop beside Reply as soon as the reply has anything in it, which throws it away', function () { + fakeThread(); + + $screen = Native::visit('/log/commits/c2'); + + expect(rendersRef($screen, 'reply-stash'))->toBeFalse(); + + $screen->input('reply-input', 'Not this after all'); + $actions = childRefs($screen, 'reply-actions'); + + // A draft you're writing now has drop alone. Only one that came back from the stash says stash@{0}. + expect(array_slice($actions, -2))->toBe(['reply-stash', 'send-reply']) + ->and(childRefs($screen, 'reply-stash'))->toBe(['reply-stash-drop']) + ->and(nodeByRef($screen, 'reply-stash-drop')['props']['a11y_label'] ?? null)->toBe('Discard the draft'); + + $screen->tap('reply-stash-drop'); + + expect($screen->instance()->reply)->toBe('') + ->and(nodeByRef($screen, 'reply-input')['props']['value'])->toBe('') + ->and(rendersRef($screen, 'reply-stash'))->toBeFalse() + ->and(app(Stash::class)->names(app(Account::class)->user()?->id))->toBe([]); +}); + +it('says nothing about a long reply being folded in feeds, beside Reply or in the sheet, and still counts down near the limit', function () { + fakeThread(); + + $screen = Native::visit('/log/commits/c2')->input('reply-input', str_repeat('a', 281)); + + expect(rendersRef($screen, 'reply-budget-fold'))->toBeFalse() + ->and(rendersRef($screen, 'reply-budget'))->toBeFalse(); + + $screen->input('reply-input', str_repeat('a', Commit::MaxLength - 20)); + + expect(nodeByRef($screen, 'reply-budget')['props']['text'])->toBe('20'); + + $screen->call('replyInSheet', 'c2'); + + expect(rendersRef($screen, 'sheet-budget-fold'))->toBeFalse() + ->and(nodeByRef($screen, 'sheet-budget')['props']['text'])->toBe('20'); +}); it('runs the rail from the folded ancestors into the parent, which shows its avatar', function () { $ada = userJson(['id' => 'u2', 'handle' => 'ada', 'name' => 'Ada', 'lane' => 1]); @@ -190,7 +290,7 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): ->and(findNode($screen->tree(), fn (array $node): bool => str_starts_with((string) ($node['ref'] ?? ''), 'thread-end-')))->toBeNull(); }); -it('shows the short hash under the focused commit, without the full date', function () { +it('shows the short hash at the top right of the focused commit, without the full date', function () { fakeThread(['created_at' => '2026-10-14T20:13:05Z']); $screen = Native::visit('/log/commits/c2') @@ -198,8 +298,13 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): ->assertDontSee('+0000'); $hash = nodeByRef($screen, 'focused-hash'); + // The row with the name, the handle and the time, with a spacer pushing the hash to its end. + $nameRow = findNode(nodeByRef($screen, 'focused-commit'), fn (array $node): bool => ($node['type'] ?? null) === 'row' && in_array('focused-time', array_map(fn (array $child): ?string => $child['ref'] ?? null, $node['children'] ?? []), true)); + $children = $nameRow['children'] ?? []; - expect($hash['text'] ?? $hash['props']['text'] ?? null)->toBe('c2'); + expect($hash['text'] ?? $hash['props']['text'] ?? null)->toBe('c2') + ->and($children[array_key_last($children)]['ref'] ?? null)->toBe('focused-hash') + ->and($children[count($children) - 2]['type'] ?? null)->toBe('spacer'); }); it('says when the commit was made, in your timezone, when its time is tapped, as the web does on hover', function (?string $chosen, string $toast) { @@ -250,7 +355,7 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): $staged = $screen->instance()->replies[1]->id; - expect(childRefs($screen, 'thread-page'))->toBe(['focused-commit', 'thread-reply-r1', "thread-reply-{$staged}", 'reply-bar-clearance']) + expect(childRefs($screen, 'thread-scroll'))->toBe(['focused-commit', 'thread-reply-r1', "thread-reply-{$staged}", 'reply-bar-clearance']) ->and(PendingWrite::query()->count())->toBe(1); finishRefreshes($screen) @@ -258,7 +363,7 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): ->assertSee('pending') ->assertDontSee('staged'); - expect(childRefs($screen, 'thread-page'))->toBe(['focused-commit', 'thread-reply-r1', 'thread-reply-r9', 'reply-bar-clearance']) + expect(childRefs($screen, 'thread-scroll'))->toBe(['focused-commit', 'thread-reply-r1', 'thread-reply-r9', 'reply-bar-clearance']) ->and(PendingWrite::query()->count())->toBe(0) ->and(collect(Http::recorded())->filter(fn (array $sent): bool => $sent[0]->method() === 'POST'))->toHaveCount(1); }); @@ -286,7 +391,7 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): ->call('loadMoreReplies') ->assertSet('repliesCursor', null); - expect(childRefs($screen, 'thread-page'))->toBe(['focused-commit', 'thread-reply-r1', 'thread-reply-r2', 'thread-reply-r9', 'reply-bar-clearance']); + expect(childRefs($screen, 'thread-scroll'))->toBe(['focused-commit', 'thread-reply-r1', 'thread-reply-r2', 'thread-reply-r9', 'reply-bar-clearance']); }); it('marks a reply waiting for approval as pending on its row', function () { @@ -323,7 +428,7 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): Native::visit('/log/commits/c2') ->input('reply-input', ' ') - ->tap('send-reply') + ->call('sendReply') ->input('reply-input', str_repeat('a', 4000)) ->assertElement('text', fn (array $node): bool => ($node['ref'] ?? null) === 'reply-budget' && ($node['text'] ?? $node['props']['text'] ?? null) === '0' @@ -336,7 +441,7 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): fakeThread(extra: ['POST /api/v1/commits' => [['data' => replyJson(['id' => 'r9', 'parent_id' => 'c2', 'body' => $body])], 201]]); $screen = Native::visit('/log/commits/c2')->input('reply-input', $body); - expect(nodeByRef($screen, 'send-reply')['props']['disabled'] ?? false)->toBeFalse() + expect(canSend($screen, 'send-reply'))->toBeTrue() ->and(nodeByRef($screen, 'reply-input')['props']['max_length'])->toBe(40000); $screen->tap('send-reply')->assertSet('reply', ''); @@ -347,7 +452,7 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): fakeThread(); $screen = Native::visit('/log/commits/c2')->input('reply-input', 'https://example.com/'.str_repeat('x', 2030)) ->assertSee('Each link must not be greater than 2048 characters.'); - expect(nodeByRef($screen, 'send-reply')['props']['disabled'])->toBeTrue(); + expect(canSend($screen, 'send-reply'))->toBeFalse(); $screen->call('sendReply'); Http::assertNotSent(fn (Request $request): bool => $request->method() === 'POST'); }); @@ -407,10 +512,11 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): }); it('opens ancestors, replies and profiles', function () { - fakeThread(replies: [replyJson(['id' => 'r1'])]); + fakeThread(replies: [replyJson(['id' => 'r1', 'parent_id' => 'c2'])]); - Native::visit('/log/commits/c2')->tap('earlier-commits')->tap('commit-c1')->assertNavigatedTo('/log/commits/c1'); - Native::visit('/log/commits/c2')->tap('replies-c2')->tap('thread-reply-r1')->assertNavigatedTo('/log/commits/r1'); + // Commits in the tree move the page to them, and anything else opens its own page. + Native::visit('/log/commits/c2')->tap('earlier-commits')->tap('commit-c1')->assertNoNavigation()->assertSet('id', 'c1'); + Native::visit('/log/commits/c2')->tap('replies-c2')->tap('thread-reply-r1')->assertNoNavigation()->assertSet('id', 'r1'); Native::visit('/log/commits/c2')->call('openProfile', 'ada')->assertNavigatedTo('/log/users/ada'); }); @@ -429,29 +535,28 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): $screen->tap('replies-c2')->assertDontSee('First reply')->assertSee('1 reply'); expect($chevron('replies-c2')['props'])->toMatchArray(['name' => 'custom:chevron-right', 'rotate' => 0.0, 'animate-duration' => 220.0]); - // A reply's button opens its page rather than its replies in place, so its chevron stays put. + // A reply's button opens its replies in place too, so its chevron turns the same way. $screen->tap('replies-c2'); - expect($chevron('replies-r1')['props'])->not->toHaveKey('rotate'); + expect($chevron('replies-r1')['props'])->toMatchArray(['rotate' => 0.0, 'animate-duration' => 220.0]); })->with(['ios', 'android']); it('opens with its replies showing from a replies button', function () { fakeThread(['replies_count' => 1], replies: [replyJson(['id' => 'r1', 'parent_id' => 'c2', 'body' => 'First reply', 'replies_count' => 1])], extra: [ 'GET /api/v1/commits/r1' => [commitPageJson(replyJson(['id' => 'r1', 'parent_id' => 'c2', 'body' => 'First reply', 'replies_count' => 1]))], - 'GET /api/v1/commits/r1/replies' => [pageJson([replyJson(['id' => 'r2', 'parent_id' => 'r1', 'body' => 'Answering the reply'])])], + // Someone other than r1's author, whose reply to themselves would carry r1 on as a thread instead. + 'GET /api/v1/commits/r1/replies' => [pageJson([replyJson(['id' => 'r2', 'parent_id' => 'r1', 'body' => 'Answering the reply', 'author' => userJson(['id' => 'u3', 'handle' => 'grace', 'name' => 'Grace'])])])], ]); Native::visit('/log/commits/c2', ['replies' => true]) ->assertSee('First reply') ->assertSee('Hide replies'); - // A reply's replies don't open in place on a commit page, so its button opens its page with them showing. + // A reply's replies open in place under it, as on the web, rather than on its page. Native::visit('/log/commits/c2') ->tap('replies-c2') ->tap('replies-r1') - ->assertNavigatedTo('/log/commits/r1') - ->follow() - ->assertSee('Answering the reply') - ->assertSee('Hide replies'); + ->assertNoNavigation() + ->assertSee('Answering the reply'); }); it('asks for the replies a page at a time, and the next page from Show more', function () { @@ -568,7 +673,7 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): // One level in, on an elbow off the deleted reply's spine. expect(findNode(nodeByRef($screen, 'thread-reply-r3'), fn (array $node): bool => ($node['ref'] ?? null) === 'thread-elbow'))->not->toBeNull(); - $screen->tap('thread-reply-r3')->assertNavigatedTo('/log/commits/r3'); + $screen->tap('thread-reply-r3')->assertNoNavigation()->assertSet('id', 'r3'); Native::visit('/log/commits/c2') ->tap('replies-c2') @@ -696,7 +801,7 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): expect(app(Account::class)->user())->toBeNull(); }); -it('reloads when you come back from a reply you deleted', function () { +it('moves back to the parent when you delete a reply the page moved to', function () { $replyDeleted = false; Http::fake(function (Request $request) use (&$replyDeleted) { @@ -713,15 +818,15 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): }; }); - $reply = Native::visit('/log/commits/c2') + // The page moved to the reply, so deleting it moves the page back to its parent, asked for again. + Native::visit('/log/commits/c2') ->tap('replies-c2') ->assertSee('Soon gone') ->tap('thread-reply-r1') - ->follow() + ->assertSet('id', 'r1') ->call('deleteCommit', 'r1') - ->assertWentBack(); - - $reply->goBack() + ->assertNoNavigation() + ->assertSet('id', 'c2') ->assertSee('Parent') ->assertDontSee('Soon gone') ->assertSee('No replies yet.'); @@ -766,7 +871,7 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): it('stars the focused commit and its replies in place', function () { $grace = userJson(['id' => 'u3', 'handle' => 'grace', 'name' => 'Grace']); - fakeThread(['author' => $grace], replies: [replyJson(['id' => 'r1', 'parent_id' => 'c2', 'author' => $grace])], extra: [ + fakeThread(['author' => $grace], replies: [replyJson(['id' => 'r1', 'parent_id' => 'c2'])], extra: [ 'POST /api/v1/commits/c2/star' => [['data' => commitJson(['id' => 'c2', 'stars_count' => 1, 'starred' => true])]], 'POST /api/v1/commits/r1/star' => [['data' => commitJson(['id' => 'r1', 'starred' => true])]], ]); @@ -789,29 +894,95 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): expect(pressFeedbackInScroller($screen))->toBe([]); }); -it('paints the reply bar solid on Android, with its hairline, so the replies never show through', function () { +it('puts the reply bar on glass on iOS and the surface on Android, with no line, and fades the page out above it', function (string $platform) { fakeThread(); - $screen = Native::visit('/log/commits/c2', platform: 'android'); - $bar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); + if ($platform === 'ios') { + GlassOpacity::skipUnlessSupported(); + } - expect($bar['children'][0]['ref'] ?? null)->toBe('reply-bar') - ->and($bar['children'][0]['style']['bg_color'] ?? null)->toBe(config('native-ui.theme.light.surface')) - ->and($bar['children'][0]['props']['dark_bg_color'] ?? null)->toBe(config('native-ui.theme.dark.surface')) - ->and($bar['children'][0]['children'][0]['style']['bg_color'] ?? null)->toBe(config('native-ui.theme.light.hairline')) - ->and(nodeByRef($screen, 'reply-plate')['props']['glass'] ?? null)->toBeNull(); + $screen = Native::visit('/log/commits/c2', platform: $platform); + $bottomBar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); + $bar = $bottomBar['children'][0]; + $surface = substr(strtoupper(config('native-ui.theme.light.surface')), 1); + $darkSurface = substr(strtoupper(config('native-ui.theme.dark.surface')), 1); + + expect($bar['ref'] ?? null)->toBe('reply-bar') + ->and($bar['props']['glass'] ?? null)->toBeNull() + ->and(childRefs($screen, 'reply-content')[0])->toBe('reply-mention-slot'); + + if ($platform === 'ios') { + // The page runs on under the bar, which is glass, so it shows through blurred. The bar draws the fade at its + // top, ending at the glass's tint, and its rows carry the tint. The bar itself has no background, which iOS + // would paint behind the fade. + expect($bottomBar['props']['glass'] ?? null)->toBe(1) + ->and($bar['style']['bg_color'] ?? null)->toBeNull() + ->and(nodeByRef($screen, 'reply-rows')['style']['bg_color'] ?? null)->toBe('#66'.$surface) + ->and(nodeByRef($screen, 'reply-rows')['props']['dark_bg_color'] ?? null)->toBe('#66'.$darkSurface) + ->and(nodeByRef($screen, 'reply-fade')['props']['gradient_stops'] ?? null)->toBe('#00'.$surface.',#66'.$surface) + ->and(childRefs($screen, 'reply-bar'))->toBe(['reply-fade', 'reply-rows']) + ->and(childRefs($screen, 'thread-stack'))->toBe(['thread-scroll']); + } else { + // No glass on Android. The page stops at the bar, which is the surface, and the fade lies over its foot. + expect($bottomBar['props']['glass'] ?? null)->toBeNull() + ->and($bar['style']['bg_color'] ?? null)->toBe(config('native-ui.theme.light.surface')) + ->and(nodeByRef($screen, 'reply-rows')['style']['bg_color'] ?? null)->toBe(config('native-ui.theme.light.surface')) + ->and(nodeByRef($screen, 'reply-rows')['props']['dark_bg_color'] ?? null)->toBe(config('native-ui.theme.dark.surface')) + ->and(str_ends_with(nodeByRef($screen, 'reply-fade')['props']['gradient_stops'] ?? '', ',#'.$surface))->toBeTrue() + ->and(childRefs($screen, 'reply-bar'))->toBe(['reply-rows']) + ->and(childRefs($screen, 'thread-stack'))->toBe(['thread-scroll', 'reply-fade']); + } +})->with(['ios', 'android']); + +it('keeps the reply field closer to the fade than to the row of tools under it', function (string $platform) { + fakeThread(); + + $screen = Native::visit('/log/commits/c2', platform: $platform); + + // [top, right, bottom, left]. The row has no top padding, so the field starts 4pt under the fade, and the field + // row leaves 8pt between the field and the tools. + expect(nodeByRef($screen, 'reply-row')['layout']['padding'])->toEqual([0, 16, 8, 16]) + ->and(nodeByRef($screen, 'reply-field-row')['layout']['padding'])->toEqual([4, 12, 8, 16]); +})->with(['ios', 'android']); + +it('fades the glass under the reply bar to 80% on iOS only', function (string $platform) { + GlassOpacity::skipUnlessSupported(); + fakeThread(); + + $screen = Native::visit('/log/commits/c2', platform: $platform); + $bottomBar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); + + expect($bottomBar['props']['glass_opacity'] ?? null)->toBe($platform === 'ios' ? Display::ComposerGlassOpacity / 100 : null); +})->with(['ios', 'android']); + +it('stands the reply bar on the scroll edge effect from iOS 26, with no fade or tint, and glass for older iOS', function () { + fakeThread(replies: [replyJson(['id' => 'r1', 'parent_id' => 'c2', 'body' => 'The last reply'])]); + + ScrollEdge::onIos('26.1', function (): void { + $screen = Native::visit('/log/commits/c2', platform: 'ios'); + $bottomBar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); + + // The bar asks for the edge effect and keeps its glass for older iOS, which mobile-air leaves out here. + // The field and tools sit in the glass box. The page ends where the bar starts, with no fade above it. + expect($bottomBar['props']['edge_blur'] ?? null)->toBe(Display::ComposerEdgeBlur) + ->and($bottomBar['props']['glass'] ?? null)->toBe(1) + ->and(childRefs($screen, 'reply-bar'))->toBe(['reply-rows']) + ->and(nodeByRef($screen, 'reply-rows')['style']['bg_color'] ?? null)->toBeNull() + ->and(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'reply-fade'))->toBeNull() + ->and(nodeByRef($screen, 'reply-box')['props']['glass'] ?? null)->toBe(Display::ComposerInGlassBox ? 1 : null) + ->and(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual(24 + Display::composerBoxBarHeight() + 34); + }); }); -it('leaves the reply bar bare on iOS and floats the field on Liquid Glass', function () { +it('keeps the fade at the top of the reply bar before iOS 26', function () { fakeThread(); - $screen = Native::visit('/log/commits/c2', platform: 'ios'); - $bar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); + ScrollEdge::onIos('18.5', function (): void { + $screen = Native::visit('/log/commits/c2', platform: 'ios'); - expect($bar['children'][0]['ref'] ?? null)->toBe('reply-bar') - ->and($bar['children'][0]['style']['bg_color'] ?? null)->toBeNull() - ->and($bar['children'][0]['children'][0]['style']['bg_color'] ?? null)->toBeNull() - ->and(nodeByRef($screen, 'reply-plate')['props']['glass'] ?? null)->toBe(1); + expect(childRefs($screen, 'reply-bar'))->toBe(['reply-fade', 'reply-rows']) + ->and(nodeByRef($screen, 'reply-box')['props']['glass'] ?? null)->toBeNull(); + }); }); it("keeps the reply bar's root full width and centres a readable column in it, for Android's full-width bar box", function (string $platform) { @@ -819,13 +990,17 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): $screen = Native::visit('/log/commits/c2', platform: $platform); $bar = nodeByRef($screen, 'reply-bar'); + $rows = nodeByRef($screen, 'reply-rows'); $content = nodeByRef($screen, 'reply-content'); $variant = json_decode($content['props']['_variants'], true)[0]; + // The rows under the fade carry the tint full width, so they're what centres the readable column. expect($bar['props'])->not->toHaveKey('_variants') - ->and($bar['layout'])->toMatchArray(['width' => 'fill', 'align_items' => AlignItems::Center->value]) + ->and($bar['layout']['width'] ?? null)->toBe('fill') + ->and($rows['props'])->not->toHaveKey('_variants') + ->and($rows['layout'])->toMatchArray(['width' => 'fill', 'align_items' => AlignItems::Center->value]) ->and($variant)->toMatchArray(['min' => TailwindParser::breakpointMinWidth('expanded'), 'layout' => TailwindParser::parse(Display::ReadableColumn)['variants']['expanded']]) - ->and(childRefs($screen, 'reply-bar'))->toBe([null, 'reply-content']) + ->and(childRefs($screen, 'reply-rows'))->toBe(['reply-content']) ->and(childRefs($screen, 'reply-content'))->toContain('reply-mention-slot', 'reply-row'); })->with(['ios', 'android']); @@ -833,17 +1008,20 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): fakeThread(replies: [replyJson(['id' => 'r1', 'parent_id' => 'c2', 'body' => 'The last reply'])]); $screen = Native::visit('/log/commits/c2', platform: 'ios'); - $page = childRefs($screen, 'thread-page'); + $scroller = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'scroll_view'); + $page = $scroller['children']; + + // The clearance is the last thing on the page, under the last reply: the fade, the bar and the home indicator. + $bar = 24 + Display::ComposerFadeHeight + Display::ComposerBoxBarHeight + 34; - // The clearance is the last thing on the page, under the last reply: the bar's line and the home indicator. - expect(end($page))->toBe('reply-bar-clearance') - ->and(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual(24 + 53 + 34); + expect(end($page)['ref'] ?? null)->toBe('reply-bar-clearance') + ->and(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual($bar); $screen->input('reply-input', "Three lines\nof a\ndraft"); - expect(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual(24 + 53 + 2 * 21 + 34); + expect(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual($bar + 2 * 21); $screen->input('reply-input', str_repeat("A line\n", 12)); - expect(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual(24 + 53 + 4 * 21 + 34); + expect(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual($bar + 4 * 21); }); diff --git a/tests/Feature/Screens/CommitMentionsTest.php b/tests/Feature/Screens/CommitMentionsTest.php index 4d35f14f..69c2e0b0 100644 --- a/tests/Feature/Screens/CommitMentionsTest.php +++ b/tests/Feature/Screens/CommitMentionsTest.php @@ -1,9 +1,12 @@ 'http://devnull.test']); @@ -70,11 +73,11 @@ function mentionsCommitPage(?array $mentions = null): TestableComponent * The Log, with Ada's c1 in it and devnull's mention search answering, and the composer sheet open: for a new commit, * or for a quote of c1. */ -function mentionsComposer(bool $quoting = false): TestableComponent +function mentionsComposer(bool $quoting = false, ?array $mentions = null): TestableComponent { fakeApi([ 'GET /api/v1/log/following' => [pageJson([commitJson(['id' => 'c1', 'body' => 'Required reading.', 'author' => userJson(['id' => 'u2', 'handle' => 'ada', 'name' => 'Ada Lovelace'])])])], - 'GET /api/v1/search/mentions' => mentionsFound(), + 'GET /api/v1/search/mentions' => $mentions ?? mentionsFound(), ]); $screen = Native::visit('/log', platform: 'ios'); @@ -95,6 +98,31 @@ function mentionsComposer(bool $quoting = false): TestableComponent ->assertMissingElement('column', fn (array $node): bool => ($node['ref'] ?? null) === 'mention-suggestions'); }); +it('holds the reply bar\'s suggestions to six rows and scrolls the rest inside the list', function () { + $people = array_map(fn (int $n): array => userJson(['id' => "u{$n}", 'handle' => "ada{$n}", 'name' => "Ada {$n}"]), range(1, 7)); + $screen = mentionsCommitPage([['data' => $people, 'organizations' => [['handle' => 'adaptive', 'name' => 'Adaptive', 'avatar_url' => null]]]]) + ->input('reply-input', '@ada', 4); + + // Eight rows, so they sit in a list six rows tall, which scrolls. The slot and the field's row around it stay put. + $list = nodeByRef($screen, 'mention-scroll'); + + expect(childRefs($screen, 'mention-suggestions'))->toBe(['mention-scroll']) + ->and($list['type'])->toBe('scroll_view') + ->and($list['layout']['height'] ?? null)->toEqual(6 * 44) + ->and(childRefs($screen, 'mention-scroll'))->toBe([...array_map(fn (int $n): string => "mention-ada{$n}", range(1, 7)), 'mention-adaptive']) + ->and(childRefs($screen, 'reply-content'))->toBe(['reply-mention-slot', 'reply-photos-slot', 'reply-row']); + + $screen->tap('mention-ada7')->assertSet('reply', '@ada7 '); +}); + +it('leaves six suggestions or fewer as tall as their rows, with no list to scroll', function () { + $people = array_map(fn (int $n): array => userJson(['id' => "u{$n}", 'handle' => "ada{$n}", 'name' => "Ada {$n}"]), range(1, 6)); + $screen = mentionsCommitPage([['data' => $people]])->input('reply-input', '@ada', 4); + + expect(childRefs($screen, 'mention-suggestions'))->toBe(array_map(fn (int $n): string => "mention-ada{$n}", range(1, 6))) + ->and(rendersRef($screen, 'mention-scroll'))->toBeFalse(); +}); + it('puts the person picked in the reply where the @ was, with the caret after them', function () { $screen = mentionsCommitPage() ->input('reply-input', 'cc @adfor review', 6) @@ -181,3 +209,95 @@ function mentionsComposer(bool $quoting = false): TestableComponent ->assertSet('mention', null) ->assertSet('mentionPeople', []); }); + +it('floats the suggestions over the quoted commit on glass, just under the caret line and as tall as their rows', function () { + $screen = mentionsComposer(quoting: true) + ->input('sheet-body', "see\n@a", 6) + ->moveCaretTo('sheet-body', new Caret(x: 20, y: 22, width: 2, height: 22, line: 1, fieldWidth: 350, fieldHeight: 240)); + $overlay = nodeByRef($screen, 'sheet-mentions'); + + // Out of the layout, over the field and the card under it, so neither moves. + expect($overlay['layout']['position_type'])->toBe(1) + ->and($overlay['layout']['position'])->toEqual([ + ComposerSheet::FieldTop + 44 + ComposerSheet::MentionGap, + 12, + null, + 12, + ]) + ->and($overlay['layout']['height'] ?? null)->toEqual(ComposerSheet::mentionHeight(3)) + // There's room for them under the caret, so the field still fills. + ->and(nodeByRef($screen, 'sheet-field-slot')['layout']['flex_grow'] ?? null)->toEqual(1) + ->and($overlay['props']['glass'])->toBe(1) + ->and(childRefs($screen, 'sheet-body-area'))->toBe(['sheet-field-slot', 'sheet-below', 'sheet-mentions']) + ->and(findNode(nodeByRef($screen, 'sheet-below'), fn (array $node): bool => ($node['ref'] ?? null) === 'quote-card'))->not->toBeNull() + // The list scrolls inside it when there are more than fit. + ->and(findNode($overlay, fn (array $node): bool => $node['type'] === 'scroll_view' && ($node['ref'] ?? null) === 'sheet-mentions-scroll'))->not->toBeNull() + ->and(childRefs($screen, 'mention-suggestions'))->toBe(['mention-ada', 'mention-adam', 'mention-adaptive']); +}); + +it('scrolls a long list of suggestions in the sheet with one scroll view, its own', function () { + $people = array_map(fn (int $n): array => userJson(['id' => "u{$n}", 'handle' => "ada{$n}", 'name' => "Ada {$n}"]), range(1, 9)); + $screen = mentionsComposer(mentions: [['data' => $people]]) + ->input('sheet-body', "see\n\n\n\n\n\n@a", 12) + ->moveCaretTo('sheet-body', new Caret(x: 20, y: 132, width: 2, height: 22, line: 6, fieldWidth: 350, fieldHeight: 240)); + $overlay = nodeByRef($screen, 'sheet-mentions'); + + // Nine rows is past the six the mention list scrolls by itself, but the sheet scrolls it already, so there is no + // second scroll view inside (two scroll bars on a short phone). + expect(findNodes($overlay, fn (array $node): bool => $node['type'] === 'scroll_view'))->toHaveCount(1) + ->and(nodeByRef($screen, 'sheet-mentions-scroll')['type'])->toBe('scroll_view') + ->and(rendersRef($screen, 'mention-scroll'))->toBeFalse() + ->and(childRefs($screen, 'mention-suggestions'))->toBe(array_map(fn (int $n): string => "mention-ada{$n}", range(1, 9))); +}); + +it('shortens the field to end on the caret line when the suggestions would not fit under it, and fills it again once they go', function () { + $screen = mentionsComposer(quoting: true)->input('sheet-body', "see\n\n\n\n\n\n\n\n@a", 14); + $field = idsDownTo($screen->tree(), 'sheet-body'); + + // The caret's line ends 20pt above the field's bottom, where three people don't fit. + $screen->moveCaretTo('sheet-body', new Caret(x: 20, y: 196, width: 2, height: 24, line: 8, fieldWidth: 350, fieldHeight: 240)); + $shortened = 240 - ComposerSheet::MentionGap - ComposerSheet::MentionInset - ComposerSheet::mentionHeight(3); + $overlay = nodeByRef($screen, 'sheet-mentions'); + + expect(nodeByRef($screen, 'sheet-field-slot')['layout']['height'] ?? null)->toEqual(ComposerSheet::FieldTop + $shortened) + ->and(nodeByRef($screen, 'sheet-field-slot')['layout']['flex_grow'] ?? 0)->toEqual(0) + // Under the shortened field, so off the caret's line, and down to the toolbar over the quoted commit. + ->and($overlay['layout']['position'])->toEqual([ComposerSheet::FieldTop + $shortened + ComposerSheet::MentionGap, 12, ComposerSheet::MentionInset, 12]) + ->and(childRefs($screen, 'sheet-body-area'))->toBe(['sheet-field-slot', 'sheet-below', 'sheet-mentions']) + ->and(idsDownTo($screen->tree(), 'sheet-body'))->toBe($field); + + // The shortened field reports its caret at its new height, which doesn't move anything. + $screen->moveCaretTo('sheet-body', new Caret(x: 20, y: $shortened - 24, width: 2, height: 24, line: 8, fieldWidth: 350, fieldHeight: $shortened)) + ->assertSet('sheetCaret', ['bottom' => 220.0, 'line_height' => 24.0, 'field_height' => 240.0]); + + // Picked, the list goes and the field fills again, the same view. + $screen->tap('mention-ada'); + expect(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'sheet-mentions'))->toBeNull() + ->and(nodeByRef($screen, 'sheet-field-slot')['layout']['flex_grow'] ?? null)->toEqual(1) + ->and(nodeByRef($screen, 'sheet-field-slot')['layout'])->not->toHaveKey('height') + ->and(idsDownTo($screen->tree(), 'sheet-body'))->toBe($field); +}); + +it('animates the field and the suggestions moving in the sheet', function () { + LayoutAnimation::skipUnlessSupported(); + + expect(nodeByRef(mentionsComposer(), 'sheet-body-area')['props'])->toHaveKey('animate_layout', true); +}); + +it('draws the floating suggestions on a raised surface on Android', function () { + fakeApi([ + 'GET /api/v1/log/following' => [pageJson([])], + 'GET /api/v1/search/mentions' => mentionsFound(), + ]); + + $overlay = nodeByRef(Native::visit('/log', platform: 'android')->press('composeInSheet')->input('sheet-body', 'hi @a', 5), 'sheet-mentions'); + + expect($overlay['props'])->not->toHaveKey('glass') + ->and(strtolower($overlay['style']['bg_color']))->toBe(strtolower(config('native-ui.theme.light.surface'))); +}); + +it('leaves a gap between the suggestions and the reply box under them on iOS', function () { + $screen = mentionsCommitPage()->input('reply-input', 'thanks @ad', 10); + + expect(nodeByRef($screen, 'reply-mention-slot')['layout']['padding'][2])->toBe(8.0); +}); diff --git a/tests/Feature/Screens/CommitMenuTest.php b/tests/Feature/Screens/CommitMenuTest.php index aedf1ae3..41d75ed2 100644 --- a/tests/Feature/Screens/CommitMenuTest.php +++ b/tests/Feature/Screens/CommitMenuTest.php @@ -130,7 +130,7 @@ $deleted = true; }), 'GET /api/v1/commits/c2' => Http::response(commitPageJson(commitJson(['id' => 'c2', 'body' => 'Ada asks', 'replies_count' => $deleted ? 0 : 1, 'author' => userJson(['id' => 'u2', 'handle' => 'ada'])]))), - 'GET /api/v1/commits/c2/replies' => Http::response(pageJson($deleted ? [] : [replyJson(['id' => 'r1', 'parent_id' => 'c2', 'body' => 'Soon gone'])])), + 'GET /api/v1/commits/c2/replies' => Http::response(pageJson($deleted ? [] : [replyJson(['id' => 'r1', 'parent_id' => 'c2', 'body' => 'Soon gone', 'author' => userJson()])])), default => Http::response(['message' => 'No fake.'], 404), }; }); diff --git a/tests/Feature/Screens/ComposeSheetTest.php b/tests/Feature/Screens/ComposeSheetTest.php index 7158888c..9a5af929 100644 --- a/tests/Feature/Screens/ComposeSheetTest.php +++ b/tests/Feature/Screens/ComposeSheetTest.php @@ -1,11 +1,13 @@ 'http://devnull.test']); @@ -281,6 +283,52 @@ function sheetCommitDisabled(TestableComponent $screen): bool ->and(idsDownTo($screen->tree(), 'sheet-body'))->toBe($field); }); +it('fills the sheet with the field, with nothing scrolling around it', function () { + $screen = composeSheetOnLog(); + $field = nodeByRef($screen, 'sheet-body')['props']; + + expect(findNodes(nodeByRef($screen, 'sheet'), fn (array $node): bool => $node['type'] === 'scroll_view'))->toBe([]) + // As tall as the space between the author row and the toolbar, scrolling its own text. + ->and($field['fills_height'] ?? null)->toBeTrue() + ->and($field['min_lines'])->toBe(ComposerSheet::MinFieldLines) + ->and($field)->not->toHaveKey('max_lines') + ->and(nodeByRef($screen, 'sheet-field-slot')['layout']['flex_grow'] ?? null)->toEqual(1) + // It says where its caret is drawn, for the mention list. + ->and($field['on_caret_change'] ?? null)->toBeInt(); +}); + +it('puts the poll under the field, which gives up the room it takes', function () { + $screen = composeSheetOnLog()->tap('sheet-poll'); + + expect(childRefs($screen, 'sheet-body-area'))->toBe(['sheet-field-slot', 'sheet-below']) + ->and(findNode(nodeByRef($screen, 'sheet-below'), fn (array $node): bool => ($node['ref'] ?? null) === 'poll-editor'))->not->toBeNull(); +}); + +it('keeps where the field says its caret is until the sheet goes', function () { + $screen = composeSheetOnLog() + ->moveCaretTo('sheet-body', new Caret(y: 48, height: 24, line: 2, fieldWidth: 350, fieldHeight: 240)) + ->assertSet('sheetCaret', ['bottom' => 72.0, 'line_height' => 24.0, 'field_height' => 240.0]); + + $screen->press('hideCommitSheet')->assertSet('sheetCaret', null); +}); + +it('keeps the field the same view while photos, a poll and mentions come and go around it', function () { + fakeApi([ + 'GET /api/v1/log/following' => [pageJson([])], + 'GET /api/v1/search/mentions' => [['data' => [userJson(['id' => 'u9', 'handle' => 'ada'])], 'organizations' => []]], + ]); + $screen = Native::visit('/log', platform: 'ios')->press('composeInSheet'); + $field = idsDownTo($screen->tree(), 'sheet-body'); + + $screen->input('sheet-body', 'hi @a', 5); + expect(nodeByRef($screen, 'sheet-mentions'))->not->toBeEmpty() + ->and(idsDownTo($screen->tree(), 'sheet-body'))->toBe($field); + + $screen->input('sheet-body', 'hi', 2)->tap('sheet-poll'); + expect(nodeByRef($screen, 'poll-editor'))->not->toBeEmpty() + ->and(idsDownTo($screen->tree(), 'sheet-body'))->toBe($field); +}); + it('only commits from a sheet that has a composer in it', function () { fakeApi(['GET /api/v1/log/following' => [pageJson([commitJson(['id' => 'c1', 'author' => userJson(['id' => 'u2', 'handle' => 'ada'])])])]]); diff --git a/tests/Feature/Screens/ComposerPhotosTest.php b/tests/Feature/Screens/ComposerPhotosTest.php index 9338fce8..5600ab62 100644 --- a/tests/Feature/Screens/ComposerPhotosTest.php +++ b/tests/Feature/Screens/ComposerPhotosTest.php @@ -41,11 +41,11 @@ function isTool(TestableComponent $screen, string $ref): bool return nodeByRef($screen, $ref)['type'] === 'pressable'; } -it('pins the toolbar under the scroll view, so it stays just above the keyboard', function () { +it('pins the toolbar under the field and what is around it, so it stays just above the keyboard', function () { $screen = composerOnLog(); $toolbar = nodeByRef($screen, 'sheet-toolbar'); - expect(findNode(nodeByRef($screen, 'sheet-composer'), fn (array $node): bool => ($node['ref'] ?? null) === 'sheet-toolbar'))->toBeNull() + expect(findNode(nodeByRef($screen, 'sheet-body-area'), fn (array $node): bool => ($node['ref'] ?? null) === 'sheet-toolbar'))->toBeNull() ->and(findNode($toolbar, fn (array $node): bool => ($node['ref'] ?? null) === 'sheet-tools'))->not->toBeNull() ->and(findNode($toolbar, fn (array $node): bool => ($node['ref'] ?? null) === 'sheet-preview'))->not->toBeNull(); }); @@ -228,105 +228,106 @@ function isTool(TestableComponent $screen, string $ref): bool ->and(app(Stash::class)->names(app(Account::class)->user()?->id))->toBe([]); }); -it('opens a commit\'s reply in the sheet with what the reply bar had, and replies with photos', function () { +/** + * The commit page for c2, by Ada, which a reply can be sent to. + */ +function replyPage(string $platform = 'ios'): TestableComponent +{ serveApi([ 'GET /api/v1/commits/c2' => [commitPageJson(commitJson(['id' => 'c2', 'body' => 'The focused commit', 'author' => userJson(['id' => 'u2', 'handle' => 'ada', 'name' => 'Ada'])]))], 'GET /api/v1/commits/c2/replies' => [pageJson([])], - 'POST /api/v1/commits' => [['data' => replyJson(['id' => 'r9', 'parent_id' => 'c2', 'body' => 'Here it is'])], 201], + 'POST /api/v1/commits' => [['data' => replyJson(['id' => 'r9', 'parent_id' => 'c2', 'body' => 'Look'])], 201], ]); - $screen = Native::visit('/log/commits/c2') - ->input('reply-input', 'Here it') - ->tap('reply-expand') - ->assertSee('Reply to @ada'); - - expect(nodeByRef($screen, 'sheet-body')['props'])->toMatchArray(['value' => 'Here it', 'placeholder' => 'Reply to @ada']) - ->and(nodeByRef($screen, 'quote-card')['props']['a11y_label'])->toBe('Replying to Ada') - ->and(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'sheet-stash'))->toBeNull() - ->and(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'sheet-poll'))->toBeNull() - ->and(nodeByRef($screen, 'sheet-commit')['props']['a11y_label'] ?? null)->toBe('Reply'); - - photosPicked($screen, [testPhoto()]) - ->input('sheet-body', 'Here it is') - ->tap('sheet-commit') - ->dismissSheet('sheet') - ->assertSee('Here it is'); + return Native::visit('/log/commits/c2', platform: $platform); +} - Http::assertSent(fn (Request $request): bool => $request->method() === 'POST' && multipartParts($request)[0]['contents'] === '{"body":"Here it is","parent_id":"c2"}'); +it('adds photos to a reply from the bar, from the library or the camera, without the sheet', function () { + $screen = replyPage()->input('reply-input', 'Look')->tap('reply-pick-photos'); - expect(array_map(fn ($reply): string => $reply->id, $screen->instance()->replies))->toBe(['r9']) - ->and($screen->instance()->reply)->toBe('') - ->and(nodeByRef($screen, 'reply-input')['props']['value'])->toBe(''); -}); + $screen->assertNativeCalled('Camera.PickMedia', fn (array $params): bool => $params['mediaType'] === 'images' && $params['multiple'] === true && $params['maxItems'] === 3); -it('hands the reply back to the reply bar when the sheet goes unsent', function () { - serveApi([ - 'GET /api/v1/commits/c2' => [commitPageJson(commitJson(['id' => 'c2', 'author' => userJson(['id' => 'u2', 'handle' => 'ada'])]))], - 'GET /api/v1/commits/c2/replies' => [pageJson([])], - ]); + photosPicked($screen, [testPhoto()])->tap('reply-take-photo')->assertNativeCalled('Camera.GetPhoto'); + $screen->emitNative(PhotoTaken::class, ['path' => testPhoto('jpg', 30, 40), 'mimeType' => 'image/jpeg']); - $screen = Native::visit('/log/commits/c2') - ->input('reply-input', 'Half') - ->tap('reply-expand') - ->input('sheet-body', 'Half a reply') - ->dismissSheet('sheet'); + // They show above the field, which keeps its place, and go in the reply's stash with its text. + expect($screen->instance()->replyImages)->toHaveCount(2) + ->and(childRefs($screen, 'reply-content'))->toBe(['reply-mention-slot', 'reply-photos-slot', 'reply-row']) + ->and(nodeByRef($screen, 'reply-photo-0'))->not->toBeNull() + ->and(nodeByRef($screen, 'reply-photo-1'))->not->toBeNull() + ->and(nodeByRef($screen, 'sheet')['props']['visible'] ?? false)->toBeFalse() + ->and(app(Stash::class)->get(app(Account::class)->user()?->id, 'reply-c2')->images)->toHaveCount(2); - expect(nodeByRef($screen, 'reply-input')['props']['value'])->toBe('Half a reply') - ->and(app(Stash::class)->get(app(Account::class)->user()?->id, 'reply-c2')->body)->toBe('Half a reply'); + // A third fills it, and the button can't add more. + photosPicked($screen, [testPhoto()]); - Http::assertNotSent(fn (Request $request): bool => $request->method() === 'POST'); + expect(menuItems($screen, 'reply-add-photos'))->toBe([]) + ->and(nodeByRef($screen, 'reply-add-photos')['a11y_label'] ?? nodeByRef($screen, 'reply-add-photos')['props']['a11y_label'] ?? null)->toBe('A reply can have up to 3 photos'); }); -it('hands the reply\'s photos back to the reply bar too, which counts them, keeps them and replies with them', function () { - serveApi([ - 'GET /api/v1/commits/c2' => [commitPageJson(commitJson(['id' => 'c2', 'author' => userJson(['id' => 'u2', 'handle' => 'ada'])]))], - 'GET /api/v1/commits/c2/replies' => [pageJson([])], - 'POST /api/v1/commits' => [['data' => replyJson(['id' => 'r9', 'parent_id' => 'c2', 'body' => 'Look'])], 201], - ]); +it('takes a photo off the reply in the bar with its ✕, and off the phone', function () { + $screen = photosPicked(replyPage(), [testPhoto(), testPhoto()]); + $removed = $screen->instance()->replyImages[0]->path; - $screen = photosPicked(Native::visit('/log/commits/c2')->input('reply-input', 'Look')->tap('reply-expand'), [testPhoto()]) - ->dismissSheet('sheet'); - $path = $screen->instance()->replyImages[0]->path; + $screen->tap('reply-photo-0-remove'); + + expect($screen->instance()->replyImages)->toHaveCount(1) + ->and(file_exists($removed))->toBeFalse() + ->and(app(Stash::class)->get(app(Account::class)->user()?->id, 'reply-c2')->images)->toHaveCount(1); +}); - expect(treeShows(nodeByRef($screen, 'reply-photos'), '1 photo'))->toBeTrue() - ->and(nodeByRef($screen, 'reply-photos')['props']['a11y_label'] ?? null)->toBe('1 photo attached'); +it('keeps a reply\'s photos for when you come back to the commit, and replies with them', function () { + photosPicked(replyPage()->input('reply-input', 'Look'), [testPhoto()]); - // Coming back to the commit, the bar has them still. $screen = Native::visit('/log/commits/c2'); + $path = $screen->instance()->replyImages[0]->path; expect($screen->instance()->reply)->toBe('Look') - ->and($screen->instance()->replyImages)->toHaveCount(1) + ->and(nodeByRef($screen, 'reply-photo-0'))->not->toBeNull() ->and(nodeByRef($screen, 'reply-stash'))->not->toBeNull(); - // The count opens the sheet on them. - $screen->tap('reply-photos'); - - expect(nodeByRef($screen, 'sheet')['props']['visible'])->toBeTrue() - ->and($screen->instance()->sheetImages[0]->path)->toBe($path); - - $screen->dismissSheet('sheet')->tap('send-reply')->assertSee('Look'); + $screen->tap('send-reply')->assertSee('Look'); Http::assertSent(fn (Request $request): bool => $request->method() === 'POST' && multipartParts($request)[0]['contents'] === '{"body":"Look","parent_id":"c2"}' && multipartParts($request)[1]['name'] === 'images[]'); expect($screen->instance()->replyImages)->toBe([]) - ->and(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'reply-photos'))->toBeNull() + ->and(rendersRef($screen, 'reply-photo-0'))->toBeFalse() ->and(file_exists($path))->toBeFalse() ->and(app(Stash::class)->names(app(Account::class)->user()?->id))->toBe([]); }); -it('hands the reply and its photos back to the reply bar when Cancel closes the sheet on Android, which never says it has gone', function () { - serveApi([ - 'GET /api/v1/commits/c2' => [commitPageJson(commitJson(['id' => 'c2', 'author' => userJson(['id' => 'u2', 'handle' => 'ada'])]))], - 'GET /api/v1/commits/c2/replies' => [pageJson([])], - ]); +it('previews a reply with its photos in the bar', function () { + $screen = photosPicked(replyPage()->input('reply-input', 'Look'), [testPhoto()])->tap('reply-preview'); - $screen = photosPicked(Native::visit('/log/commits/c2', platform: 'android')->input('reply-input', 'Half')->tap('reply-expand'), [testPhoto()]) - ->input('sheet-body', 'Half a reply') - ->tap('sheet-cancel') - ->input('reply-input', 'Half a reply, and more'); + // The photos move into the preview, as the reply will show them, and their row above the field goes. + expect(treeShows(nodeByRef($screen, 'reply-draft-preview'), 'Look'))->toBeTrue() + ->and(findNode(nodeByRef($screen, 'reply-draft-preview'), fn (array $node): bool => ($node['type'] ?? null) === 'image'))->not->toBeNull() + ->and(rendersRef($screen, 'reply-photo-0'))->toBeFalse(); +}); - expect($screen->instance()->replyImages)->toHaveCount(1) - ->and(app(Stash::class)->get(app(Account::class)->user()?->id, 'reply-c2')->images)->toHaveCount(1); +it('drops a reply\'s photos with it, off the phone', function () { + $screen = photosPicked(replyPage(), [testPhoto()]); + $path = $screen->instance()->replyImages[0]->path; + + $screen->tap('reply-stash-drop'); + + expect($screen->instance()->replyImages)->toBe([]) + ->and(file_exists($path))->toBeFalse() + ->and(app(Stash::class)->names(app(Account::class)->user()?->id))->toBe([]); }); + +it('hands a reply opened in the sheet back to the reply bar, photos too, when the sheet goes unsent', function (string $platform) { + $screen = replyPage($platform)->input('reply-input', 'Half')->call('replyInSheet', 'c2'); + + photosPicked($screen, [testPhoto()])->input('sheet-body', 'Half a reply'); + + $platform === 'ios' ? $screen->dismissSheet('sheet') : $screen->tap('sheet-cancel'); + + expect(nodeByRef($screen, 'reply-input')['props']['value'])->toBe('Half a reply') + ->and($screen->instance()->replyImages)->toHaveCount(1) + ->and(app(Stash::class)->get(app(Account::class)->user()?->id, 'reply-c2')->images)->toHaveCount(1); + + Http::assertNotSent(fn (Request $request): bool => $request->method() === 'POST'); +})->with(['ios', 'android']); diff --git a/tests/Feature/Screens/ConversationTest.php b/tests/Feature/Screens/ConversationTest.php index 29330a47..9d2a9f55 100644 --- a/tests/Feature/Screens/ConversationTest.php +++ b/tests/Feature/Screens/ConversationTest.php @@ -2,6 +2,7 @@ use App\Devnull\Account; use App\Devnull\Data\Remotes; +use App\Devnull\Display; use App\Devnull\ImageCache; use App\Devnull\ImageViewer; use App\NativeComponents\Conversation; @@ -764,18 +765,18 @@ function pulledAvatars(TestableComponent $screen, int $id): array ->assertNativeNotCalled('Browser.OpenInApp'); }); -it('pads the end of the thread for the composer bar alone, and for the reply bar while replying', function () { +it('pads the end of the thread for the fade and the composer bar alone, and for the reply bar while replying', function () { serveRemoteThread(threadJson([remoteMessageJson(['id' => 1])], ['read_through_id' => 1])); $screen = finishRefreshes(Native::visit('/remotes/conversations/ada')); $clearance = fn (): mixed => nodeByRef($screen, 'composer-clearance')['layout']['height'] ?? null; // The scroll view adds the home indicator itself while the keyboard is down, so it isn't counted here. - expect($clearance())->toEqual(Conversation::ComposerBarHeight + 8); + expect($clearance())->toEqual(Display::ComposerFadeHeight + Conversation::ComposerBarHeight + 8); $screen->trigger('swipe-1'); - expect($clearance())->toEqual(Conversation::ComposerBarHeight + Conversation::ReplyingBarHeight + 8); + expect($clearance())->toEqual(Display::ComposerFadeHeight + Conversation::ComposerBarHeight + Conversation::ReplyingBarHeight + 8); }); // ── Pins ──────────────────────────────── @@ -1030,7 +1031,7 @@ function serveOrgThread(array $thread, ?array $poll = null, ?Closure $pins = nul ->assertSee(' release checklist'); // It lies over the thread, which clears it at the top. - expect(childRefs($screen, 'thread-stack'))->toBe(['thread', 'pinned-bar']) + expect(array_slice(childRefs($screen, 'thread-stack'), 0, 2))->toBe(['thread', 'pinned-bar']) ->and(childRefs($screen, 'thread')[0])->toBe('pinned-clearance') ->and(nodeByRef($screen, 'pinned-bar')['props']['a11y_label'] ?? null)->toBe('2 pinned messages. Latest from Ada Lovelace: release checklist'); @@ -1284,7 +1285,7 @@ function orgWithMembers(array $people): array ->assertMissingElement('column', fn (array $node): bool => ($node['ref'] ?? null) === 'mention-suggestions'); }); -it('filters org members as the web ranks them: exact handle, handle prefix, name prefix, then the rest, followed first, six at most', function () { +it('filters org members as the web ranks them: exact handle, handle prefix, name prefix, then the rest, followed first, all of them in a list that scrolls past six', function () { serveOrgThread(orgWithMembers([ ['grace', 'Grace Hopper'], ['tobias', 'Ada Tobias'], @@ -1298,7 +1299,8 @@ function orgWithMembers(array $people): array $screen = finishRefreshes(Native::visit('/remotes/orgs/org-1'))->input('message-input', '@ADA', 4); - expect(childRefs($screen, 'mention-suggestions'))->toBe(['mention-ada', 'mention-adams', 'mention-adamant', 'mention-tobias', 'mention-bada', 'mention-cada']); + expect(childRefs($screen, 'mention-scroll'))->toBe(['mention-ada', 'mention-adams', 'mention-adamant', 'mention-tobias', 'mention-bada', 'mention-cada', 'mention-dada']) + ->and(nodeByRef($screen, 'mention-scroll')['layout']['height'])->toEqual(Display::MentionRowsShown * Display::MentionRowHeight); }); it('never suggests you, or a member devnull says not to, and suggests nothing in a thread with one person', function () { @@ -1394,6 +1396,15 @@ function orgWithMembers(array $people): array ->assertSet('draft', 'hi'); }); +it('leaves a gap between the suggestions and the message box under them on iOS', function () { + serveOrgThread(orgWithMembers([['ada', 'Ada Lovelace']])); + + $screen = finishRefreshes(Native::visit('/remotes/orgs/org-1', platform: 'ios'))->input('message-input', '@ADA', 4); + + expect(childRefs($screen, 'mention-suggestions'))->not->toBe([]) + ->and(nodeByRef($screen, 'mention-slot')['layout']['padding'][2])->toBe(8.0); +}); + /** * A message's photos as devnull sends them: $count of them, numbered from $first, the first described. * diff --git a/tests/Feature/Screens/DraftStashTest.php b/tests/Feature/Screens/DraftStashTest.php index 9a608c78..b112a26d 100644 --- a/tests/Feature/Screens/DraftStashTest.php +++ b/tests/Feature/Screens/DraftStashTest.php @@ -3,7 +3,6 @@ use App\Devnull\Account; use App\Devnull\Data\Pasteis; use App\Devnull\Data\StashedDraft; -use App\Devnull\Display; use App\Devnull\Stash; use Carbon\CarbonImmutable; use Illuminate\Http\Client\Request; @@ -199,16 +198,18 @@ function stashLabel(TestableComponent $screen, string $ref): array $screen = Native::visit('/log/commits/c2')->input('reply-input', 'A reply in progress'); $clearance = nodeByRef($screen, 'reply-bar-clearance')['layout']['height']; + // While you write it, there's only drop. expect(stashed('reply-c2'))->toBe('A reply in progress') - ->and(showsRef($screen, 'reply-stash'))->toBeFalse(); + ->and(stashLabel($screen, 'reply-stash'))->toBe(['drop', 'Discard the draft']); $screen = Native::visit('/log/commits/c2'); expect(nodeByRef($screen, 'reply-input')['props']['value'])->toBe('A reply in progress') ->and(stashLabel($screen, 'reply-stash'))->toBe(['stash@{0}', 'Discard the restored draft']) - ->and(nodeByRef($screen, 'send-reply')['props']['disabled'] ?? false)->toBeFalse() - // The page ends above the row that marks it, too. - ->and(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual($clearance + Display::ReplyBarStashLabelHeight); + ->and(canSend($screen, 'send-reply'))->toBeTrue() + // It's marked in the row under the field, beside Reply, so the bar is no taller for it. + ->and(array_slice(childRefs($screen, 'reply-actions'), -2))->toBe(['reply-stash', 'send-reply']) + ->and(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual($clearance); }); it("forgets a reply's stash once it's sent", function () { diff --git a/tests/Feature/Screens/FeedWorkspaceTest.php b/tests/Feature/Screens/FeedWorkspaceTest.php index 80a40750..58cf8fde 100644 --- a/tests/Feature/Screens/FeedWorkspaceTest.php +++ b/tests/Feature/Screens/FeedWorkspaceTest.php @@ -332,7 +332,15 @@ function serveWorkspace(): void holdRefreshes(); serveWorkspace(); $screen = finishRefreshes(Native::test(FeedWorkspace::class, platform: 'ios'))->tap('commit-c2'); - finishRefreshes($screen)->input('reply-input', 'Fast rejected reply')->tap('reply-expand')->tap('sheet-commit'); + finishRefreshes($screen); + + // The reply bar sends a reply without the sheet, so the conversation's sheet here is a quote of its commit. + $inDetail = fn (string $ref): array => findNode( + findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'adaptive_detail'), + fn (array $node): bool => ($node['ref'] ?? null) === $ref, + ); + $screen->fireEvent('hostChanged', TestableComponent::EVENT_PRESS, ['callback_id' => $inDetail('quote-c2')['on_press']]) + ->input('sheet-body', 'Fast rejected reply')->tap('sheet-commit'); $old = ['action' => $action, 'depth' => 0, 'expected_depth' => 1, 'expected_revision' => 1, 'expected_history' => ['conversation-1']]; serveApi(['POST /api/v1/commits' => [['message' => 'Fast rejection'], 422]]); finishRefreshes($screen); diff --git a/tests/Feature/Screens/LaneButtonsTest.php b/tests/Feature/Screens/LaneButtonsTest.php index 29fa415b..5bb9d2ac 100644 --- a/tests/Feature/Screens/LaneButtonsTest.php +++ b/tests/Feature/Screens/LaneButtonsTest.php @@ -64,14 +64,6 @@ function laneLog(): TestableComponent return Native::visit('/log/users/ada/followers'); }, 'follow-grace'], - 'Reply' => [function (): TestableComponent { - serveApi([ - 'GET /api/v1/commits/c2' => [commitPageJson(commitJson(['id' => 'c2']))], - 'GET /api/v1/commits/c2/replies' => [pageJson([])], - ]); - - return Native::visit('/log/commits/c2'); - }, 'send-reply'], 'Edit on GitHub, on the Account screen' => [function (): TestableComponent { serveApi(['GET /api/v1/me' => [currentUserJson(['lane' => app(Account::class)->user()?->lane()])]]); @@ -107,6 +99,27 @@ function laneLog(): TestableComponent 'rose, checked in white' => 4, ]); +it("fills the reply bar's round Reply with your lane, with an arrow that reads on it", function (int $lane) { + signIn(['lane' => $lane]); + serveApi([ + 'GET /api/v1/commits/c2' => [commitPageJson(commitJson(['id' => 'c2']))], + 'GET /api/v1/commits/c2/replies' => [pageJson([])], + ]); + + $circle = nodeByRef(Native::visit('/log/commits/c2')->input('reply-input', 'Agreed'), 'send-reply-circle'); + $icon = findNode($circle, fn (array $node): bool => $node['type'] === 'icon')['props']; + + expect(array_map(strtolower(...), [$circle['style']['bg_color'], $circle['props']['dark_bg_color'], $icon['color'], $icon['dark_color']]))->toBe(array_map(strtolower(...), [ + config("native-ui.theme.light.lane-{$lane}"), + config("native-ui.theme.dark.lane-{$lane}"), + config("native-ui.theme.light.on-lane-{$lane}"), + config("native-ui.theme.dark.on-lane-{$lane}"), + ])); +})->with([ + 'green, an arrow in ink' => 1, + 'rose, a white arrow' => 4, +]); + it('draws the tab underline in your lane, in its light and dark shades', function (string $path, int $lane) { signIn(['lane' => $lane]); Http::fake(['devnull.test/*' => Http::response(pageJson([]))]); diff --git a/tests/Feature/Screens/LogThreadTest.php b/tests/Feature/Screens/LogThreadTest.php index e17e2da9..de2badd5 100644 --- a/tests/Feature/Screens/LogThreadTest.php +++ b/tests/Feature/Screens/LogThreadTest.php @@ -162,7 +162,7 @@ function refNode(array $node, string $ref): ?array 'GET /api/v1/log/following' => [pageJson([threadedJson(2)])], 'GET /api/v1/commits/c1/replies' => [pageJson([ replyJson(['id' => 'r1', 'parent_id' => 'c1', 'body' => 'First', 'replies_count' => 12, 'author' => grace()]), - replyJson(['id' => 'r2', 'parent_id' => 'c1', 'body' => 'Second', 'author' => threadAda()]), + replyJson(['id' => 'r2', 'parent_id' => 'c1', 'body' => 'Second', 'author' => replierJson()]), ])], 'GET /api/v1/commits/r1/replies' => [pageJson(repliesJson('r1', 12, 'n', overrides: ['author' => threadAda(), 'replies_count' => 2]))], ]); @@ -200,7 +200,7 @@ function refNode(array $node, string $ref): ?array fakeApi([ 'GET /api/v1/log/following' => [pageJson([threadedJson(1)])], 'GET /api/v1/commits/c1/replies' => [pageJson([replyJson(['id' => 'r1', 'parent_id' => 'c1', 'replies_count' => 1, 'author' => grace()])])], - 'GET /api/v1/commits/r1/replies' => [pageJson(repliesJson('r1', 1, 'n'))], + 'GET /api/v1/commits/r1/replies' => [pageJson(repliesJson('r1', 1, 'n', overrides: ['author' => threadAda()]))], ]); $screen = Native::visit('/log', platform: 'ios')->tap('replies-c1')->tap('replies-r1')->assertSee('Reply n1'); @@ -333,7 +333,7 @@ function refNode(array $node, string $ref): ?array it('stops the rail at the end dot, past the replies line, and carries it on in dashes once the replies open', function () { fakeApi([ 'GET /api/v1/log/following' => [pageJson([commitJson(['id' => 'c1', 'author' => grace(), 'replies_count' => 1])])], - 'GET /api/v1/commits/c1/replies' => [pageJson(repliesJson('c1', 1))], + 'GET /api/v1/commits/c1/replies' => [pageJson(repliesJson('c1', 1, overrides: ['author' => threadAda()]))], ]); $screen = Native::visit('/log', platform: 'ios'); @@ -358,7 +358,7 @@ function refNode(array $node, string $ref): ?array it("keeps a commit's row the same height with its replies shut, opening, open and closing, so the list never moves it", function (string $platform) { holdRefreshes(); keep('log/following', pageJson([commitJson(['id' => 'c1', 'author' => grace(), 'replies_count' => 2])])); - keep('commits/c1/replies', pageJson(repliesJson('c1', 2))); + keep('commits/c1/replies', pageJson(repliesJson('c1', 2, overrides: ['author' => threadAda()]))); serveApi(fn () => Http::response(pageJson([]))); $screen = Native::visit('/log', platform: $platform); diff --git a/tests/Feature/Screens/MentionSuggestionsTest.php b/tests/Feature/Screens/MentionSuggestionsTest.php new file mode 100644 index 00000000..04a7eb65 --- /dev/null +++ b/tests/Feature/Screens/MentionSuggestionsTest.php @@ -0,0 +1,54 @@ + 'body', 'start' => 0, 'query' => 'ada', 'text' => '@ada']; + + /** @var list */ + public array $mentionPeople = []; + + /** @var list */ + public array $mentionOrganizations = []; + + /** @var array */ + public array $options = []; + + public function mount(int $rows = 8, array $options = []): void + { + $this->mentionPeople = array_map(fn (int $n): User => User::fromArray(userJson(['id' => "u{$n}", 'handle' => "ada{$n}", 'name' => "Ada {$n}"])), range(1, $rows)); + $this->options = $options; + } + + public function pickMention(string $field, string $username): void {} + + public function render(): View + { + return view('fixtures::mention-suggestions', ['options' => $this->options]); + } +} + +beforeEach(fn () => view()->addNamespace('fixtures', base_path('tests/Fixtures/views'))); + +it('scrolls more than six rows inside the list by default', function () { + $screen = Native::test(MentionSuggestionsFixture::class, ['rows' => 8]); + + expect(childRefs($screen, 'mention-suggestions'))->toBe(['mention-scroll']) + ->and(nodeByRef($screen, 'mention-scroll')['type'])->toBe('scroll_view'); +}); + +it('draws every row with no scroll view inside when the caller scrolls the list itself', function () { + $screen = Native::test(MentionSuggestionsFixture::class, ['rows' => 8, 'options' => ['scrolls' => false]]); + + expect(rendersRef($screen, 'mention-scroll'))->toBeFalse() + ->and(childRefs($screen, 'mention-suggestions'))->toBe(array_map(fn (int $n): string => "mention-ada{$n}", range(1, 8))) + ->and(nodeByRef($screen, 'mention-ada8')['children'][0]['layout']['height'] ?? null)->toBeNull(); +}); diff --git a/tests/Feature/Screens/NestedRepliesTest.php b/tests/Feature/Screens/NestedRepliesTest.php new file mode 100644 index 00000000..57fa618e --- /dev/null +++ b/tests/Feature/Screens/NestedRepliesTest.php @@ -0,0 +1,342 @@ + 'http://devnull.test']); + signIn(); +}); + +/** + * A commit page for c2 whose replies chain five deep: r1 answers c2, r2 answers r1, and so on, each from someone + * other than the one they answer, so none of them carries a thread on. + */ +function fakeDeepThread(): void +{ + $handles = ['grace', 'linus', 'alan', 'edsger', 'ken']; + $reply = fn (int $depth): array => replyJson([ + 'id' => "r{$depth}", + 'parent_id' => $depth === 1 ? 'c2' : 'r'.($depth - 1), + 'body' => "Reply at depth {$depth}", + 'replies_count' => $depth < 5 ? 1 : 0, + 'author' => userJson(['handle' => $handles[$depth - 1], 'name' => ucfirst($handles[$depth - 1]), 'lane' => $depth]), + ]); + + Http::fake(function (Request $request) use ($reply) { + $path = parse_url($request->url(), PHP_URL_PATH); + + return match (true) { + $path === '/api/v1/commits/c2' => Http::response(commitPageJson(commitJson(['id' => 'c2', 'body' => 'The focused commit', 'replies_count' => 1]))), + $path === '/api/v1/commits/c2/related' => Http::response(['data' => []]), + $path === '/api/v1/commits/c2/replies' => Http::response(pageJson([$reply(1)])), + (bool) preg_match('#^/api/v1/commits/r(\d)/replies$#', $path, $match) => Http::response(pageJson((int) $match[1] < 5 ? [$reply((int) $match[1] + 1)] : [])), + default => Http::response(['message' => 'No fake.'], 404), + }; + }); +} + +it('opens replies of replies in place on a commit page, as deep as they go, without leaving the page', function () { + fakeDeepThread(); + + $screen = Native::visit('/log/commits/c2', ['replies' => true])->assertSee('Reply at depth 1'); + + foreach (range(1, 4) as $depth) { + $screen->tap("replies-r{$depth}")->assertSee('Reply at depth '.($depth + 1)); + } + + $screen->assertNoNavigation()->assertSee('Reply at depth 5'); + + // Hiding a reply's replies takes the ones opened under them away too. + $screen->tap('replies-r2')->assertDontSee('Reply at depth 3'); + finishRefreshes($screen)->assertDontSee('Reply at depth 5'); + + // Tapping a reply itself moves the page to it. + $screen->tap('thread-reply-r2')->assertNoNavigation()->assertSet('id', 'r2'); +}); + +it('steps replies in up to the third level, and lines deeper ones up under it saying who they answer', function () { + fakeDeepThread(); + + $screen = Native::visit('/log/commits/c2', ['replies' => true]); + + foreach (range(1, 4) as $depth) { + $screen->tap("replies-r{$depth}"); + } + + // The left padding of the row the reply's avatar sits in, past the commit's 64pt gutter. + $indent = fn (string $id): float => (float) (findNode(nodeByRef($screen, "thread-reply-{$id}"), fn (array $node): bool => ($node['type'] ?? null) === 'row' && isset($node['layout']['padding']))['layout']['padding'][3] ?? 0); + $elbow = fn (string $id): bool => findNode(nodeByRef($screen, "thread-reply-{$id}"), fn (array $node): bool => ($node['ref'] ?? null) === 'thread-elbow') !== null; + + expect([$indent('r1'), $indent('r2'), $indent('r3'), $indent('r4'), $indent('r5')])->toEqual([0, 32, 64, 64, 64]) + ->and([$elbow('r1'), $elbow('r2'), $elbow('r3'), $elbow('r4'), $elbow('r5')])->toBe([true, true, true, false, false]) + ->and(rendersRef($screen, 'replying-to-r3'))->toBeFalse(); + + $screen->assertSee('replying to @alan')->assertSee('replying to @edsger'); +}); + +it('moves the page to a reply in its tree rather than pushing another, keeping what was open', function () { + fakeDeepThread(); + + $screen = Native::visit('/log/commits/c2', ['replies' => true]); + + foreach (range(1, 3) as $depth) { + $screen->tap("replies-r{$depth}"); + } + + $screen->tap('thread-reply-r3') + ->assertNoNavigation() + ->assertSet('id', 'r3') + ->assertSet('scrollTarget', 3); + + // The reply is the commit the page is on, under the commits above it, with its replies showing at once. + expect(childRefs($screen, 'thread-scroll'))->toBe(['commit-c2', 'commit-r1', 'commit-r2', 'focused-commit', 'thread-reply-r4', 'reply-bar-clearance']) + ->and(nodeByRef($screen, 'thread-scroll')['props']['auto_scroll_to'])->toBe(3); + + // Back up at the top, the reply the page was on is still open under its parents. + $screen->tap('commit-c2') + ->assertNoNavigation() + ->assertSet('id', 'c2') + ->assertSet('scrollTarget', 0) + ->assertSee('Reply at depth 4'); + + expect(childRefs($screen, 'thread-scroll'))->toBe(['focused-commit', 'thread-reply-r1', 'thread-reply-r2', 'thread-reply-r3', 'thread-reply-r4', 'reply-bar-clearance']); +}); + +it('answers a reply in the tree from the bar, on the same page', function () { + fakeDeepThread(); + + Native::visit('/log/commits/c2', ['replies' => true]) + ->call('replyTo', 'r1') + ->assertNoNavigation() + ->assertSet('id', 'r1') + ->assertSet('focusReply', true); +}); + +it('still pushes a page for a commit outside the tree', function () { + fakeDeepThread(); + + Native::visit('/log/commits/c2', ['replies' => true]) + ->call('openCommit', 'q9') + ->assertNavigatedTo('/log/commits/q9'); +}); + +it('opens at the top with no scroll asked for until the page moves', function () { + fakeDeepThread(); + + $screen = Native::visit('/log/commits/c2', ['replies' => true]); + + expect(nodeByRef($screen, 'thread-scroll')['props'] ?? [])->not->toHaveKey('auto_scroll_to'); +}); + +it('keeps the commit row and the scroll view the same nodes when the page moves', function () { + fakeDeepThread(); + + $screen = Native::visit('/log/commits/c2', ['replies' => true]); + $screen->tap('replies-r1'); + $screen->tap('thread-reply-r2'); + $scroller = nodeByRef($screen, 'thread-scroll')['id']; + $ancestor = nodeByRef($screen, 'commit-c2')['id']; + + // The commit the page moves to keeps the node it had above the focus, so its row slides into place. The scroll + // view keeps its node too: a new one would make every row in it new. + $screen->tap('commit-c2')->assertSet('id', 'c2'); + + expect(nodeByRef($screen, 'focused-commit')['id'])->toBe($ancestor) + ->and(nodeByRef($screen, 'thread-scroll')['id'])->toBe($scroller); +}); + +it('animates the move and asks again for a row it went to before', function () { + LayoutAnimation::skipUnlessSupported(); + fakeDeepThread(); + + $screen = Native::visit('/log/commits/c2', ['replies' => true]); + $props = fn (): array => nodeByRef($screen, 'thread-scroll')['props']; + + expect($props())->toHaveKey('animate_layout', true) + ->and($props())->toHaveKey('auto_scroll_animated', true) + ->and($props())->toHaveKey('auto_scroll_token', '0'); + + $screen->tap('replies-r1'); + $screen->tap('thread-reply-r1')->assertSet('scrollTarget', 1); + $screen->tap('commit-c2')->assertSet('scrollTarget', 0); + $first = $props()['auto_scroll_token']; + $screen->tap('thread-reply-r1'); + $screen->tap('commit-c2')->assertSet('scrollTarget', 0); + + // The same row as two moves ago, under a new token, so the scroll view goes back to it. + expect($props()['auto_scroll_to'])->toBe(0) + ->and($props()['auto_scroll_token'])->not->toBe($first); +}); + +/** + * A commit page for c2, which answers c1. c1 has another reply, x1, and x1 has one of its own, x2. c2 has one reply, r1. + */ +function fakeAncestorThread(): void +{ + $person = fn (string $handle, int $lane): array => userJson(['handle' => $handle, 'name' => ucfirst($handle), 'lane' => $lane]); + $c1 = commitJson(['id' => 'c1', 'body' => 'The commit above', 'replies_count' => 2, 'author' => $person('ada', 1)]); + $c2 = commitJson(['id' => 'c2', 'parent_id' => 'c1', 'body' => 'The focused commit', 'replies_count' => 1, 'author' => $person('grace', 2)]); + $x1 = replyJson(['id' => 'x1', 'parent_id' => 'c1', 'body' => 'Another reply above', 'replies_count' => 1, 'author' => $person('linus', 4)]); + $x2 = replyJson(['id' => 'x2', 'parent_id' => 'x1', 'body' => 'A reply to the other reply', 'author' => $person('alan', 5)]); + $r1 = replyJson(['id' => 'r1', 'parent_id' => 'c2', 'body' => 'A reply below', 'author' => $person('ken', 6)]); + + Http::fake(function (Request $request) use ($c1, $c2, $x1, $x2, $r1) { + $path = parse_url($request->url(), PHP_URL_PATH); + + return match ($path) { + '/api/v1/commits/c2' => Http::response(commitPageJson($c2, [$c1])), + '/api/v1/commits/c1' => Http::response(commitPageJson($c1)), + '/api/v1/commits/r1' => Http::response(commitPageJson($r1, [$c1, $c2])), + '/api/v1/commits/c1/related', '/api/v1/commits/c2/related', '/api/v1/commits/r1/related' => Http::response(['data' => []]), + '/api/v1/commits/c1/replies' => Http::response(pageJson([$c2, $x1])), + '/api/v1/commits/c2/replies' => Http::response(pageJson([$r1])), + '/api/v1/commits/x1/replies' => Http::response(pageJson([$x2])), + '/api/v1/commits/r1/replies', '/api/v1/commits/x2/replies' => Http::response(pageJson([])), + default => Http::response(['message' => 'No fake.'], 404), + }; + }); +} + +it('opens the replies of a commit above the commit in place, leaving out the one on the way down', function () { + fakeAncestorThread(); + + $screen = Native::visit('/log/commits/c2', ['replies' => true]); + + // c1 has two replies, and one of them is the commit the page is on, so its button counts the other. + expect(nodeByRef($screen, 'replies-c1')['props']['a11y_label'] ?? null)->toBe('1 reply'); + + $screen->tap('replies-c1')->assertNoNavigation()->assertSee('Another reply above'); + + // The other reply opens under c1, and the commit the page is on shows once, as the commit. + expect(childRefs($screen, 'thread-scroll'))->toBe(['commit-c1', 'thread-reply-x1', 'focused-commit', 'thread-reply-r1', 'reply-bar-clearance']) + // c1 gives up its hairline to its replies, and the last of them ends on it above the commit. The commit's own + // replies end the page, so they end on none. + ->and(rendersRef($screen, 'thread-end-x1'))->toBeTrue() + ->and(rendersRef($screen, 'thread-end-r1'))->toBeFalse(); + + // Its replies open in place too, at any depth, and the hairline moves down under the last of them. + $screen->tap('replies-x1')->assertNoNavigation()->assertSee('A reply to the other reply'); + + expect(rendersRef($screen, 'thread-end-x2'))->toBeTrue() + ->and(rendersRef($screen, 'thread-end-x1'))->toBeFalse(); + + $screen->tap('replies-c1'); + finishRefreshes($screen)->assertDontSee('Another reply above')->assertDontSee('A reply to the other reply'); + + expect(childRefs($screen, 'thread-scroll'))->toBe(['commit-c1', 'focused-commit', 'thread-reply-r1', 'reply-bar-clearance']); +}); + +it('folds the replies of the commits above when the page moves down to a reply', function () { + fakeAncestorThread(); + + $screen = Native::visit('/log/commits/c2', ['replies' => true]); + $screen->tap('replies-c1')->assertSee('Another reply above'); + $screen->tap('thread-reply-r1')->assertSet('id', 'r1')->assertSet('scrollTarget', 2)->assertDontSee('Another reply above'); + + // c1 is back to its button, still leaving out c2 on the way down. r1 has no replies, so "No replies yet" follows it. + expect(childRefs($screen, 'thread-scroll'))->toBe(['commit-c1', 'commit-c2', 'focused-commit', null, 'reply-bar-clearance']) + ->and(nodeByRef($screen, 'replies-c1')['props']['a11y_label'] ?? null)->toBe('1 reply') + ->and(rendersRef($screen, 'replies-c2'))->toBeFalse(); + + // Opening them again later doesn't scroll the page. + $screen->tap('replies-c1')->assertSee('Another reply above')->assertSet('scrollTarget', 2); +}); + +it('folds the replies of the commit the page was on when it moves down to one of them, and opens them again moving back up', function () { + fakeAncestorThread(); + + $screen = Native::visit('/log/commits/c1', ['replies' => true])->assertSee('Another reply above'); + $screen->tap('thread-reply-c2')->assertNoNavigation()->assertSet('id', 'c2')->assertDontSee('Another reply above'); + + expect(childRefs($screen, 'thread-scroll'))->toBe(['commit-c1', 'focused-commit', 'thread-reply-r1', 'reply-bar-clearance']) + ->and(nodeByRef($screen, 'replies-c1')['props']['a11y_label'] ?? null)->toBe('1 reply'); + + // Back up on c1, its replies show as the commit's do, with c2's still open under it. + $screen->tap('commit-c1')->assertSet('id', 'c1')->assertSee('Another reply above')->assertSee('A reply below'); +}); + +it('opens on a reply with the replies of the commits above it folded', function () { + fakeAncestorThread(); + + $screen = Native::visit('/log/commits/r1')->call('showEarlier')->assertDontSee('Another reply above'); + + expect(nodeByRef($screen, 'replies-c1')['props']['a11y_label'] ?? null)->toBe('1 reply') + ->and(rendersRef($screen, 'replies-c2'))->toBeFalse() + ->and($screen->get('threads'))->toBe([]); +}); + +it('keeps the replies of the commits on the line open when the replies of one above them close', function () { + fakeDeepThread(); + + $screen = Native::visit('/log/commits/c2', ['replies' => true]); + $screen->tap('replies-r1'); + $screen->tap('replies-r2'); + $screen->tap('thread-reply-r3')->assertSet('id', 'r3'); + + // The commits above r3 fold their replies. Each has one, the one on the way down, so none of them has a button. + expect($screen->get('threads'))->toBe([]) + ->and(rendersRef($screen, 'replies-c2'))->toBeFalse() + ->and(rendersRef($screen, 'replies-r1'))->toBeFalse(); + + // Opened again, closing c2's replies leaves r1's be, since r1 draws a row of its own. + $screen->call('toggleReplies', 'c2'); + $screen->call('toggleReplies', 'r1'); + expect($screen->get('threads'))->toHaveKeys(['c2', 'r1']); + + $screen->call('toggleReplies', 'c2'); + finishRefreshes($screen); + + expect($screen->get('threads'))->toHaveKey('r1')->not->toHaveKey('c2'); +}); + +/** + * c3 answers c2, which answers c1, shaped like devnull's API: the ancestors on c3's page come without their counts, + * since CommitAncestorsQuery doesn't load them. Only a commit's own page says how many replies it has. c2 has two + * besides c3, and c1 has one besides c2. Neither page was opened before. + */ +function fakeUncountedAncestors(): void +{ + $person = fn (string $handle, int $lane): array => userJson(['handle' => $handle, 'name' => ucfirst($handle), 'lane' => $lane]); + $uncounted = fn (array $commit): array => array_diff_key($commit, array_flip(['replies_count', 'stars_count'])); + $c1 = commitJson(['id' => 'c1', 'body' => 'The first commit', 'replies_count' => 2, 'author' => $person('ada', 1)]); + $c2 = commitJson(['id' => 'c2', 'parent_id' => 'c1', 'body' => 'The commit above', 'replies_count' => 3, 'author' => $person('grace', 2)]); + $c3 = commitJson(['id' => 'c3', 'parent_id' => 'c2', 'body' => 'The focused commit', 'author' => $person('ken', 3)]); + $y1 = replyJson(['id' => 'y1', 'parent_id' => 'c1', 'body' => 'Another reply to the first', 'author' => $person('linus', 4)]); + $x1 = replyJson(['id' => 'x1', 'parent_id' => 'c2', 'body' => 'Another reply above', 'author' => $person('alan', 5)]); + $x2 = replyJson(['id' => 'x2', 'parent_id' => 'c2', 'body' => 'One more reply above', 'author' => $person('edsger', 6)]); + + Http::fake(function (Request $request) use ($uncounted, $c1, $c2, $c3, $x1, $x2, $y1) { + return match (parse_url($request->url(), PHP_URL_PATH)) { + '/api/v1/commits/c3' => Http::response(commitPageJson($c3, [$uncounted($c1), $uncounted($c2)])), + '/api/v1/commits/c2' => Http::response(commitPageJson($c2, [$uncounted($c1)])), + '/api/v1/commits/c1' => Http::response(commitPageJson($c1)), + '/api/v1/commits/c1/related', '/api/v1/commits/c2/related', '/api/v1/commits/c3/related' => Http::response(['data' => []]), + '/api/v1/commits/c1/replies' => Http::response(pageJson([$c2, $y1])), + '/api/v1/commits/c2/replies' => Http::response(pageJson([$c3, $x1, $x2])), + '/api/v1/commits/c3/replies', '/api/v1/commits/x1/replies', '/api/v1/commits/x2/replies', '/api/v1/commits/y1/replies' => Http::response(pageJson([])), + default => Http::response(['message' => 'No fake.'], 404), + }; + }); +} + +it('shows the folded replies of a commit above that was never opened, from that commit\'s own page', function () { + fakeUncountedAncestors(); + + $screen = finishRefreshes(Native::visit('/log/commits/c3')); + + // c2's page says it has three replies, and c3 is one of them, on the way down. + expect(nodeByRef($screen, 'replies-c2')['props']['a11y_label'] ?? null)->toBe('2 replies') + ->and($screen->get('threads'))->toBe([]); + + $screen->tap('replies-c2')->assertNoNavigation()->assertSee('Another reply above')->assertSee('One more reply above'); + + // The earlier commits get theirs once they show. + expect(rendersRef($screen, 'replies-c1'))->toBeFalse(); + + finishRefreshes($screen->call('showEarlier')); + + expect(nodeByRef($screen, 'replies-c1')['props']['a11y_label'] ?? null)->toBe('1 reply'); +}); diff --git a/tests/Feature/Screens/NotificationsTest.php b/tests/Feature/Screens/NotificationsTest.php index b160b4ef..06cef232 100644 --- a/tests/Feature/Screens/NotificationsTest.php +++ b/tests/Feature/Screens/NotificationsTest.php @@ -84,6 +84,13 @@ function ringColour(TestableComponent $screen, string $id): ?string Native::visit('/notifications')->tap('group-n-starred')->tap('group-actor-older')->assertNavigatedTo('/notifications/users/linus'); }); +it('opens the page of an organization that replied to you, from its name', function () { + $organization = [...personJson('dev-null-sh', '/dev/null'), 'type' => 'organization']; + fakeApi(['GET /api/v1/notifications' => [inboxJson([notificationJson('replied', ['actor' => $organization, 'actors' => [$organization]])])]]); + + Native::visit('/notifications')->tap('actor-name-n-replied')->assertNavigatedTo('/notifications/organizations/dev-null-sh'); +}); + it('does not navigate to an actor absent from the displayed notifications', function () { fakeApi(['GET /api/v1/notifications' => [inboxJson([])]]); Native::visit('/notifications')->call('openActor', 'nobody')->assertNoNavigation(); diff --git a/tests/Feature/Screens/OrganizationCommitsTest.php b/tests/Feature/Screens/OrganizationCommitsTest.php new file mode 100644 index 00000000..d540573e --- /dev/null +++ b/tests/Feature/Screens/OrganizationCommitsTest.php @@ -0,0 +1,256 @@ + 'http://devnull.test']); + signIn(); +}); + +/** + * NativePHP as `GET /me` lists an organization you're in. + * + * @return array + */ +function nativephpMembershipJson(): array +{ + return [ + 'type' => 'organization', + 'id' => 'o-nativephp', + 'role' => 'member', + 'handle' => 'nativephp', + 'name' => 'NativePHP', + 'avatar_url' => 'https://avatars.githubusercontent.com/u/7?v=4', + 'github_url' => 'https://github.com/nativephp', + 'html_url' => 'http://devnull.test/@nativephp', + 'lane' => 5, + ]; +} + +/** + * A commit from NativePHP, posted by whichever member it was: devnull never says who. + * + * @param array $overrides + * @return array + */ +function nativephpCommitJson(array $overrides = []): array +{ + return commitJson(['author' => ['type' => 'organization', 'id' => 'o-nativephp', 'handle' => 'nativephp', 'name' => 'NativePHP', 'lane' => 5], ...$overrides]); +} + +/** + * Makes you a member of NativePHP, as the last `GET /me` said. + */ +function joinNativephp(): void +{ + app(Account::class)->rememberOrganizations(CurrentUser::fromArray(currentUserJson(['organizations' => [nativephpMembershipJson()]]))->organizations); +} + +/** + * The Log showing NativePHP's commit c1, with the API answering $routes besides. + * + * @param array $commit + * @param array $routes + */ +function nativephpCommitOnLog(array $commit = [], array $routes = []): TestableComponent +{ + serveApi([ + 'GET /api/v1/log/following' => [pageJson([nativephpCommitJson(['id' => 'c1', 'body' => 'NativePHP ships', ...$commit])])], + ...$routes, + ]); + + return Native::visit('/log', platform: 'ios'); +} + +it('treats an organization\'s commit as yours when you\'re a member, whoever posted it', function () { + joinNativephp(); + app(Account::class)->rememberPasteis(new Pasteis(Pasteis::Daily, CarbonImmutable::now()->addDay())); + + $screen = nativephpCommitOnLog(['stars_count' => 2]); + + // Delete, as for your own, but no Pin: devnull pins to a person's profile. No Report, as devnull won't take one. + expect(menuItems($screen, 'more-c1'))->toBe([ + ['share-c1', 'Share link', 'custom:link'], + 'divider', + ['delete-c1', 'Delete commit', 'custom:trash-2'], + ]) + // You can't star it, so its star is the count, as on your own. + ->and(rendersRef($screen, 'star-c1'))->toBeFalse() + ->and(nodeByRef($screen, 'star-count-c1')['props']['a11y_label'])->toBe('2 stars, show who starred') + // An organization's commit takes no pastéis from anyone, so the web shows none. + ->and(rendersRef($screen, 'pastel-c1'))->toBeFalse() + ->and(rendersRef($screen, 'pastel-count-c1'))->toBeFalse(); + + $screen->call('toggleStar', 'c1') + ->call('givePastel', 'c1') + ->call('reportCommit', 'c1') + ->call('togglePin', 'c1') + ->assertSet('sheetOpen', false); + + Http::assertNotSent(fn (Request $request): bool => $request->method() !== 'GET'); +}); + +it('lets a member delete an organization\'s commit they didn\'t post', function () { + joinNativephp(); + $deleted = false; + + serveApi(function (Request $request) use (&$deleted) { + return match ($request->method().' '.parse_url($request->url(), PHP_URL_PATH)) { + 'DELETE /api/v1/commits/c1' => tap(Http::response(null, 204), function () use (&$deleted): void { + $deleted = true; + }), + 'GET /api/v1/log/following' => Http::response(pageJson([ + ...($deleted ? [] : [nativephpCommitJson(['id' => 'c1', 'body' => 'Delete me'])]), + commitJson(['id' => 'c2', 'body' => 'Keep me']), + ])), + default => Http::response(currentUserJson(['organizations' => [nativephpMembershipJson()]])), + }; + }); + + Native::visit('/log', platform: 'ios') + ->tap('delete-c1') + ->assertNativeCalled('Dialog.Alert', fn (array $params): bool => $params['title'] === 'Delete this commit?') + ->emitNative(ButtonPressed::class, ['index' => 1, 'label' => 'Delete', 'id' => 'delete-commit']) + ->assertNativeCalled('ToastKit.Show', fn (array $params): bool => str_starts_with($params['message'], 'rm ')) + ->assertDontSee('Delete me') + ->assertSee('Keep me'); + + Http::assertSent(fn (Request $request): bool => $request->method() === 'DELETE' && $request->url() === 'http://devnull.test/api/v1/commits/c1'); +}); + +it('puts Delete in the nav bar of an organization\'s commit page for a member', function () { + joinNativephp(); + fakeApi(['GET /api/v1/commits/c1' => [commitPageJson(nativephpCommitJson(['id' => 'c1']))]]); + + Native::visit('/log/commits/c1', platform: 'ios') + ->assertElement('top_bar_action', fn (array $node): bool => ($node['props']['id'] ?? null) === 'delete'); +}); + +it('offers someone outside the organization a star, the pastel and Report, never Delete', function () { + app(Account::class)->rememberPasteis(new Pasteis(Pasteis::Daily, CarbonImmutable::now()->addDay())); + + $screen = nativephpCommitOnLog(); + + expect(menuItems($screen, 'more-c1'))->toBe([ + ['share-c1', 'Share link', 'custom:link'], + 'divider', + ['report-c1', 'Report commit', 'custom:flag'], + ]) + ->and(rendersRef($screen, 'star-c1'))->toBeTrue() + // Still no pastel: it would go to whoever posted it. + ->and(rendersRef($screen, 'pastel-c1'))->toBeFalse() + ->and(rendersRef($screen, 'pastel-count-c1'))->toBeFalse(); + + $screen->call('confirmDelete', 'c1')->call('deleteCommit', 'c1'); + + Http::assertNotSent(fn (Request $request): bool => $request->method() === 'DELETE'); +}); + +it('lets a member quote an organization\'s commit still waiting for approval, as the web does', function () { + $screen = nativephpCommitOnLog(['status' => 'pending']); + + expect(rendersRef($screen, 'quote-c1'))->toBeFalse(); + + joinNativephp(); + $screen = nativephpCommitOnLog(['status' => 'pending']); + + expect(rendersRef($screen, 'quote-c1'))->toBeTrue(); + + $screen->call('quoteCommit', 'c1')->assertSet('sheetOpen', true); +}); + +it('doesn\'t let a member vote on an organization\'s poll', function () { + $poll = [ + 'id' => 'poll1', + 'closes_at' => now()->addDay()->toIso8601ZuluString(), + 'is_closed' => false, + 'has_voted' => false, + 'total_votes' => null, + 'options' => [ + ['id' => 'o1', 'label' => 'Tabs', 'votes_count' => null, 'voted' => false, 'percentage' => null], + ['id' => 'o2', 'label' => 'Spaces', 'votes_count' => null, 'voted' => false, 'percentage' => null], + ], + ]; + + expect(rendersRef(nativephpCommitOnLog(['poll' => $poll]), 'poll-vote-c1'))->toBeTrue(); + + joinNativephp(); + $screen = nativephpCommitOnLog(['poll' => $poll]); + + expect(rendersRef($screen, 'poll-vote-c1'))->toBeFalse(); + + $screen->call('choosePollOption', 'c1', 'o1')->call('voteOnPoll', 'c1'); + + Http::assertNotSent(fn (Request $request): bool => str_ends_with($request->url(), Client::pollVotesPath('c1'))); +}); + +it('says devnull\'s no when you\'ve left the organization, and stops offering Delete once /me says so', function () { + joinNativephp(); + $left = false; + + serveApi(function (Request $request) use (&$left) { + return match ($request->method().' '.parse_url($request->url(), PHP_URL_PATH)) { + 'DELETE /api/v1/commits/c1' => tap(Http::response(['message' => 'This action is unauthorized.'], 403), function () use (&$left): void { + $left = true; + }), + 'GET /api/v1/log/following' => Http::response(pageJson([nativephpCommitJson(['id' => 'c1', 'body' => 'NativePHP ships'])])), + default => Http::response(currentUserJson(['organizations' => $left ? [] : [nativephpMembershipJson()]])), + }; + }); + + $screen = Native::visit('/log', platform: 'ios'); + $asked = count(sentTo('GET', 'me')); + + $screen->tap('delete-c1') + ->emitNative(ButtonPressed::class, ['index' => 1, 'label' => 'Delete', 'id' => 'delete-commit']) + ->assertSee('This action is unauthorized.') + ->assertSee('NativePHP ships'); + + expect(sentTo('GET', 'me'))->toHaveCount($asked + 1) + ->and(app(Account::class)->organizations())->toBe([]) + ->and(menuItems($screen, 'more-c1'))->toBe([ + ['share-c1', 'Share link', 'custom:link'], + 'divider', + ['report-c1', 'Report commit', 'custom:flag'], + ]); +}); + +it('lists who starred an organization\'s commit, or says only the member who posted it can', function () { + joinNativephp(); + + nativephpCommitOnLog(['stars_count' => 1], ['GET /api/v1/commits/c1/stars' => [pageJson([userJson(['id' => 'u-grace', 'handle' => 'grace', 'name' => 'Grace Hopper'])], path: 'http://devnull.test/api/v1/commits/c1/stars')]]) + ->tap('star-count-c1') + ->assertSee('Grace Hopper') + ->assertDontSee('Only the member who posted this commit can see who starred it here.'); + + // The API answers someone who didn't post it as though the list isn't there, where the web shows it them. + nativephpCommitOnLog(['stars_count' => 1], ['GET /api/v1/commits/c1/stars' => [['message' => 'Not found.'], 404]]) + ->tap('star-count-c1') + ->assertSee('Only the member who posted this commit can see who starred it here.') + ->assertDontSee('fatal: could not load stars') + ->assertDontSee('Try again'); +}); + +it('keeps an organization\'s commits off your profile\'s count, posted or deleted', function () { + keep('users/local_dev', ['data' => userWithCountsJson(commits: 3)]); + keep('users/local_dev/commits', pageJson([commitJson(['id' => 'c0'])])); + keep('log/following', pageJson([nativephpCommitJson(['id' => 'c1']), commitJson(['id' => 'c0'])])); + fakeApi(['DELETE /api/v1/commits/c1' => [null, 204]]); + + app(ResponseCache::class)->commitAdded(nativephpCommitJson(['id' => 'c2'])); + app(Client::class)->deleteCommit('c1'); + + expect(kept('users/local_dev')['data']['commits_count'])->toBe(3) + ->and(array_column(kept('users/local_dev/commits')['data'], 'id'))->toBe(['c0']) + ->and(array_column(kept('log/following')['data'], 'id'))->toBe(['c2', 'c0']); +}); diff --git a/tests/Feature/Screens/PasteisTest.php b/tests/Feature/Screens/PasteisTest.php index 83d8ea98..73e2801f 100644 --- a/tests/Feature/Screens/PasteisTest.php +++ b/tests/Feature/Screens/PasteisTest.php @@ -293,7 +293,7 @@ function textInside(TestableComponent $screen, string $ref): ?string it('gives pastéis to replies in a thread and on a commit page', function () { pasteisOn(); - $reply = commitJson(['id' => 'r1', 'parent_id' => 'c1', 'pasteis_count' => 1, 'author' => pastelAuthor()]); + $reply = commitJson(['id' => 'r1', 'parent_id' => 'c1', 'pasteis_count' => 1, 'author' => replierJson()]); fakeApi([ 'GET /api/v1/log/following' => [pageJson([commitJson(['id' => 'c1', 'replies_count' => 1, 'author' => pastelAuthor()])])], 'GET /api/v1/commits/c1/replies' => [pageJson([$reply])], diff --git a/tests/Feature/Screens/PostAsTest.php b/tests/Feature/Screens/PostAsTest.php new file mode 100644 index 00000000..700b2202 --- /dev/null +++ b/tests/Feature/Screens/PostAsTest.php @@ -0,0 +1,418 @@ + 'http://devnull.test']); + signIn(); +}); + +/** + * An organization as `GET /me` lists one you're a member of. + * + * @param array $overrides + * @return array + */ +function memberOrganizationJson(array $overrides = []): array +{ + return [ + 'type' => 'organization', + 'id' => '0199e5c4-0000-7000-8000-0000000000aa', + 'role' => 'admin', + 'handle' => 'dev-null-sh', + 'name' => '/dev/null', + 'avatar_url' => 'https://avatars.githubusercontent.com/u/9?v=4', + 'bio' => null, + 'location' => null, + 'website' => null, + 'github_url' => 'https://github.com/dev-null-sh', + 'html_url' => 'http://devnull.test/@dev-null-sh', + 'lane' => null, + ...$overrides, + ]; +} + +/** + * Makes you a member of these organizations, as the last `GET /me` said. + * + * @param list> $organizations + */ +function memberOf(array $organizations): void +{ + app(Account::class)->rememberOrganizations(CurrentUser::fromArray(currentUserJson(['organizations' => $organizations]))->organizations); +} + +/** + * The Log with its composer open in the sheet, devnull answering a new commit with $answer. + * + * @param array{0: mixed, 1?: int}|null $answer + * @param array $extra + */ +function composeOnLogAs(?array $answer = null, array $extra = []): TestableComponent +{ + fakeApi([ + 'GET /api/v1/log/following' => [pageJson([commitJson(['id' => 'c1', 'body' => 'An older commit', 'author' => userJson(['id' => 'u2', 'handle' => 'ada'])])])], + 'POST /api/v1/commits' => $answer ?? [['data' => commitJson(['id' => '0199e5c4-2222-7000-8000-00000000cafe', 'body' => 'From the org.', 'author' => memberOrganizationJson()])], 201], + ...$extra, + ]); + + return Native::visit('/log', platform: 'ios')->press('composeInSheet'); +} + +/** + * The Post as menu a pressable opens, as each row's ref, label and subtitle. + * + * @return list + */ +function postAsRows(TestableComponent $screen, string $ref): array +{ + $rows = array_filter(nodeByRef($screen, $ref)['children'] ?? [], fn (array $child): bool => ($child['type'] ?? null) === 'top_bar_action'); + + return array_values(array_map(fn (array $row): array => [$row['ref'] ?? null, $row['props']['label'] ?? null, $row['props']['subtitle'] ?? null], $rows)); +} + +/** + * The JSON of the commits sent to devnull. + * + * @return list> + */ +function commitsSent(): array +{ + return collect(Http::recorded()) + ->filter(fn (array $sent): bool => $sent[0]->method() === 'POST' && str_ends_with(parse_url($sent[0]->url(), PHP_URL_PATH), '/commits')) + ->map(fn (array $sent): array => json_decode($sent[0]->body(), true)) + ->values() + ->all(); +} + +it('reads the organizations you can post as from GET /me, oldest membership first', function () { + $current = CurrentUser::fromArray(currentUserJson(['organizations' => [ + memberOrganizationJson(), + memberOrganizationJson(['id' => 'o2', 'handle' => 'nativephp', 'name' => 'NativePHP', 'role' => 'member', 'lane' => 5, 'type' => 'user']), + ['handle' => ''], + ]])); + + expect(array_map(fn (User $organization): array => [$organization->username, $organization->isOrganization, $organization->lane()], $current->organizations)) + ->toBe([['dev-null-sh', true, 'primary'], ['nativephp', true, 5]]) + ->and(CurrentUser::fromArray(currentUserJson())->organizations)->toBeNull(); +}); + +it('keeps the organizations GET /me lists, and what it had when devnull is too old to say', function () { + fakeApi([ + 'GET /api/v1/log/following' => [pageJson([])], + 'GET /api/v1/me' => [currentUserJson(['organizations' => [memberOrganizationJson()]])], + ]); + + Native::visit('/log'); + + expect(array_map(fn (User $organization): string => $organization->username, app(Account::class)->organizations()))->toBe(['dev-null-sh']); + + app(Account::class)->rememberOrganizations(null); + + expect(app(Account::class)->organizations())->toHaveCount(1); + + app(Account::class)->forget(); + + expect(app(Account::class)->organizations())->toBe([]); +}); + +it('shows no Post as to someone in no organization, as the web hides it', function () { + composeOnLogAs() + ->assertSee('New commit') + ->assertMissingElement('pressable', fn (array $node): bool => ($node['ref'] ?? null) === 'sheet-post-as'); +}); + +it('draws each account in the Post as menu with its avatar, round for you, square for an organization, and ticks who posts now', function () { + memberOf([memberOrganizationJson(), memberOrganizationJson(['id' => 'o2', 'handle' => 'nativephp', 'name' => 'NativePHP', 'role' => 'member', 'avatar_url' => null])]); + + $screen = composeOnLogAs(); + + $rows = fn (): array => array_map(fn (array $item): array => [ + $item['ref'], + $item['props']['image'] ?? null, + $item['props']['image_shape'], + $item['props']['checked'], + $item['props']['icon'], + ], array_values(array_filter(nodeByRef($screen, 'sheet-post-as')['children'], fn (array $child): bool => $child['type'] === 'top_bar_action'))); + + $me = app(Account::class)->user(); + $person = Lucide::UserRound->ios(); + $building = Lucide::Building2->ios(); + + expect($me->avatarUrl)->not->toBeNull() + ->and($rows())->toBe([ + ['post-as-local_dev', $me->avatarUrl, 'circle', true, $person], + ['post-as-dev-null-sh', 'https://avatars.githubusercontent.com/u/9?v=4', 'rounded', false, $building], + // No avatar: the building stands in. + ['post-as-nativephp', null, 'rounded', false, $building], + ]); + + $screen->call('postAsInSheet', 'dev-null-sh'); + + expect(array_column($rows(), 3))->toBe([false, true, false]); +}); + +it('starts the composer as you, and lists you and your organizations under Post as', function () { + memberOf([memberOrganizationJson(), memberOrganizationJson(['id' => 'o2', 'handle' => 'nativephp', 'name' => 'NativePHP', 'role' => 'member', 'lane' => 5])]); + + $screen = composeOnLogAs(); + + expect(nodeByRef($screen, 'sheet-post-as-name')['props']['text'])->toBe('Local Dev') + ->and(nodeByRef($screen, 'sheet-post-as-handle')['props']['text'])->toBe('@local_dev') + ->and(nodeByRef($screen, 'sheet-post-as')['props']['a11y_label'])->toBe('Posting as @local_dev. Choose who to post as') + ->and(array_column(menuItems($screen, 'sheet-post-as'), 0))->toBe(['post-as-local_dev', 'post-as-dev-null-sh', 'post-as-nativephp']); + + $screen->call('postAsInSheet', 'nativephp'); + + expect(nodeByRef($screen, 'sheet-post-as-name')['props']['text'])->toBe('NativePHP') + ->and(nodeByRef($screen, 'sheet-post-as-handle')['props']['text'])->toBe('@nativephp') + ->and(nodeByRef($screen, 'sheet-post-as')['props']['a11y_label'])->toBe('Posting as @nativephp. Choose who to post as'); + + $screen->input('sheet-body', 'a'); + $organizationFill = sheetButtonCircle($screen, 'sheet-commit')['style']['bg_color']; + + // Commit is filled with the organization's lane rather than yours. + $screen->call('postAsInSheet', ''); + + expect(sheetButtonCircle($screen, 'sheet-commit')['style']['bg_color'])->not->toBe($organizationFill); +}); + +it('names each account in the Post as menu, with its handle under the name', function () { + MenuSubtitle::skipUnlessSupported(); + memberOf([memberOrganizationJson(), memberOrganizationJson(['id' => 'o2', 'handle' => 'nativephp', 'name' => 'NativePHP', 'role' => 'member'])]); + + expect(postAsRows(composeOnLogAs(), 'sheet-post-as'))->toBe([ + ['post-as-local_dev', 'Local Dev', '@local_dev'], + ['post-as-dev-null-sh', '/dev/null', '@dev-null-sh'], + ['post-as-nativephp', 'NativePHP', '@nativephp'], + ]); +}); + +it('puts the handle in the label when core has no menu row subtitles', function () { + MenuSubtitle::skipIfSupported(); + memberOf([memberOrganizationJson()]); + + expect(postAsRows(composeOnLogAs(), 'sheet-post-as'))->toBe([ + ['post-as-local_dev', 'Local Dev (@local_dev)', null], + ['post-as-dev-null-sh', '/dev/null (@dev-null-sh)', null], + ]); +}); + +it('commits as the organization picked, and shows it staged as the organization', function () { + memberOf([memberOrganizationJson()]); + holdRefreshes(); + + $screen = composeOnLogAs() + ->call('postAsInSheet', 'dev-null-sh') + ->input('sheet-body', 'From the org.') + ->tap('sheet-commit'); + + $staged = $screen->instance()->commits[0]; + + expect($staged->isStaged())->toBeTrue() + ->and($staged->author->username)->toBe('dev-null-sh') + ->and($staged->author->isOrganization)->toBeTrue() + ->and(PendingWrite::query()->sole()->author())->toBe('dev-null-sh'); + + finishRefreshes($screen); + + expect(commitsSent())->toBe([['body' => 'From the org.', 'author' => 'dev-null-sh']]) + ->and($screen->instance()->commits[0]->author->username)->toBe('dev-null-sh'); +}); + +it('commits as you again once you pick yourself, and ignores an organization you are not in', function () { + memberOf([memberOrganizationJson()]); + + composeOnLogAs() + ->call('postAsInSheet', 'laravel') + ->assertSet('sheetAuthor', null) + ->call('postAsInSheet', 'dev-null-sh') + ->call('postAsInSheet', '') + ->input('sheet-body', 'From me.') + ->tap('sheet-commit'); + + expect(commitsSent())->toBe([['body' => 'From me.']]); +}); + +it('quotes as the organization picked', function () { + memberOf([memberOrganizationJson()]); + fakeApi([ + 'GET /api/v1/log/following' => [pageJson([commitJson(['id' => 'c1', 'body' => 'Quote me', 'author' => userJson(['id' => 'u2', 'handle' => 'ada'])])])], + 'POST /api/v1/commits' => [['data' => commitJson(['id' => 'q1', 'body' => 'Our take', 'quoted_commit_id' => 'c1', 'author' => memberOrganizationJson()])], 201], + ]); + + $screen = Native::visit('/log', platform: 'ios')->call('quoteCommit', 'c1'); + + expect(rendersRef($screen, 'sheet-post-as'))->toBeTrue(); + + $screen->call('postAsInSheet', 'dev-null-sh')->input('sheet-body', 'Our take')->tap('sheet-commit'); + + expect(commitsSent())->toBe([['body' => 'Our take', 'quoted_commit_id' => 'c1', 'author' => 'dev-null-sh']]); +}); + +it('replies from the commit page as the organization picked in the bar', function () { + memberOf([memberOrganizationJson()]); + fakeApi([ + 'GET /api/v1/commits/c2' => [commitPageJson(commitJson(['id' => 'c2', 'body' => 'The focused commit']))], + 'GET /api/v1/commits/c2/replies' => [pageJson([])], + 'GET /api/v1/commits/c2/related' => [['data' => []]], + 'POST /api/v1/commits' => [['data' => replyJson(['id' => 'r9', 'parent_id' => 'c2', 'body' => 'From the org', 'author' => memberOrganizationJson()])], 201], + ]); + + $screen = Native::visit('/log/commits/c2'); + + // It leads the row under the field, ahead of the photo button. + expect(array_slice(childRefs($screen, 'reply-actions'), 0, 2))->toBe(['reply-post-as', 'reply-add-photos']) + ->and(array_column(menuItems($screen, 'reply-post-as'), 0))->toBe(['post-as-local_dev', 'post-as-dev-null-sh']); + + $screen->call('postAsInReply', 'dev-null-sh') + ->input('reply-input', 'From the org') + ->tap('send-reply') + ->assertSee('From the org'); + + expect(commitsSent())->toBe([['body' => 'From the org', 'parent_id' => 'c2', 'author' => 'dev-null-sh']]) + ->and($screen->instance()->replies[0]->author->username)->toBe('dev-null-sh'); +}); + +it("fills the reply bar's send button with the lane of the organization it replies as", function () { + memberOf([memberOrganizationJson(['handle' => 'nativephp', 'name' => 'NativePHP', 'lane' => 5])]); + fakeApi([ + 'GET /api/v1/commits/c2' => [commitPageJson(commitJson(['id' => 'c2', 'body' => 'The focused commit']))], + 'GET /api/v1/commits/c2/replies' => [pageJson([])], + 'GET /api/v1/commits/c2/related' => [['data' => []]], + ]); + + $screen = Native::visit('/log/commits/c2')->input('reply-input', 'Agreed'); + $mine = nodeByRef($screen, 'send-reply-circle')['style']['bg_color']; + + $screen->call('postAsInReply', 'nativephp'); + + expect(strtolower(nodeByRef($screen, 'send-reply-circle')['style']['bg_color']))->toBe(strtolower(config('native-ui.theme.light.lane-5'))) + ->and(nodeByRef($screen, 'reply-post-as')['props']['a11y_label'])->toBe('Posting as @nativephp. Choose who to post as'); + + $screen->call('postAsInReply', ''); + + expect(nodeByRef($screen, 'send-reply-circle')['style']['bg_color'])->toBe($mine); +}); + +it('replies as the organization picked in the bar with photos', function () { + memberOf([memberOrganizationJson()]); + fakeApi([ + 'GET /api/v1/commits/c2' => [commitPageJson(commitJson(['id' => 'c2', 'body' => 'The focused commit']))], + 'GET /api/v1/commits/c2/replies' => [pageJson([])], + 'GET /api/v1/commits/c2/related' => [['data' => []]], + 'POST /api/v1/commits' => [['data' => replyJson(['id' => 'r9', 'parent_id' => 'c2', 'body' => 'Look', 'author' => memberOrganizationJson()])], 201], + ]); + + $screen = photosPicked(Native::visit('/log/commits/c2')->call('postAsInReply', 'dev-null-sh')->input('reply-input', 'Look'), [testPhoto()]) + ->tap('send-reply') + ->assertSee('Look'); + + Http::assertSent(fn (Request $request): bool => $request->method() === 'POST' + && multipartParts($request)[0]['contents'] === '{"body":"Look","parent_id":"c2","author":"dev-null-sh"}' + && multipartParts($request)[1]['name'] === 'images[]'); + + expect($screen->instance()->replies[0]->author->username)->toBe('dev-null-sh'); +}); + +it('posts as the organization picked in a reply sheet, which starts as you, apart from the bar', function () { + memberOf([memberOrganizationJson()]); + fakeApi([ + 'GET /api/v1/commits/c2' => [commitPageJson(commitJson(['id' => 'c2', 'body' => 'The focused commit']))], + 'GET /api/v1/commits/c2/replies' => [pageJson([])], + 'GET /api/v1/commits/c2/related' => [['data' => []]], + 'POST /api/v1/commits' => [['data' => replyJson(['id' => 'r9', 'parent_id' => 'c2', 'body' => 'Sheet reply'])], 201], + ]); + + // The bar no longer opens the sheet, but a reply written there before it took over comes back to it if devnull + // turned it down. + $screen = Native::visit('/log/commits/c2', platform: 'ios') + ->call('postAsInReply', 'dev-null-sh') + ->call('replyInSheet', 'c2') + ->assertSet('sheetAuthor', null); + + expect(rendersRef($screen, 'sheet-post-as'))->toBeTrue(); + + $screen->call('postAsInSheet', 'dev-null-sh')->input('sheet-body', 'Sheet reply')->tap('sheet-commit'); + + expect(commitsSent())->toBe([['body' => 'Sheet reply', 'parent_id' => 'c2', 'author' => 'dev-null-sh']]); +}); + +it('puts a commit turned down for leaving the organization back in the sheet, asks devnull again, and then posts as you', function () { + memberOf([memberOrganizationJson()]); + $refused = 'You can only post as an organization you are a member of.'; + $routes = [ + 'GET /api/v1/log/following' => [pageJson([commitJson(['id' => 'c1'])])], + 'GET /api/v1/me' => [currentUserJson(['organizations' => [memberOrganizationJson()]])], + ]; + serveApi($routes); + + $screen = Native::visit('/log', platform: 'ios') + ->press('composeInSheet') + ->call('postAsInSheet', 'dev-null-sh') + ->input('sheet-body', 'From the org.'); + + // You were taken out of the organization since the app last asked. + serveApi([ + ...$routes, + 'POST /api/v1/commits' => [['message' => $refused, 'errors' => ['author' => [$refused]]], 422], + 'GET /api/v1/me' => [currentUserJson(['organizations' => []])], + ]); + + $screen->tap('sheet-commit') + ->assertNativeCalled('ToastKit.Show', fn (array $params): bool => $params['message'] === $refused && $params['variant'] === 'error'); + + expect(commitsSent())->toBe([['body' => 'From the org.', 'author' => 'dev-null-sh']]) + ->and(app(Account::class)->organizations())->toBe([]); + + // The sheet opens on the draft again, as the organization picked, which now posts as you. + $screen->dismissSheet('sheet'); + + expect($screen->instance()) + ->sheetOpen->toBeTrue() + ->sheetBody->toBe('From the org.') + ->sheetAuthor->toBe('dev-null-sh'); + expect(nodeByRef($screen, 'sheet-post-as-handle')['props']['text'])->toBe('@local_dev') + ->and(menuItems($screen, 'sheet-post-as'))->toHaveCount(1); + + serveApi([...$routes, 'POST /api/v1/commits' => [['data' => commitJson(['id' => 'c9', 'body' => 'From the org.'])], 201]]); + $screen->tap('sheet-commit'); + + expect(commitsSent())->toBe([['body' => 'From the org.', 'author' => 'dev-null-sh'], ['body' => 'From the org.']]); +}); + +it('schedules a commit as the organization picked, and lists it as the organization', function () { + phoneIn('Europe/Lisbon'); + $this->travelTo(CarbonImmutable::parse('2026-10-19 15:30:00', 'UTC')); + memberOf([memberOrganizationJson()]); + + composeOnLogAs(extra: [ + 'POST /api/v1/scheduled-commits' => [['data' => scheduledCommitJson(['author' => memberOrganizationJson()])], 201], + 'GET /api/v1/scheduled-commits' => [scheduledPageJson([scheduledCommitJson(['author' => memberOrganizationJson()]), scheduledCommitJson(['id' => 's2'])])], + ]) + ->call('postAsInSheet', 'dev-null-sh') + ->input('sheet-body', 'Shipping this tomorrow.') + ->tap('sheet-schedule') + ->pickDateTime('scheduled-at', '2026-10-20T09:00') + ->tap('sheet-commit'); + + Http::assertSent(fn (Request $request): bool => $request->method() === 'POST' + && str_ends_with($request->url(), '/scheduled-commits') + && $request['author'] === 'dev-null-sh'); + + $list = Native::visit('/log/scheduled'); + + expect(rendersRef($list, 'scheduled-author-0199e5c4-3333-7000-8000-00000000da7e'))->toBeTrue() + ->and(rendersRef($list, 'scheduled-author-s2'))->toBeFalse(); + $list->assertSee('As @dev-null-sh'); +}); diff --git a/tests/Feature/Screens/QuoteTest.php b/tests/Feature/Screens/QuoteTest.php index 3ce4a7b5..38d28c21 100644 --- a/tests/Feature/Screens/QuoteTest.php +++ b/tests/Feature/Screens/QuoteTest.php @@ -211,3 +211,13 @@ function quoteButtonDisabled(TestableComponent $screen): bool expect(nodeByRef($screen, 'sheet')['props']['visible'])->toBeFalse() ->and($screen->instance()->commit->id)->toBe('c2'); }); + +it('puts the quoted commit right under the field, which gives up the room it takes', function () { + $screen = quoteSheetOnLog(); + + expect(childRefs($screen, 'sheet-below'))->toBe(['quote-card']) + ->and(childRefs($screen, 'sheet-body-area'))->toBe(['sheet-field-slot', 'sheet-below']) + ->and(nodeByRef($screen, 'sheet-body')['props']['fills_height'] ?? null)->toBeTrue() + // [top, right, bottom, left]: the card keeps clear of the toolbar, as the field does of "Replying to". + ->and(nodeByRef($screen, 'sheet-below')['layout']['padding'])->toEqual([12, 20, 12, 20]); +}); diff --git a/tests/Feature/Screens/RelatedCommitsTest.php b/tests/Feature/Screens/RelatedCommitsTest.php index a6265735..b3f9a350 100644 --- a/tests/Feature/Screens/RelatedCommitsTest.php +++ b/tests/Feature/Screens/RelatedCommitsTest.php @@ -1,9 +1,13 @@ 'http://devnull.test']); @@ -25,6 +29,45 @@ function serveRelatedThread(array $related = [], array $extra = []): void ]); } +/** + * Lets every Beat the screen has dispatched come back, as the phone would once it had drawn the step before, and + * leaves any other task (a held refresh) where it is. Like finishBeats() in LogThreadTest, except that it opens a + * task's sealed payload without reading it through AsyncTaskTransport::readPayload(), which deletes it, so a held + * refresh would have nothing left for finishRefreshes() to run. + */ +function landBeats(TestableComponent $screen): TestableComponent +{ + $done = []; + + while (true) { + $beats = array_filter($screen->bridge()->callsTo('AsyncTask.Dispatch'), function (array $call) use (&$done): bool { + $id = $call['params']['id']; + $path = AsyncTaskTransport::directory('payload').DIRECTORY_SEPARATOR.$id.'.task'; + $unseal = Closure::bind(fn (string $id, string $sealed): ?string => static::unseal($id, $sealed), null, AsyncTaskTransport::class); + + return ! isset($done[$id]) && is_file($path) && str_contains((string) $unseal($id, (string) file_get_contents($path)), serialize(Beat::class)); + }); + + if ($beats === []) { + return $screen; + } + + foreach ($beats as $call) { + $done[$call['params']['id']] = true; + AsyncTaskTransport::forgetPayload($call['params']['id']); + $screen->emitNative(AsyncTaskFinished::class, ['id' => $call['params']['id'], 'result' => true]); + } + } +} + +/** + * Opens the related commits under their header, and lets them fade in. + */ +function openRelated(TestableComponent $screen): TestableComponent +{ + return landBeats($screen->tap('related-commits-toggle')); +} + it('shows related commits below the thread in relevance order on their own rail', function (string $platform) { serveRelatedThread([ commitJson(['id' => 'c9', 'body' => 'Closest match', 'author' => userJson(['id' => 'u2', 'handle' => 'ada', 'name' => 'Ada'])]), @@ -34,7 +77,7 @@ function serveRelatedThread(array $related = [], array $extra = []): void 'GET /api/v1/commits/c1/replies' => [pageJson([replyJson(['id' => 'r1', 'parent_id' => 'c1', 'body' => 'A reply'])])], ]); - $screen = Native::visit('/log/commits/c1', ['replies' => true], platform: $platform) + $screen = openRelated(Native::visit('/log/commits/c1', ['replies' => true], platform: $platform)) ->assertSee('The focused commit') ->assertSee('A reply') ->assertSee('Related commits') @@ -42,8 +85,9 @@ function serveRelatedThread(array $related = [], array $extra = []): void ->assertSee('Next match') ->assertSee('Third match'); - expect(childRefs($screen, 'thread-page'))->toBe(['focused-commit', 'thread-reply-r1', 'related-commits', 'reply-bar-clearance']) - ->and(childRefs($screen, 'related-commits'))->toBe(['related-commits-heading', 'commit-c9', 'commit-c3', 'commit-c7']) + expect(childRefs($screen, 'thread-scroll'))->toBe(['focused-commit', 'thread-reply-r1', 'related-commits', 'reply-bar-clearance']) + ->and(childRefs($screen, 'related-commits'))->toBe(['related-commits-toggle', 'related-c9', 'related-c3', 'related-c7']) + ->and(childRefs($screen, 'related-c9'))->toBe(['commit-c9']) ->and(railNode($screen, 'commit-c9'))->toBe('avatar') ->and(pressFeedbackInScroller($screen))->toBe([]); @@ -73,7 +117,7 @@ function serveRelatedThread(array $related = [], array $extra = []): void Http::assertNothingSent(); - finishRefreshes($screen)->assertSee('Closest match')->input('reply-input', 'A draft'); + openRelated(finishRefreshes($screen))->assertSee('Closest match')->input('reply-input', 'A draft'); expect(collect(Http::recorded())->filter(fn (array $sent): bool => str_ends_with($sent[0]->url(), '/related')))->toHaveCount(1); }); @@ -84,7 +128,7 @@ function serveRelatedThread(array $related = [], array $extra = []): void keep('commits/c1/related', ['data' => [commitJson(['id' => 'c9', 'body' => 'Old match'])]]); serveRelatedThread([commitJson(['id' => 'c3', 'body' => 'Fresh match'])]); - $screen = Native::visit('/log/commits/c1')->assertSee('Old match'); + $screen = openRelated(Native::visit('/log/commits/c1'))->assertSee('Old match'); finishRefreshes($screen)->assertSee('Fresh match')->assertDontSee('Old match'); @@ -128,7 +172,7 @@ function serveRelatedThread(array $related = [], array $extra = []): void 'GET /api/v1/commits/c9/replies' => [pageJson([replyJson(['id' => 'r9', 'parent_id' => 'c9', 'body' => 'Answer to the match'])])], ]); - Native::visit("/{$tab}/commits/c1") + openRelated(Native::visit("/{$tab}/commits/c1")) ->tap($ref) ->assertNavigatedTo("/{$tab}/commits/c9") ->follow() @@ -146,7 +190,7 @@ function serveRelatedThread(array $related = [], array $extra = []): void 'POST /api/v1/commits/c9/star' => [['data' => [...$related, 'starred' => true, 'stars_count' => 1]]], ]); - $screen = Native::visit('/log/commits/c1')->tap('star-c9'); + $screen = openRelated(Native::visit('/log/commits/c1'))->tap('star-c9'); expect($screen->instance()->related[0]->starred)->toBeTrue() ->and(kept('commits/c1/related')['data'][0]['starred'])->toBeTrue() @@ -158,7 +202,7 @@ function serveRelatedThread(array $related = [], array $extra = []): void 'POST /api/v1/commits/c9/star' => [['message' => 'Cannot star now.'], 422], ]); - $screen = Native::visit('/log/commits/c1')->tap('star-c9'); + $screen = openRelated(Native::visit('/log/commits/c1'))->tap('star-c9'); expect($screen->instance()->related[0]->starred)->toBeFalse() ->and(kept('commits/c1/related')['data'][0]['starred'])->toBeFalse(); @@ -169,8 +213,103 @@ function serveRelatedThread(array $related = [], array $extra = []): void keep('commits/c1', commitPageJson(commitJson(['id' => 'c1', 'body' => 'The focused commit']))); keep('commits/c1/related', ['data' => [commitJson(['id' => 'c9', 'body' => 'Closest match'])]]); - $screen = Native::visit('/log/commits/c1')->assertSee('Closest match'); + $screen = openRelated(Native::visit('/log/commits/c1'))->assertSee('Closest match'); app(ResponseCache::class)->commitDeleted('c9'); $screen->call('onResume')->assertDontSee('Closest match')->assertDontSee('Related commits'); }); + +it('keeps related commits closed under a header with their count until it is tapped', function (string $platform) { + serveRelatedThread([ + commitJson(['id' => 'c9', 'body' => 'Closest match']), + commitJson(['id' => 'c3', 'body' => 'Next match']), + ]); + + $screen = Native::visit('/log/commits/c1', platform: $platform) + ->assertSee('Related commits') + ->assertDontSee('Closest match') + ->assertDontSee('Next match'); + + expect(childRefs($screen, 'related-commits'))->toBe(['related-commits-toggle']) + ->and(nodeByRef($screen, 'related-commits-count')['props']['text'])->toBe('2') + ->and(nodeByRef($screen, 'related-commits-toggle')['props']['a11y_label'] ?? null)->toBe('2 related commits') + ->and(nodeByRef($screen, 'related-commits-chevron')['props']['rotate'] ?? 0.0)->toEqual(0.0); + + openRelated($screen)->assertSee('Closest match')->assertSee('Next match'); + + expect(nodeByRef($screen, 'related-commits-chevron')['props']['rotate'])->toEqual(90.0); + + landBeats($screen->tap('related-commits-toggle'))->assertDontSee('Closest match')->assertSee('Related commits'); + + expect(nodeByRef($screen, 'related-commits-chevron')['props']['rotate'] ?? 0.0)->toEqual(0.0); +})->with(['ios', 'android']); + +it("draws one full-width line above related commits, with the replies shut or open, and no hairline from the commit's text", function (string $platform) { + serveRelatedThread([commitJson(['id' => 'c9', 'body' => 'Closest match'])], [ + 'GET /api/v1/commits/c1' => [commitPageJson(commitJson(['id' => 'c1', 'body' => 'The focused commit', 'replies_count' => 1]))], + 'GET /api/v1/commits/c1/replies' => [pageJson([replyJson(['id' => 'r1', 'parent_id' => 'c1', 'body' => 'A reply'])])], + ]); + + $screen = Native::visit('/log/commits/c1', platform: $platform)->assertSee('Related commits'); + $commitLine = fn (): float => (float) (nodeByRef($screen, 'focused-commit')['children'][0]['props']['border_b'] ?? 0); + $relatedLine = fn (): float => (float) (nodeByRef($screen, 'related-commits')['props']['border_t'] ?? 0); + + // Shut, the commit sits right on the section, whose line is the only one. + expect(childRefs($screen, 'thread-scroll'))->toBe(['focused-commit', 'related-commits', 'reply-bar-clearance']) + ->and($commitLine())->toBe(0.0) + ->and($relatedLine())->toBe(1.0); + + // Open, the last reply ends with no hairline of its own, so the section's line is still the only one. + $screen->tap('replies-c1')->assertSee('A reply'); + expect(childRefs($screen, 'thread-scroll'))->toBe(['focused-commit', 'thread-reply-r1', 'related-commits', 'reply-bar-clearance']) + ->and($commitLine())->toBe(0.0) + ->and(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'thread-end-r1'))->toBeNull() + ->and($relatedLine())->toBe(1.0); +})->with(['ios', 'android']); + +it('keeps the hairline under the commit when nothing comes after it, or "No replies yet" does', function (array $commit, array $related) { + serveRelatedThread($related, [ + 'GET /api/v1/commits/c1' => [commitPageJson(commitJson(['id' => 'c1', 'body' => 'The focused commit', ...$commit]))], + ]); + + $screen = Native::visit('/log/commits/c1'); + + expect((float) (nodeByRef($screen, 'focused-commit')['children'][0]['props']['border_b'] ?? 0))->toBe(1.0); +})->with([ + 'no related commits' => [['replies_count' => 1], []], + 'no replies yet' => [['replies_count' => 0], [commitJson(['id' => 'c9', 'body' => 'Closest match'])]], +]); + +it('fades related commits in one after another as they open, and out together as they close', function () { + holdRefreshes(); + serveRelatedThread([ + commitJson(['id' => 'c9', 'body' => 'Closest match']), + commitJson(['id' => 'c3', 'body' => 'Next match']), + ]); + + $screen = finishRefreshes(Native::visit('/log/commits/c1', platform: 'ios')); + + // Drawn see-through and nudged up first, with the animation each eases in by, the second a beat later. + $screen->tap('related-commits-toggle'); + expect(nodeByRef($screen, 'related-c9')['style']['opacity'] ?? null)->toBe(0.0) + ->and(nodeByRef($screen, 'related-c9')['props']['translate-y'] ?? null)->toBe(-8.0) + ->and(nodeByRef($screen, 'related-c9')['props']['animate-duration'] ?? null)->toBe(220.0) + ->and(nodeByRef($screen, 'related-c9')['props']['animate-delay'] ?? 0.0)->toEqual(0.0) + ->and(nodeByRef($screen, 'related-c3')['props']['animate-delay'] ?? null)->toEqual(40.0) + ->and(nodeByRef($screen, 'related-commits-chevron')['props']['rotate'])->toEqual(90.0) + ->and(nodeByRef($screen, 'related-commits-chevron')['props']['animate-duration'] ?? null)->toBe(220.0); + + landBeats($screen); + expect(nodeByRef($screen, 'related-c9')['style']['opacity'] ?? 1.0)->toBe(1.0) + ->and(nodeByRef($screen, 'related-c9')['props']['translate-y'] ?? null)->toBe(0.0); + + // Closing fades them out together, chevron back first, and they go once that's done. A tap meanwhile does nothing. + $screen->tap('related-commits-toggle')->tap('related-commits-toggle')->assertSee('Closest match'); + expect(nodeByRef($screen, 'related-c9')['style']['opacity'] ?? null)->toBe(0.0) + ->and(nodeByRef($screen, 'related-c3')['props']['animate-delay'] ?? 0.0)->toEqual(0.0) + ->and(nodeByRef($screen, 'related-commits-chevron')['props']['rotate'] ?? 0.0)->toEqual(0.0); + + landBeats($screen)->assertDontSee('Closest match'); + expect($screen->instance()->relatedShown)->toBeFalse() + ->and($screen->instance()->relatedFaded)->toBeFalse(); +}); diff --git a/tests/Feature/Screens/RemotesComposerTest.php b/tests/Feature/Screens/RemotesComposerTest.php index f86f3e61..e8948222 100644 --- a/tests/Feature/Screens/RemotesComposerTest.php +++ b/tests/Feature/Screens/RemotesComposerTest.php @@ -1,12 +1,17 @@ toBeTrue(); + expect(canSend($screen, 'push'))->toBeFalse(); photosPicked($screen, [testPhoto(), testPhoto()])->tap('photo-0-alt')->input('photo-description-input', 'A terminal.'); - expect(nodeByRef($screen, 'push')['props']['disabled'] ?? false)->toBeFalse(); + expect(canSend($screen, 'push'))->toBeTrue(); finishRefreshes($screen->tap('push'))->assertSet('pending', []); @@ -195,6 +200,20 @@ function threadWithAda(string $platform = 'ios'): TestableComponent expect(nodeByRef($screen, 'attach-photos')['props']['disabled'] ?? false)->toBeTrue(); }); +it('keeps every photo picked at once, however long ago they were taken', function () { + serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]); + + // The library hands photos over with the time they were taken, which a photo nothing holds yet shares with one + // forgotten a day ago. + $picked = [testPhoto(), testPhoto()]; + array_walk($picked, fn (string $path): bool => touch($path, now()->subYears(5)->getTimestamp())); + + $screen = photosPicked(threadWithAda(), $picked); + + expect($screen->instance()->photos)->toHaveCount(2) + ->and(array_filter($screen->instance()->photos, fn ($photo): bool => file_exists($photo->path)))->toHaveCount(2); +}); + it('takes a photo off the draft and the phone with its ✕', function () { serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]); @@ -215,11 +234,11 @@ function threadWithAda(string $platform = 'ios'): TestableComponent photosPicked($screen, [testPhoto()]); - expect($clearance())->toEqual(Conversation::ComposerBarHeight + Conversation::PhotosHeight + 8); + expect($clearance())->toEqual(Display::ComposerFadeHeight + Conversation::ComposerBarHeight + Conversation::PhotosHeight + 8); $screen->tap('photo-0-alt'); - expect($clearance())->toEqual(Conversation::ComposerBarHeight + Conversation::PhotosHeight + Conversation::DescriptionHeight + 8); + expect($clearance())->toEqual(Display::ComposerFadeHeight + Conversation::ComposerBarHeight + Conversation::PhotosHeight + Conversation::DescriptionHeight + 8); }); it('keeps the keyboard up through presses in the thread, and the field in place as the reply strip and photos come and go', function () { @@ -227,7 +246,7 @@ function threadWithAda(string $platform = 'ios'): TestableComponent $screen = threadWithAda()->input('message-input', 'on it'); $field = idsDownTo($screen->tree(), 'message-input'); - $rows = childRefs($screen, 'composer-bar'); + $rows = childRefs($screen, 'composer-rows'); expect(nodeByRef($screen, 'message-input')['props']['keep_focus_on_submit'] ?? false)->toBeTrue(); @@ -237,7 +256,7 @@ function threadWithAda(string $platform = 'ios'): TestableComponent // The strip fills a slot the bar always has, so the field's row keeps its place among the bar's rows, which // Android needs as well as the same id to keep the field. expect(idsDownTo($screen->tree(), 'message-input'))->toBe($field) - ->and(childRefs($screen, 'composer-bar'))->toBe($rows); + ->and(childRefs($screen, 'composer-rows'))->toBe($rows); $screen->tap('cancel-reply'); @@ -251,34 +270,140 @@ function threadWithAda(string $platform = 'ios'): TestableComponent expect($withPhotos)->not->toBe($field) ->and(idsDownTo($screen->tree(), 'message-input'))->toBe($withPhotos) - ->and(childRefs($screen, 'composer-bar'))->toBe($rows); + ->and(childRefs($screen, 'composer-rows'))->toBe($rows); }); -it('puts a + for photos, a voice note and Ping inside the Liquid Glass field on iOS', function () { +it('draws one box with the field over the + and a round Push, on both platforms', function (string $platform) { serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]); - $screen = threadWithAda('ios'); - $bar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); + $screen = threadWithAda($platform); + $actions = childRefs($screen, 'message-actions'); - expect(childRefs($screen, 'message-plate'))->toBe(['message-field', 'composer-tools']) + expect(childRefs($screen, 'message-row'))->toBe(['message-box']) + ->and(childRefs($screen, 'message-box'))->toBe(['message-field-row', 'message-actions']) + ->and(childRefs($screen, 'message-field-row'))->toBe(['message-field']) + ->and($actions[0])->toBe('composer-tools') + ->and(end($actions))->toBe('push') ->and(array_slice(childRefs($screen, 'composer-tools'), 0, 3))->toBe(['attach-photos', 'record-voice-note', 'ping']) - ->and(nodeByRef($screen, 'message-plate')['props']['glass'] ?? null)->toBe(1) - ->and($bar['children'][0]['ref'] ?? null)->toBe('composer-bar') - ->and($bar['children'][0]['style']['bg_color'] ?? null)->toBeNull() - ->and(nodeByRef($screen, 'ping')['props']['label'])->toBe('Ping @ada'); + ->and(nodeByRef($screen, 'ping')['props']['label'])->toBe('Ping @ada') + ->and(nodeByRef($screen, 'push')['props']['a11y_label'] ?? nodeByRef($screen, 'push')['a11y_label'] ?? null)->toBe('Push'); +})->with(['ios', 'android']); + +it('keeps the field closer to the fade than to the + and Push under it', function (string $platform) { + serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]); + + $screen = threadWithAda($platform); + + // [top, right, bottom, left]. As on a commit's reply bar: no top padding on the row, so the field starts 4pt + // under the fade, and 8pt between the field and the row under it. + expect(nodeByRef($screen, 'message-row')['layout']['padding'])->toEqual([0, 16, 8, 16]) + ->and(nodeByRef($screen, 'message-field-row')['layout']['padding'])->toEqual([4, 12, 8, 16]); +})->with(['ios', 'android']); + +it('puts the bar on glass on iOS and the surface on Android, with no box or line, and fades the thread out above it', function (string $platform) { + if ($platform === 'ios') { + GlassOpacity::skipUnlessSupported(); + } + + serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]); + + $screen = threadWithAda($platform); + $bottomBar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); + $bar = nodeByRef($screen, 'composer-bar'); + $fade = nodeByRef($screen, 'composer-fade'); + $surface = substr(strtoupper(config('native-ui.theme.light.surface')), 1); + $darkSurface = substr(strtoupper(config('native-ui.theme.dark.surface')), 1); + + expect($bar['props']['glass'] ?? null)->toBeNull() + ->and(childRefs($screen, 'composer-rows')[0])->toBe('mention-slot') + ->and(nodeByRef($screen, 'message-box')['style']['border_width'] ?? 0)->toEqual(0) + ->and(nodeByRef($screen, 'message-box')['style']['bg_color'] ?? null)->toBeNull() + ->and($fade['layout']['height'] ?? null)->toEqual(Display::ComposerFadeHeight); + + if ($platform === 'ios') { + // The thread runs on under the bar, which is glass, so it shows through blurred. The bar draws the fade at its + // top, ending at the glass's tint, and its rows carry the tint, in either appearance. The bar itself has no + // background, which iOS would paint behind the fade. + expect($bottomBar['props']['glass'] ?? null)->toBe(1) + ->and($bottomBar['props']['glass_opacity'] ?? null)->toBe(Display::ComposerGlassOpacity / 100) + ->and(childRefs($screen, 'composer-bar'))->toBe(['composer-fade', 'composer-rows']) + ->and($bar['style']['bg_color'] ?? null)->toBeNull() + ->and(nodeByRef($screen, 'composer-rows')['style']['bg_color'] ?? null)->toBe('#66'.$surface) + ->and(nodeByRef($screen, 'composer-rows')['props']['dark_bg_color'] ?? null)->toBe('#66'.$darkSurface) + ->and($fade['props']['gradient_stops'] ?? null)->toBe('#00'.$surface.',#66'.$surface) + ->and(childRefs($screen, 'thread-stack'))->not->toContain('composer-fade'); + } else { + // No glass on Android. The thread stops at the bar, so the fade lies over its foot, and the bar is the surface. + expect($bottomBar['props']['glass'] ?? null)->toBeNull() + ->and($bottomBar['props']['glass_opacity'] ?? null)->toBeNull() + ->and(childRefs($screen, 'composer-bar'))->toBe(['composer-rows']) + ->and($bar['style']['bg_color'] ?? null)->toBe(config('native-ui.theme.light.surface')) + ->and(nodeByRef($screen, 'composer-rows')['style']['bg_color'] ?? null)->toBe(config('native-ui.theme.light.surface')) + ->and($fade['props']['gradient_stops'] ?? null)->toBe('#00'.$surface.',#B3'.$surface.',#'.$surface) + ->and(array_slice(childRefs($screen, 'thread-stack'), -1))->toBe(['composer-fade']); + } +})->with(['ios', 'android']); + +it('stands the message bar on the scroll edge effect from iOS 26, with no fade or tint', function () { + serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]); + + ScrollEdge::onIos('26.0', function (): void { + $screen = threadWithAda(); + $bottomBar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); + + expect($bottomBar['props']['edge_blur'] ?? null)->toBe(Display::ComposerEdgeBlur) + ->and(nodeByRef($screen, 'message-box')['props']['glass'] ?? null)->toBe(Display::ComposerInGlassBox ? 1 : null) + ->and(childRefs($screen, 'composer-bar'))->toBe(['composer-rows']) + ->and(nodeByRef($screen, 'composer-bar')['style']['bg_color'] ?? null)->toBeNull() + ->and(nodeByRef($screen, 'composer-rows')['style']['bg_color'] ?? null)->toBeNull() + ->and(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'composer-fade'))->toBeNull() + ->and(nodeByRef($screen, 'composer-clearance')['layout']['height'] ?? null)->toEqual(Display::composerBoxBarHeight() + 8); + }); }); -it('leads the bar with the + on Android, on a solid bar', function () { +it('fades to the dark surface in dark mode, and draws again when the phone switches', function () { serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]); - $screen = threadWithAda('android'); + $screen = threadWithAda(); + $light = substr(strtoupper(config('native-ui.theme.light.surface')), 1); + $dark = substr(strtoupper(config('native-ui.theme.dark.surface')), 1); - expect(array_slice(childRefs($screen, 'message-row'), 0, 2))->toBe(['composer-tools', 'message-plate']) - ->and(childRefs($screen, 'message-plate'))->toBe(['message-field']) - ->and(nodeByRef($screen, 'message-plate')['props']['glass'] ?? null)->toBeNull() - ->and(nodeByRef($screen, 'composer-bar')['style']['bg_color'] ?? null)->toBe(config('native-ui.theme.light.surface')); + expect(str_ends_with(nodeByRef($screen, 'composer-fade')['props']['gradient_stops'], $light))->toBeTrue(); + + System::rememberAppearance('dark'); + + try { + $screen->emitNative(AppearanceChanged::class, ['mode' => 'dark']); + + expect(str_ends_with(nodeByRef($screen, 'composer-fade')['props']['gradient_stops'], $dark))->toBeTrue(); + } finally { + System::rememberAppearance('light'); + } }); +it('counts a long message beside Push from 1,600 characters, amber from 1,900 and red at 2,000', function (int $length, ?string $colour) { + serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]); + + $screen = threadWithAda()->input('message-input', str_repeat('a', $length)); + + if ($colour === null) { + expect(rendersRef($screen, 'message-length'))->toBeFalse(); + + return; + } + + $actions = childRefs($screen, 'message-actions'); + + expect(nodeByRef($screen, 'message-length')['props']['text'])->toBe(number_format($length).'/2,000') + ->and(strtolower(nodeByRef($screen, 'message-length')['props']['color'] ?? ''))->toBe(strtolower(config("native-ui.theme.light.{$colour}"))) + ->and(array_slice($actions, -2))->toBe(['message-length', 'push']); +})->with([ + 'short' => [1599, null], + 'long' => [1600, 'ink-muted'], + 'nearly full' => [1900, 'pending'], + 'full' => [2000, 'destructive'], +]); + it('pings Ada, logging it in the thread as the web does and buzzing the phone', function () { serveThreadWithAda([remoteMessageJson(['id' => 1, 'body' => 'you there?'])], ['read_through_id' => 1]); @@ -363,3 +488,11 @@ function threadWithAda(string $platform = 'ios'): TestableComponent expect(sentTo('POST', 'remotes/orgs/org-1/ping'))->toBe(['']); }); + +it('leaves a gap between what you are replying to and the message box under it on iOS', function () { + serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]); + + $screen = threadWithAda()->trigger('swipe-1')->assertSee('Replying to Ada Lovelace'); + + expect(nodeByRef($screen, 'replying-slot')['layout']['padding'][2])->toBe(8.0); +}); diff --git a/tests/Feature/Screens/RemotesVoiceNotesTest.php b/tests/Feature/Screens/RemotesVoiceNotesTest.php index 7dee858e..01a2038a 100644 --- a/tests/Feature/Screens/RemotesVoiceNotesTest.php +++ b/tests/Feature/Screens/RemotesVoiceNotesTest.php @@ -184,10 +184,11 @@ function playedBars(TestableComponent $screen, string $ref): int && $params['maxDuration'] == 60 && $params['id'] === $screen->instance()->recordingId); - expect(childRefs($screen, 'message-plate'))->toBe(['voice-recorder']) + expect(childRefs($screen, 'message-field-row'))->toBe(['voice-recorder']) + ->and(childRefs($screen, 'message-actions'))->not->toContain('composer-tools') ->and(nodeByRef($screen, 'voice-elapsed')['props']['text'] ?? null)->toBe('0:00/1:00') ->and(rendersEvery($screen))->toBe([200]) - ->and(nodeByRef($screen, 'push')['props']['disabled'] ?? false)->toBeFalse(); + ->and(canSend($screen, 'push'))->toBeTrue(); // The level is the loudest sample since the last look, square-rooted as the web draws it, and the clock turns amber // in the last ten seconds. @@ -207,7 +208,7 @@ function playedBars(TestableComponent $screen, string $ref): int $screen = voiceThread()->tap('record-voice-note')->assertSee('opening microphone…'); - expect(nodeByRef($screen, 'push')['props']['disabled'] ?? false)->toBeTrue(); + expect(canSend($screen, 'push'))->toBeFalse(); // The clock counts from when the microphone starts, not from the tap. $this->travel(5)->seconds(); @@ -217,7 +218,7 @@ function playedBars(TestableComponent $screen, string $ref): int $screen->call('poll'); expect(nodeByRef($screen, 'voice-elapsed')['props']['text'])->toBe('0:02/1:00') - ->and(nodeByRef($screen, 'push')['props']['disabled'] ?? false)->toBeFalse(); + ->and(canSend($screen, 'push'))->toBeTrue(); }); it('stops to listen to the recording first, then pushes it staged at once and pushed once devnull has it', function () { @@ -228,7 +229,7 @@ function playedBars(TestableComponent $screen, string $ref): int $screen = voiceThread()->tap('record-voice-note')->tap('stop-voice-note'); $screen->assertNativeCalled('Microphone.Stop')->assertSee('encoding…'); - expect(nodeByRef($screen, 'push')['props']['disabled'] ?? false)->toBeTrue(); + expect(canSend($screen, 'push'))->toBeFalse(); voiceRecorded($screen, $recording); $kept = $screen->instance()->recorded->url; @@ -245,7 +246,7 @@ function playedBars(TestableComponent $screen, string $ref): int $screen->tap('push')->assertSee('staged')->assertSet('recorder', null)->assertNativeCalled('MediaPlayer.Stop'); $clientId = $screen->instance()->pending[0]->clientId; - expect(childRefs($screen, 'message-plate'))->toBe(['message-field', 'composer-tools']) + expect(childRefs($screen, 'message-field-row'))->toBe(['message-field']) ->and(nodeByRef($screen, 'voice-'.$clientId.'-clock')['props']['text'])->toBe('0:02'); finishRefreshes($screen)->assertSee('pushed')->assertSet('pending', []); @@ -321,7 +322,7 @@ function playedBars(TestableComponent $screen, string $ref): int } expect(file_exists($recording))->toBeFalse() - ->and(childRefs($screen, 'message-plate'))->toBe(['message-field', 'composer-tools']) + ->and(childRefs($screen, 'message-field-row'))->toBe(['message-field']) ->and(voiceUploads())->toBe([]); })->with(['while recording' => [true], 'once recorded' => [false]]); diff --git a/tests/Feature/Screens/RowCacheScreensTest.php b/tests/Feature/Screens/RowCacheScreensTest.php index 902cbd0d..d7c547cd 100644 --- a/tests/Feature/Screens/RowCacheScreensTest.php +++ b/tests/Feature/Screens/RowCacheScreensTest.php @@ -88,10 +88,10 @@ function expectKeptRowsMatchFreshOnes(TestableComponent $screen, string $class, }); $screen = Native::visit('/log/commits/c2')->tap('replies-c2')->assertSee('Second reply'); - // The commits above the replies read what the screen shows of the thread, so they're built every time. The last - // reply of a page changes when the next page comes, since it no longer carries "more". + // The commits above the replies read what the screen shows of the thread, so they're built every time. "Show + // more" is a row of its own, so the last reply of a page stays as it was when the next page comes. expect(rowsBuiltBy(fn () => $screen->call('navTitle')))->toBe(['c2']) - ->and(rowsBuiltBy(fn () => $screen->call('loadMoreReplies')->assertSee('Third reply')))->toBe(['c2', 'r2', 'r3']); + ->and(rowsBuiltBy(fn () => $screen->call('loadMoreReplies')->assertSee('Third reply')))->toBe(['c2', 'r3']); expectKeptRowsMatchFreshOnes($screen, CommitDetail::class, 'replyRows', null); }); diff --git a/tests/Feature/Screens/ScrollToReplyTest.php b/tests/Feature/Screens/ScrollToReplyTest.php new file mode 100644 index 00000000..be04ecf7 --- /dev/null +++ b/tests/Feature/Screens/ScrollToReplyTest.php @@ -0,0 +1,129 @@ + 'http://devnull.test']); + signIn(); +}); + +/** + * A commit page for c2, under c1 and c0, with a first page of ten replies and more after them. r1 has a reply of + * its own, n1. Everything is kept from before, so the page shows it at once and holds its refreshes, the reply + * you post among them, until the test lets them go. + * + * @param array $commit + */ +function fakeLongThread(array $commit = [], array $posted = []): void +{ + holdRefreshes(); + + $grace = userJson(['handle' => 'grace', 'name' => 'Grace']); + $c0 = commitJson(['id' => 'c0', 'body' => 'The root commit', 'author' => userJson(['handle' => 'ada', 'name' => 'Ada'])]); + $c1 = commitJson(['id' => 'c1', 'parent_id' => 'c0', 'body' => 'The parent commit', 'author' => userJson(['handle' => 'linus', 'name' => 'Linus'])]); + $c2 = commitJson(['id' => 'c2', 'parent_id' => 'c1', 'body' => 'The focused commit', 'replies_count' => 11, 'author' => $grace, ...$commit]); + $replies = array_map(fn (int $n): array => replyJson(['id' => "r{$n}", 'parent_id' => 'c2', 'body' => "Reply {$n}", 'replies_count' => $n === 1 ? 1 : 0]), range(1, 10)); + $repliesPage = pageJson($replies, 'page2', 'http://devnull.test/api/v1/commits/c2/replies'); + $nested = pageJson([replyJson(['id' => 'n1', 'parent_id' => 'r1', 'body' => 'A reply to the first reply', 'author' => userJson(['handle' => 'alan', 'name' => 'Alan'])])]); + + keep('commits/c2', commitPageJson($c2, [$c0, $c1])); + keep('commits/c2/replies', $repliesPage); + keep('commits/r1/replies', $nested); + + fakeApi([ + 'GET /api/v1/commits/c2' => [commitPageJson($c2, [$c0, $c1])], + 'GET /api/v1/commits/c2/replies' => [$repliesPage], + 'GET /api/v1/commits/c2/related' => [['data' => []]], + 'GET /api/v1/commits/r1/replies' => [$nested], + 'POST /api/v1/commits' => [['data' => commitJson(['id' => 'r99', 'parent_id' => 'c2', 'body' => 'My fresh reply', ...$posted])], 201], + ]); +} + +/** + * Where the scroll view is asked to go: the ref of the child at auto-scroll-to, and the request it's under, which + * the scroll view takes as its auto-scroll-token where mobile-ui has it. + * + * @return array{0: string|null, 1: int} + */ +function scrolledTo(TestableComponent $screen): array +{ + $index = nodeByRef($screen, 'thread-scroll')['props']['auto_scroll_to'] ?? -1; + + return [childRefs($screen, 'thread-scroll')[$index] ?? null, $screen->instance()->scrollRequest]; +} + +function stagedReplyId(TestableComponent $screen): string +{ + /** @var CommitDetail $page */ + $page = $screen->instance(); + + return collect($page->replies)->first(fn ($reply): bool => $reply->isStaged())->id; +} + +it('scrolls to a reply sent from the bar, under the commits above and past ten replies', function () { + fakeLongThread(); + + $screen = Native::visit('/log/commits/c2')->assertSet('scrollRequest', 0); + + $screen->input('reply-input', 'My fresh reply')->tap('send-reply')->assertSet('repliesShown', true); + + $staged = stagedReplyId($screen); + $children = childRefs($screen, 'thread-scroll'); + + expect($children)->toBe([ + 'earlier-commits', 'commit-c1', 'focused-commit', + ...array_map(fn (int $n): string => "thread-reply-r{$n}", range(1, 10)), + "thread-reply-{$staged}", null, 'reply-bar-clearance', + ]) + ->and($screen->instance()->scrollTarget)->toBe(array_search("thread-reply-{$staged}", $children, true)) + ->and(scrolledTo($screen))->toBe(["thread-reply-{$staged}", 1]); + + // devnull's reply takes the staged one's place, on the same row, and the page doesn't scroll again. + finishRefreshes($screen)->assertDontSee('staged'); + + expect(scrolledTo($screen))->toBe(['thread-reply-r99', 1]); +}); + +it('scrolls to a reply sent from the sheet, past replies opened in place under the ones before it', function () { + fakeLongThread(); + + $screen = Native::visit('/log/commits/c2') + ->tap('earlier-commits') + ->tap('replies-c2') + ->tap('replies-r1'); + + finishRefreshes($screen) + ->assertSee('A reply to the first reply') + ->assertSet('scrollRequest', 0); + + $screen->call('replyInSheet', 'c2')->input('sheet-body', 'My fresh reply')->tap('sheet-commit'); + + $staged = stagedReplyId($screen); + $children = childRefs($screen, 'thread-scroll'); + + expect(array_slice($children, 0, 5))->toBe(['commit-c0', 'commit-c1', 'focused-commit', 'thread-reply-r1', 'thread-reply-n1']) + ->and(scrolledTo($screen))->toBe(["thread-reply-{$staged}", 1]) + ->and($screen->instance()->scrollTarget)->toBe(14); + + finishRefreshes($screen); + + expect(scrolledTo($screen))->toBe(['thread-reply-r99', 1]); +}); + +it('follows a reply to your own commit when devnull has it carry your thread on', function () { + // The commit is yours, and so is the reply, so once devnull has it, it's the next part of your thread, below the + // commit's replies, rather than one of them. + fakeLongThread(commit: ['author' => userJson()]); + + $screen = Native::visit('/log/commits/c2'); + $screen->input('reply-input', 'My fresh reply')->tap('send-reply'); + + expect(scrolledTo($screen))->toBe(['thread-reply-'.stagedReplyId($screen), 1]); + + finishRefreshes($screen); + + // It moved a row down, past "Show more" under the replies, so the page goes after it. + expect(scrolledTo($screen))->toBe(['commit-r99', 2]); +}); diff --git a/tests/Feature/Screens/SelfThreadTest.php b/tests/Feature/Screens/SelfThreadTest.php new file mode 100644 index 00000000..b78153cc --- /dev/null +++ b/tests/Feature/Screens/SelfThreadTest.php @@ -0,0 +1,204 @@ + 'http://devnull.test']); + signIn(); +}); + +/** + * One of Ada's commits, $minutes ago, replying to $parent. + * + * @param array $overrides + * @return array + */ +function adaJson(string $id, ?string $parent = null, int $minutes = 30, array $overrides = []): array +{ + return commitJson([ + 'id' => $id, + 'parent_id' => $parent, + 'body' => "Ada's {$id}", + 'author' => userJson(['handle' => 'ada', 'name' => 'Ada', 'lane' => 2]), + 'created_at' => now()->subMinutes($minutes)->toIso8601ZuluString(), + ...$overrides, + ]); +} + +/** + * Serves a commit page and the replies of every commit in $replies, by id, and 404s anything else. + * + * @param array $commit + * @param list> $ancestors + * @param array>> $replies + */ +function serveSelfThread(array $commit, array $ancestors, array $replies): void +{ + Http::fake(function (Request $request) use ($commit, $ancestors, $replies) { + $path = (string) parse_url($request->url(), PHP_URL_PATH); + + if ($path === '/api/v1/commits/'.$commit['id']) { + return Http::response(commitPageJson($commit, $ancestors)); + } + + if (preg_match('#^/api/v1/commits/([^/]+)/replies$#', $path, $match) === 1 && array_key_exists($match[1], $replies)) { + return Http::response(pageJson($replies[$match[1]])); + } + + if (str_ends_with($path, '/related')) { + return Http::response(['data' => []]); + } + + return Http::response(['message' => 'No fake.'], 404); + }); +} + +/** + * The refs of the rows down a commit page, top to bottom. + * + * @return list + */ +function selfThreadRows(TestableComponent $screen): array +{ + return array_values(array_filter(childRefs($screen, 'thread-scroll'), fn (?string $ref): bool => $ref !== 'reply-bar-clearance')); +} + +/** + * The text of a commit's place in its thread. + */ +function threadPositionOf(TestableComponent $screen, string $id): string +{ + $text = findNode(nodeByRef($screen, 'thread-position-'.$id), fn (array $node): bool => ($node['type'] ?? null) === 'text'); + + return $text['props']['text'] ?? ''; +} + +it("reads an author's replies to themselves in order under the commit, as the web's thread", function () { + serveSelfThread(adaJson('c1', overrides: ['replies_count' => 2]), [], [ + 'c1' => [ + replyJson(['id' => 'r1', 'parent_id' => 'c1', 'body' => 'Grace answers', 'created_at' => now()->subMinutes(28)->toIso8601ZuluString()]), + adaJson('p2', 'c1', 25), + adaJson('later', 'c1', 5, ['body' => 'Ada again, later']), + ], + 'p2' => [replyJson(['id' => 'x1', 'parent_id' => 'p2', 'body' => 'Under part two']), adaJson('p3', 'p2', 20)], + 'p3' => [replyJson(['id' => 'y1', 'parent_id' => 'p3', 'body' => 'Under the last part'])], + ]); + + $screen = Native::visit('/log/commits/c1') + ->assertSee("Ada's p2") + ->assertSee("Ada's p3") + ->assertSee('Under the last part') + ->assertDontSee('Under part two') + ->assertDontSee('Grace answers') + ->assertDontSee('No replies yet.'); + + expect(selfThreadRows($screen))->toBe(['focused-commit', 'commit-p2', 'commit-p3', 'thread-reply-y1']) + ->and(threadPositionOf($screen, 'c1'))->toBe('1/3') + ->and(threadPositionOf($screen, 'p2'))->toBe('2/3') + ->and(threadPositionOf($screen, 'p3'))->toBe('3/3') + ->and(railNode($screen, 'commit-p2'))->toBe('dot') + // The last part's replies show under it, so its action row doesn't offer them again. + ->and(findNode(nodeByRef($screen, 'commit-p3'), fn (array $node): bool => ($node['ref'] ?? null) === 'replies-p3'))->toBeNull(); + + // The commit's own replies leave out the part that carries it on, and keep its later replies to itself. + $screen->tap('replies-c1')->assertSee('Grace answers')->assertSee('Ada again, later'); + + expect(selfThreadRows($screen))->toBe(['focused-commit', 'thread-reply-r1', 'thread-reply-later', 'commit-p2', 'commit-p3', 'thread-reply-y1']); +}); + +it('marks the earlier parts above a commit in the middle of its thread', function () { + serveSelfThread(adaJson('p2', 'c1', 20), [adaJson('c1', minutes: 30)], [ + 'c1' => [adaJson('p2', 'c1', 20)], + 'p2' => [], + ]); + + $screen = Native::visit('/log/commits/p2'); + + expect(threadPositionOf($screen, 'c1'))->toBe('1/2') + ->and(threadPositionOf($screen, 'p2'))->toBe('2/2'); +}); + +it("doesn't mark a commit its author replied to some other way first", function () { + serveSelfThread(adaJson('p2', 'c1', 10), [adaJson('c1', minutes: 30)], [ + 'c1' => [adaJson('first', 'c1', 20), adaJson('p2', 'c1', 10)], + 'p2' => [], + ]); + + $screen = Native::visit('/log/commits/p2')->assertSee("Ada's c1"); + + expect(findNode($screen->tree(), fn (array $node): bool => str_starts_with((string) ($node['ref'] ?? ''), 'thread-position-')))->toBeNull(); +}); + +it('shows ten parts at a time, and the rest from Show more of this thread', function () { + $replies = ['c1' => [adaJson('p2', 'c1', 29)]]; + + foreach (range(2, 11) as $part) { + $replies['p'.$part] = [adaJson('p'.($part + 1), 'p'.$part, 29 - $part)]; + } + + $replies['p12'] = []; + serveSelfThread(adaJson('c1', minutes: 30), [], $replies); + + $screen = Native::visit('/log/commits/c1') + ->assertSee("Ada's p11") + ->assertDontSee("Ada's p12"); + + expect(threadPositionOf($screen, 'c1'))->toBe('1/12+'); + + $screen->tap('more-thread')->assertSee("Ada's p12"); + + expect(threadPositionOf($screen, 'c1'))->toBe('1/12') + ->and(threadPositionOf($screen, 'p12'))->toBe('12/12') + ->and(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'more-thread'))->toBeNull(); +}); + +it("leaves the author's next part out of a thread opened on the Log, and links to the thread instead", function () { + Http::fake(fn (Request $request) => match (parse_url($request->url(), PHP_URL_PATH)) { + '/api/v1/log/following' => Http::response(pageJson([adaJson('c1', overrides: ['replies_count' => 1])])), + '/api/v1/commits/c1/replies' => Http::response(pageJson([adaJson('p2', 'c1', 25), replyJson(['id' => 'r1', 'parent_id' => 'c1', 'body' => 'Grace answers'])])), + default => Http::response(['message' => 'No fake.'], 404), + }); + + $screen = Native::visit('/log')->assertDontSee('Show thread')->tap('replies-c1') + ->assertSee('Grace answers') + ->assertDontSee("Ada's p2") + ->assertSee('Show thread'); + + expect(array_map(fn ($reply): string => $reply->id, $screen->instance()->threads['c1']))->toBe(['r1']); + + $screen->tap('show-thread-c1')->assertNavigatedTo('/log/commits/c1'); +}); + +it("leaves a reply's next part out of its replies opened in place on the Log, and links that reply to its thread", function () { + $grace = userJson(['handle' => 'grace', 'name' => 'Grace', 'lane' => 4]); + + Http::fake(fn (Request $request) => match (parse_url($request->url(), PHP_URL_PATH)) { + '/api/v1/log/following' => Http::response(pageJson([adaJson('c1', overrides: ['replies_count' => 1])])), + '/api/v1/commits/c1/replies' => Http::response(pageJson([replyJson(['id' => 'r1', 'parent_id' => 'c1', 'body' => 'Grace answers', 'author' => $grace, 'replies_count' => 2])])), + '/api/v1/commits/r1/replies' => Http::response(pageJson([ + replyJson(['id' => 'g2', 'parent_id' => 'r1', 'body' => 'Grace carries on', 'author' => $grace, 'created_at' => now()->subMinutes(4)->toIso8601ZuluString()]), + replyJson(['id' => 'n1', 'parent_id' => 'r1', 'body' => 'Someone else answers Grace']), + ])), + default => Http::response(['message' => 'No fake.'], 404), + }); + + $screen = Native::visit('/log')->tap('replies-c1')->assertSee('Grace answers')->assertDontSee('Show thread') + ->tap('replies-r1') + ->assertSee('Someone else answers Grace') + ->assertDontSee('Grace carries on') + ->assertSee('Show thread'); + + expect(array_map(fn ($reply): string => $reply->id, $screen->instance()->threads['r1']))->toBe(['n1']) + ->and($screen->instance()->threadsContinued)->toBe(['r1']); + + $screen->tap('show-thread-r1')->assertNavigatedTo('/log/commits/r1'); +}); + +it('links to the thread when devnull says which reply carries it on', function () { + Http::fake(['devnull.test/api/v1/log/following*' => Http::response(pageJson([adaJson('c1', overrides: ['continuation_id' => 'p2'])]))]); + + Native::visit('/log')->assertSee('Show thread')->tap('show-thread-c1')->assertNavigatedTo('/log/commits/c1'); +}); diff --git a/tests/Feature/Screens/SeriesTest.php b/tests/Feature/Screens/SeriesTest.php index ad0ff31a..07829c2b 100644 --- a/tests/Feature/Screens/SeriesTest.php +++ b/tests/Feature/Screens/SeriesTest.php @@ -131,7 +131,8 @@ function railRunsOn(TestableComponent $screen, string $ref): bool ->and(railRunsOn($screen, 'focused-commit'))->toBeTrue() ->and(railRunsOn($screen, 'commit-p3'))->toBeFalse(); - $screen->tap('commit-p3')->assertNavigatedTo('/log/commits/p3'); + // A part in the tree moves the page to it rather than pushing another. + $screen->tap('commit-p3')->assertNoNavigation()->assertSet('id', 'p3'); }); it('puts a part\'s replies under it, above the later parts, as on the web', function () { @@ -154,7 +155,10 @@ function railRunsOn(TestableComponent $screen, string $ref): bool ->assertSee('Agreed') ->assertDontSee('2 replies'); - expect(threadRows($screen))->toBe(['focused-commit', 'thread-reply-r1', 'thread-reply-r2', 'commit-p2', 'commit-p3']); + expect(threadRows($screen))->toBe(['focused-commit', 'thread-reply-r1', 'thread-reply-r2', 'commit-p2', 'commit-p3']) + // The focused part gave up its hairline to its replies, and the later parts follow, so the last reply ends on it. + ->and(rendersRef($screen, 'thread-end-r2'))->toBeTrue() + ->and(rendersRef($screen, 'thread-end-r1'))->toBeFalse(); }); it('keeps replies at the foot of the last part\'s page', function () { @@ -167,7 +171,9 @@ function railRunsOn(TestableComponent $screen, string $ref): bool ->assertSee('The end'); expect(threadRows($screen))->toBe(['commit-p1', 'commit-p2', 'focused-commit', 'thread-reply-r1']) - ->and(railRunsOn($screen, 'focused-commit'))->toBeFalse(); + ->and(railRunsOn($screen, 'focused-commit'))->toBeFalse() + // Nothing follows the replies at the foot of the page, so they end on no hairline. + ->and(rendersRef($screen, 'thread-end-r1'))->toBeFalse(); }); it('keeps a deleted part in its place in the series', function () { diff --git a/tests/Fixtures/views/mention-suggestions.blade.php b/tests/Fixtures/views/mention-suggestions.blade.php new file mode 100644 index 00000000..d29b0fbf --- /dev/null +++ b/tests/Fixtures/views/mention-suggestions.blade.php @@ -0,0 +1,4 @@ +{{-- The mention list alone, for MentionSuggestionsTest: the partial with whatever options the test passes. --}} + + @include('native.partials.mention-suggestions', ['field' => 'body', ...$options]) + diff --git a/tests/Pest.php b/tests/Pest.php index 6eb917e7..22ceec2f 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -409,7 +409,8 @@ function userJson(array $overrides = []): array $username = $overrides['handle'] ?? 'local_dev'; return [ - 'id' => '0199e5c4-0000-7000-8000-000000000001', + // Someone else, named by a handle of their own, is someone else to the app too. + 'id' => $username === 'local_dev' ? '0199e5c4-0000-7000-8000-000000000001' : 'user-'.$username, 'handle' => $username, 'name' => 'Local Dev', 'avatar_url' => 'https://avatars.githubusercontent.com/u/1?v=4', @@ -426,6 +427,17 @@ function userJson(array $overrides = []): array ]; } +/** + * Someone replying to a commit, who isn't its author. + * + * @param array $overrides + * @return array + */ +function replierJson(array $overrides = []): array +{ + return userJson(['id' => '0199e5c4-0000-7000-8000-0000000000aa', 'handle' => 'replier', 'name' => 'Re Plier', 'lane' => 5, ...$overrides]); +} + /** * A user with their counts, as `/me`, a profile and a key sync send them. * @@ -584,14 +596,16 @@ function commitPageJson(array $commit, array $ancestors = [], array $series = [] /** * A reply as `GET /commits/{id}/replies` sends it: like any commit, but without - * stars_count or starred, which that list doesn't load. + * stars_count or starred, which that list doesn't load. It comes from someone + * other than the commit's author unless a test says who, since a reply of + * theirs carries their own thread on (see SelfThread). * * @param array $overrides * @return array */ function replyJson(array $overrides = []): array { - return array_diff_key(commitJson($overrides), array_flip(['stars_count', 'starred'])); + return array_diff_key(commitJson(['author' => replierJson(), ...$overrides]), array_flip(['stars_count', 'starred'])); } /** @@ -850,6 +864,15 @@ function sheetButtonEnabled(TestableComponent $screen, string $ref): bool return nodeByRef($screen, $ref)['type'] === 'pressable'; } +/** + * Whether a composer's round send button (partials/send-button) can be tapped. A disabled one is drawn as a plain + * circle, not a pressable. + */ +function canSend(TestableComponent $screen, string $ref): bool +{ + return nodeByRef($screen, $ref)['type'] === 'pressable'; +} + /** * The circle of a round button in a sheet's bar, whether it can be tapped or not. * diff --git a/tests/Support/GlassOpacity.php b/tests/Support/GlassOpacity.php new file mode 100644 index 00000000..4acf0dac --- /dev/null +++ b/tests/Support/GlassOpacity.php @@ -0,0 +1,24 @@ +markTestSkipped('Needs a mobile-air that reads glass/N (NativePHP/mobile-air#735)'); + } + } +} diff --git a/tests/Support/LayoutAnimation.php b/tests/Support/LayoutAnimation.php new file mode 100644 index 00000000..155686c8 --- /dev/null +++ b/tests/Support/LayoutAnimation.php @@ -0,0 +1,25 @@ +markTestSkipped('Needs a mobile-air with layout animation (NativePHP/mobile-air#736)'); + } + } +} diff --git a/tests/Support/MenuSubtitle.php b/tests/Support/MenuSubtitle.php new file mode 100644 index 00000000..4ad7d904 --- /dev/null +++ b/tests/Support/MenuSubtitle.php @@ -0,0 +1,32 @@ +markTestSkipped('Needs a core with NavAction::subtitle() (NativePHP/mobile-air#740)'); + } + } + + public static function skipIfSupported(): void + { + if (self::supported()) { + test()->markTestSkipped('The installed core has NavAction::subtitle(), so the menu never falls back to one label'); + } + } +} diff --git a/tests/Support/ScrollEdge.php b/tests/Support/ScrollEdge.php new file mode 100644 index 00000000..13616b6f --- /dev/null +++ b/tests/Support/ScrollEdge.php @@ -0,0 +1,48 @@ +markTestSkipped('Needs a mobile-air with edge-blur on a bottom bar and System::osVersion()'); + } + } + + /** + * Run $test as on a phone with this iOS, then forget it again. + * + * @template T + * + * @param callable(): T $test + * @return T + */ + public static function onIos(string $version, callable $test): mixed + { + self::skipUnlessSupported(); + + System::rememberOsVersion($version); + + try { + return $test(); + } finally { + System::rememberOsVersion(null); + } + } +} diff --git a/tests/Unit/Devnull/ComposerSheetTest.php b/tests/Unit/Devnull/ComposerSheetTest.php new file mode 100644 index 00000000..c5cdf23f --- /dev/null +++ b/tests/Unit/Devnull/ComposerSheetTest.php @@ -0,0 +1,83 @@ +toBe([ + 'field' => null, + 'top' => ComposerSheet::FieldTop + 72 + ComposerSheet::MentionGap, + 'height' => ComposerSheet::MentionPadding + 3 * ComposerSheet::MentionRowHeight, + ]); +}); + +it('holds the list to six rows, plus its heading, and scrolls the rest', function () { + expect(ComposerSheet::mentionHeight(10))->toBe(ComposerSheet::MentionPadding + 6 * ComposerSheet::MentionRowHeight) + ->and(ComposerSheet::mentionHeight(2, heading: true))->toBe(ComposerSheet::MentionPadding + ComposerSheet::MentionHeadingHeight + 2 * ComposerSheet::MentionRowHeight); +}); + +it('shortens the field to end on the caret\'s line when the list would not fit under it, and puts the list under the field', function () { + // The caret low in the field, as in build 42: six people need 272pt, and there's 360 - 300 under the caret. + $layout = ComposerSheet::mentionLayout(composerCaret(300), rows: 8); + $list = ComposerSheet::mentionHeight(8); + $field = 360 - ComposerSheet::MentionGap - ComposerSheet::MentionInset - $list; + + expect($layout)->toBe(['field' => $field, 'top' => ComposerSheet::FieldTop + $field + ComposerSheet::MentionGap, 'height' => null]) + // The list starts under the caret's line, never over it: the field ends on that line. + ->and($layout['top'])->toBeGreaterThan(ComposerSheet::FieldTop + $layout['field']) + // And the list has its six rows from there to the toolbar. + ->and(ComposerSheet::FieldTop + 360 - ComposerSheet::MentionInset - $layout['top'])->toBe($list); +}); + +it('shortens the field only as far as the list needs', function () { + $layout = ComposerSheet::mentionLayout(composerCaret(300), rows: 2); + + expect($layout['field'])->toBe(360 - ComposerSheet::MentionGap - ComposerSheet::MentionInset - ComposerSheet::mentionHeight(2)) + ->and($layout['field'])->toBeLessThan(300); +}); + +it('keeps two lines of field on a short phone, and the list scrolls in what\'s left', function () { + $layout = ComposerSheet::mentionLayout(composerCaret(140, fieldHeight: 160), rows: 6); + + expect($layout)->toBe(['field' => ComposerSheet::MinFieldLines * 24, 'top' => ComposerSheet::FieldTop + 48 + ComposerSheet::MentionGap, 'height' => null]); +}); + +it('leaves the field alone when the caret is already in its first lines', function () { + $layout = ComposerSheet::mentionLayout(composerCaret(24, fieldHeight: 160), rows: 6); + + expect($layout['field'])->toBeNull() + ->and($layout['top'])->toBe(ComposerSheet::FieldTop + 24 + ComposerSheet::MentionGap) + ->and($layout['height'])->toBe(160 - 24 - ComposerSheet::MentionGap - ComposerSheet::MentionInset); +}); + +it('keeps where the caret is at the field\'s full height while the field is shortened', function () { + $kept = composerCaret(300); + $shortened = ComposerSheet::mentionLayout($kept, rows: 8)['field']; + + // The shortened field reports itself scrolled to the caret: that's not where the caret is at full height. + expect(ComposerSheet::reported(new Caret(y: $shortened - 24, height: 24, fieldHeight: $shortened), $kept, $shortened))->toBe($kept) + // A report at another height is the field at its full height again. + ->and(ComposerSheet::reported(new Caret(y: 48, height: 24, fieldHeight: 360), $kept, $shortened))->toBe(composerCaret(72)) + ->and(ComposerSheet::reported(new Caret(y: 48, height: 24, fieldHeight: 360), $kept, null))->toBe(composerCaret(72)); +}); + +it('keeps a caret the field has scrolled out of view to the field\'s edges', function () { + expect(ComposerSheet::caret(new Caret(y: -60, height: 24, fieldHeight: 300)))->toBe(['bottom' => 0.0, 'line_height' => 24.0, 'field_height' => 300.0]) + ->and(ComposerSheet::caret(new Caret(y: 400, height: 24, fieldHeight: 300)))->toBe(['bottom' => 300.0, 'line_height' => 24.0, 'field_height' => 300.0]); +}); + +it('puts the list under about one line, down to the toolbar, before the field has said where its caret is', function () { + expect(ComposerSheet::mentionLayout(null, rows: 3))->toBe([ + 'field' => null, + 'top' => ComposerSheet::FieldTop + ComposerSheet::FirstLineHeight + ComposerSheet::MentionGap, + 'height' => null, + ]); +}); diff --git a/tests/Unit/Devnull/DisplayTest.php b/tests/Unit/Devnull/DisplayTest.php index fe38524f..e7c8ed64 100644 --- a/tests/Unit/Devnull/DisplayTest.php +++ b/tests/Unit/Devnull/DisplayTest.php @@ -8,6 +8,16 @@ expect(Display::replyBarClearance($url))->toBe(Display::replyBarClearance(str_repeat('a', mb_strlen($url))) + 3 * Display::ReplyBarLineHeight); }); +it('grows a composer box by a line height for each line the draft wraps to, up to five lines', function (string $draft, int $lines) { + expect(Display::composerBoxGrowth($draft))->toBe(($lines - 1) * Display::ReplyBarLineHeight); +})->with([ + 'empty' => ['', 1], + 'one line' => [str_repeat('a', Display::ComposerBoxCharactersPerLine), 1], + 'wraps once' => [str_repeat('a', Display::ComposerBoxCharactersPerLine + 1), 2], + 'its own lines' => ["one\ntwo\nthree", 3], + 'past five' => [str_repeat("line\n", 9), 5], +]); + it('prints compact counts from a thousand as the web does', function (int $count, string $expected) { expect(Display::compactCount($count))->toBe($expected); })->with([ diff --git a/tests/Unit/Devnull/SelfThreadTest.php b/tests/Unit/Devnull/SelfThreadTest.php new file mode 100644 index 00000000..5f9cc7e6 --- /dev/null +++ b/tests/Unit/Devnull/SelfThreadTest.php @@ -0,0 +1,105 @@ + $overrides + */ +function threadCommit(string $id, string $handle = 'ada', ?string $parent = null, int $minutes = 10, array $overrides = []): Commit +{ + return Commit::fromArray(commitJson([ + 'id' => $id, + 'parent_id' => $parent, + 'author' => userJson(['handle' => $handle]), + 'created_at' => now()->subMinutes($minutes)->toIso8601ZuluString(), + ...$overrides, + ])); +} + +/** + * @param array> $replies + * @return Closure(Commit): (list|null) + */ +function repliesFrom(array $replies): Closure +{ + return fn (Commit $commit): ?array => $replies[$commit->id] ?? null; +} + +it("carries a commit on with its author's earliest reply to it", function () { + $commit = threadCommit('c1', minutes: 30); + $replies = [ + threadCommit('r1', 'grace', 'c1', 25), + threadCommit('p3', 'ada', 'c1', 10), + threadCommit('p2', 'ada', 'c1', 20), + ]; + + expect(SelfThread::next($commit, $replies)?->id)->toBe('p2') + ->and(array_map(fn (Commit $reply): string => $reply->id, SelfThread::others($commit, $replies)))->toBe(['r1', 'p3']); +}); + +it('never carries a commit on with a deleted reply, a quote, or a reply still on its way', function () { + $commit = threadCommit('c1', minutes: 30); + + expect(SelfThread::next($commit, [ + Commit::fromArray(['id' => 'gone', 'parent_id' => 'c1', 'deleted_at' => now()->toIso8601ZuluString()]), + threadCommit('quote', 'ada', null, 20, ['quoted_commit_id' => 'c1']), + threadCommit('staged', 'ada', 'c1', 1, ['status' => Commit::Staged]), + threadCommit('r1', 'grace', 'c1', 15), + ]))->toBeNull(); +}); + +it("takes devnull's word for which reply carries the thread on", function () { + $commit = threadCommit('c1', minutes: 30, overrides: ['continuation_id' => 'p3']); + + expect(SelfThread::next($commit, [threadCommit('p2', 'ada', 'c1', 20), threadCommit('p3', 'ada', 'c1', 10)])?->id)->toBe('p3'); +}); + +it('walks down the parts as far as their replies have come', function () { + $c1 = threadCommit('c1', minutes: 30); + $p2 = threadCommit('p2', 'ada', 'c1', 20); + $p3 = threadCommit('p3', 'ada', 'p2', 10); + + $waiting = SelfThread::below($c1, repliesFrom(['c1' => [$p2]])); + $ended = SelfThread::below($c1, repliesFrom(['c1' => [$p2], 'p2' => [$p3], 'p3' => [threadCommit('r1', 'grace', 'p3', 5)]])); + + expect(array_map(fn (Commit $part): string => $part->id, $waiting->parts))->toBe(['p2']) + ->and($waiting->waiting)->toBe('p2') + ->and($waiting->hasEnded)->toBeFalse() + ->and(array_map(fn (Commit $part): string => $part->id, $ended->parts))->toBe(['p2', 'p3']) + ->and($ended->hasEnded)->toBeTrue() + ->and($ended->waiting)->toBeNull(); +}); + +it('stops at the limit and says another part follows', function () { + $c1 = threadCommit('c1', minutes: 30); + $p2 = threadCommit('p2', 'ada', 'c1', 20); + $p3 = threadCommit('p3', 'ada', 'p2', 10); + + $thread = SelfThread::below($c1, repliesFrom(['c1' => [$p2], 'p2' => [$p3]]), limit: 1); + + expect(array_map(fn (Commit $part): string => $part->id, $thread->parts))->toBe(['p2']) + ->and($thread->hasMore)->toBeTrue() + ->and($thread->hasEnded)->toBeFalse(); +}); + +it('counts the earlier parts above a commit, only while each is the one its author carried on', function () { + $c1 = threadCommit('c1', minutes: 30); + $p2 = threadCommit('p2', 'ada', 'c1', 20); + $p3 = threadCommit('p3', 'ada', 'p2', 10); + $other = threadCommit('o1', 'ada', 'p2', 15); + + expect(SelfThread::above([$c1, $p2], $p3, repliesFrom(['c1' => [$p2], 'p2' => [$p3]])))->toBe([2, null]) + ->and(SelfThread::above([$c1, $p2], $p3, repliesFrom(['p2' => [$p3]])))->toBe([1, 'c1']) + // Ada's earliest reply to p2 is o1, so p3 isn't part of the thread. + ->and(SelfThread::above([$c1, $p2], $p3, repliesFrom(['p2' => [$other, $p3]])))->toBe([0, null]) + ->and(SelfThread::above([threadCommit('g1', 'grace')], threadCommit('p9', 'ada', 'g1'), repliesFrom([])))->toBe([0, null]); +}); + +it("writes a commit's place in its thread as the web does", function () { + expect(SelfThread::position(2, 5, false))->toBe('2/5') + ->and(SelfThread::position(1, 12, true))->toBe('1/12+') + ->and(SelfThread::position(1, 1, false))->toBeNull(); +}); diff --git a/tests/Unit/Devnull/ThreadRowsTest.php b/tests/Unit/Devnull/ThreadRowsTest.php new file mode 100644 index 00000000..dfad7144 --- /dev/null +++ b/tests/Unit/Devnull/ThreadRowsTest.php @@ -0,0 +1,86 @@ + $id, 'parent_id' => $parent, 'author' => userJson(['handle' => $handle, 'lane' => strlen($handle)]), ...$overrides])); +} + +/** + * The rows of a chain five replies deep under c1, with a second reply at the deepest step (r3b), each opened. + * + * @return array> + */ +function deepRows(int $opensInPlace = PHP_INT_MAX): array +{ + $commit = Commit::fromArray(commitJson(['id' => 'c1', 'author' => userJson(['handle' => 'ada'])])); + $threads = [ + 'c1' => [nestedReply('r1', 'c1', 'grace')], + 'r1' => [nestedReply('r2', 'r1', 'linus')], + 'r2' => [nestedReply('r3', 'r2', 'alan'), nestedReply('r3b', 'r2', 'barbara')], + 'r3' => [nestedReply('r4', 'r3', 'edsger', ['quoted_commit_id' => 'r3'])], + 'r4' => [nestedReply('r5', 'r4', 'ken')], + ]; + + $rows = ThreadRows::under($commit, $threads, ['r4' => 'next'], [], opensInPlace: $opensInPlace, onPage: true); + + return array_column(array_map(fn (array $row): array => [$row['key'], $row['data']], $rows), 1, 0); +} + +it('steps replies in up to the web\'s depth of three, and lines deeper ones up under the third', function () { + $rows = deepRows(); + + expect(array_keys($rows))->toBe(['thread-reply-r1', 'thread-reply-r2', 'thread-reply-r3', 'thread-reply-r4', 'thread-reply-r5', 'thread-more-r4', 'thread-reply-r3b']) + ->and(array_map(fn (array $row): int => $row['indent'], $rows))->toBe([ + 'thread-reply-r1' => 0, + 'thread-reply-r2' => 32, + 'thread-reply-r3' => 64, + 'thread-reply-r4' => 64, + 'thread-reply-r5' => 64, + 'thread-more-r4' => 64, + 'thread-reply-r3b' => 64, + ]); +}); + +it('says who a flattened reply answers, and draws it no lines of its own', function () { + $rows = deepRows(); + + expect($rows['thread-reply-r3']['replyingTo'])->toBeNull() + ->and($rows['thread-reply-r3']['links'])->toBeTrue() + ->and($rows['thread-reply-r4']['replyingTo'])->toBe('quoting @alan') + ->and($rows['thread-reply-r5']['replyingTo'])->toBe('replying to @edsger') + ->and($rows['thread-reply-r4']['links'])->toBeFalse() + ->and($rows['thread-reply-r4']['hasNext'])->toBeFalse() + ->and($rows['thread-more-r4']['links'])->toBeFalse() + ->and($rows['thread-more-r4']['to'])->toBe('@edsger'); +}); + +it('hangs each reply at the deepest step on its own elbow, with the line of the reply it answers running on past', function () { + $rows = deepRows(); + $lane = $rows['thread-reply-r3b']['lane']; + + // r3 and r3b both answer r2, so both hang on elbows off r2's line, which runs past r3's own replies to r3b. + expect($rows['thread-reply-r3']['previousLane'])->toBeNull() + ->and($rows['thread-reply-r3b']['previousLane'])->toBeNull() + ->and($rows['thread-reply-r3']['hasNext'])->toBeFalse() + ->and($rows['thread-reply-r3']['spines'])->toBe([['left' => 107.5, 'lane' => $lane, 'top' => 22]]) + ->and($rows['thread-reply-r4']['spines'])->toBe([['left' => 107.5, 'lane' => $lane]]) + ->and($rows['thread-more-r4']['spines'])->toBe([['left' => 107.5, 'lane' => $lane]]) + ->and($rows['thread-reply-r3b']['spines'])->toBe([]) + // Above that the replies chain from avatar to avatar as before. + ->and($rows['thread-reply-r2']['hasNext'])->toBeTrue() + ->and($rows['thread-reply-r3b']['last'])->toBeTrue(); +}); + +it('opens replies in place as deep as the caller allows', function () { + $inPlace = fn (array $rows): array => array_map(fn (array $row): bool => $row['repliesInPlace'], array_filter($rows, fn (array $row): bool => isset($row['repliesInPlace']))); + + expect($inPlace(deepRows()))->each->toBeTrue() + ->and($inPlace(deepRows(opensInPlace: 1))) + ->toBe(['thread-reply-r1' => true, 'thread-reply-r2' => false, 'thread-reply-r3' => false, 'thread-reply-r4' => false, 'thread-reply-r5' => false, 'thread-reply-r3b' => false]); +}); diff --git a/tests/Unit/Devnull/TimelineTest.php b/tests/Unit/Devnull/TimelineTest.php index b21edb2a..c68a082b 100644 --- a/tests/Unit/Devnull/TimelineTest.php +++ b/tests/Unit/Devnull/TimelineTest.php @@ -3,6 +3,7 @@ use App\Devnull\Data\Commit; use App\Devnull\Data\TimelineRow; use App\Devnull\LastVisit; +use App\Devnull\Ownership; use App\Devnull\Timeline; use Carbon\CarbonImmutable; @@ -166,14 +167,18 @@ function describeRows(array $rows): array timelineCommit('c1', 'grace', '2026-10-15T09:00:00Z'), ]; - expect(LastVisit::firstSeenId($commits, '2026-10-15T10:00:00+00:00', 'ada'))->toBe('c2') - ->and(LastVisit::firstSeenId($commits, '2026-10-15T09:30:00+00:00', 'ada'))->toBe('c1') + $ada = new Ownership('ada'); + + expect(LastVisit::firstSeenId($commits, '2026-10-15T10:00:00+00:00', $ada))->toBe('c2') + ->and(LastVisit::firstSeenId($commits, '2026-10-15T09:30:00+00:00', $ada))->toBe('c1') // Nothing new. - ->and(LastVisit::firstSeenId($commits, '2026-10-15T11:00:00+00:00', 'ada'))->toBeNull() + ->and(LastVisit::firstSeenId($commits, '2026-10-15T11:00:00+00:00', $ada))->toBeNull() // Only your own commit is new. - ->and(LastVisit::firstSeenId($commits, '2026-10-15T10:00:00+00:00', 'grace'))->toBeNull() + ->and(LastVisit::firstSeenId($commits, '2026-10-15T10:00:00+00:00', new Ownership('grace')))->toBeNull() + // Only a commit from an organization you're in is new, as the web counts it. + ->and(LastVisit::firstSeenId($commits, '2026-10-15T10:00:00+00:00', new Ownership('linus', ['grace'])))->toBeNull() // Everything is new, so there's nothing to mark. - ->and(LastVisit::firstSeenId($commits, '2026-10-15T08:00:00+00:00', 'ada'))->toBeNull() + ->and(LastVisit::firstSeenId($commits, '2026-10-15T08:00:00+00:00', $ada))->toBeNull() // A first visit. - ->and(LastVisit::firstSeenId($commits, null, 'ada'))->toBeNull(); + ->and(LastVisit::firstSeenId($commits, null, $ada))->toBeNull(); });