From f6c54e27e789c786b15d633fe993d03450d02d65 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Mon, 16 Nov 2026 02:00:07 +0000 Subject: [PATCH 1/4] Move the commit reply bar onto the Remotes composer box The reply bar is now the same rounded box as the Remotes composer: the field across the top, and under it the expand button on the left and a round send button in your colour on the right. The bar is Liquid Glass on iOS and the solid surface on Android. The text Reply button is gone. The expand button no longer opens the composer sheet. Presenting a sheet takes the keyboard down and puts it back up on both platforms, however early its field asks for focus, so the box grows in place instead (8 lines, up to 12) and the keyboard stays where it is. Grown, the box gets a photos and preview button that opens the sheet as before. Photos attached there show as a count in the box. A restored draft's stash@{0} and drop sit under the box, since the grown row has no room for them. A reply long enough to be folded in feeds now says "folded in feeds" in small muted text, here and in the sheet. The FoldVertical icon read as a button that did nothing, so it's gone. Related commits start closed under a header with their count. Tapping it fades them in one after another and turns the chevron; tapping again fades them out, then takes them out. It uses the Beat task from the Log threads work (PR 179), copied as is so the two branches merge cleanly. The old composer-plate partial had no users left, so it's deleted. Co-Authored-By: Claude Opus 5.5 --- app/Devnull/Beat.php | 34 +++++ app/Devnull/Display.php | 40 +++--- app/Icons/Lucide.php | 4 +- app/NativeComponents/CommitDetail.php | 91 ++++++++++++- resources/icons/fold-vertical.svg | 1 - resources/icons/minimize-2.svg | 1 + .../views/native/commit-detail.blade.php | 85 ++++++------ .../native/partials/body-counter.blade.php | 15 +-- .../native/partials/composer-plate.blade.php | 24 ---- .../native/partials/composer-tool.blade.php | 11 +- .../native/partials/related-commits.blade.php | 50 ++++--- .../native/partials/reply-field.blade.php | 12 +- tests/Feature/Screens/CommitDetailTest.php | 124 +++++++++++++----- tests/Feature/Screens/ComposerPhotosTest.php | 12 +- tests/Feature/Screens/DraftStashTest.php | 5 +- tests/Feature/Screens/LaneButtonsTest.php | 29 ++-- tests/Feature/Screens/RelatedCommitsTest.php | 119 +++++++++++++++-- 17 files changed, 482 insertions(+), 175 deletions(-) create mode 100644 app/Devnull/Beat.php delete mode 100644 resources/icons/fold-vertical.svg create mode 100644 resources/icons/minimize-2.svg delete mode 100644 resources/views/native/partials/composer-plate.blade.php diff --git a/app/Devnull/Beat.php b/app/Devnull/Beat.php new file mode 100644 index 00000000..c6598cfe --- /dev/null +++ b/app/Devnull/Beat.php @@ -0,0 +1,34 @@ +runningUnitTests()) { + usleep(max(0, $milliseconds) * 1000); + } + + return true; + } +} diff --git a/app/Devnull/Display.php b/app/Devnull/Display.php index d8da90be..fbe4a1bd 100644 --- a/app/Devnull/Display.php +++ b/app/Devnull/Display.php @@ -12,19 +12,22 @@ 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 reply box on a commit's page grown by its expand button: it starts this many lines tall, and grows to + * ExpandedReplyMaxLines. + */ + public const int ExpandedReplyMinLines = 8; + + public const int ExpandedReplyMaxLines = 12; /** - * The row under the reply bar's field that marks a restored draft (see partials/stash-label) and counts its photos. + * The row under the reply box that marks a restored draft (see partials/stash-label). */ public const int ReplyBarStashLabelHeight = 28; @@ -35,8 +38,7 @@ final class Display public const int ComposerBoxBarHeight = 97; /** - * About how many characters fit on a line of the box's field. It runs the width of the box, so more fit than - * beside the reply bar's tools and button. + * 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; @@ -228,16 +230,22 @@ 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). + * 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. Grown by its + * expand button ($expanded), the box is ExpandedReplyMinLines tall to + * start with. A restored draft adds the row under the box that marks it + * ($restored), and a link too long for devnull the line that says so. */ - public static function replyBarClearance(string $draft, bool $draftRow = false): int + public static function replyBarClearance(string $draft, bool $expanded = false, bool $restored = false): int { - return self::ReplyBarHeight - + (min(self::ReplyBarMaxLines, self::lineCount($draft, self::ReplyBarCharactersPerLine)) - 1) * self::ReplyBarLineHeight - + ($draftRow ? self::ReplyBarStashLabelHeight : 0) + $lines = $expanded + ? max(self::ExpandedReplyMinLines, min(self::ExpandedReplyMaxLines, self::lineCount($draft, self::ComposerBoxCharactersPerLine))) + : null; + + return self::ComposerBoxBarHeight + + ($lines === null ? self::composerBoxGrowth($draft) : ($lines - 1) * self::ReplyBarLineHeight) + + ($restored ? self::ReplyBarStashLabelHeight : 0) + (CommitBody::hasOversizedUrl($draft) ? 3 * self::ReplyBarLineHeight : 0) + self::HomeIndicatorHeight; } diff --git a/app/Icons/Lucide.php b/app/Icons/Lucide.php index b6ea5bb9..b6e5c0e1 100644 --- a/app/Icons/Lucide.php +++ b/app/Icons/Lucide.php @@ -49,7 +49,6 @@ enum Lucide case UserPlus; case UserCheck; case AtSign; - case FoldVertical; case Award; case Ellipsis; case Flag; @@ -75,6 +74,7 @@ enum Lucide case EyeOff; case Plus; case Maximize2; + case Minimize2; case Vibrate; // The achievement badges, named as devnull names their icons (see forBadge()). @@ -189,7 +189,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', @@ -216,6 +215,7 @@ public function custom(bool $filled = false): string self::EyeOff => 'eye-off', self::Plus => 'plus', self::Maximize2 => 'maximize-2', + self::Minimize2 => 'minimize-2', self::Vibrate => 'vibrate', self::Terminal => 'terminal', self::FileCode => 'file-code', diff --git a/app/NativeComponents/CommitDetail.php b/app/NativeComponents/CommitDetail.php index f20c88a3..0647820f 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; @@ -50,11 +51,18 @@ * leaving the page keeps it, and it's in the reply bar again, marked as * restored, when you come back to the commit. * - * 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 reply bar's expand button gives the reply more room where it is: the + * box grows taller over the page, with the same field in it, so the keyboard + * stays up (see toggleReplyExpanded()). A sheet can't do that: presenting + * one takes the keyboard down and puts it back up on both platforms, however + * soon its field takes focus. Grown, the box has the photos and preview + * button, which opens the reply in the composer sheet (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. + * Photos left in it show as a count in the box, 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 @@ -101,6 +109,36 @@ class CommitDetail extends NativeComponent */ public array $related = []; + /** + * Whether the reply box has grown to give the reply more room. + */ + public bool $replyExpanded = false; + + /** + * 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 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. */ @@ -278,6 +316,50 @@ public function toggleReplies(): void $this->repliesShown = ! $this->repliesShown; } + /** + * The expand button in the reply box: the box grows taller where it is, + * the same field in it, so the keyboard stays where it was, and again it + * shrinks back. + */ + public function toggleReplyExpanded(): void + { + $this->replyExpanded = ! $this->replyExpanded; + } + + /** + * 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); + } + /** * A deleted reply has no page of its own, so its replies open in place below it. */ @@ -357,6 +439,7 @@ public function sendReply(): void $this->reply = ''; $this->replyImages = []; + $this->replyExpanded = false; $this->forgetMention('reply'); $this->updatedReply(); $this->repliesShown = true; 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/minimize-2.svg b/resources/icons/minimize-2.svg new file mode 100644 index 00000000..f3cb0e4b --- /dev/null +++ b/resources/icons/minimize-2.svg @@ -0,0 +1 @@ + diff --git a/resources/views/native/commit-detail.blade.php b/resources/views/native/commit-detail.blade.php index c633a3d0..54930e8e 100644 --- a/resources/views/native/commit-detail.blade.php +++ b/resources/views/native/commit-detail.blade.php @@ -108,68 +108,73 @@ Display::replyBarClearance): the last reply and its actions end above the bar, keyboard up or down. --}} @if ($commit) - + @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: one rounded box with 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). The + bar is Liquid Glass tinted with the surface on iOS, so the thread scrolling under it blurs, and the solid + surface with a hairline on Android. native:bottom-bar takes no classes of its own, so the bar is painted + from this column. - 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. + The expand button grows the box where it is, the same field in it, so the keyboard stays up, and shrinks + it back. A sheet can't take the reply over with the keyboard up: presenting one takes the keyboard down + and back up on both platforms. Grown, the box also has the button for photos and a preview, which opens + the reply in the composer sheet, and once the sheet has put photos on the draft, their count opens the + sheet on them. Beside the send button, how long the reply is. A reply that came back when you returned to + the commit has the web's stash@{0} and drop under the box, on a row of its own, since the box's row has no + room left for it once it has grown. --}} - + {{-- - 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 keep a slot above the box, empty and 0.1pt tall when there's no one, so the + box'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($photoCount = $replyImages === [] ? null : \App\Devnull\Display::count(count($replyImages), 'photo', 'photos')) + @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}')"]], + 'tools' => [ + $replyExpanded + ? ['ref' => 'reply-expand', 'icon' => \App\Icons\Lucide::Minimize2, 'label' => 'Give the reply less room', 'press' => 'toggleReplyExpanded'] + : ['ref' => 'reply-expand', 'icon' => \App\Icons\Lucide::Maximize2, 'label' => 'Give the reply more room', 'press' => 'toggleReplyExpanded'], + ...($replyExpanded ? [ + ['ref' => 'reply-attach', 'icon' => \App\Icons\Lucide::ImagePlus, 'label' => 'Reply with photos or a preview', 'press' => "replyInSheet('{$commit->id}')"], + ] : []), + ...($photoCount === null ? [] : [ + ['ref' => 'reply-photos', 'icon' => \App\Icons\Lucide::ImagePlus, 'text' => $photoCount, 'label' => $photoCount.' attached', 'hint' => 'Opens the reply with its photos', 'press' => "replyInSheet('{$commit->id}')"], + ]), + ], + 'counter' => ['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), + ], ]) - @include('native.partials.body-counter', ['body' => $reply, 'ref' => 'reply-budget']) - Reply + @if ($replyRestored) + + @include('native.partials.stash-label', ['ref' => 'reply-stash', 'drop' => 'dropReplyStash', 'size' => 'text-xs']) + + @endif @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 @endif diff --git a/resources/views/native/partials/body-counter.blade.php b/resources/views/native/partials/body-counter.blade.php index 6bdd9736..86f4db9f 100644 --- a/resources/views/native/partials/body-counter.blade.php +++ b/resources/views/native/partials/body-counter.blade.php @@ -1,21 +1,14 @@ {{-- 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 says so. - - The composer sheet and the reply bar show the fold icon. In partials/composer-box ($foldHint), where the row has - room for words, it says "folded in feeds" in small muted text instead: people read the icon alone as a button they - couldn't work out, and text that isn't a button can't be mistaken for one. + from 20 and Rm Red at none. Before that, a body long enough to be folded in lists says "folded in feeds" in small + muted text. It used to be the FoldVertical icon, which people read as a button they couldn't work out, and text + that isn't a button can't be mistaken for one. --}} -@php($foldHint ??= false) @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) @php($foldExplained = 'Feeds show the first '.\App\Devnull\Data\Commit::PreviewLength.' characters or '.\App\Devnull\Data\Commit::PreviewLines.' lines, then Show more.') @if ($isCounting) {{ $remaining }} @elseif (\App\Devnull\Data\Commit::isFoldedInLists($body)) - @if ($foldHint) - folded in feeds - @else - - @endif + folded in feeds @endif 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-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/related-commits.blade.php b/resources/views/native/partials/related-commits.blade.php index a7398456..452eaedf 100644 --- a/resources/views/native/partials/related-commits.blade.php +++ b/resources/views/native/partials/related-commits.blade.php @@ -1,19 +1,35 @@ -{{-- 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, + ]) + + @endforeach + @endif diff --git a/resources/views/native/partials/reply-field.blade.php b/resources/views/native/partials/reply-field.blade.php index 04f37457..6400973d 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 expand button is in the row under it, so pressing it 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. The expand button grows it to + Display::ExpandedReplyMinLines tall: the same field, only taller, so the keyboard doesn't move. --}} - + diff --git a/tests/Feature/Screens/CommitDetailTest.php b/tests/Feature/Screens/CommitDetailTest.php index fc0da284..9716ce8c 100644 --- a/tests/Feature/Screens/CommitDetailTest.php +++ b/tests/Feature/Screens/CommitDetailTest.php @@ -105,17 +105,88 @@ 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 as one box, the field over the expand button 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($actions[0])->toBe('reply-expand') + ->and(end($actions))->toBe('send-reply') + ->and(nodeByRef($screen, 'send-reply')['props']['a11y_label'] ?? nodeByRef($screen, 'send-reply')['a11y_label'] ?? null)->toBe('Reply') + ->and(canSend($screen, 'send-reply'))->toBeFalse(); + + $screen->input('reply-input', 'Ready'); + + expect(canSend($screen, 'send-reply'))->toBeTrue(); +})->with(['ios', 'android']); + +it('grows the reply box where it is for more room, keeping the same field so the keyboard stays up', function (string $platform) { + fakeThread(); + + $screen = Native::visit('/log/commits/c2', platform: $platform)->input('reply-input', 'A long one'); + $field = idsDownTo($screen->tree(), 'reply-input'); + $clearance = nodeByRef($screen, 'reply-bar-clearance')['layout']['height']; + + expect(nodeByRef($screen, 'reply-input')['props']['max_lines'])->toBe(5) + ->and(rendersRef($screen, 'reply-attach'))->toBeFalse(); + + $screen->tap('reply-expand'); + + expect(idsDownTo($screen->tree(), 'reply-input'))->toBe($field) + ->and(nodeByRef($screen, 'reply-input')['props']['min_lines'])->toBe(8) + ->and(nodeByRef($screen, 'reply-input')['props']['max_lines'])->toBe(12) + ->and(nodeByRef($screen, 'reply-expand')['props']['a11y_label'] ?? null)->toBe('Give the reply less room') + ->and(childRefs($screen, 'reply-actions')[1])->toBe('reply-attach') + ->and(nodeByRef($screen, 'sheet')['props']['visible'] ?? false)->toBeFalse() + ->and(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual($clearance + 7 * 21); + + // Photos and a preview are a tap further, in the composer sheet, with the draft. + $screen->tap('reply-attach'); + + expect(nodeByRef($screen, 'sheet')['props']['visible'])->toBeTrue() + ->and($screen->instance()->sheetBody)->toBe('A long one'); + + $screen->dismissSheet('sheet')->tap('reply-expand'); + + expect(idsDownTo($screen->tree(), 'reply-input'))->toBe($field) + ->and(nodeByRef($screen, 'reply-input')['props']['max_lines'])->toBe(5) + ->and(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual($clearance); +})->with(['ios', 'android']); + +it('shrinks the grown reply box back once the reply is sent', function () { + fakeThread(extra: ['POST /api/v1/commits' => [['data' => replyJson(['id' => 'r9', 'parent_id' => 'c2', 'body' => 'Sent'])], 201]]); + + $screen = Native::visit('/log/commits/c2')->tap('reply-expand')->input('reply-input', 'Sent')->tap('send-reply'); + + expect($screen->instance()->replyExpanded)->toBeFalse() + ->and(nodeByRef($screen, 'reply-input')['props']['max_lines'])->toBe(5); +}); + +it('says a reply long enough to be folded in feeds is, in words beside Reply and in the sheet, rather than an icon', function () { + fakeThread(); + + $screen = Native::visit('/log/commits/c2')->input('reply-input', 'Short'); + + expect(rendersRef($screen, 'reply-budget-fold'))->toBeFalse(); + + $screen->input('reply-input', str_repeat('a', 281)); + $hint = nodeByRef($screen, 'reply-budget-fold'); + + expect($hint['type'])->toBe('text') + ->and($hint['props']['text'])->toBe('folded in feeds') + ->and($hint['props']['a11y_label'] ?? $hint['a11y_label'] ?? null)->toBe('Feeds show the first 280 characters or 8 lines, then Show more.') + ->and(array_slice(childRefs($screen, 'reply-actions'), -2))->toBe(['reply-budget-fold', 'send-reply']) + ->and(findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'icon' && ($node['ref'] ?? null) === 'reply-budget-fold'))->toBeNull(); + + $screen->tap('reply-expand')->tap('reply-attach'); + + expect(nodeByRef($screen, 'sheet-budget-fold')['type'])->toBe('text') + ->and(nodeByRef($screen, 'sheet-budget-fold')['props']['text'])->toBe('folded in feeds'); +}); 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]); @@ -320,7 +391,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' @@ -333,7 +404,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', ''); @@ -344,7 +415,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'); }); @@ -766,29 +837,20 @@ 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 Liquid Glass tinted with the surface on iOS, and on the solid surface on Android', function () { fakeThread(); - $screen = Native::visit('/log/commits/c2', platform: 'android'); - $bar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); + $ios = Native::visit('/log/commits/c2', platform: 'ios'); + $android = Native::visit('/log/commits/c2', platform: 'android'); + $bar = findNode($android->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); - expect($bar['children'][0]['ref'] ?? null)->toBe('reply-bar') + expect(nodeByRef($ios, 'reply-bar')['props']['glass'] ?? null)->toBe(1) + ->and(nodeByRef($ios, 'reply-bar')['style']['bg_color'] ?? null)->not->toBeNull() + ->and($bar['children'][0]['ref'] ?? null)->toBe('reply-bar') + ->and($bar['children'][0]['props']['glass'] ?? null)->toBeNull() ->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(); -}); - -it('leaves the reply bar bare on iOS and floats the field on Liquid Glass', function () { - fakeThread(); - - $screen = Native::visit('/log/commits/c2', platform: 'ios'); - $bar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); - - 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); + ->and($bar['children'][0]['children'][0]['style']['bg_color'] ?? null)->toBe(config('native-ui.theme.light.hairline')); }); it('ends the page above the reply bar, and further as the draft grows', function () { @@ -800,13 +862,13 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): // The clearance is the last thing on the page, under the last reply: the bar's line and the home indicator. expect(end($page)['ref'] ?? null)->toBe('reply-bar-clearance') - ->and(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual(24 + 53 + 34); + ->and(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual(24 + 97 + 34); $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(24 + 97 + 2 * 21 + 34); $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(24 + 97 + 4 * 21 + 34); }); diff --git a/tests/Feature/Screens/ComposerPhotosTest.php b/tests/Feature/Screens/ComposerPhotosTest.php index 9338fce8..81d2bd8a 100644 --- a/tests/Feature/Screens/ComposerPhotosTest.php +++ b/tests/Feature/Screens/ComposerPhotosTest.php @@ -237,7 +237,7 @@ function isTool(TestableComponent $screen, string $ref): bool $screen = Native::visit('/log/commits/c2') ->input('reply-input', 'Here it') - ->tap('reply-expand') + ->tap('reply-expand')->tap('reply-attach') ->assertSee('Reply to @ada'); expect(nodeByRef($screen, 'sheet-body')['props'])->toMatchArray(['value' => 'Here it', 'placeholder' => 'Reply to @ada']) @@ -267,7 +267,7 @@ function isTool(TestableComponent $screen, string $ref): bool $screen = Native::visit('/log/commits/c2') ->input('reply-input', 'Half') - ->tap('reply-expand') + ->tap('reply-expand')->tap('reply-attach') ->input('sheet-body', 'Half a reply') ->dismissSheet('sheet'); @@ -284,12 +284,14 @@ function isTool(TestableComponent $screen, string $ref): bool 'POST /api/v1/commits' => [['data' => replyJson(['id' => 'r9', 'parent_id' => 'c2', 'body' => 'Look'])], 201], ]); - $screen = photosPicked(Native::visit('/log/commits/c2')->input('reply-input', 'Look')->tap('reply-expand'), [testPhoto()]) + $screen = photosPicked(Native::visit('/log/commits/c2')->input('reply-input', 'Look')->tap('reply-expand')->tap('reply-attach'), [testPhoto()]) ->dismissSheet('sheet'); $path = $screen->instance()->replyImages[0]->path; expect(treeShows(nodeByRef($screen, 'reply-photos'), '1 photo'))->toBeTrue() - ->and(nodeByRef($screen, 'reply-photos')['props']['a11y_label'] ?? null)->toBe('1 photo attached'); + ->and(nodeByRef($screen, 'reply-photos')['props']['a11y_label'] ?? null)->toBe('1 photo attached') + // In the box, after its other tools. + ->and(array_slice(childRefs($screen, 'reply-actions'), 0, 3))->toBe(['reply-expand', 'reply-attach', 'reply-photos']); // Coming back to the commit, the bar has them still. $screen = Native::visit('/log/commits/c2'); @@ -322,7 +324,7 @@ function isTool(TestableComponent $screen, string $ref): bool 'GET /api/v1/commits/c2/replies' => [pageJson([])], ]); - $screen = photosPicked(Native::visit('/log/commits/c2', platform: 'android')->input('reply-input', 'Half')->tap('reply-expand'), [testPhoto()]) + $screen = photosPicked(Native::visit('/log/commits/c2', platform: 'android')->input('reply-input', 'Half')->tap('reply-expand')->tap('reply-attach'), [testPhoto()]) ->input('sheet-body', 'Half a reply') ->tap('sheet-cancel') ->input('reply-input', 'Half a reply, and more'); diff --git a/tests/Feature/Screens/DraftStashTest.php b/tests/Feature/Screens/DraftStashTest.php index 46baedf4..139954a7 100644 --- a/tests/Feature/Screens/DraftStashTest.php +++ b/tests/Feature/Screens/DraftStashTest.php @@ -206,8 +206,9 @@ function stashLabel(TestableComponent $screen, string $ref): array 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(canSend($screen, 'send-reply'))->toBeTrue() + // It's marked on a row under the box, and the page ends above that too. + ->and(childRefs($screen, 'reply-stash-row'))->toBe(['reply-stash']) ->and(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual($clearance + Display::ReplyBarStashLabelHeight); }); diff --git a/tests/Feature/Screens/LaneButtonsTest.php b/tests/Feature/Screens/LaneButtonsTest.php index 3e966d04..40689705 100644 --- a/tests/Feature/Screens/LaneButtonsTest.php +++ b/tests/Feature/Screens/LaneButtonsTest.php @@ -72,14 +72,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()])]]); @@ -115,6 +107,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/RelatedCommitsTest.php b/tests/Feature/Screens/RelatedCommitsTest.php index a6265735..9e8f15b6 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') @@ -43,7 +86,8 @@ function serveRelatedThread(array $related = [], array $extra = []): void ->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']) + ->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,67 @@ 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('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(); +}); From a5d112cd2d80a03502def696c5aa6adef3f173b6 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Wed, 18 Nov 2026 00:34:38 +0000 Subject: [PATCH 2/4] Reply with photos and a preview from the bar, and drop any time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The reply bar no longer has the expand button or grows in place, and it never opens the composer sheet. Its row has a photo button (a menu with the library and the camera) and Preview. Photos show above the field with their ✕ and ALT, go in the reply's stash, and send with it. Preview shows the reply as it will look in the field's place, with the body devnull keeps, and pressed again brings the field back with the keyboard. The field grows with the reply to five lines and then scrolls. Nothing in PHP changes its line limits any more. Drop shows beside Reply as soon as the reply has anything in it, so a draft can be thrown away at any time. stash@{0} still marks a draft that came back from the stash. Both moved into the row, so the bar no longer gets taller for them. The page fades out above the bar, as Remotes does, from the stack now around its scroll view. composer-preview takes its draft as parameters so the sheet and the bar share it. The expand icons are gone. Co-Authored-By: Claude Opus 5.5 --- app/Devnull/ComposerMenu.php | 14 ++ app/Devnull/Display.php | 40 +++-- app/Icons/Lucide.php | 4 - app/NativeComponents/CommitDetail.php | 128 +++++++++++++--- resources/icons/maximize-2.svg | 1 - resources/icons/minimize-2.svg | 1 - .../views/native/commit-detail.blade.php | 82 ++++++----- .../native/partials/commit-sheet.blade.php | 10 +- .../partials/composer-preview.blade.php | 20 ++- .../native/partials/reply-field.blade.php | 9 +- .../native/partials/reply-preview.blade.php | 19 +++ .../native/partials/stash-label.blade.php | 10 +- tests/Feature/Screens/CommitDetailTest.php | 116 +++++++++------ tests/Feature/Screens/ComposerPhotosTest.php | 139 +++++++++--------- tests/Feature/Screens/DraftStashTest.php | 10 +- 15 files changed, 383 insertions(+), 220 deletions(-) delete mode 100644 resources/icons/maximize-2.svg delete mode 100644 resources/icons/minimize-2.svg create mode 100644 resources/views/native/partials/reply-preview.blade.php 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/Display.php b/app/Devnull/Display.php index 2c3515d9..42b339ef 100644 --- a/app/Devnull/Display.php +++ b/app/Devnull/Display.php @@ -19,17 +19,12 @@ final class Display public const int ReplyBarMaxLines = 5; /** - * The reply box on a commit's page grown by its expand button: it starts this many lines tall, and grows to - * ExpandedReplyMaxLines. + * 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 ExpandedReplyMinLines = 8; + public const int ReplyBarPhotosHeight = 88; - public const int ExpandedReplyMaxLines = 12; - - /** - * The row under the reply box that marks a restored draft (see partials/stash-label). - */ - public const int ReplyBarStashLabelHeight = 28; + public const int ReplyBarDescriptionHeight = 100; /** * A bar holding partials/composer-box with one line of draft, as drawn on an iPhone: the bar's padding, then the @@ -235,22 +230,21 @@ 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 (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. Grown by its - * expand button ($expanded), the box is ExpandedReplyMinLines tall to - * start with. A restored draft adds the row under the box that marks it - * ($restored), and a link too long for devnull the line that says so. + * 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 $expanded = false, bool $restored = false): int + public static function replyBarClearance(string $draft, bool $hasPhotos = false, bool $describing = false): int { - $lines = $expanded - ? max(self::ExpandedReplyMinLines, min(self::ExpandedReplyMaxLines, self::lineCount($draft, self::ComposerBoxCharactersPerLine))) - : null; - - return self::ComposerBoxBarHeight - + ($lines === null ? self::composerBoxGrowth($draft) : ($lines - 1) * self::ReplyBarLineHeight) - + ($restored ? 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; } diff --git a/app/Icons/Lucide.php b/app/Icons/Lucide.php index b6e5c0e1..3df5fa55 100644 --- a/app/Icons/Lucide.php +++ b/app/Icons/Lucide.php @@ -73,8 +73,6 @@ enum Lucide case Eye; case EyeOff; case Plus; - case Maximize2; - case Minimize2; case Vibrate; // The achievement badges, named as devnull names their icons (see forBadge()). @@ -214,8 +212,6 @@ public function custom(bool $filled = false): string self::Eye => 'eye', self::EyeOff => 'eye-off', self::Plus => 'plus', - self::Maximize2 => 'maximize-2', - self::Minimize2 => 'minimize-2', self::Vibrate => 'vibrate', self::Terminal => 'terminal', self::FileCode => 'file-code', diff --git a/app/NativeComponents/CommitDetail.php b/app/NativeComponents/CommitDetail.php index 0647820f..169606fd 100644 --- a/app/NativeComponents/CommitDetail.php +++ b/app/NativeComponents/CommitDetail.php @@ -18,10 +18,12 @@ use App\Devnull\RowCache; use App\Devnull\Stash; use App\Devnull\Timeline; +use App\Devnull\Toasts; use App\Icons\Lucide; use App\Models\PendingWrite; 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; @@ -49,17 +51,16 @@ * * 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's expand button gives the reply more room where it is: the - * box grows taller over the page, with the same field in it, so the keyboard - * stays up (see toggleReplyExpanded()). A sheet can't do that: presenting - * one takes the keyboard down and puts it back up on both platforms, however - * soon its field takes focus. Grown, the box has the photos and preview - * button, which opens the reply in the composer sheet (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 in the box, which opens the sheet on - * them, and Reply in the bar sends them with the text. + * 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. * * Related commits wait under a header with their count, closed, and open * in place when it's tapped (see toggleRelated()). @@ -75,11 +76,16 @@ class CommitDetail extends NativeComponent { use OpensInTab; use OpensLiveStream; + use RedrawsOnAppearanceChange; use RefreshesInBackground; use ShowsCommits { 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; @@ -110,9 +116,16 @@ class CommitDetail extends NativeComponent public array $related = []; /** - * Whether the reply box has grown to give the reply more room. + * Whether the reply bar shows the reply as it will look, in the field's place. */ - public bool $replyExpanded = false; + public bool $replyPreviewing = false; + + /** + * What devnull sent back for the reply's body, with the body it was for under `draft`. + * + * @var array|null + */ + public ?array $replyPreview = null; /** * Whether the related commits show under their header. @@ -317,13 +330,34 @@ public function toggleReplies(): void } /** - * The expand button in the reply box: the box grows taller where it is, - * the same field in it, so the keyboard stays where it was, and again it - * shrinks back. + * 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 toggleReplyExpanded(): void + public function toggleReplyPreview(): void { - $this->replyExpanded = ! $this->replyExpanded; + $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); } /** @@ -439,7 +473,8 @@ public function sendReply(): void $this->reply = ''; $this->replyImages = []; - $this->replyExpanded = false; + $this->replyPreviewing = false; + $this->replyPreview = null; $this->forgetMention('reply'); $this->updatedReply(); $this->repliesShown = true; @@ -473,13 +508,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(); } @@ -552,6 +591,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. */ 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/icons/minimize-2.svg b/resources/icons/minimize-2.svg deleted file mode 100644 index f3cb0e4b..00000000 --- a/resources/icons/minimize-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 fd724368..6469c124 100644 --- a/resources/views/native/commit-detail.blade.php +++ b/resources/views/native/commit-detail.blade.php @@ -5,7 +5,9 @@ @include('native.partials.live-stream-sheet') @include('native.partials.stargazers-sheet') - + {{-- The stack around the page holds the fade over its foot, just above the reply bar (see partials/composer-fade). --}} + + @if (! $commit && $error === null) @@ -105,60 +107,69 @@ {{-- 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 bar, keyboard up or down. + Display::replyBarClearance): the last reply and its actions end above the fade and the bar, keyboard + up or down. --}} @if ($commit) - + @endif + @if ($commit) + @include('native.partials.composer-fade', ['ref' => 'reply-fade']) + @endif + + @if ($commit) {{-- - The reply bar, drawn as the Remotes composer is: one rounded box with 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). The - bar is Liquid Glass tinted with the surface on iOS, so the thread scrolling under it blurs, and the solid - surface with a hairline on Android. native:bottom-bar takes no classes of its own, so the bar is painted - from this column. + 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), straight on the + surface, with the page fading out above it. native:bottom-bar takes no classes of its own, so the bar is + painted from this column, which also 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 grows the box where it is, the same field in it, so the keyboard stays up, and shrinks - it back. A sheet can't take the reply over with the keyboard up: presenting one takes the keyboard down - and back up on both platforms. Grown, the box also has the button for photos and a preview, which opens - the reply in the composer sheet, and once the sheet has put photos on the draft, their count opens the - sheet on them. Beside the send button, how long the reply is. A reply that came back when you returned to - the commit has the web's stash@{0} and drop under the box, on a row of its own, since the box's row has no - room left for it once it has grown. + A "post as" avatar, for people in a GitHub organization, goes at the start of the row as composer-box's + $lead. --}} - - + {{-- - The people to mention keep a slot above the box, empty and 0.1pt tall when there's no one, so the - box'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. + 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']) + @php($showsPhotos = $replyImages !== [] && ! $replyPreviewing) + + @if ($showsPhotos) + @include('native.partials.composer-photos', ['photos' => $replyImages, 'photoRef' => 'reply-photo']) + @endif + - @php($photoCount = $replyImages === [] ? null : \App\Devnull\Display::count(count($replyImages), 'photo', 'photos')) + @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', + 'field' => $replyPreviewing ? 'native.partials.reply-preview' : 'native.partials.reply-field', 'tools' => [ - $replyExpanded - ? ['ref' => 'reply-expand', 'icon' => \App\Icons\Lucide::Minimize2, 'label' => 'Give the reply less room', 'press' => 'toggleReplyExpanded'] - : ['ref' => 'reply-expand', 'icon' => \App\Icons\Lucide::Maximize2, 'label' => 'Give the reply more room', 'press' => 'toggleReplyExpanded'], - ...($replyExpanded ? [ - ['ref' => 'reply-attach', 'icon' => \App\Icons\Lucide::ImagePlus, 'label' => 'Reply with photos or a preview', 'press' => "replyInSheet('{$commit->id}')"], - ] : []), - ...($photoCount === null ? [] : [ - ['ref' => 'reply-photos', 'icon' => \App\Icons\Lucide::ImagePlus, 'text' => $photoCount, 'label' => $photoCount.' attached', 'hint' => 'Opens the reply with its photos', 'press' => "replyInSheet('{$commit->id}')"], - ]), + ['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']], ], - 'trail' => [['native.partials.body-counter', ['body' => $reply, 'ref' => 'reply-budget']]], 'send' => [ 'ref' => 'send-reply', 'label' => 'Reply', @@ -167,11 +178,6 @@ ], ]) - @if ($replyRestored) - - @include('native.partials.stash-label', ['ref' => 'reply-stash', 'drop' => 'dropReplyStash', 'size' => 'text-xs']) - - @endif @if (\App\Devnull\Data\CommitBody::hasOversizedUrl($reply)) Each link must not be greater than {{ \App\Devnull\Data\BodyLink::MaxLength }} characters. @endif diff --git a/resources/views/native/partials/commit-sheet.blade.php b/resources/views/native/partials/commit-sheet.blade.php index 97a5b0b1..d30a12ee 100644 --- a/resources/views/native/partials/commit-sheet.blade.php +++ b/resources/views/native/partials/commit-sheet.blade.php @@ -79,7 +79,15 @@ @endif @if ($previewing) - @include('native.partials.composer-preview') + @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 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/reply-field.blade.php b/resources/views/native/partials/reply-field.blade.php index 6400973d..1879f43a 100644 --- a/resources/views/native/partials/reply-field.blade.php +++ b/resources/views/native/partials/reply-field.blade.php @@ -1,10 +1,10 @@ {{-- 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 expand button is in the row under it, so pressing it + 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. The expand button grows it to - Display::ExpandedReplyMinLines tall: the same field, only taller, so the keyboard doesn't move. + 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/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/tests/Feature/Screens/CommitDetailTest.php b/tests/Feature/Screens/CommitDetailTest.php index 3c5ea1b3..45ef0fd2 100644 --- a/tests/Feature/Screens/CommitDetailTest.php +++ b/tests/Feature/Screens/CommitDetailTest.php @@ -107,7 +107,7 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): ->and(idsDownTo($screen->tree(), 'reply-input'))->toBe($field); }); -it('draws the reply bar as one box, the field over the expand button and a round Reply, on both platforms', function (string $platform) { +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); @@ -116,9 +116,11 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): 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($actions[0])->toBe('reply-expand') + ->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'); @@ -126,46 +128,74 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): expect(canSend($screen, 'send-reply'))->toBeTrue(); })->with(['ios', 'android']); -it('grows the reply box where it is for more room, keeping the same field so the keyboard stays up', function (string $platform) { +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 long one'); + $screen = Native::visit('/log/commits/c2', platform: $platform)->input('reply-input', 'A short one'); $field = idsDownTo($screen->tree(), 'reply-input'); - $clearance = nodeByRef($screen, 'reply-bar-clearance')['layout']['height']; - expect(nodeByRef($screen, 'reply-input')['props']['max_lines'])->toBe(5) - ->and(rendersRef($screen, 'reply-attach'))->toBeFalse(); - - $screen->tap('reply-expand'); + $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']['min_lines'])->toBe(8) - ->and(nodeByRef($screen, 'reply-input')['props']['max_lines'])->toBe(12) - ->and(nodeByRef($screen, 'reply-expand')['props']['a11y_label'] ?? null)->toBe('Give the reply less room') - ->and(childRefs($screen, 'reply-actions')[1])->toBe('reply-attach') - ->and(nodeByRef($screen, 'sheet')['props']['visible'] ?? false)->toBeFalse() - ->and(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual($clearance + 7 * 21); + ->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']); - // Photos and a preview are a tap further, in the composer sheet, with the draft. - $screen->tap('reply-attach'); +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'); - expect(nodeByRef($screen, 'sheet')['props']['visible'])->toBeTrue() - ->and($screen->instance()->sheetBody)->toBe('A long one'); + // 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(); - $screen->dismissSheet('sheet')->tap('reply-expand'); + finishRefreshes($screen); - expect(idsDownTo($screen->tree(), 'reply-input'))->toBe($field) - ->and(nodeByRef($screen, 'reply-input')['props']['max_lines'])->toBe(5) - ->and(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual($clearance); -})->with(['ios', 'android']); + expect(treeShows(nodeByRef($screen, 'reply-draft-preview'), 'Shipped 🚀 with '))->toBeTrue() + ->and(canSend($screen, 'send-reply'))->toBeTrue(); -it('shrinks the grown reply box back once the reply is sent', function () { - fakeThread(extra: ['POST /api/v1/commits' => [['data' => replyJson(['id' => 'r9', 'parent_id' => 'c2', 'body' => 'Sent'])], 201]]); + Http::assertSent(fn (Request $request): bool => str_ends_with($request->url(), '/api/v1/commits/preview') + && $request->body() === '{"body":"Shipped :rocket: with @ada"}'); - $screen = Native::visit('/log/commits/c2')->tap('reply-expand')->input('reply-input', 'Sent')->tap('send-reply'); + $screen->tap('reply-preview'); - expect($screen->instance()->replyExpanded)->toBeFalse() - ->and(nodeByRef($screen, 'reply-input')['props']['max_lines'])->toBe(5); + 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 () { @@ -835,21 +865,21 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): expect(pressFeedbackInScroller($screen))->toBe([]); }); -it('puts the reply bar on Liquid Glass tinted with the surface on iOS, and on the solid surface on Android', function () { +it('puts the reply bar on the surface with no glass or line, and fades the page out above it, on both platforms', function (string $platform) { fakeThread(); - $ios = Native::visit('/log/commits/c2', platform: 'ios'); - $android = Native::visit('/log/commits/c2', platform: 'android'); - $bar = findNode($android->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); + $screen = Native::visit('/log/commits/c2', platform: $platform); + $bar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); + $surface = strtoupper(config('native-ui.theme.light.surface')); - expect(nodeByRef($ios, 'reply-bar')['props']['glass'] ?? null)->toBe(1) - ->and(nodeByRef($ios, 'reply-bar')['style']['bg_color'] ?? null)->not->toBeNull() - ->and($bar['children'][0]['ref'] ?? null)->toBe('reply-bar') + expect($bar['children'][0]['ref'] ?? null)->toBe('reply-bar') ->and($bar['children'][0]['props']['glass'] ?? null)->toBeNull() ->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(childRefs($screen, 'reply-bar')[0])->toBe('reply-mention-slot') + ->and(childRefs($screen, 'thread-stack'))->toBe(['thread-scroll', 'reply-fade']) + ->and(str_ends_with(nodeByRef($screen, 'reply-fade')['props']['gradient_stops'] ?? '', $surface))->toBeTrue(); +})->with(['ios', 'android']); it('ends the page above the reply bar, and further as the draft grows', function () { fakeThread(replies: [replyJson(['id' => 'r1', 'parent_id' => 'c2', 'body' => 'The last reply'])]); @@ -858,15 +888,17 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): $scroller = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'scroll_view'); $page = $scroller['children'][0]['children']; - // The clearance is the last thing on the page, under the last reply: the bar's line and the home indicator. + // 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; + expect(end($page)['ref'] ?? null)->toBe('reply-bar-clearance') - ->and(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual(24 + Display::ComposerBoxBarHeight + 34); + ->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 + Display::ComposerBoxBarHeight + 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 + Display::ComposerBoxBarHeight + 4 * 21 + 34); + expect(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual($bar + 4 * 21); }); diff --git a/tests/Feature/Screens/ComposerPhotosTest.php b/tests/Feature/Screens/ComposerPhotosTest.php index 81d2bd8a..4ea4abd0 100644 --- a/tests/Feature/Screens/ComposerPhotosTest.php +++ b/tests/Feature/Screens/ComposerPhotosTest.php @@ -228,107 +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')->tap('reply-attach') - ->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')->tap('reply-attach') - ->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-bar'))->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')->tap('reply-attach'), [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') - // In the box, after its other tools. - ->and(array_slice(childRefs($screen, 'reply-actions'), 0, 3))->toBe(['reply-expand', 'reply-attach', 'reply-photos']); +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')->tap('reply-attach'), [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/DraftStashTest.php b/tests/Feature/Screens/DraftStashTest.php index 139954a7..a346e29d 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,17 +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(canSend($screen, 'send-reply'))->toBeTrue() - // It's marked on a row under the box, and the page ends above that too. - ->and(childRefs($screen, 'reply-stash-row'))->toBe(['reply-stash']) - ->and(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual($clearance + Display::ReplyBarStashLabelHeight); + // 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 () { From 07e127dcaa3601838d2279e8be8b77f51229a50f Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Wed, 18 Nov 2026 00:44:52 +0000 Subject: [PATCH 3/4] Draw the reply bar's fade in the bar on iOS, as Remotes does The page runs on under the bar on iOS, so the fade is the bar's first row there, over the reply's rows, which have the surface. On Android it stays over the foot of the page. Co-Authored-By: Claude Opus 5.5 --- .../views/native/commit-detail.blade.php | 13 ++++++++---- tests/Feature/Screens/CommitDetailTest.php | 20 ++++++++++++------- tests/Feature/Screens/ComposerPhotosTest.php | 2 +- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/resources/views/native/commit-detail.blade.php b/resources/views/native/commit-detail.blade.php index 6469c124..46adefdd 100644 --- a/resources/views/native/commit-detail.blade.php +++ b/resources/views/native/commit-detail.blade.php @@ -116,7 +116,7 @@ - @if ($commit) + @if ($commit && ! \App\Devnull\Display::fadesInBar()) @include('native.partials.composer-fade', ['ref' => 'reply-fade']) @endif @@ -125,8 +125,8 @@ {{-- 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), straight on the - surface, with the page fading out above it. native:bottom-bar takes no classes of its own, so the bar is - painted from this column, which also fills the strip under the home indicator. + surface, with the page fading out above it (see partials/composer-fade). native:bottom-bar takes no classes + of its own, so the bar is painted from this column, which also 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 @@ -139,7 +139,11 @@ $lead. --}} - + + @if (\App\Devnull\Display::fadesInBar()) + @include('native.partials.composer-fade', ['ref' => 'reply-fade', 'inBar' => true]) + @endif + {{-- 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 @@ -181,6 +185,7 @@ @if (\App\Devnull\Data\CommitBody::hasOversizedUrl($reply)) Each link must not be greater than {{ \App\Devnull\Data\BodyLink::MaxLength }} characters. @endif + @endif diff --git a/tests/Feature/Screens/CommitDetailTest.php b/tests/Feature/Screens/CommitDetailTest.php index 45ef0fd2..3a89d1ca 100644 --- a/tests/Feature/Screens/CommitDetailTest.php +++ b/tests/Feature/Screens/CommitDetailTest.php @@ -869,16 +869,22 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): fakeThread(); $screen = Native::visit('/log/commits/c2', platform: $platform); - $bar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); + $bar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar')['children'][0]; $surface = strtoupper(config('native-ui.theme.light.surface')); - expect($bar['children'][0]['ref'] ?? null)->toBe('reply-bar') - ->and($bar['children'][0]['props']['glass'] ?? null)->toBeNull() - ->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(childRefs($screen, 'reply-bar')[0])->toBe('reply-mention-slot') - ->and(childRefs($screen, 'thread-stack'))->toBe(['thread-scroll', 'reply-fade']) + // The bar's rows have the surface. The bar itself has it only on Android: iOS would paint it behind the fade. + expect($bar['ref'] ?? null)->toBe('reply-bar') + ->and($bar['props']['glass'] ?? null)->toBeNull() + ->and($bar['style']['bg_color'] ?? null)->toBe($platform === 'ios' ? null : 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(childRefs($screen, 'reply-rows')[0])->toBe('reply-mention-slot') ->and(str_ends_with(nodeByRef($screen, 'reply-fade')['props']['gradient_stops'] ?? '', $surface))->toBeTrue(); + + // On iOS the page runs on under the bar, which draws the fade. On Android the page stops at the bar, and the fade + // lies over its foot. + expect(childRefs($screen, 'reply-bar'))->toBe($platform === 'ios' ? ['reply-fade', 'reply-rows'] : ['reply-rows']) + ->and(childRefs($screen, 'thread-stack'))->toBe($platform === 'ios' ? ['thread-scroll'] : ['thread-scroll', 'reply-fade']); })->with(['ios', 'android']); it('ends the page above the reply bar, and further as the draft grows', function () { diff --git a/tests/Feature/Screens/ComposerPhotosTest.php b/tests/Feature/Screens/ComposerPhotosTest.php index 4ea4abd0..9a0fa6e1 100644 --- a/tests/Feature/Screens/ComposerPhotosTest.php +++ b/tests/Feature/Screens/ComposerPhotosTest.php @@ -252,7 +252,7 @@ function replyPage(string $platform = 'ios'): TestableComponent // 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-bar'))->toBe(['reply-mention-slot', 'reply-photos-slot', 'reply-row']) + ->and(childRefs($screen, 'reply-rows'))->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() From a529a8731f2b39ca382f6b7ee19b81ac5a643ed9 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Wed, 18 Nov 2026 02:12:22 +0000 Subject: [PATCH 4/4] Put the reply bar on Liquid Glass on iOS, as Remotes does The commit page's reply bar takes the same glass as the Remotes composer: the page shows through it blurred, the glass fades in at the top and runs on under the home indicator, and the rows tint it with the surface. It needs the same patched mobile-air. Android is unchanged. Co-Authored-By: Claude Opus 5.5 --- .../views/native/commit-detail.blade.php | 11 ++--- tests/Feature/Screens/CommitDetailTest.php | 42 ++++++++++++------- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/resources/views/native/commit-detail.blade.php b/resources/views/native/commit-detail.blade.php index 46adefdd..3667a822 100644 --- a/resources/views/native/commit-detail.blade.php +++ b/resources/views/native/commit-detail.blade.php @@ -124,9 +124,10 @@ @if ($commit) {{-- 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), straight on the - surface, with the page fading out above it (see partials/composer-fade). native:bottom-bar takes no classes - of its own, so the bar is painted from this column, which also fills the strip under the home indicator. + 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()). 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 @@ -138,12 +139,12 @@ A "post as" avatar, for people in a GitHub organization, goes at the start of the row as composer-box's $lead. --}} - + @if (\App\Devnull\Display::fadesInBar()) @include('native.partials.composer-fade', ['ref' => 'reply-fade', 'inBar' => true]) @endif - + {{-- 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 diff --git a/tests/Feature/Screens/CommitDetailTest.php b/tests/Feature/Screens/CommitDetailTest.php index 3a89d1ca..8b692e51 100644 --- a/tests/Feature/Screens/CommitDetailTest.php +++ b/tests/Feature/Screens/CommitDetailTest.php @@ -865,26 +865,40 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): expect(pressFeedbackInScroller($screen))->toBe([]); }); -it('puts the reply bar on the surface with no glass or line, and fades the page out above it, on both platforms', function (string $platform) { +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: $platform); - $bar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar')['children'][0]; - $surface = strtoupper(config('native-ui.theme.light.surface')); + $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); - // The bar's rows have the surface. The bar itself has it only on Android: iOS would paint it behind the fade. expect($bar['ref'] ?? null)->toBe('reply-bar') ->and($bar['props']['glass'] ?? null)->toBeNull() - ->and($bar['style']['bg_color'] ?? null)->toBe($platform === 'ios' ? null : 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(childRefs($screen, 'reply-rows')[0])->toBe('reply-mention-slot') - ->and(str_ends_with(nodeByRef($screen, 'reply-fade')['props']['gradient_stops'] ?? '', $surface))->toBeTrue(); - - // On iOS the page runs on under the bar, which draws the fade. On Android the page stops at the bar, and the fade - // lies over its foot. - expect(childRefs($screen, 'reply-bar'))->toBe($platform === 'ios' ? ['reply-fade', 'reply-rows'] : ['reply-rows']) - ->and(childRefs($screen, 'thread-stack'))->toBe($platform === 'ios' ? ['thread-scroll'] : ['thread-scroll', 'reply-fade']); + ->and(childRefs($screen, 'reply-rows')[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('ends the page above the reply bar, and further as the draft grows', function () {