From 5fcb78e6963727dcd7af29d5f2c56c8c619759d1 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Sat, 21 Nov 2026 03:24:55 +0000 Subject: [PATCH 01/11] Fill the composer sheet with the field, and float mentions over it The sheet's field stopped at eight lines with its own scroll bar, inside a scroll view, with empty space under it. Now nothing scrolls but the field. It gets as many lines as fit between the author row and the toolbar, less whatever sits under it: photos, the poll editor, the quoted commit or the schedule box. ComposerSheet works those heights out, since neither platform tells PHP how tall the sheet is and mobile-ui's multiline field sizes itself in lines rather than to the space it's given. The mention list is no longer in the layout. It floats over the field and the quoted commit, on Liquid Glass on iOS and a raised surface on Android, from just under the caret's line down to the toolbar, and scrolls inside. The caret's line is estimated from the text before it, wrapped at the field's width, because the field doesn't report where the caret is drawn. Each part of the sheet has a keyed slot that is always drawn, so the field keeps its id and its place among its siblings and the keyboard stays up. Co-Authored-By: Claude Opus 5.5 --- app/Devnull/ComposerSheet.php | 190 ++++++++++++++++++ .../native/partials/commit-sheet.blade.php | 162 ++++++++++----- tests/Feature/Screens/CommitMentionsTest.php | 33 +++ tests/Feature/Screens/ComposeSheetTest.php | 40 ++++ tests/Feature/Screens/ComposerPhotosTest.php | 4 +- tests/Feature/Screens/QuoteTest.php | 12 ++ tests/Unit/Devnull/ComposerSheetTest.php | 41 ++++ 7 files changed, 428 insertions(+), 54 deletions(-) create mode 100644 app/Devnull/ComposerSheet.php create mode 100644 tests/Unit/Devnull/ComposerSheetTest.php diff --git a/app/Devnull/ComposerSheet.php b/app/Devnull/ComposerSheet.php new file mode 100644 index 00000000..b3f3dc7d --- /dev/null +++ b/app/Devnull/ComposerSheet.php @@ -0,0 +1,190 @@ + $above + * @param list $below + */ + public static function fieldLines(array $above, array $below): int + { + $parts = [...array_filter($above), ...array_filter($below)]; + $free = self::BodyHeight - self::TopPadding - self::BottomPadding - array_sum($parts) - count($parts) * self::Gap; + + return max(self::MinFieldLines, intdiv($free, self::FieldLineHeight)); + } + + /** + * The height of the space under the stack above the field: the field and what's under it, where the mention list + * floats. + * + * @param list $above + */ + public static function bodyHeight(array $above): int + { + $above = array_filter($above); + + return self::BodyHeight - array_sum($above) - count($above) * self::Gap; + } + + /** + * Which of the field's shown lines the caret is on, from the top, counting from 0: the text before it, wrapped a + * word at a time at the field's width. Past the last line shown, the field has scrolled to keep the caret in + * view, so it's on the last. + */ + public static function caretLine(string $text, int $caret, int $shownLines, bool $ios = true): int + { + $perLine = $ios ? self::IosCharactersPerLine : self::AndroidCharactersPerLine; + $lines = 0; + + foreach (explode("\n", mb_substr($text, 0, max(0, $caret))) as $paragraph) { + $lines += self::wrappedLines($paragraph, $perLine); + } + + return min(max(0, $lines - 1), max(0, $shownLines - 1)); + } + + /** + * Where the mention list's top goes in the space under the stack: just under the caret's line, or higher when + * that would leave it room for fewer than three people. + */ + public static function mentionTop(int $caretLine, int $bodyHeight): int + { + $underCaret = self::TopPadding + ($caretLine + 1) * self::FieldLineHeight + self::MentionGap; + $lowest = $bodyHeight - self::MentionInset - self::MentionMinRows * self::MentionRowHeight - 8; + + return max(0, min($underCaret, $lowest)); + } + + /** + * A commit drawn as a static card (partials/quoted-commit): its chrome, its body clamped to six lines, its poll. + */ + public static function cardHeight(Commit $commit): int + { + $lines = 0; + + foreach (explode("\n", $commit->plainText()) as $paragraph) { + $lines += self::wrappedLines($paragraph, self::CardCharactersPerLine); + } + + return self::CardChromeHeight + + min(self::CardMaxLines, max(1, $lines)) * self::CardLineHeight + + ($commit->poll === null ? 0 : 4 + count($commit->poll->options) * self::CardPollOptionHeight); + } + + /** + * The poll editor (partials/poll-editor): its padding, a field per option, Add option until there are four, then + * Poll length and Remove poll under a hairline. + * + * @param list $options + */ + public static function pollEditorHeight(array $options): int + { + $count = count($options); + + return 24 + $count * 64 + ($count < PollDraft::MaxOptions ? 44 : 0) + 9 + 56; + } + + /** + * A note in small text, such as an error, at its wrapped height. + */ + public static function noteHeight(string $note): int + { + return self::wrappedLines($note, self::NoteCharactersPerLine) * self::NoteLineHeight; + } + + /** + * How many lines a paragraph wraps to, a word at a time, at about $perLine characters. A word longer than a line + * breaks, as the fields and Text break it. + */ + private static function wrappedLines(string $paragraph, int $perLine): int + { + return $paragraph === '' ? 1 : substr_count(wordwrap($paragraph, $perLine, "\n", true), "\n") + 1; + } +} diff --git a/resources/views/native/partials/commit-sheet.blade.php b/resources/views/native/partials/commit-sheet.blade.php index 1af931c2..a9633432 100644 --- a/resources/views/native/partials/commit-sheet.blade.php +++ b/resources/views/native/partials/commit-sheet.blade.php @@ -26,11 +26,14 @@ A commit's page opens its reply here too, as "Reply to @handle", with the commit being answered as a static card over the field, for the photos and the preview its reply bar has no room for. Commit says Reply there. - While the caret is after an "@handle", the people to mention show right under the field, as the web's composer lists - them (see SuggestsMentions): for a bare "@" in a new commit, the people you follow, under that heading. The field - keeps the keyboard up through presses in the sheet (keep-focus), so picking someone leaves you typing after them. + While the caret is after an "@handle", the people to mention float over the field just under the caret's line, as + the web's composer lists them (see SuggestsMentions): for a bare "@" in a new commit, the people you follow, under + that heading. They cover a quoted commit too, and run down to the toolbar. The field keeps the keyboard up through + presses in the sheet (keep-focus), so picking someone leaves you typing after them. - Under what's being written come its photos and the poll editor. A toolbar is pinned to the bottom of the sheet, so + The sheet doesn't scroll. The field fills the space between the author row and the toolbar, less what's under it: + the photos as a strip of 80pt squares, the poll editor, the commit being quoted, or "Submit at", each at its own + height (see ComposerSheet). Only the field scrolls its text. A toolbar is pinned to the bottom of the sheet, so it stays just above the keyboard: the tools on the left, photos, the camera, a poll (not on a reply) and the preview, which shows the draft as the commit it would become in place of the field (see AttachesToCommits), and stash@{0} and the counter on the right. An issue draft has no tools, as on the web. With photos, Commit spins while @@ -70,37 +73,74 @@ @endif - - - @if ($postsAs) - - @include('native.partials.post-as', ['ref' => 'sheet-post-as', 'me' => $postingMe, 'picked' => $sheetAuthor, 'method' => 'postAsInSheet', 'size' => 36, 'withName' => true]) - - @endif - - @if ($sheetError) - {{ $sheetError }} - @endif + {{-- + Nothing here scrolls but the field (or the preview in its place). What's over the field and under + it take their own height, and the field takes the lines left between them and the toolbar (see + ComposerSheet). Each part has a keyed slot that's always drawn, empty or not, so the field never + moves among its siblings: Android rebuilds a node that does, and the keyboard goes down with it. + --}} + @php($sheetLayout = \App\Devnull\ComposerSheet::class) + @php($linkTooLong = ! $issueCommand && \App\Devnull\Data\CommitBody::hasOversizedUrl($sheetBody)) + @php($pollShown = $sheetPoll !== null && ! $replying) + @php($offersIssues = ! $quoting && ! $scheduling && ! $replying && ! $issueCommand) + @php($issueCommands = $offersIssues && $sheetTyped ? \App\Devnull\IssueCommand::suggested($sheetBody) : []) + @php($issueHint = $offersIssues && ! $issueHintsDismissed ? \App\Devnull\IssueCommand::hinted($sheetBody) : null) + @php($above = [ + $postsAs ? $sheetLayout::PostAsHeight : 0, + $sheetError ? $sheetLayout::noteHeight($sheetError) : 0, + $issueCommand ? $sheetLayout::IssueBadgeHeight : 0, + $replying ? $sheetLayout::cardHeight($sheetCommit) : 0, + ]) + @php($below = $previewing ? [] : [ + $linkTooLong ? $sheetLayout::NoteLineHeight * 2 : 0, + $sheetImages === [] ? 0 : $sheetLayout::PhotosHeight + ($describing !== null ? $sheetLayout::PhotoDescriptionHeight : 0), + $pollShown ? $sheetLayout::pollEditorHeight($sheetPoll) : 0, + match (true) { + $quoting => $sheetLayout::cardHeight($sheetCommit), + $scheduling => $sheetLayout::ScheduleHeight, + $issueCommands !== [] => count($issueCommands) * $sheetLayout::IssueCommandRowHeight + 8, + $issueHint !== null => $sheetLayout::IssueHintHeight, + default => 0, + }, + ]) + @php($fieldLines = $sheetLayout::fieldLines($above, $below)) + @php($hasAbove = array_filter($above) !== []) + + @if ($postsAs) + + @include('native.partials.post-as', ['ref' => 'sheet-post-as', 'me' => $postingMe, 'picked' => $sheetAuthor, 'method' => 'postAsInSheet', 'size' => 36, 'withName' => true]) + + @endif - @if ($issueCommand) - @include('native.partials.issue-badge', ['command' => $issueCommand]) - @endif + @if ($sheetError) + {{ $sheetError }} + @endif - @if ($replying) - @include('native.partials.quoted-commit', ['quoted' => $sheetCommit, 'static' => true, 'label' => 'Replying to']) - @endif + @if ($issueCommand) + @include('native.partials.issue-badge', ['command' => $issueCommand]) + @endif - @if ($previewing) - @include('native.partials.composer-preview', [ - 'ref' => 'sheet-draft', - 'body' => $sheetBody, - 'preview' => $sheetPreview, - 'images' => $sheetImages, - 'poll' => $replying ? null : $sheetPoll, - 'pollLength' => $sheetPollLength, - 'quoted' => $quoting ? $sheetCommit : null, - ]) - @else + @if ($replying) + @include('native.partials.quoted-commit', ['quoted' => $sheetCommit, 'static' => true, 'label' => 'Replying to']) + @endif + + + @if ($previewing) + + + @include('native.partials.composer-preview', [ + 'ref' => 'sheet-draft', + 'body' => $sheetBody, + 'preview' => $sheetPreview, + 'images' => $sheetImages, + 'poll' => $replying ? null : $sheetPoll, + 'pollLength' => $sheetPollLength, + 'quoted' => $quoting ? $sheetCommit : null, + ]) + + + @else + - - @include('native.partials.mention-suggestions', [ - 'field' => 'sheetBody', - 'heading' => ($mention['query'] ?? null) === '' && $sheetView === 'compose' ? 'People you follow' : null, - 'label' => 'Mention a developer', - 'class' => 'w-full py-1 rounded-md border border-theme-hairline bg-theme-surface', - ]) - - @if (! $issueCommand && \App\Devnull\Data\CommitBody::hasOversizedUrl($sheetBody)) + + @php($hasBelow = array_filter($below) !== []) + + @if ($linkTooLong) Each link must not be greater than {{ \App\Devnull\Data\BodyLink::MaxLength }} characters. @endif @include('native.partials.composer-photos') - @if ($sheetPoll !== null && ! $replying) + @if ($pollShown) @include('native.partials.poll-editor') @endif @@ -139,17 +176,38 @@ class="w-full text-theme-ink" @include('native.partials.quoted-commit', ['quoted' => $sheetCommit, 'static' => true]) @elseif ($scheduling) @include('native.partials.schedule-picker') - @elseif (! $replying && ! $issueCommand) - @include('native.partials.issue-suggestions', [ - 'suggestions' => $sheetTyped ? \App\Devnull\IssueCommand::suggested($sheetBody) : [], - 'hint' => $issueHintsDismissed ? null : \App\Devnull\IssueCommand::hinted($sheetBody), - ]) + @elseif ($offersIssues) + @include('native.partials.issue-suggestions', ['suggestions' => $issueCommands, 'hint' => $issueHint]) @endif - @endif + - - - {{-- Pinned under the scroll view, so it rides just above the keyboard, and above the home indicator without it. --}} + {{-- + The people to mention float over the field and whatever is under it, out of the layout, so + nothing moves when they come and go. They start just under the line the caret is on, as + near as the app can tell (see ComposerSheet::caretLine()), and run down to the toolbar, + scrolling inside when there are more than fit. On Liquid Glass on iOS, like the reply + bar's, and on a raised surface on Android. + --}} + @if (($mention['field'] ?? null) === 'sheetBody' && ($mentionPeople !== [] || $mentionOrganizations !== [])) + @php($caretLine = $sheetLayout::caretLine($mention['text'], $mention['start'] + mb_strlen($mention['query']) + 1, $fieldLines, \Native\Mobile\Platform::isIos())) + + + @include('native.partials.mention-suggestions', [ + 'field' => 'sheetBody', + 'heading' => ($mention['query'] ?? null) === '' && $sheetView === 'compose' ? 'People you follow' : null, + 'label' => 'Mention a developer', + 'class' => 'w-full py-1', + ]) + + + @endif + @endif + + {{-- Pinned under the field and what's around it, so it rides just above the keyboard, and above the home indicator without it. --}} @unless ($issueCommand) diff --git a/tests/Feature/Screens/CommitMentionsTest.php b/tests/Feature/Screens/CommitMentionsTest.php index 4d35f14f..f9b4fe2c 100644 --- a/tests/Feature/Screens/CommitMentionsTest.php +++ b/tests/Feature/Screens/CommitMentionsTest.php @@ -1,5 +1,6 @@ assertSet('mention', null) ->assertSet('mentionPeople', []); }); + +it('floats the suggestions over the quoted commit on glass, from just under the caret line down to the toolbar', function () { + $screen = mentionsComposer(quoting: true)->input('sheet-body', "see\n@a", 6); + $overlay = nodeByRef($screen, 'sheet-mentions'); + + // Out of the layout, over the field and the card under it, so neither moves. + expect($overlay['layout']['position_type'])->toBe(1) + ->and($overlay['layout']['position'])->toEqual([ + ComposerSheet::TopPadding + 2 * ComposerSheet::FieldLineHeight + ComposerSheet::MentionGap, + 12, + ComposerSheet::MentionInset, + 12, + ]) + ->and($overlay['props']['glass'])->toBe(1) + ->and(childRefs($screen, 'sheet-body-area'))->toBe(['sheet-field-slot', 'sheet-below', 'sheet-mentions']) + ->and(findNode(nodeByRef($screen, 'sheet-below'), fn (array $node): bool => ($node['ref'] ?? null) === 'quote-card'))->not->toBeNull() + // The list scrolls inside it when there are more than fit. + ->and(findNode($overlay, fn (array $node): bool => $node['type'] === 'scroll_view' && ($node['ref'] ?? null) === 'sheet-mentions-scroll'))->not->toBeNull() + ->and(childRefs($screen, 'mention-suggestions'))->toBe(['mention-ada', 'mention-adam', 'mention-adaptive']); +}); + +it('draws the floating suggestions on a raised surface on Android', function () { + fakeApi([ + 'GET /api/v1/log/following' => [pageJson([])], + 'GET /api/v1/search/mentions' => mentionsFound(), + ]); + + $overlay = nodeByRef(Native::visit('/log', platform: 'android')->press('composeInSheet')->input('sheet-body', 'hi @a', 5), 'sheet-mentions'); + + expect($overlay['props'])->not->toHaveKey('glass') + ->and(strtolower($overlay['style']['bg_color']))->toBe(strtolower(config('native-ui.theme.light.surface'))); +}); diff --git a/tests/Feature/Screens/ComposeSheetTest.php b/tests/Feature/Screens/ComposeSheetTest.php index d0f319ee..490768e6 100644 --- a/tests/Feature/Screens/ComposeSheetTest.php +++ b/tests/Feature/Screens/ComposeSheetTest.php @@ -1,5 +1,6 @@ and(idsDownTo($screen->tree(), 'sheet-body'))->toBe($field); }); +it('fills the sheet with the field, with nothing scrolling around it', function () { + $screen = composeSheetOnLog(); + $field = nodeByRef($screen, 'sheet-body')['props']; + + expect(findNodes(nodeByRef($screen, 'sheet'), fn (array $node): bool => $node['type'] === 'scroll_view'))->toBe([]) + // As many lines as the sheet has room for, so the field reaches down to the toolbar. + ->and($field['min_lines'])->toBe($field['max_lines']) + ->and($field['max_lines'])->toBe(ComposerSheet::fieldLines([], [])) + ->and($field['line_height_px'])->toEqual(ComposerSheet::FieldLineHeight); +}); + +it('gives the field fewer lines while a poll takes its room, and the poll sits under the field', function () { + $screen = composeSheetOnLog(); + $lines = nodeByRef($screen, 'sheet-body')['props']['max_lines']; + + $screen->tap('sheet-poll'); + + expect(nodeByRef($screen, 'sheet-body')['props']['max_lines'])->toBeLessThan($lines) + ->and(nodeByRef($screen, 'sheet-body')['props']['min_lines'])->toBe(nodeByRef($screen, 'sheet-body')['props']['max_lines']) + ->and(findNode(nodeByRef($screen, 'sheet-below'), fn (array $node): bool => ($node['ref'] ?? null) === 'poll-editor'))->not->toBeNull(); +}); + +it('keeps the field the same view while photos, a poll and mentions come and go around it', function () { + fakeApi([ + 'GET /api/v1/log/following' => [pageJson([])], + 'GET /api/v1/search/mentions' => [['data' => [userJson(['id' => 'u9', 'handle' => 'ada'])], 'organizations' => []]], + ]); + $screen = Native::visit('/log', platform: 'ios')->press('composeInSheet'); + $field = idsDownTo($screen->tree(), 'sheet-body'); + + $screen->input('sheet-body', 'hi @a', 5); + expect(nodeByRef($screen, 'sheet-mentions'))->not->toBeEmpty() + ->and(idsDownTo($screen->tree(), 'sheet-body'))->toBe($field); + + $screen->input('sheet-body', 'hi', 2)->tap('sheet-poll'); + expect(nodeByRef($screen, 'poll-editor'))->not->toBeEmpty() + ->and(idsDownTo($screen->tree(), 'sheet-body'))->toBe($field); +}); + it('only commits from a sheet that has a composer in it', function () { fakeApi(['GET /api/v1/log/following' => [pageJson([commitJson(['id' => 'c1', 'author' => userJson(['id' => 'u2', 'handle' => 'ada'])])])]]); diff --git a/tests/Feature/Screens/ComposerPhotosTest.php b/tests/Feature/Screens/ComposerPhotosTest.php index 9a0fa6e1..5e3bc826 100644 --- a/tests/Feature/Screens/ComposerPhotosTest.php +++ b/tests/Feature/Screens/ComposerPhotosTest.php @@ -41,11 +41,11 @@ function isTool(TestableComponent $screen, string $ref): bool return nodeByRef($screen, $ref)['type'] === 'pressable'; } -it('pins the toolbar under the scroll view, so it stays just above the keyboard', function () { +it('pins the toolbar under the field and what is around it, so it stays just above the keyboard', function () { $screen = composerOnLog(); $toolbar = nodeByRef($screen, 'sheet-toolbar'); - expect(findNode(nodeByRef($screen, 'sheet-composer'), fn (array $node): bool => ($node['ref'] ?? null) === 'sheet-toolbar'))->toBeNull() + expect(findNode(nodeByRef($screen, 'sheet-body-area'), fn (array $node): bool => ($node['ref'] ?? null) === 'sheet-toolbar'))->toBeNull() ->and(findNode($toolbar, fn (array $node): bool => ($node['ref'] ?? null) === 'sheet-tools'))->not->toBeNull() ->and(findNode($toolbar, fn (array $node): bool => ($node['ref'] ?? null) === 'sheet-preview'))->not->toBeNull(); }); diff --git a/tests/Feature/Screens/QuoteTest.php b/tests/Feature/Screens/QuoteTest.php index 3ce4a7b5..5f08c99c 100644 --- a/tests/Feature/Screens/QuoteTest.php +++ b/tests/Feature/Screens/QuoteTest.php @@ -1,5 +1,6 @@ toBeFalse() ->and($screen->instance()->commit->id)->toBe('c2'); }); + +it('puts the quoted commit right under the field, which gives up the room it takes', function () { + $screen = quoteSheetOnLog(); + $field = nodeByRef($screen, 'sheet-body')['props']; + $card = ComposerSheet::cardHeight(Commit::fromArray(commitJson(['id' => 'c1', 'body' => 'Required reading.', 'author' => quoteAda()]))); + + expect(childRefs($screen, 'sheet-below'))->toBe(['quote-card']) + ->and($field['max_lines'])->toBe(ComposerSheet::fieldLines([], [$card])) + ->and($field['max_lines'])->toBeLessThan(ComposerSheet::fieldLines([], [])) + ->and($field['min_lines'])->toBe($field['max_lines']); +}); diff --git a/tests/Unit/Devnull/ComposerSheetTest.php b/tests/Unit/Devnull/ComposerSheetTest.php new file mode 100644 index 00000000..eeb6b09c --- /dev/null +++ b/tests/Unit/Devnull/ComposerSheetTest.php @@ -0,0 +1,41 @@ +toBe(intdiv(ComposerSheet::BodyHeight - ComposerSheet::TopPadding - ComposerSheet::BottomPadding, ComposerSheet::FieldLineHeight)) + // A quoted card under the field takes its height and a gap off the field. + ->and(ComposerSheet::fieldLines([], [96]))->toBe(intdiv(ComposerSheet::BodyHeight - ComposerSheet::TopPadding - ComposerSheet::BottomPadding - 96 - ComposerSheet::Gap, ComposerSheet::FieldLineHeight)) + // Nothing there is nothing taken. + ->and(ComposerSheet::fieldLines([0], [0, 0]))->toBe($empty) + // However much is around it, the field keeps two lines. + ->and(ComposerSheet::fieldLines([200], [300]))->toBe(ComposerSheet::MinFieldLines); +}); + +it('finds the line the caret is on from the text before it, wrapped a word at a time', function () { + expect(ComposerSheet::caretLine('see @a', 6, 10))->toBe(0) + ->and(ComposerSheet::caretLine("one\ntwo\n@a", 10, 10))->toBe(2) + // A blank line still counts. + ->and(ComposerSheet::caretLine("one\n\n@a", 7, 10))->toBe(2) + // Wrapped at about 40 characters on iOS, and fewer on Android's bigger text. + ->and(ComposerSheet::caretLine(str_repeat('word ', 9).'@a', 47, 10))->toBe(1) + ->and(ComposerSheet::caretLine(str_repeat('word ', 7).'@a', 37, 10, ios: true))->toBe(0) + ->and(ComposerSheet::caretLine(str_repeat('word ', 7).'@a', 37, 10, ios: false))->toBe(1) + // Only the text before the caret moves it. + ->and(ComposerSheet::caretLine("@a\nmore\nlines", 2, 10))->toBe(0); +}); + +it('keeps the caret on the last line the field shows once the field has scrolled', function () { + expect(ComposerSheet::caretLine(str_repeat("line\n", 20).'@a', 102, 6))->toBe(5); +}); + +it('starts the mention list under the caret line, or higher when that would leave it room for fewer than three', function () { + $underFirstLine = ComposerSheet::TopPadding + ComposerSheet::FieldLineHeight + ComposerSheet::MentionGap; + $lowest = 300 - ComposerSheet::MentionInset - ComposerSheet::MentionMinRows * ComposerSheet::MentionRowHeight - 8; + + expect(ComposerSheet::mentionTop(0, 300))->toBe($underFirstLine) + ->and(ComposerSheet::mentionTop(9, 300))->toBe($lowest) + ->and(ComposerSheet::mentionTop(0, 100))->toBe(0); +}); From 12bc35d42760a8f227cf8344fe633ffbf928fd30 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Sat, 21 Nov 2026 09:09:29 +0000 Subject: [PATCH 02/11] Fill the composer sheet with a field that really fills, and place mentions by its caret The sheet's field had its lines worked out from an estimate of the sheet's height and of everything under it, and the mention list's top from the text before the caret, wrapped at a guessed width. mobile-ui#227 lets a multiline field fill the height it's given (h-full) and report where its caret is drawn (@caretChange), so the field is now h-full in a flex-1 slot and the list starts just under the caret's line as the field reports it. ComposerSheet keeps only the list's placement. Its line and height estimates, and the 24pt line height set on the field for them, are gone. Tests of the fill and the caret skip on a mobile-ui without them (Tests\Support\TextFieldFill), where the field is as tall as its lines. Co-Authored-By: Claude Opus 5.5 --- app/Devnull/ComposerSheet.php | 183 ++++-------------- .../Concerns/OpensCommitSheet.php | 20 ++ .../native/partials/commit-sheet.blade.php | 49 ++--- tests/Feature/Screens/CommitMentionsTest.php | 10 +- tests/Feature/Screens/ComposeSheetTest.php | 35 ++-- tests/Feature/Screens/QuoteTest.php | 11 +- tests/Support/TextFieldFill.php | 25 +++ tests/Unit/Devnull/ComposerSheetTest.php | 47 ++--- 8 files changed, 151 insertions(+), 229 deletions(-) create mode 100644 tests/Support/TextFieldFill.php diff --git a/app/Devnull/ComposerSheet.php b/app/Devnull/ComposerSheet.php index b3f3dc7d..226b443a 100644 --- a/app/Devnull/ComposerSheet.php +++ b/app/Devnull/ComposerSheet.php @@ -2,79 +2,24 @@ namespace App\Devnull; -use App\Devnull\Data\Commit; -use App\Devnull\Data\PollDraft; +use Native\Mobile\UI\Caret; /** - * How the composer sheet (partials/commit-sheet) shares its height out, in points. The field takes what the rest - * leaves between the author row and the toolbar, and the mention list floats under the line the caret is on. + * Where the composer sheet (partials/commit-sheet) floats its mention list: just under the line the caret is on, which + * the field reports (`@caretChange`, see OpensCommitSheet::sheetCaretMoved()), down to the toolbar. * - * Neither platform tells PHP how tall the sheet is, or where the caret is drawn, and mobile-ui's multiline field is as - * tall as its lines (min-lines to max-lines), not as tall as the space it's given. So this works both out from what - * the app knows: the sheet's height on a 6.1" iPhone with the keyboard up, how tall each thing under the field is - * drawn, and how the draft wraps at the field's width. The field's line height is set (FieldLineHeight), so a line - * is the same height on both platforms. + * The field fills the space between the author row and what's under it by itself (`h-full`), so nothing here sizes + * it. The list's top is in the sheet's body area, whose top is the field slot's top: the slot's padding, then the + * caret's line in the field's own points. */ final class ComposerSheet { - /** - * The sheet between its bar's hairline and the toolbar's hairline, keyboard up, on a 6.1" iPhone. Bigger phones - * leave a little room under the field; nothing smaller is supported for composing. - */ - public const int BodyHeight = 340; - - /** The padding above the first thing in the sheet and under the last. */ - public const int TopPadding = 12; - - public const int BottomPadding = 8; - - /** The gap between the things stacked above and under the field. */ - public const int Gap = 12; - - public const int FieldLineHeight = 24; + /** The field slot's padding above the field (pt-3). */ + public const int FieldTop = 12; + /** The least the field shows, on a phone short enough that the rest leaves it little room. */ public const int MinFieldLines = 2; - /** - * About how many characters of the field's text fit on a line across the sheet: 18pt on iOS, 20sp on Android. - */ - public const int IosCharactersPerLine = 40; - - public const int AndroidCharactersPerLine = 36; - - /** The Post as row's avatar, with its name and handle beside it. */ - public const int PostAsHeight = 36; - - public const int IssueBadgeHeight = 32; - - /** A line of small text: an error, or the link-length note. */ - public const int NoteLineHeight = 20; - - public const int NoteCharactersPerLine = 48; - - /** The photo strip's 80pt squares, and the description under them while it's open. */ - public const int PhotosHeight = 80; - - public const int PhotoDescriptionHeight = 150; - - /** The schedule box: "Submit at", the picker, the timezone and its lines, then Scheduled commits →. */ - public const int ScheduleHeight = 170; - - public const int IssueCommandRowHeight = 44; - - public const int IssueHintHeight = 32; - - /** A quoted commit's card: its margin, padding and header, then up to six lines of its body. */ - public const int CardChromeHeight = 44; - - public const int CardLineHeight = 24; - - public const int CardCharactersPerLine = 42; - - public const int CardMaxLines = 6; - - public const int CardPollOptionHeight = 36; - /** The mention list's rows, and how many of them it always has room for. */ public const int MentionRowHeight = 44; @@ -85,106 +30,52 @@ final class ComposerSheet public const int MentionInset = 8; + /** The list's own padding above and under its rows (py-1). */ + public const int MentionPadding = 8; + /** - * How many lines the field shows, after everything else in the sheet has its height: $above are the heights of - * what's stacked over the field, $below of what's under it. - * - * @param list $above - * @param list $below + * Before the field has said where its caret is (it says so as soon as it has focus, so only for a moment), the + * list goes under about one line. */ - public static function fieldLines(array $above, array $below): int - { - $parts = [...array_filter($above), ...array_filter($below)]; - $free = self::BodyHeight - self::TopPadding - self::BottomPadding - array_sum($parts) - count($parts) * self::Gap; - - return max(self::MinFieldLines, intdiv($free, self::FieldLineHeight)); - } + public const int FirstLineHeight = 24; /** - * The height of the space under the stack above the field: the field and what's under it, where the mention list - * floats. + * The caret as the sheet keeps it: the bottom of its line and the field's visible height, in points. A caret the + * field has scrolled out of view is kept to its edges. * - * @param list $above + * @return array{bottom: float, field_height: float} */ - public static function bodyHeight(array $above): int + public static function caret(Caret $caret): array { - $above = array_filter($above); + $field = max(0.0, $caret->fieldHeight); + $bottom = max(0.0, $caret->bottom()); - return self::BodyHeight - array_sum($above) - count($above) * self::Gap; + return ['bottom' => $field > 0 ? min($bottom, $field) : $bottom, 'field_height' => $field]; } /** - * Which of the field's shown lines the caret is on, from the top, counting from 0: the text before it, wrapped a - * word at a time at the field's width. Past the last line shown, the field has scrolled to keep the caret in - * view, so it's on the last. + * Where the mention list's top goes in the sheet's body area: just under the caret's line, or higher when that + * would leave it room for fewer than three people above the toolbar. The room is measured to the field's bottom, + * since the field doesn't say how tall what's under it is, so with a quoted commit under it the list can go up a + * little sooner than it has to. + * + * @param array{bottom: float, field_height: float}|null $caret */ - public static function caretLine(string $text, int $caret, int $shownLines, bool $ios = true): int + public static function mentionTop(?array $caret): int { - $perLine = $ios ? self::IosCharactersPerLine : self::AndroidCharactersPerLine; - $lines = 0; - - foreach (explode("\n", mb_substr($text, 0, max(0, $caret))) as $paragraph) { - $lines += self::wrappedLines($paragraph, $perLine); + if ($caret === null) { + return self::FieldTop + self::FirstLineHeight + self::MentionGap; } - return min(max(0, $lines - 1), max(0, $shownLines - 1)); - } - - /** - * Where the mention list's top goes in the space under the stack: just under the caret's line, or higher when - * that would leave it room for fewer than three people. - */ - public static function mentionTop(int $caretLine, int $bodyHeight): int - { - $underCaret = self::TopPadding + ($caretLine + 1) * self::FieldLineHeight + self::MentionGap; - $lowest = $bodyHeight - self::MentionInset - self::MentionMinRows * self::MentionRowHeight - 8; + $underCaret = self::FieldTop + (int) ceil($caret['bottom']) + self::MentionGap; - return max(0, min($underCaret, $lowest)); - } - - /** - * A commit drawn as a static card (partials/quoted-commit): its chrome, its body clamped to six lines, its poll. - */ - public static function cardHeight(Commit $commit): int - { - $lines = 0; - - foreach (explode("\n", $commit->plainText()) as $paragraph) { - $lines += self::wrappedLines($paragraph, self::CardCharactersPerLine); + if ($caret['field_height'] <= 0) { + return $underCaret; } - return self::CardChromeHeight - + min(self::CardMaxLines, max(1, $lines)) * self::CardLineHeight - + ($commit->poll === null ? 0 : 4 + count($commit->poll->options) * self::CardPollOptionHeight); - } - - /** - * The poll editor (partials/poll-editor): its padding, a field per option, Add option until there are four, then - * Poll length and Remove poll under a hairline. - * - * @param list $options - */ - public static function pollEditorHeight(array $options): int - { - $count = count($options); + $lowest = self::FieldTop + (int) floor($caret['field_height']) + - self::MentionInset - self::MentionMinRows * self::MentionRowHeight - self::MentionPadding; - return 24 + $count * 64 + ($count < PollDraft::MaxOptions ? 44 : 0) + 9 + 56; - } - - /** - * A note in small text, such as an error, at its wrapped height. - */ - public static function noteHeight(string $note): int - { - return self::wrappedLines($note, self::NoteCharactersPerLine) * self::NoteLineHeight; - } - - /** - * How many lines a paragraph wraps to, a word at a time, at about $perLine characters. A word longer than a line - * breaks, as the fields and Text break it. - */ - private static function wrappedLines(string $paragraph, int $perLine): int - { - return $paragraph === '' ? 1 : substr_count(wordwrap($paragraph, $perLine, "\n", true), "\n") + 1; + return max(0, min($underCaret, $lowest)); } } diff --git a/app/NativeComponents/Concerns/OpensCommitSheet.php b/app/NativeComponents/Concerns/OpensCommitSheet.php index 06df216a..b4fc25af 100644 --- a/app/NativeComponents/Concerns/OpensCommitSheet.php +++ b/app/NativeComponents/Concerns/OpensCommitSheet.php @@ -3,6 +3,7 @@ namespace App\NativeComponents\Concerns; use App\Devnull\Client; +use App\Devnull\ComposerSheet; use App\Devnull\Data\Commit; use App\Devnull\Data\Draft; use App\Devnull\Data\PollDraft; @@ -20,6 +21,7 @@ use Carbon\CarbonImmutable; use Closure; use Native\Mobile\Facades\System; +use Native\Mobile\UI\Caret; /** * The sheet under a commit (see partials/commit-sheet). Report commit, in the @@ -110,6 +112,14 @@ trait OpensCommitSheet */ public string $sheetBody = ''; + /** + * Where the sheet's field last said its caret is drawn, for the mention list to float under (see ComposerSheet). + * Null until it has said, and again once the sheet is gone. + * + * @var array{bottom: float, field_height: float}|null + */ + public ?array $sheetCaret = null; + /** * The handle of the organization the sheet posts as, or null for you (see PostAs). */ @@ -307,6 +317,14 @@ public function openScheduledCommits(): void /** * Stashes the draft as it changes (see stashSheetDraft()). */ + /** + * The sheet's field drew its caret somewhere else: it moved, the text wrapped differently, or the field scrolled. + */ + public function sheetCaretMoved(Caret $caret): void + { + $this->sheetCaret = ComposerSheet::caret($caret); + } + public function updatedSheetBody(): void { $this->typeIssueCommand(); @@ -493,6 +511,7 @@ private function closeCommitSheet(): void { $this->sheetClosing = $this->sheetClosing || ($this->sheetOpen && System::isIos()); $this->sheetOpen = false; + $this->sheetCaret = null; $this->forgetMention('sheetBody'); } @@ -606,6 +625,7 @@ private function forgetCommitSheet(): void $this->reportReason = ''; $this->reportDetails = ''; $this->sheetBody = ''; + $this->sheetCaret = null; $this->sheetAuthor = null; $this->sheetRestored = false; $this->sheetError = null; diff --git a/resources/views/native/partials/commit-sheet.blade.php b/resources/views/native/partials/commit-sheet.blade.php index a9633432..55a945c9 100644 --- a/resources/views/native/partials/commit-sheet.blade.php +++ b/resources/views/native/partials/commit-sheet.blade.php @@ -26,14 +26,14 @@ A commit's page opens its reply here too, as "Reply to @handle", with the commit being answered as a static card over the field, for the photos and the preview its reply bar has no room for. Commit says Reply there. - While the caret is after an "@handle", the people to mention float over the field just under the caret's line, as - the web's composer lists them (see SuggestsMentions): for a bare "@" in a new commit, the people you follow, under + While the caret is after an "@handle", the people to mention float over the field just under the caret's line, + which the field reports (@caretChange), as the web's composer lists them (see SuggestsMentions): for a bare "@" in a new commit, the people you follow, under that heading. They cover a quoted commit too, and run down to the toolbar. The field keeps the keyboard up through presses in the sheet (keep-focus), so picking someone leaves you typing after them. The sheet doesn't scroll. The field fills the space between the author row and the toolbar, less what's under it: the photos as a strip of 80pt squares, the poll editor, the commit being quoted, or "Submit at", each at its own - height (see ComposerSheet). Only the field scrolls its text. A toolbar is pinned to the bottom of the sheet, so + height. Only the field scrolls its text. A toolbar is pinned to the bottom of the sheet, so it stays just above the keyboard: the tools on the left, photos, the camera, a poll (not on a reply) and the preview, which shows the draft as the commit it would become in place of the field (see AttachesToCommits), and stash@{0} and the counter on the right. An issue draft has no tools, as on the web. With photos, Commit spins while @@ -75,8 +75,8 @@ {{-- Nothing here scrolls but the field (or the preview in its place). What's over the field and under - it take their own height, and the field takes the lines left between them and the toolbar (see - ComposerSheet). Each part has a keyed slot that's always drawn, empty or not, so the field never + it take their own height, and the field (h-full in a flex-1 slot) takes what's left between them + and the toolbar. Each part has a keyed slot that's always drawn, empty or not, so the field never moves among its siblings: Android rebuilds a node that does, and the keyboard goes down with it. --}} @php($sheetLayout = \App\Devnull\ComposerSheet::class) @@ -85,26 +85,7 @@ @php($offersIssues = ! $quoting && ! $scheduling && ! $replying && ! $issueCommand) @php($issueCommands = $offersIssues && $sheetTyped ? \App\Devnull\IssueCommand::suggested($sheetBody) : []) @php($issueHint = $offersIssues && ! $issueHintsDismissed ? \App\Devnull\IssueCommand::hinted($sheetBody) : null) - @php($above = [ - $postsAs ? $sheetLayout::PostAsHeight : 0, - $sheetError ? $sheetLayout::noteHeight($sheetError) : 0, - $issueCommand ? $sheetLayout::IssueBadgeHeight : 0, - $replying ? $sheetLayout::cardHeight($sheetCommit) : 0, - ]) - @php($below = $previewing ? [] : [ - $linkTooLong ? $sheetLayout::NoteLineHeight * 2 : 0, - $sheetImages === [] ? 0 : $sheetLayout::PhotosHeight + ($describing !== null ? $sheetLayout::PhotoDescriptionHeight : 0), - $pollShown ? $sheetLayout::pollEditorHeight($sheetPoll) : 0, - match (true) { - $quoting => $sheetLayout::cardHeight($sheetCommit), - $scheduling => $sheetLayout::ScheduleHeight, - $issueCommands !== [] => count($issueCommands) * $sheetLayout::IssueCommandRowHeight + 8, - $issueHint !== null => $sheetLayout::IssueHintHeight, - default => 0, - }, - ]) - @php($fieldLines = $sheetLayout::fieldLines($above, $below)) - @php($hasAbove = array_filter($above) !== []) + @php($hasAbove = $postsAs || $sheetError || $issueCommand || $replying) @if ($postsAs) @@ -140,27 +121,26 @@ @else - + - @php($hasBelow = array_filter($below) !== []) + @php($hasBelow = $linkTooLong || $sheetImages !== [] || $pollShown || $quoting || $scheduling || $issueCommands !== [] || $issueHint !== null) @if ($linkTooLong) Each link must not be greater than {{ \App\Devnull\Data\BodyLink::MaxLength }} characters. @@ -183,17 +163,16 @@ class="w-full text-theme-ink" {{-- The people to mention float over the field and whatever is under it, out of the layout, so - nothing moves when they come and go. They start just under the line the caret is on, as - near as the app can tell (see ComposerSheet::caretLine()), and run down to the toolbar, + nothing moves when they come and go. They start just under the line the caret is on, where + the field says it is (see ComposerSheet::mentionTop()), and run down to the toolbar, scrolling inside when there are more than fit. On Liquid Glass on iOS, like the reply bar's, and on a raised surface on Android. --}} @if (($mention['field'] ?? null) === 'sheetBody' && ($mentionPeople !== [] || $mentionOrganizations !== [])) - @php($caretLine = $sheetLayout::caretLine($mention['text'], $mention['start'] + mb_strlen($mention['query']) + 1, $fieldLines, \Native\Mobile\Platform::isIos())) @include('native.partials.mention-suggestions', [ diff --git a/tests/Feature/Screens/CommitMentionsTest.php b/tests/Feature/Screens/CommitMentionsTest.php index f9b4fe2c..effbc57e 100644 --- a/tests/Feature/Screens/CommitMentionsTest.php +++ b/tests/Feature/Screens/CommitMentionsTest.php @@ -5,6 +5,8 @@ use Illuminate\Support\Facades\Http; use Native\Mobile\Testing\Native; use Native\Mobile\Testing\TestableComponent; +use Native\Mobile\UI\Caret; +use Tests\Support\TextFieldFill; beforeEach(function () { config(['devnull.url' => 'http://devnull.test']); @@ -184,13 +186,17 @@ function mentionsComposer(bool $quoting = false): TestableComponent }); it('floats the suggestions over the quoted commit on glass, from just under the caret line down to the toolbar', function () { - $screen = mentionsComposer(quoting: true)->input('sheet-body', "see\n@a", 6); + TextFieldFill::skipUnlessSupported(); + + $screen = mentionsComposer(quoting: true) + ->input('sheet-body', "see\n@a", 6) + ->moveCaretTo('sheet-body', new Caret(x: 20, y: 22, width: 2, height: 22, line: 1, fieldWidth: 350, fieldHeight: 240)); $overlay = nodeByRef($screen, 'sheet-mentions'); // Out of the layout, over the field and the card under it, so neither moves. expect($overlay['layout']['position_type'])->toBe(1) ->and($overlay['layout']['position'])->toEqual([ - ComposerSheet::TopPadding + 2 * ComposerSheet::FieldLineHeight + ComposerSheet::MentionGap, + ComposerSheet::FieldTop + 44 + ComposerSheet::MentionGap, 12, ComposerSheet::MentionInset, 12, diff --git a/tests/Feature/Screens/ComposeSheetTest.php b/tests/Feature/Screens/ComposeSheetTest.php index 490768e6..100b5877 100644 --- a/tests/Feature/Screens/ComposeSheetTest.php +++ b/tests/Feature/Screens/ComposeSheetTest.php @@ -7,6 +7,8 @@ use Illuminate\Support\Facades\Http; use Native\Mobile\Testing\Native; use Native\Mobile\Testing\TestableComponent; +use Native\Mobile\UI\Caret; +use Tests\Support\TextFieldFill; beforeEach(function () { config(['devnull.url' => 'http://devnull.test']); @@ -283,27 +285,38 @@ function sheetCommitDisabled(TestableComponent $screen): bool }); it('fills the sheet with the field, with nothing scrolling around it', function () { + TextFieldFill::skipUnlessSupported(); + $screen = composeSheetOnLog(); $field = nodeByRef($screen, 'sheet-body')['props']; expect(findNodes(nodeByRef($screen, 'sheet'), fn (array $node): bool => $node['type'] === 'scroll_view'))->toBe([]) - // As many lines as the sheet has room for, so the field reaches down to the toolbar. - ->and($field['min_lines'])->toBe($field['max_lines']) - ->and($field['max_lines'])->toBe(ComposerSheet::fieldLines([], [])) - ->and($field['line_height_px'])->toEqual(ComposerSheet::FieldLineHeight); + // As tall as the space between the author row and the toolbar, scrolling its own text. + ->and($field['fills_height'] ?? null)->toBeTrue() + ->and($field['min_lines'])->toBe(ComposerSheet::MinFieldLines) + ->and($field)->not->toHaveKey('max_lines') + ->and(nodeByRef($screen, 'sheet-field-slot')['layout']['flex_grow'] ?? null)->toEqual(1) + // It says where its caret is drawn, for the mention list. + ->and($field['on_caret_change'] ?? null)->toBeInt(); }); -it('gives the field fewer lines while a poll takes its room, and the poll sits under the field', function () { - $screen = composeSheetOnLog(); - $lines = nodeByRef($screen, 'sheet-body')['props']['max_lines']; - - $screen->tap('sheet-poll'); +it('puts the poll under the field, which gives up the room it takes', function () { + $screen = composeSheetOnLog()->tap('sheet-poll'); - expect(nodeByRef($screen, 'sheet-body')['props']['max_lines'])->toBeLessThan($lines) - ->and(nodeByRef($screen, 'sheet-body')['props']['min_lines'])->toBe(nodeByRef($screen, 'sheet-body')['props']['max_lines']) + expect(childRefs($screen, 'sheet-body-area'))->toBe(['sheet-field-slot', 'sheet-below']) ->and(findNode(nodeByRef($screen, 'sheet-below'), fn (array $node): bool => ($node['ref'] ?? null) === 'poll-editor'))->not->toBeNull(); }); +it('keeps where the field says its caret is until the sheet goes', function () { + TextFieldFill::skipUnlessSupported(); + + $screen = composeSheetOnLog() + ->moveCaretTo('sheet-body', new Caret(y: 48, height: 24, line: 2, fieldWidth: 350, fieldHeight: 240)) + ->assertSet('sheetCaret', ['bottom' => 72.0, 'field_height' => 240.0]); + + $screen->press('hideCommitSheet')->assertSet('sheetCaret', null); +}); + it('keeps the field the same view while photos, a poll and mentions come and go around it', function () { fakeApi([ 'GET /api/v1/log/following' => [pageJson([])], diff --git a/tests/Feature/Screens/QuoteTest.php b/tests/Feature/Screens/QuoteTest.php index 5f08c99c..e9a1eb92 100644 --- a/tests/Feature/Screens/QuoteTest.php +++ b/tests/Feature/Screens/QuoteTest.php @@ -1,11 +1,11 @@ 'http://devnull.test']); @@ -214,12 +214,11 @@ function quoteButtonDisabled(TestableComponent $screen): bool }); it('puts the quoted commit right under the field, which gives up the room it takes', function () { + TextFieldFill::skipUnlessSupported(); + $screen = quoteSheetOnLog(); - $field = nodeByRef($screen, 'sheet-body')['props']; - $card = ComposerSheet::cardHeight(Commit::fromArray(commitJson(['id' => 'c1', 'body' => 'Required reading.', 'author' => quoteAda()]))); expect(childRefs($screen, 'sheet-below'))->toBe(['quote-card']) - ->and($field['max_lines'])->toBe(ComposerSheet::fieldLines([], [$card])) - ->and($field['max_lines'])->toBeLessThan(ComposerSheet::fieldLines([], [])) - ->and($field['min_lines'])->toBe($field['max_lines']); + ->and(childRefs($screen, 'sheet-body-area'))->toBe(['sheet-field-slot', 'sheet-below']) + ->and(nodeByRef($screen, 'sheet-body')['props']['fills_height'] ?? null)->toBeTrue(); }); diff --git a/tests/Support/TextFieldFill.php b/tests/Support/TextFieldFill.php new file mode 100644 index 00000000..d714743c --- /dev/null +++ b/tests/Support/TextFieldFill.php @@ -0,0 +1,25 @@ +markTestSkipped('Needs a mobile-ui whose multiline field fills and reports its caret (NativePHP/mobile-ui#227)'); + } + } +} diff --git a/tests/Unit/Devnull/ComposerSheetTest.php b/tests/Unit/Devnull/ComposerSheetTest.php index eeb6b09c..28ccd184 100644 --- a/tests/Unit/Devnull/ComposerSheetTest.php +++ b/tests/Unit/Devnull/ComposerSheetTest.php @@ -1,41 +1,30 @@ TextFieldFill::skipUnlessSupported()); - expect($empty)->toBe(intdiv(ComposerSheet::BodyHeight - ComposerSheet::TopPadding - ComposerSheet::BottomPadding, ComposerSheet::FieldLineHeight)) - // A quoted card under the field takes its height and a gap off the field. - ->and(ComposerSheet::fieldLines([], [96]))->toBe(intdiv(ComposerSheet::BodyHeight - ComposerSheet::TopPadding - ComposerSheet::BottomPadding - 96 - ComposerSheet::Gap, ComposerSheet::FieldLineHeight)) - // Nothing there is nothing taken. - ->and(ComposerSheet::fieldLines([0], [0, 0]))->toBe($empty) - // However much is around it, the field keeps two lines. - ->and(ComposerSheet::fieldLines([200], [300]))->toBe(ComposerSheet::MinFieldLines); -}); +it('starts the mention list just under the line the field says the caret is on', function () { + $caret = ComposerSheet::caret(new Caret(y: 48, height: 24, line: 2, fieldHeight: 300)); -it('finds the line the caret is on from the text before it, wrapped a word at a time', function () { - expect(ComposerSheet::caretLine('see @a', 6, 10))->toBe(0) - ->and(ComposerSheet::caretLine("one\ntwo\n@a", 10, 10))->toBe(2) - // A blank line still counts. - ->and(ComposerSheet::caretLine("one\n\n@a", 7, 10))->toBe(2) - // Wrapped at about 40 characters on iOS, and fewer on Android's bigger text. - ->and(ComposerSheet::caretLine(str_repeat('word ', 9).'@a', 47, 10))->toBe(1) - ->and(ComposerSheet::caretLine(str_repeat('word ', 7).'@a', 37, 10, ios: true))->toBe(0) - ->and(ComposerSheet::caretLine(str_repeat('word ', 7).'@a', 37, 10, ios: false))->toBe(1) - // Only the text before the caret moves it. - ->and(ComposerSheet::caretLine("@a\nmore\nlines", 2, 10))->toBe(0); + expect(ComposerSheet::mentionTop($caret))->toBe(ComposerSheet::FieldTop + 72 + ComposerSheet::MentionGap); }); -it('keeps the caret on the last line the field shows once the field has scrolled', function () { - expect(ComposerSheet::caretLine(str_repeat("line\n", 20).'@a', 102, 6))->toBe(5); +it('moves the list up when the caret is too near the field\'s bottom to leave room for three people', function () { + $lowest = ComposerSheet::FieldTop + 300 - ComposerSheet::MentionInset - ComposerSheet::MentionMinRows * ComposerSheet::MentionRowHeight - ComposerSheet::MentionPadding; + + expect(ComposerSheet::mentionTop(ComposerSheet::caret(new Caret(y: 264, height: 24, fieldHeight: 300))))->toBe($lowest) + // A field too short for three people puts the list at the top of it. + ->and(ComposerSheet::mentionTop(ComposerSheet::caret(new Caret(y: 24, height: 24, fieldHeight: 80))))->toBe(0); }); -it('starts the mention list under the caret line, or higher when that would leave it room for fewer than three', function () { - $underFirstLine = ComposerSheet::TopPadding + ComposerSheet::FieldLineHeight + ComposerSheet::MentionGap; - $lowest = 300 - ComposerSheet::MentionInset - ComposerSheet::MentionMinRows * ComposerSheet::MentionRowHeight - 8; +it('keeps a caret the field has scrolled out of view to the field\'s edges', function () { + expect(ComposerSheet::caret(new Caret(y: -60, height: 24, fieldHeight: 300)))->toBe(['bottom' => 0.0, 'field_height' => 300.0]) + ->and(ComposerSheet::caret(new Caret(y: 400, height: 24, fieldHeight: 300)))->toBe(['bottom' => 300.0, 'field_height' => 300.0]); +}); - expect(ComposerSheet::mentionTop(0, 300))->toBe($underFirstLine) - ->and(ComposerSheet::mentionTop(9, 300))->toBe($lowest) - ->and(ComposerSheet::mentionTop(0, 100))->toBe(0); +it('puts the list under about one line before the field has said where its caret is', function () { + expect(ComposerSheet::mentionTop(null))->toBe(ComposerSheet::FieldTop + ComposerSheet::FirstLineHeight + ComposerSheet::MentionGap); }); From 31567787b97c3cab73f71f2fc936b918cfa5f367 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Sat, 21 Nov 2026 10:28:46 +0000 Subject: [PATCH 03/11] Shorten the sheet's field to make room for mentions under the caret When the mention list doesn't fit between the caret's line and the field's bottom, the field now gets shorter instead, ending on the caret's line, and the list goes under it down to the toolbar. Before, the list moved up to make room for three people and could cover the line being typed on. The list is as tall as its rows (up to six) when it floats, so it only scrolls when it has to. Once the list goes, the field fills again. The body area has animate-layout (mobile-air#736), so the field's height and the list coming and going are animated. The field slot keeps its key and place, so the keyboard stays up. Co-Authored-By: Claude Opus 5.5 --- app/Devnull/ComposerSheet.php | 130 ++++++++++++++---- .../Concerns/OpensCommitSheet.php | 27 +++- .../native/partials/commit-sheet.blade.php | 39 ++++-- tests/Feature/Screens/CommitMentionsTest.php | 44 +++++- tests/Feature/Screens/ComposeSheetTest.php | 2 +- tests/Support/LayoutAnimation.php | 25 ++++ tests/Unit/Devnull/ComposerSheetTest.php | 80 +++++++++-- 7 files changed, 284 insertions(+), 63 deletions(-) create mode 100644 tests/Support/LayoutAnimation.php diff --git a/app/Devnull/ComposerSheet.php b/app/Devnull/ComposerSheet.php index 226b443a..80a3ccf7 100644 --- a/app/Devnull/ComposerSheet.php +++ b/app/Devnull/ComposerSheet.php @@ -5,12 +5,16 @@ use Native\Mobile\UI\Caret; /** - * Where the composer sheet (partials/commit-sheet) floats its mention list: just under the line the caret is on, which - * the field reports (`@caretChange`, see OpensCommitSheet::sheetCaretMoved()), down to the toolbar. + * Where the composer sheet (partials/commit-sheet) puts its mention list, and how tall its field is meanwhile. * - * The field fills the space between the author row and what's under it by itself (`h-full`), so nothing here sizes - * it. The list's top is in the sheet's body area, whose top is the field slot's top: the slot's padding, then the - * caret's line in the field's own points. + * The field fills the space between the author row and what's under it by itself (`h-full`). The list floats just + * under the line the caret is on, which the field reports (`@caretChange`, see OpensCommitSheet::sheetCaretMoved()), + * as tall as its rows, up to six of them. When there isn't room for that under the caret, the field gets shorter + * instead, just tall enough to end on the caret's line (it scrolls its text to keep the caret in view), and the list + * goes in the room that frees, under the field. Once the list is gone, the field fills again. + * + * Everything is in points from the top of the sheet's body area, whose top is the field slot's top: the slot's + * padding, then the field. */ final class ComposerSheet { @@ -20,62 +24,128 @@ final class ComposerSheet /** The least the field shows, on a phone short enough that the rest leaves it little room. */ public const int MinFieldLines = 2; - /** The mention list's rows, and how many of them it always has room for. */ + /** + * The mention list's rows, and how many show before the rest scroll inside it. The same as + * Display::MentionRowHeight and Display::MentionRowsShown, which cap the lists by the other fields. + */ public const int MentionRowHeight = 44; - public const int MentionMinRows = 3; + public const int MentionRowsShown = 6; - /** How far under the caret's line the mention list starts, and stops above the toolbar. */ + /** The list's own padding above and under its rows (py-1), and its heading's height (one line of text-xs, py-1). */ + public const int MentionPadding = 8; + + public const int MentionHeadingHeight = 24; + + /** How far under the caret's line (or the field) the mention list starts, and stops above the toolbar. */ public const int MentionGap = 4; public const int MentionInset = 8; - /** The list's own padding above and under its rows (py-1). */ - public const int MentionPadding = 8; - /** * Before the field has said where its caret is (it says so as soon as it has focus, so only for a moment), the - * list goes under about one line. + * list goes under about one line, and a line is taken to be this tall. */ public const int FirstLineHeight = 24; /** - * The caret as the sheet keeps it: the bottom of its line and the field's visible height, in points. A caret the - * field has scrolled out of view is kept to its edges. + * The caret as the sheet keeps it, as the field shows it at its full height: the bottom of its line, the line's + * height, and the field's visible height, in points. A caret the field has scrolled out of view is kept to its + * edges. * - * @return array{bottom: float, field_height: float} + * @return array{bottom: float, line_height: float, field_height: float} */ public static function caret(Caret $caret): array { $field = max(0.0, $caret->fieldHeight); $bottom = max(0.0, $caret->bottom()); - return ['bottom' => $field > 0 ? min($bottom, $field) : $bottom, 'field_height' => $field]; + return [ + 'bottom' => $field > 0 ? min($bottom, $field) : $bottom, + 'line_height' => max(0.0, $caret->height), + 'field_height' => $field, + ]; } /** - * Where the mention list's top goes in the sheet's body area: just under the caret's line, or higher when that - * would leave it room for fewer than three people above the toolbar. The room is measured to the field's bottom, - * since the field doesn't say how tall what's under it is, so with a quoted commit under it the list can go up a - * little sooner than it has to. + * The caret to keep after the field reports a new one. While the field is shorter for the list, it reports + * itself at that height, scrolled to the caret, which says nothing about where the caret is at its full height, + * so the sheet keeps what it had. Any other report is the field at its full height. * - * @param array{bottom: float, field_height: float}|null $caret + * @param array{bottom: float, line_height: float, field_height: float}|null $kept + * @param int|null $shortened how tall the sheet has made the field, or null when it fills + * @return array{bottom: float, line_height: float, field_height: float} */ - public static function mentionTop(?array $caret): int + public static function reported(Caret $caret, ?array $kept, ?int $shortened): array { - if ($caret === null) { - return self::FieldTop + self::FirstLineHeight + self::MentionGap; + if ($kept !== null && $shortened !== null && abs($caret->fieldHeight - $shortened) <= 1) { + return $kept; } - $underCaret = self::FieldTop + (int) ceil($caret['bottom']) + self::MentionGap; + return self::caret($caret); + } - if ($caret['field_height'] <= 0) { - return $underCaret; + /** The mention list's height with all its rows showing, up to six: its padding, its heading, then its rows. */ + public static function mentionHeight(int $rows, bool $heading = false): int + { + return self::MentionPadding + + ($heading ? self::MentionHeadingHeight : 0) + + min(max($rows, 1), self::MentionRowsShown) * self::MentionRowHeight; + } + + /** + * Where the mention list goes, and how tall the field is while it shows. + * + * - `field`: the field's height, or null when it fills as usual. + * - `top`: the list's top. + * - `height`: the list's height, or null when it runs down to the toolbar. + * + * With room for the whole list (up to six rows) between the caret's line and the field's bottom, it floats there + * over the field and nothing moves. Without it, the field ends on the caret's line, shortened by as much as the + * list needs but never under two lines, and the list starts under it and runs to the toolbar, over anything + * under the field (which comes up with the field's bottom). So the list never covers the caret's line. + * + * The room is measured to the field's bottom, since nothing reports how tall what's under it is. + * + * @param array{bottom: float, line_height: float, field_height: float}|null $caret + * @return array{field: int|null, top: int, height: int|null} + */ + public static function mentionLayout(?array $caret, int $rows, bool $heading = false): array + { + if ($caret === null || $caret['field_height'] <= 0) { + $line = $caret === null ? self::FirstLineHeight : (int) ceil($caret['bottom']); + + return ['field' => null, 'top' => self::FieldTop + $line + self::MentionGap, 'height' => null]; } - $lowest = self::FieldTop + (int) floor($caret['field_height']) - - self::MentionInset - self::MentionMinRows * self::MentionRowHeight - self::MentionPadding; + $list = self::mentionHeight($rows, $heading); + $field = (int) floor($caret['field_height']); + $bottom = (int) ceil($caret['bottom']); + $room = $field - $bottom - self::MentionGap - self::MentionInset; - return max(0, min($underCaret, $lowest)); + if ($room >= $list) { + return ['field' => null, 'top' => self::FieldTop + $bottom + self::MentionGap, 'height' => $list]; + } + + $line = $caret['line_height'] > 0 ? (int) ceil($caret['line_height']) : self::FirstLineHeight; + $shortened = max(self::MinFieldLines * $line, $field - self::MentionGap - self::MentionInset - $list); + + if ($shortened >= $bottom) { + // The caret is in the field's first lines already: shortening it frees nothing, so the list takes what + // room there is under the caret, at least a row. + return [ + 'field' => null, + 'top' => self::FieldTop + $bottom + self::MentionGap, + 'height' => max($room, self::MentionPadding + self::MentionRowHeight), + ]; + } + + return ['field' => $shortened, 'top' => self::FieldTop + $shortened + self::MentionGap, 'height' => null]; + } + + /** Whether the sheet's mention list has the "People you follow" heading: a bare "@" in a new commit. */ + public static function mentionHeading(?array $mention, string $view): bool + { + return ($mention['query'] ?? null) === '' && $view === 'compose'; } } diff --git a/app/NativeComponents/Concerns/OpensCommitSheet.php b/app/NativeComponents/Concerns/OpensCommitSheet.php index b4fc25af..3964a976 100644 --- a/app/NativeComponents/Concerns/OpensCommitSheet.php +++ b/app/NativeComponents/Concerns/OpensCommitSheet.php @@ -113,10 +113,10 @@ trait OpensCommitSheet public string $sheetBody = ''; /** - * Where the sheet's field last said its caret is drawn, for the mention list to float under (see ComposerSheet). - * Null until it has said, and again once the sheet is gone. + * Where the sheet's field last said its caret is drawn at its full height, for the mention list to go under (see + * ComposerSheet). Null until it has said, and again once the sheet is gone. * - * @var array{bottom: float, field_height: float}|null + * @var array{bottom: float, line_height: float, field_height: float}|null */ public ?array $sheetCaret = null; @@ -322,7 +322,26 @@ public function openScheduledCommits(): void */ public function sheetCaretMoved(Caret $caret): void { - $this->sheetCaret = ComposerSheet::caret($caret); + $this->sheetCaret = ComposerSheet::reported($caret, $this->sheetCaret, $this->sheetMentionLayout()['field'] ?? null); + } + + /** + * Where the sheet's mention list goes and how tall its field is meanwhile (see ComposerSheet::mentionLayout()), or + * null while there's no list. + * + * @return array{field: int|null, top: int, height: int|null}|null + */ + public function sheetMentionLayout(): ?array + { + if (($this->mention['field'] ?? null) !== 'sheetBody' || ($this->mentionPeople === [] && $this->mentionOrganizations === [])) { + return null; + } + + return ComposerSheet::mentionLayout( + $this->sheetCaret, + count($this->mentionPeople) + count($this->mentionOrganizations), + ComposerSheet::mentionHeading($this->mention, $this->sheetView), + ); } public function updatedSheetBody(): void diff --git a/resources/views/native/partials/commit-sheet.blade.php b/resources/views/native/partials/commit-sheet.blade.php index 55a945c9..1f21c144 100644 --- a/resources/views/native/partials/commit-sheet.blade.php +++ b/resources/views/native/partials/commit-sheet.blade.php @@ -26,10 +26,13 @@ A commit's page opens its reply here too, as "Reply to @handle", with the commit being answered as a static card over the field, for the photos and the preview its reply bar has no room for. Commit says Reply there. - While the caret is after an "@handle", the people to mention float over the field just under the caret's line, - which the field reports (@caretChange), as the web's composer lists them (see SuggestsMentions): for a bare "@" in a new commit, the people you follow, under - that heading. They cover a quoted commit too, and run down to the toolbar. The field keeps the keyboard up through - presses in the sheet (keep-focus), so picking someone leaves you typing after them. + While the caret is after an "@handle", the people to mention show as the web's composer lists them (see + SuggestsMentions): for a bare "@" in a new commit, the people you follow, under that heading. They float over the + field just under the caret's line, which the field reports (@caretChange), as tall as their rows, up to six. When + that doesn't fit above the field's bottom, the field gets shorter instead, ending on the caret's line, and the + list goes under it, down to the toolbar and over a quoted commit or poll (see ComposerSheet). The field fills + again once they're gone, and both moves are animated. The field keeps the keyboard up through presses in the sheet + (keep-focus), so picking someone leaves you typing after them. The sheet doesn't scroll. The field fills the space between the author row and the toolbar, less what's under it: the photos as a strip of 80pt squares, the poll editor, the commit being quoted, or "Submit at", each at its own @@ -105,7 +108,14 @@ @include('native.partials.quoted-commit', ['quoted' => $sheetCommit, 'static' => true, 'label' => 'Replying to']) @endif - + @php($sheetMentionsShown = ! $previewing && ($mention['field'] ?? null) === 'sheetBody' && ($mentionPeople !== [] || $mentionOrganizations !== [])) + @php($sheetMentions = $sheetMentionsShown ? $sheetLayout::mentionLayout($sheetCaret, count($mentionPeople) + count($mentionOrganizations), $sheetLayout::mentionHeading($mention, $sheetView)) : null) + {{-- + animate-layout: when the mention list comes or goes (or photos, the poll, the preview), the field + slot's new height and the parts under it slide into place rather than jump. The parts keep their + keys, so they're matched from one frame to the next. + --}} + @if ($previewing) @@ -121,7 +131,8 @@ @else - + {{-- Shorter while the mention list needs the room under it (see ComposerSheet::mentionLayout()), the slot keeps its key and place, so the field stays the same view. --}} + {{-- - The people to mention float over the field and whatever is under it, out of the layout, so - nothing moves when they come and go. They start just under the line the caret is on, where - the field says it is (see ComposerSheet::mentionTop()), and run down to the toolbar, - scrolling inside when there are more than fit. On Liquid Glass on iOS, like the reply - bar's, and on a raised surface on Android. + The people to mention, out of the layout so nothing moves when they come and go unless the + field has to make room for them: just under the caret's line, as tall as their rows, or + under the shortened field down to the toolbar (see ComposerSheet::mentionLayout()). They + scroll inside past six rows, or when even the shortened field leaves less room. On Liquid + Glass on iOS, like the reply bar's, and on a raised surface on Android. --}} - @if (($mention['field'] ?? null) === 'sheetBody' && ($mentionPeople !== [] || $mentionOrganizations !== [])) + @if ($sheetMentions !== null) @include('native.partials.mention-suggestions', [ 'field' => 'sheetBody', - 'heading' => ($mention['query'] ?? null) === '' && $sheetView === 'compose' ? 'People you follow' : null, + 'heading' => $sheetLayout::mentionHeading($mention, $sheetView) ? 'People you follow' : null, 'label' => 'Mention a developer', 'class' => 'w-full py-1', ]) diff --git a/tests/Feature/Screens/CommitMentionsTest.php b/tests/Feature/Screens/CommitMentionsTest.php index effbc57e..4ee44cb0 100644 --- a/tests/Feature/Screens/CommitMentionsTest.php +++ b/tests/Feature/Screens/CommitMentionsTest.php @@ -6,6 +6,7 @@ use Native\Mobile\Testing\Native; use Native\Mobile\Testing\TestableComponent; use Native\Mobile\UI\Caret; +use Tests\Support\LayoutAnimation; use Tests\Support\TextFieldFill; beforeEach(function () { @@ -185,7 +186,7 @@ function mentionsComposer(bool $quoting = false): TestableComponent ->assertSet('mentionPeople', []); }); -it('floats the suggestions over the quoted commit on glass, from just under the caret line down to the toolbar', function () { +it('floats the suggestions over the quoted commit on glass, just under the caret line and as tall as their rows', function () { TextFieldFill::skipUnlessSupported(); $screen = mentionsComposer(quoting: true) @@ -198,9 +199,12 @@ function mentionsComposer(bool $quoting = false): TestableComponent ->and($overlay['layout']['position'])->toEqual([ ComposerSheet::FieldTop + 44 + ComposerSheet::MentionGap, 12, - ComposerSheet::MentionInset, + null, 12, ]) + ->and($overlay['layout']['height'] ?? null)->toEqual(ComposerSheet::mentionHeight(3)) + // There's room for them under the caret, so the field still fills. + ->and(nodeByRef($screen, 'sheet-field-slot')['layout']['flex_grow'] ?? null)->toEqual(1) ->and($overlay['props']['glass'])->toBe(1) ->and(childRefs($screen, 'sheet-body-area'))->toBe(['sheet-field-slot', 'sheet-below', 'sheet-mentions']) ->and(findNode(nodeByRef($screen, 'sheet-below'), fn (array $node): bool => ($node['ref'] ?? null) === 'quote-card'))->not->toBeNull() @@ -209,6 +213,42 @@ function mentionsComposer(bool $quoting = false): TestableComponent ->and(childRefs($screen, 'mention-suggestions'))->toBe(['mention-ada', 'mention-adam', 'mention-adaptive']); }); +it('shortens the field to end on the caret line when the suggestions would not fit under it, and fills it again once they go', function () { + TextFieldFill::skipUnlessSupported(); + + $screen = mentionsComposer(quoting: true)->input('sheet-body', "see\n\n\n\n\n\n\n\n@a", 14); + $field = idsDownTo($screen->tree(), 'sheet-body'); + + // The caret's line ends 20pt above the field's bottom, where three people don't fit. + $screen->moveCaretTo('sheet-body', new Caret(x: 20, y: 196, width: 2, height: 24, line: 8, fieldWidth: 350, fieldHeight: 240)); + $shortened = 240 - ComposerSheet::MentionGap - ComposerSheet::MentionInset - ComposerSheet::mentionHeight(3); + $overlay = nodeByRef($screen, 'sheet-mentions'); + + expect(nodeByRef($screen, 'sheet-field-slot')['layout']['height'] ?? null)->toEqual(ComposerSheet::FieldTop + $shortened) + ->and(nodeByRef($screen, 'sheet-field-slot')['layout']['flex_grow'] ?? 0)->toEqual(0) + // Under the shortened field, so off the caret's line, and down to the toolbar over the quoted commit. + ->and($overlay['layout']['position'])->toEqual([ComposerSheet::FieldTop + $shortened + ComposerSheet::MentionGap, 12, ComposerSheet::MentionInset, 12]) + ->and(childRefs($screen, 'sheet-body-area'))->toBe(['sheet-field-slot', 'sheet-below', 'sheet-mentions']) + ->and(idsDownTo($screen->tree(), 'sheet-body'))->toBe($field); + + // The shortened field reports its caret at its new height, which doesn't move anything. + $screen->moveCaretTo('sheet-body', new Caret(x: 20, y: $shortened - 24, width: 2, height: 24, line: 8, fieldWidth: 350, fieldHeight: $shortened)) + ->assertSet('sheetCaret', ['bottom' => 220.0, 'line_height' => 24.0, 'field_height' => 240.0]); + + // Picked, the list goes and the field fills again, the same view. + $screen->tap('mention-ada'); + expect(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'sheet-mentions'))->toBeNull() + ->and(nodeByRef($screen, 'sheet-field-slot')['layout']['flex_grow'] ?? null)->toEqual(1) + ->and(nodeByRef($screen, 'sheet-field-slot')['layout'])->not->toHaveKey('height') + ->and(idsDownTo($screen->tree(), 'sheet-body'))->toBe($field); +}); + +it('animates the field and the suggestions moving in the sheet', function () { + LayoutAnimation::skipUnlessSupported(); + + expect(nodeByRef(mentionsComposer(), 'sheet-body-area')['props'])->toHaveKey('animate_layout', true); +}); + it('draws the floating suggestions on a raised surface on Android', function () { fakeApi([ 'GET /api/v1/log/following' => [pageJson([])], diff --git a/tests/Feature/Screens/ComposeSheetTest.php b/tests/Feature/Screens/ComposeSheetTest.php index 100b5877..1bfc7e9b 100644 --- a/tests/Feature/Screens/ComposeSheetTest.php +++ b/tests/Feature/Screens/ComposeSheetTest.php @@ -312,7 +312,7 @@ function sheetCommitDisabled(TestableComponent $screen): bool $screen = composeSheetOnLog() ->moveCaretTo('sheet-body', new Caret(y: 48, height: 24, line: 2, fieldWidth: 350, fieldHeight: 240)) - ->assertSet('sheetCaret', ['bottom' => 72.0, 'field_height' => 240.0]); + ->assertSet('sheetCaret', ['bottom' => 72.0, 'line_height' => 24.0, 'field_height' => 240.0]); $screen->press('hideCommitSheet')->assertSet('sheetCaret', null); }); diff --git a/tests/Support/LayoutAnimation.php b/tests/Support/LayoutAnimation.php new file mode 100644 index 00000000..155686c8 --- /dev/null +++ b/tests/Support/LayoutAnimation.php @@ -0,0 +1,25 @@ +markTestSkipped('Needs a mobile-air with layout animation (NativePHP/mobile-air#736)'); + } + } +} diff --git a/tests/Unit/Devnull/ComposerSheetTest.php b/tests/Unit/Devnull/ComposerSheetTest.php index 28ccd184..8832a306 100644 --- a/tests/Unit/Devnull/ComposerSheetTest.php +++ b/tests/Unit/Devnull/ComposerSheetTest.php @@ -6,25 +6,81 @@ beforeEach(fn () => TextFieldFill::skipUnlessSupported()); -it('starts the mention list just under the line the field says the caret is on', function () { - $caret = ComposerSheet::caret(new Caret(y: 48, height: 24, line: 2, fieldHeight: 300)); +/** A field 360pt tall, as on a phone with the keyboard up, with its caret's line ending at $bottom. */ +function composerCaret(float $bottom, float $fieldHeight = 360): array +{ + return ComposerSheet::caret(new Caret(y: $bottom - 24, height: 24, fieldHeight: $fieldHeight)); +} - expect(ComposerSheet::mentionTop($caret))->toBe(ComposerSheet::FieldTop + 72 + ComposerSheet::MentionGap); +it('floats the list just under the caret, as tall as its rows, when they fit above the field\'s bottom', function () { + $layout = ComposerSheet::mentionLayout(composerCaret(72), rows: 3); + + expect($layout)->toBe([ + 'field' => null, + 'top' => ComposerSheet::FieldTop + 72 + ComposerSheet::MentionGap, + 'height' => ComposerSheet::MentionPadding + 3 * ComposerSheet::MentionRowHeight, + ]); +}); + +it('holds the list to six rows, plus its heading, and scrolls the rest', function () { + expect(ComposerSheet::mentionHeight(10))->toBe(ComposerSheet::MentionPadding + 6 * ComposerSheet::MentionRowHeight) + ->and(ComposerSheet::mentionHeight(2, heading: true))->toBe(ComposerSheet::MentionPadding + ComposerSheet::MentionHeadingHeight + 2 * ComposerSheet::MentionRowHeight); +}); + +it('shortens the field to end on the caret\'s line when the list would not fit under it, and puts the list under the field', function () { + // The caret low in the field, as in build 42: six people need 272pt, and there's 360 - 300 under the caret. + $layout = ComposerSheet::mentionLayout(composerCaret(300), rows: 8); + $list = ComposerSheet::mentionHeight(8); + $field = 360 - ComposerSheet::MentionGap - ComposerSheet::MentionInset - $list; + + expect($layout)->toBe(['field' => $field, 'top' => ComposerSheet::FieldTop + $field + ComposerSheet::MentionGap, 'height' => null]) + // The list starts under the caret's line, never over it: the field ends on that line. + ->and($layout['top'])->toBeGreaterThan(ComposerSheet::FieldTop + $layout['field']) + // And the list has its six rows from there to the toolbar. + ->and(ComposerSheet::FieldTop + 360 - ComposerSheet::MentionInset - $layout['top'])->toBe($list); +}); + +it('shortens the field only as far as the list needs', function () { + $layout = ComposerSheet::mentionLayout(composerCaret(300), rows: 2); + + expect($layout['field'])->toBe(360 - ComposerSheet::MentionGap - ComposerSheet::MentionInset - ComposerSheet::mentionHeight(2)) + ->and($layout['field'])->toBeLessThan(300); +}); + +it('keeps two lines of field on a short phone, and the list scrolls in what\'s left', function () { + $layout = ComposerSheet::mentionLayout(composerCaret(140, fieldHeight: 160), rows: 6); + + expect($layout)->toBe(['field' => ComposerSheet::MinFieldLines * 24, 'top' => ComposerSheet::FieldTop + 48 + ComposerSheet::MentionGap, 'height' => null]); +}); + +it('leaves the field alone when the caret is already in its first lines', function () { + $layout = ComposerSheet::mentionLayout(composerCaret(24, fieldHeight: 160), rows: 6); + + expect($layout['field'])->toBeNull() + ->and($layout['top'])->toBe(ComposerSheet::FieldTop + 24 + ComposerSheet::MentionGap) + ->and($layout['height'])->toBe(160 - 24 - ComposerSheet::MentionGap - ComposerSheet::MentionInset); }); -it('moves the list up when the caret is too near the field\'s bottom to leave room for three people', function () { - $lowest = ComposerSheet::FieldTop + 300 - ComposerSheet::MentionInset - ComposerSheet::MentionMinRows * ComposerSheet::MentionRowHeight - ComposerSheet::MentionPadding; +it('keeps where the caret is at the field\'s full height while the field is shortened', function () { + $kept = composerCaret(300); + $shortened = ComposerSheet::mentionLayout($kept, rows: 8)['field']; - expect(ComposerSheet::mentionTop(ComposerSheet::caret(new Caret(y: 264, height: 24, fieldHeight: 300))))->toBe($lowest) - // A field too short for three people puts the list at the top of it. - ->and(ComposerSheet::mentionTop(ComposerSheet::caret(new Caret(y: 24, height: 24, fieldHeight: 80))))->toBe(0); + // The shortened field reports itself scrolled to the caret: that's not where the caret is at full height. + expect(ComposerSheet::reported(new Caret(y: $shortened - 24, height: 24, fieldHeight: $shortened), $kept, $shortened))->toBe($kept) + // A report at another height is the field at its full height again. + ->and(ComposerSheet::reported(new Caret(y: 48, height: 24, fieldHeight: 360), $kept, $shortened))->toBe(composerCaret(72)) + ->and(ComposerSheet::reported(new Caret(y: 48, height: 24, fieldHeight: 360), $kept, null))->toBe(composerCaret(72)); }); it('keeps a caret the field has scrolled out of view to the field\'s edges', function () { - expect(ComposerSheet::caret(new Caret(y: -60, height: 24, fieldHeight: 300)))->toBe(['bottom' => 0.0, 'field_height' => 300.0]) - ->and(ComposerSheet::caret(new Caret(y: 400, height: 24, fieldHeight: 300)))->toBe(['bottom' => 300.0, 'field_height' => 300.0]); + expect(ComposerSheet::caret(new Caret(y: -60, height: 24, fieldHeight: 300)))->toBe(['bottom' => 0.0, 'line_height' => 24.0, 'field_height' => 300.0]) + ->and(ComposerSheet::caret(new Caret(y: 400, height: 24, fieldHeight: 300)))->toBe(['bottom' => 300.0, 'line_height' => 24.0, 'field_height' => 300.0]); }); -it('puts the list under about one line before the field has said where its caret is', function () { - expect(ComposerSheet::mentionTop(null))->toBe(ComposerSheet::FieldTop + ComposerSheet::FirstLineHeight + ComposerSheet::MentionGap); +it('puts the list under about one line, down to the toolbar, before the field has said where its caret is', function () { + expect(ComposerSheet::mentionLayout(null, rows: 3))->toBe([ + 'field' => null, + 'top' => ComposerSheet::FieldTop + ComposerSheet::FirstLineHeight + ComposerSheet::MentionGap, + 'height' => null, + ]); }); From 75cb547a4c2f8d66b6a9898882f82c252a7d6f4d Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Sat, 21 Nov 2026 11:00:46 +0000 Subject: [PATCH 04/11] Ask the sheet's mention list not to scroll inside its own scroll view The sheet sizes its mention list and scrolls it. #196 gives the shared mention list a six-row scroll view of its own, so once both are merged a list of more than six would show two scroll bars on a short phone. The sheet now passes 'scrolls' => false, which #196 adds. Before #196 merges the partial ignores it. Co-Authored-By: Claude Opus 5.5 --- .../native/partials/commit-sheet.blade.php | 2 ++ tests/Feature/Screens/CommitMentionsTest.php | 21 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/resources/views/native/partials/commit-sheet.blade.php b/resources/views/native/partials/commit-sheet.blade.php index 1f21c144..752f5022 100644 --- a/resources/views/native/partials/commit-sheet.blade.php +++ b/resources/views/native/partials/commit-sheet.blade.php @@ -191,6 +191,8 @@ class="absolute left-[12] right-[12] top-[{{ $sheetMentions['top'] }}] {{ $sheet 'heading' => $sheetLayout::mentionHeading($mention, $sheetView) ? 'People you follow' : null, 'label' => 'Mention a developer', 'class' => 'w-full py-1', + // This scroll view scrolls them; the partial's own six-row one would be a second. + 'scrolls' => false, ]) diff --git a/tests/Feature/Screens/CommitMentionsTest.php b/tests/Feature/Screens/CommitMentionsTest.php index 4ee44cb0..471b2886 100644 --- a/tests/Feature/Screens/CommitMentionsTest.php +++ b/tests/Feature/Screens/CommitMentionsTest.php @@ -74,11 +74,11 @@ function mentionsCommitPage(?array $mentions = null): TestableComponent * The Log, with Ada's c1 in it and devnull's mention search answering, and the composer sheet open: for a new commit, * or for a quote of c1. */ -function mentionsComposer(bool $quoting = false): TestableComponent +function mentionsComposer(bool $quoting = false, ?array $mentions = null): TestableComponent { fakeApi([ 'GET /api/v1/log/following' => [pageJson([commitJson(['id' => 'c1', 'body' => 'Required reading.', 'author' => userJson(['id' => 'u2', 'handle' => 'ada', 'name' => 'Ada Lovelace'])])])], - 'GET /api/v1/search/mentions' => mentionsFound(), + 'GET /api/v1/search/mentions' => $mentions ?? mentionsFound(), ]); $screen = Native::visit('/log', platform: 'ios'); @@ -213,6 +213,23 @@ function mentionsComposer(bool $quoting = false): TestableComponent ->and(childRefs($screen, 'mention-suggestions'))->toBe(['mention-ada', 'mention-adam', 'mention-adaptive']); }); +it('scrolls a long list of suggestions in the sheet with one scroll view, its own', function () { + TextFieldFill::skipUnlessSupported(); + + $people = array_map(fn (int $n): array => userJson(['id' => "u{$n}", 'handle' => "ada{$n}", 'name' => "Ada {$n}"]), range(1, 9)); + $screen = mentionsComposer(mentions: [['data' => $people]]) + ->input('sheet-body', "see\n\n\n\n\n\n@a", 12) + ->moveCaretTo('sheet-body', new Caret(x: 20, y: 132, width: 2, height: 22, line: 6, fieldWidth: 350, fieldHeight: 240)); + $overlay = nodeByRef($screen, 'sheet-mentions'); + + // Nine rows is past the six the mention list scrolls by itself, but the sheet scrolls it already, so there is no + // second scroll view inside (two scroll bars on a short phone). + expect(findNodes($overlay, fn (array $node): bool => $node['type'] === 'scroll_view'))->toHaveCount(1) + ->and(nodeByRef($screen, 'sheet-mentions-scroll')['type'])->toBe('scroll_view') + ->and(rendersRef($screen, 'mention-scroll'))->toBeFalse() + ->and(childRefs($screen, 'mention-suggestions'))->toBe(array_map(fn (int $n): string => "mention-ada{$n}", range(1, 9))); +}); + it('shortens the field to end on the caret line when the suggestions would not fit under it, and fills it again once they go', function () { TextFieldFill::skipUnlessSupported(); From de4235bed5ec8e8920c23898f8ce779dcff611db Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Sun, 22 Nov 2026 10:23:02 +0000 Subject: [PATCH 05/11] Blur what scrolls under the composer bars with iOS 26's scroll edge effect Both composer bars now carry scroll-edge-soft next to glass/80. With a mobile-air that knows the class, iOS 26 and later draw the system scroll edge effect under the bar, a progressive blur like the one under its own toolbars, and the bar drops its fade row and the tint on its rows so the effect shows. Older iOS keeps the fade over glass, and Android its fade over the surface. Which iOS the phone runs comes from System::osVersion(). Without a mobile-air that has it, every iOS keeps the fade, and the new tests skip (tests/Support/ScrollEdge.php). Co-Authored-By: Claude Opus 5.5 --- app/Devnull/Display.php | 52 ++++++++++++++++++- app/NativeComponents/Conversation.php | 2 +- .../views/native/commit-detail.blade.php | 7 +-- resources/views/native/conversation.blade.php | 5 +- .../native/partials/composer-fade.blade.php | 3 +- .../Devnull/ComposerScrollEdgeTest.php | 45 ++++++++++++++++ tests/Feature/Screens/CommitDetailTest.php | 29 +++++++++++ tests/Feature/Screens/RemotesComposerTest.php | 17 ++++++ tests/Support/ScrollEdge.php | 48 +++++++++++++++++ 9 files changed, 199 insertions(+), 9 deletions(-) create mode 100644 tests/Feature/Devnull/ComposerScrollEdgeTest.php create mode 100644 tests/Support/ScrollEdge.php diff --git a/app/Devnull/Display.php b/app/Devnull/Display.php index 6648e4e7..32e9d307 100644 --- a/app/Devnull/Display.php +++ b/app/Devnull/Display.php @@ -5,6 +5,7 @@ use App\Devnull\Data\CommitBody; use Carbon\CarbonImmutable; use Carbon\CarbonInterface; +use Native\Mobile\Facades\System; use Native\Mobile\Platform; /** @@ -50,6 +51,11 @@ final class Display */ public const int ComposerGlassOpacity = 80; + /** + * The first iOS whose scroll views draw a scroll edge effect under a bar (see hasScrollEdge()). + */ + public const int ScrollEdgeIosVersion = 26; + /** * About how many characters fit on a line of the box's field, which runs the width of the box. */ @@ -253,7 +259,7 @@ public static function maskedKey(string $openSsh): string */ public static function replyBarClearance(string $draft, bool $hasPhotos = false, bool $describing = false): int { - return self::ComposerFadeHeight + return self::composerFadeHeight() + self::ComposerBoxBarHeight + self::composerBoxGrowth($draft) + ($hasPhotos ? self::ReplyBarPhotosHeight : 0) @@ -302,6 +308,40 @@ public static function fadesInBar(): bool return Platform::isIos(); } + /** + * Whether the composer bars stand on iOS's own scroll edge effect: iOS 26 and later blur what scrolls under the + * bar progressively, as under its own toolbars, from the bar's scroll-edge-soft class (see composerBarGlass()). + * That stands in for the fade and the tinted glass, so a bar there draws neither and lets the effect show. Older + * iOS keeps the fade over glass, and Android its fade over the surface. + * + * It needs a mobile-air that draws the effect for a bottom bar and says which iOS the phone runs + * (System::osVersion()). Without one this is false and every iOS keeps the fade. + */ + public static function hasScrollEdge(): bool + { + if (! Platform::isIos() || ! method_exists(\Native\Mobile\System::class, 'osVersion')) { + return false; + } + + return (int) System::osVersion() >= self::ScrollEdgeIosVersion; + } + + /** + * Whether a composer bar draws partials/composer-fade as its first row: on iOS, before the scroll edge effect. + */ + public static function fadeRowInBar(): bool + { + return self::fadesInBar() && ! self::hasScrollEdge(); + } + + /** + * How tall the composer fade is where it's drawn: none where the scroll edge effect replaces it. + */ + public static function composerFadeHeight(): int + { + return self::hasScrollEdge() ? 0 : self::ComposerFadeHeight; + } + /** * The classes for a composer's native:bottom-bar. On iOS that's Liquid Glass: what scrolls under the bar shows * through it, blurred. A patched mobile-air draws the glass behind the whole bar, under the home indicator too, @@ -309,10 +349,14 @@ public static function fadesInBar(): bool * an element can't be faded, and stops short of the home indicator. The glass stops at ComposerGlassOpacity * percent (glass/N), so a little of the screen under the bar shows through. Android has no glass, so the bar * stays the surface there. + * + * scroll-edge-soft asks iOS 26 and later for its scroll edge effect under the bar instead, a progressive blur + * like the one under its own toolbars, and a patched mobile-air leaves the glass out there (see hasScrollEdge()). + * Older iOS ignores it and keeps the glass. */ public static function composerBarGlass(): string { - return self::fadesInBar() ? 'glass/'.self::ComposerGlassOpacity : ''; + return self::fadesInBar() ? 'glass/'.self::ComposerGlassOpacity.' scroll-edge-soft' : ''; } /** @@ -333,6 +377,10 @@ public static function composerBar(): string */ public static function composerSurface(): string { + if (self::hasScrollEdge()) { + return ''; + } + return self::fadesInBar() ? 'bg-theme-surface/'.self::ComposerGlassTint : 'bg-theme-surface'; } diff --git a/app/NativeComponents/Conversation.php b/app/NativeComponents/Conversation.php index 3f8767e5..8bd97c9b 100644 --- a/app/NativeComponents/Conversation.php +++ b/app/NativeComponents/Conversation.php @@ -1839,7 +1839,7 @@ private function longPins(): array */ private static function composerClearance(string $draft, bool $replying, bool $hasPhotos, bool $describing): int { - return Display::ComposerFadeHeight + self::ComposerBarHeight + Display::composerBoxGrowth($draft) + return Display::composerFadeHeight() + self::ComposerBarHeight + Display::composerBoxGrowth($draft) + ($replying ? self::ReplyingBarHeight : 0) + ($hasPhotos ? self::PhotosHeight : 0) + ($hasPhotos && $describing ? self::DescriptionHeight : 0) diff --git a/resources/views/native/commit-detail.blade.php b/resources/views/native/commit-detail.blade.php index 5d26c304..91978b39 100644 --- a/resources/views/native/commit-detail.blade.php +++ b/resources/views/native/commit-detail.blade.php @@ -135,8 +135,9 @@ The reply bar, drawn as the Remotes composer is: the field across the top and a row under it with the tools on the left and the round send button on the right (see partials/composer-box), with the page fading out above it (see partials/composer-fade). On iOS the bar is Liquid Glass, faded in at the top, so the page - shows through it blurred (see Display::composerBarGlass()). On Android it's the surface, painted from this - column. Either fills the strip under the home indicator. + shows through it blurred (see Display::composerBarGlass()). From iOS 26 the system's scroll edge effect + blurs the page under the bar instead, with no fade or glass (see Display::hasScrollEdge()). 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 @@ -153,7 +154,7 @@ @php($replyPostsAs = $replyPostingMe !== null && \App\Devnull\PostAs::offered($replyAuthor)) - @if (\App\Devnull\Display::fadesInBar()) + @if (\App\Devnull\Display::fadeRowInBar()) @include('native.partials.composer-fade', ['ref' => 'reply-fade', 'inBar' => true]) @endif diff --git a/resources/views/native/conversation.blade.php b/resources/views/native/conversation.blade.php index 5191385f..c68a3c5a 100644 --- a/resources/views/native/conversation.blade.php +++ b/resources/views/native/conversation.blade.php @@ -81,14 +81,15 @@ The composer: the field over a row holding the + and the round send button (see partials/composer-box), with the thread fading out above it (see partials/composer-fade) rather than meeting a line. On iOS the bar is Liquid Glass, faded in at the top, so the thread shows through it blurred (see - Display::composerBarGlass()). On Android it's the surface. Either fills the strip under the home indicator. + Display::composerBarGlass()). From iOS 26 the system's scroll edge effect blurs the thread under the bar + instead, with no fade or glass (see Display::hasScrollEdge()). On Android it's the surface. Either fills the strip under the home indicator. The web's tools, photos, the microphone and Ping, open from the one +. Above the field sit the people to mention, what you're replying to and the photos on the draft. While the thread can't take a message, why goes in the field's place. --}} - @if (\App\Devnull\Display::fadesInBar()) + @if (\App\Devnull\Display::fadeRowInBar()) @include('native.partials.composer-fade', ['ref' => 'composer-fade', 'inBar' => true]) @endif diff --git a/resources/views/native/partials/composer-fade.blade.php b/resources/views/native/partials/composer-fade.blade.php index 7a817f43..023b2a87 100644 --- a/resources/views/native/partials/composer-fade.blade.php +++ b/resources/views/native/partials/composer-fade.blade.php @@ -6,7 +6,8 @@ Where it goes depends on the platform (Display::fadesInBar()). On iOS the screen runs on under the bar, so the fade is the bar's first row ($inBar), over what runs under it, and the bar's glass fades in under it over the same height (see Display::composerBarGlass()). On Android the screen stops at the bar, so the fade lies over the foot of - the screen's scroll view, at the bottom of the stack around it. $ref names it. + the screen's scroll view, at the bottom of the stack around it. From iOS 26 there's no fade at all: the system's + scroll edge effect blurs what runs under the bar (Display::fadeRowInBar()). $ref names it. --}} @php($inBar ??= false) diff --git a/tests/Feature/Devnull/ComposerScrollEdgeTest.php b/tests/Feature/Devnull/ComposerScrollEdgeTest.php new file mode 100644 index 00000000..2da10027 --- /dev/null +++ b/tests/Feature/Devnull/ComposerScrollEdgeTest.php @@ -0,0 +1,45 @@ +toBe($edge) + ->and(Display::fadeRowInBar())->toBe($platform === 'ios' && ! $edge) + ->and(Display::composerFadeHeight())->toBe($edge ? 0 : Display::ComposerFadeHeight) + ->and(Display::composerSurface() === '')->toBe($edge); + } finally { + System::rememberPlatform(null); + } + }); +})->with([ + 'iOS 18' => ['ios', '18.5', false], + 'iOS 26' => ['ios', '26.0', true], + 'iOS 26.1' => ['ios', '26.1', true], + 'iOS 27' => ['ios', '27.0.1', true], + 'Android 16' => ['android', '16', false], + 'Android 26' => ['android', '26', false], +]); + +it('asks iOS for the soft scroll edge effect under the composer bars, over glass for older iOS', function () { + System::rememberPlatform('ios'); + + try { + expect(Display::composerBarGlass())->toBe('glass/'.Display::ComposerGlassOpacity.' scroll-edge-soft'); + } finally { + System::rememberPlatform(null); + } + + System::rememberPlatform('android'); + + try { + expect(Display::composerBarGlass())->toBe(''); + } finally { + System::rememberPlatform(null); + } +}); diff --git a/tests/Feature/Screens/CommitDetailTest.php b/tests/Feature/Screens/CommitDetailTest.php index 591eb7f1..4a9bda70 100644 --- a/tests/Feature/Screens/CommitDetailTest.php +++ b/tests/Feature/Screens/CommitDetailTest.php @@ -10,6 +10,7 @@ use Native\Mobile\Events\Alert\ButtonPressed; use Native\Mobile\Testing\Native; use Tests\Support\GlassOpacity; +use Tests\Support\ScrollEdge; beforeEach(function () { config(['devnull.url' => 'http://devnull.test']); @@ -927,6 +928,34 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): expect($bottomBar['props']['glass_opacity'] ?? null)->toBe($platform === 'ios' ? Display::ComposerGlassOpacity / 100 : null); })->with(['ios', 'android']); +it('stands the reply bar on the scroll edge effect from iOS 26, with no fade or tint, and glass for older iOS', function () { + fakeThread(replies: [replyJson(['id' => 'r1', 'parent_id' => 'c2', 'body' => 'The last reply'])]); + + ScrollEdge::onIos('26.1', function (): void { + $screen = Native::visit('/log/commits/c2', platform: 'ios'); + $bottomBar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); + + // The bar asks for the soft edge effect and keeps its glass for older iOS, which mobile-air leaves out here. + // The page ends where the bar starts, with no fade above it to clear. + expect($bottomBar['props']['scroll_edge'] ?? null)->toBe(1) + ->and($bottomBar['props']['glass'] ?? null)->toBe(1) + ->and(childRefs($screen, 'reply-bar'))->toBe(['reply-rows']) + ->and(nodeByRef($screen, 'reply-rows')['style']['bg_color'] ?? null)->toBeNull() + ->and(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'reply-fade'))->toBeNull() + ->and(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual(24 + Display::ComposerBoxBarHeight + 34); + }); +}); + +it('keeps the fade at the top of the reply bar before iOS 26', function () { + fakeThread(); + + ScrollEdge::onIos('18.5', function (): void { + $screen = Native::visit('/log/commits/c2', platform: 'ios'); + + expect(childRefs($screen, 'reply-bar'))->toBe(['reply-fade', 'reply-rows']); + }); +}); + 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'])]); diff --git a/tests/Feature/Screens/RemotesComposerTest.php b/tests/Feature/Screens/RemotesComposerTest.php index 6e3e0079..eb0c0be8 100644 --- a/tests/Feature/Screens/RemotesComposerTest.php +++ b/tests/Feature/Screens/RemotesComposerTest.php @@ -11,6 +11,7 @@ use Native\Mobile\Testing\Native; use Native\Mobile\Testing\TestableComponent; use Tests\Support\GlassOpacity; +use Tests\Support\ScrollEdge; const ComposerViewerId = '0199e5c4-0000-7000-8000-000000000001'; @@ -341,6 +342,22 @@ function threadWithAda(string $platform = 'ios'): TestableComponent } })->with(['ios', 'android']); +it('stands the message bar on the scroll edge effect from iOS 26, with no fade or tint', function () { + serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]); + + ScrollEdge::onIos('26.0', function (): void { + $screen = threadWithAda(); + $bottomBar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); + + expect($bottomBar['props']['scroll_edge'] ?? null)->toBe(1) + ->and(childRefs($screen, 'composer-bar'))->toBe(['composer-rows']) + ->and(nodeByRef($screen, 'composer-bar')['style']['bg_color'] ?? null)->toBeNull() + ->and(nodeByRef($screen, 'composer-rows')['style']['bg_color'] ?? null)->toBeNull() + ->and(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'composer-fade'))->toBeNull() + ->and(nodeByRef($screen, 'composer-clearance')['layout']['height'] ?? null)->toEqual(Conversation::ComposerBarHeight + 8); + }); +}); + it('fades to the dark surface in dark mode, and draws again when the phone switches', function () { serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]); diff --git a/tests/Support/ScrollEdge.php b/tests/Support/ScrollEdge.php new file mode 100644 index 00000000..a6d073b3 --- /dev/null +++ b/tests/Support/ScrollEdge.php @@ -0,0 +1,48 @@ +markTestSkipped('Needs a mobile-air with scroll-edge-soft on a bottom bar and System::osVersion()'); + } + } + + /** + * Run $test as on a phone with this iOS, then forget it again. + * + * @template T + * + * @param callable(): T $test + * @return T + */ + public static function onIos(string $version, callable $test): mixed + { + self::skipUnlessSupported(); + + System::rememberOsVersion($version); + + try { + return $test(); + } finally { + System::rememberOsVersion(null); + } + } +} From 65bd2cefd7655c7a23ee68d6d427bebc245707d2 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Sun, 22 Nov 2026 11:10:16 +0000 Subject: [PATCH 06/11] Put the composer back in a glass box over the edge blur From iOS 26 the field and its row of tools on the commit page's reply bar and the Remote composer sit in a rounded Liquid Glass box, 16pt in from the screen's sides, over the system's scroll edge effect. The bar asks for the effect with mobile-air's new edge-blur attribute in place of the old scroll-edge-soft class. Two Display constants switch it: ComposerInGlassBox (on) and ComposerEdgeBlur ("soft", or "hard" for the opaque fade). In the box the field sits 16pt under the box's edge, as far as it sits above the tools, and the send button is 8pt in from the box's right and bottom edges, so the box is rounded at 24. That makes the bar 6pt taller, which the page and thread clearances follow. Older iOS and Android draw the bars as before. Co-Authored-By: Claude Opus 5.5 --- app/Devnull/Display.php | 85 ++++++++++++++++--- app/NativeComponents/Conversation.php | 2 +- .../views/native/commit-detail.blade.php | 7 +- resources/views/native/conversation.blade.php | 6 +- .../native/partials/composer-box.blade.php | 13 +-- .../Devnull/ComposerScrollEdgeTest.php | 22 ++++- tests/Feature/Screens/CommitDetailTest.php | 12 +-- tests/Feature/Screens/RemotesComposerTest.php | 5 +- tests/Support/ScrollEdge.php | 8 +- 9 files changed, 124 insertions(+), 36 deletions(-) diff --git a/app/Devnull/Display.php b/app/Devnull/Display.php index 32e9d307..e4f75b03 100644 --- a/app/Devnull/Display.php +++ b/app/Devnull/Display.php @@ -5,6 +5,7 @@ use App\Devnull\Data\CommitBody; use Carbon\CarbonImmutable; use Carbon\CarbonInterface; +use Native\Mobile\Edge\Elements\BottomBar; use Native\Mobile\Facades\System; use Native\Mobile\Platform; @@ -56,6 +57,24 @@ final class Display */ public const int ScrollEdgeIosVersion = 26; + /** + * Whether a composer's field and its row of tools sit in a rounded Liquid Glass box over the scroll edge effect, + * as in Messages (see composerInGlassBox()). Off, they sit straight on the effect. Only on iOS 26 and later. + */ + public const bool ComposerInGlassBox = true; + + /** + * Which scroll edge effect iOS 26 and later draw under a composer bar (see composerEdgeBlur()): "soft", the + * progressive blur under the system's own toolbars, or "hard", an opaque fade. + */ + public const string ComposerEdgeBlur = 'soft'; + + /** + * A bar holding partials/composer-box in its glass box with one line of draft: ComposerBoxBarHeight, plus the + * box's own padding over and under what it holds (see composerBox()). + */ + public const int ComposerGlassBoxBarHeight = 100; + /** * About how many characters fit on a line of the box's field, which runs the width of the box. */ @@ -260,7 +279,7 @@ public static function maskedKey(string $openSsh): string public static function replyBarClearance(string $draft, bool $hasPhotos = false, bool $describing = false): int { return self::composerFadeHeight() - + self::ComposerBoxBarHeight + + self::composerBoxBarHeight() + self::composerBoxGrowth($draft) + ($hasPhotos ? self::ReplyBarPhotosHeight : 0) + ($hasPhotos && $describing ? self::ReplyBarDescriptionHeight : 0) @@ -310,16 +329,18 @@ public static function fadesInBar(): bool /** * Whether the composer bars stand on iOS's own scroll edge effect: iOS 26 and later blur what scrolls under the - * bar progressively, as under its own toolbars, from the bar's scroll-edge-soft class (see composerBarGlass()). - * That stands in for the fade and the tinted glass, so a bar there draws neither and lets the effect show. Older - * iOS keeps the fade over glass, and Android its fade over the surface. + * bar, as under its own toolbars, from the bar's edge-blur attribute (see composerEdgeBlur()). That stands in for + * the fade and the tinted glass, so a bar there draws neither and lets the effect show. Older iOS keeps the fade + * over glass, and Android its fade over the surface. * - * It needs a mobile-air that draws the effect for a bottom bar and says which iOS the phone runs + * It needs a mobile-air that takes edge-blur on a bottom bar and says which iOS the phone runs * (System::osVersion()). Without one this is false and every iOS keeps the fade. */ public static function hasScrollEdge(): bool { - if (! Platform::isIos() || ! method_exists(\Native\Mobile\System::class, 'osVersion')) { + if (! Platform::isIos() + || ! method_exists(\Native\Mobile\System::class, 'osVersion') + || ! method_exists(BottomBar::class, 'edgeBlurStyle')) { return false; } @@ -334,6 +355,42 @@ public static function fadeRowInBar(): bool return self::fadesInBar() && ! self::hasScrollEdge(); } + /** + * Whether the composer's field and tools sit in a rounded Liquid Glass box on the bar (ComposerInGlassBox): on + * iOS 26 and later, over the scroll edge effect. Older iOS and Android draw them straight on the bar, as before. + */ + public static function composerInGlassBox(): bool + { + return self::ComposerInGlassBox && self::hasScrollEdge(); + } + + /** + * The classes for partials/composer-box's outer column. In the glass box it's rounded to match the send button + * inside it, which sits 8pt in from its right and bottom edges: the row of tools leaves 6pt at its end and 2pt + * under the button, and the box 2pt more under the row. + */ + public static function composerBox(): string + { + return self::composerInGlassBox() ? 'rounded-[24] glass pb-[2]' : ''; + } + + /** + * The padding over the field inside partials/composer-box. In the glass box the field sits as far under the + * box's top edge as the row of tools sits under the field, 16pt to the text either way. + */ + public static function composerFieldTop(): string + { + return self::composerInGlassBox() ? 'pt-2' : 'pt-1'; + } + + /** + * How tall a composer bar is with one line of draft (see ComposerBoxBarHeight and ComposerGlassBoxBarHeight). + */ + public static function composerBoxBarHeight(): int + { + return self::composerInGlassBox() ? self::ComposerGlassBoxBarHeight : self::ComposerBoxBarHeight; + } + /** * How tall the composer fade is where it's drawn: none where the scroll edge effect replaces it. */ @@ -350,13 +407,21 @@ public static function composerFadeHeight(): int * percent (glass/N), so a little of the screen under the bar shows through. Android has no glass, so the bar * stays the surface there. * - * scroll-edge-soft asks iOS 26 and later for its scroll edge effect under the bar instead, a progressive blur - * like the one under its own toolbars, and a patched mobile-air leaves the glass out there (see hasScrollEdge()). - * Older iOS ignores it and keeps the glass. + * From iOS 26 the bar's edge-blur takes the glass's place (see composerEdgeBlur()). */ public static function composerBarGlass(): string { - return self::fadesInBar() ? 'glass/'.self::ComposerGlassOpacity.' scroll-edge-soft' : ''; + return self::fadesInBar() ? 'glass/'.self::ComposerGlassOpacity : ''; + } + + /** + * The edge-blur attribute for a composer's native:bottom-bar: on iOS, ComposerEdgeBlur, so iOS 26 and later draw + * the system's scroll edge effect under the bar, and mobile-air leaves the bar's glass out there. Older iOS ignores + * it and keeps the glass. Android has no such effect, so nothing is asked there. + */ + public static function composerEdgeBlur(): string + { + return self::fadesInBar() ? self::ComposerEdgeBlur : ''; } /** diff --git a/app/NativeComponents/Conversation.php b/app/NativeComponents/Conversation.php index 8bd97c9b..7ef029b1 100644 --- a/app/NativeComponents/Conversation.php +++ b/app/NativeComponents/Conversation.php @@ -1839,7 +1839,7 @@ private function longPins(): array */ private static function composerClearance(string $draft, bool $replying, bool $hasPhotos, bool $describing): int { - return Display::composerFadeHeight() + self::ComposerBarHeight + Display::composerBoxGrowth($draft) + return Display::composerFadeHeight() + Display::composerBoxBarHeight() + Display::composerBoxGrowth($draft) + ($replying ? self::ReplyingBarHeight : 0) + ($hasPhotos ? self::PhotosHeight : 0) + ($hasPhotos && $describing ? self::DescriptionHeight : 0) diff --git a/resources/views/native/commit-detail.blade.php b/resources/views/native/commit-detail.blade.php index 91978b39..50b8f2c4 100644 --- a/resources/views/native/commit-detail.blade.php +++ b/resources/views/native/commit-detail.blade.php @@ -136,8 +136,9 @@ tools on the left and the round send button on the right (see partials/composer-box), with the page fading out above it (see partials/composer-fade). On iOS the bar is Liquid Glass, faded in at the top, so the page shows through it blurred (see Display::composerBarGlass()). From iOS 26 the system's scroll edge effect - blurs the page under the bar instead, with no fade or glass (see Display::hasScrollEdge()). On Android - it's the surface, painted from this column. Either fills the strip under the home indicator. + blurs the page under the bar instead, with no fade or glass (see Display::composerEdgeBlur()), and the + field and tools sit in a rounded glass box on it (Display::composerInGlassBox()). On Android it's the + surface, painted from this column. Either fills the strip under the home indicator. The bar does everything the composer sheet did for a reply, so a reply never needs the sheet, whose presenting takes the keyboard down and back up on both platforms. The photo button adds photos from the @@ -152,7 +153,7 @@ --}} @php($replyPostingMe = app(\App\Devnull\Account::class)->user()) @php($replyPostsAs = $replyPostingMe !== null && \App\Devnull\PostAs::offered($replyAuthor)) - + @if (\App\Devnull\Display::fadeRowInBar()) @include('native.partials.composer-fade', ['ref' => 'reply-fade', 'inBar' => true]) diff --git a/resources/views/native/conversation.blade.php b/resources/views/native/conversation.blade.php index c68a3c5a..aa77c391 100644 --- a/resources/views/native/conversation.blade.php +++ b/resources/views/native/conversation.blade.php @@ -82,12 +82,14 @@ with the thread fading out above it (see partials/composer-fade) rather than meeting a line. On iOS the bar is Liquid Glass, faded in at the top, so the thread shows through it blurred (see Display::composerBarGlass()). From iOS 26 the system's scroll edge effect blurs the thread under the bar - instead, with no fade or glass (see Display::hasScrollEdge()). On Android it's the surface. Either fills the strip under the home indicator. + instead, with no fade or glass (see Display::composerEdgeBlur()), and the field and tools sit in a rounded + glass box on it (Display::composerInGlassBox()). On Android it's the surface. Either fills the strip under + the home indicator. The web's tools, photos, the microphone and Ping, open from the one +. Above the field sit the people to mention, what you're replying to and the photos on the draft. While the thread can't take a message, why goes in the field's place. --}} - + @if (\App\Devnull\Display::fadeRowInBar()) @include('native.partials.composer-fade', ['ref' => 'composer-fade', 'inBar' => true]) diff --git a/resources/views/native/partials/composer-box.blade.php b/resources/views/native/partials/composer-box.blade.php index c706afc0..fb84f564 100644 --- a/resources/views/native/partials/composer-box.blade.php +++ b/resources/views/native/partials/composer-box.blade.php @@ -1,8 +1,10 @@ {{-- A composer bar's field, tools and send button, laid out the way the Claude and Messages apps lay theirs out: the field across the top, growing to its five lines, and under it a row with the tools on the left and a round send - button in your colour on the right. The same on both platforms. Nothing is drawn around them: they sit straight on - the bar, which is glass on iOS and the surface on Android, under the fade at its top (see partials/composer-fade). + button in your colour on the right. The same on both platforms. Before iOS 26 nothing is drawn around them: they sit + straight on the bar, which is glass on iOS and the surface on Android, under the fade at its top (see + partials/composer-fade). From iOS 26 they sit in a rounded Liquid Glass box over the system's scroll edge effect, + unless Display::ComposerInGlassBox is off (see Display::composerBox()). $ref names the box ("{$ref}-box", also its key, so the field keeps its place as rows above it come and go) and its rows ("{$ref}-field-row", "{$ref}-actions"). $field is the partial that draws the field, keyed itself, so it stays @@ -12,12 +14,13 @@ send-button's: its ref, label, method, and whether it can send yet. The field's text lines up with the tools' icons under it. The field sits a little nearer the fade above it than - the row under it: the row around the box has no top padding, and the field row leaves 8pt under the field. + the row under it: the row around the box has no top padding, and the field row leaves 8pt under the field. In the + glass box the field sits as far under the box's edge as above the tools (Display::composerFieldTop()). --}} @php($lead ??= []) @php($trail ??= []) - - + + @include($field) diff --git a/tests/Feature/Devnull/ComposerScrollEdgeTest.php b/tests/Feature/Devnull/ComposerScrollEdgeTest.php index 2da10027..c56f3556 100644 --- a/tests/Feature/Devnull/ComposerScrollEdgeTest.php +++ b/tests/Feature/Devnull/ComposerScrollEdgeTest.php @@ -12,7 +12,10 @@ expect(Display::hasScrollEdge())->toBe($edge) ->and(Display::fadeRowInBar())->toBe($platform === 'ios' && ! $edge) ->and(Display::composerFadeHeight())->toBe($edge ? 0 : Display::ComposerFadeHeight) - ->and(Display::composerSurface() === '')->toBe($edge); + ->and(Display::composerSurface() === '')->toBe($edge) + ->and(Display::composerInGlassBox())->toBe($edge && Display::ComposerInGlassBox) + ->and(Display::composerBoxBarHeight())->toBe($edge && Display::ComposerInGlassBox ? Display::ComposerGlassBoxBarHeight : Display::ComposerBoxBarHeight) + ->and(Display::composerBox() === '')->toBe(! ($edge && Display::ComposerInGlassBox)); } finally { System::rememberPlatform(null); } @@ -26,11 +29,12 @@ 'Android 26' => ['android', '26', false], ]); -it('asks iOS for the soft scroll edge effect under the composer bars, over glass for older iOS', function () { +it('asks iOS for the composer edge blur on the bar, over glass for older iOS, and Android for neither', function () { System::rememberPlatform('ios'); try { - expect(Display::composerBarGlass())->toBe('glass/'.Display::ComposerGlassOpacity.' scroll-edge-soft'); + expect(Display::composerBarGlass())->toBe('glass/'.Display::ComposerGlassOpacity) + ->and(Display::composerEdgeBlur())->toBe(Display::ComposerEdgeBlur); } finally { System::rememberPlatform(null); } @@ -38,8 +42,18 @@ System::rememberPlatform('android'); try { - expect(Display::composerBarGlass())->toBe(''); + expect(Display::composerBarGlass())->toBe('') + ->and(Display::composerEdgeBlur())->toBe(''); } finally { System::rememberPlatform(null); } }); + +it('asks for an edge blur mobile-air takes', function () { + expect(Display::ComposerEdgeBlur)->toBeIn(['soft', 'hard']); +}); + +it('keeps the glass box as tall as the bar it replaces, plus its own padding', function () { + // The field's padding over it grows from 4 to 8, and the box adds 2 under the row of tools. + expect(Display::ComposerGlassBoxBarHeight)->toBe(Display::ComposerBoxBarHeight + 4 + 2); +}); diff --git a/tests/Feature/Screens/CommitDetailTest.php b/tests/Feature/Screens/CommitDetailTest.php index 4a9bda70..e560f1b2 100644 --- a/tests/Feature/Screens/CommitDetailTest.php +++ b/tests/Feature/Screens/CommitDetailTest.php @@ -935,14 +935,15 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): $screen = Native::visit('/log/commits/c2', platform: 'ios'); $bottomBar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); - // The bar asks for the soft edge effect and keeps its glass for older iOS, which mobile-air leaves out here. - // The page ends where the bar starts, with no fade above it to clear. - expect($bottomBar['props']['scroll_edge'] ?? null)->toBe(1) + // The bar asks for the edge effect and keeps its glass for older iOS, which mobile-air leaves out here. + // The field and tools sit in the glass box. The page ends where the bar starts, with no fade above it. + expect($bottomBar['props']['edge_blur'] ?? null)->toBe(Display::ComposerEdgeBlur) ->and($bottomBar['props']['glass'] ?? null)->toBe(1) ->and(childRefs($screen, 'reply-bar'))->toBe(['reply-rows']) ->and(nodeByRef($screen, 'reply-rows')['style']['bg_color'] ?? null)->toBeNull() ->and(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'reply-fade'))->toBeNull() - ->and(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual(24 + Display::ComposerBoxBarHeight + 34); + ->and(nodeByRef($screen, 'reply-box')['props']['glass'] ?? null)->toBe(Display::ComposerInGlassBox ? 1 : null) + ->and(nodeByRef($screen, 'reply-bar-clearance')['layout']['height'])->toEqual(24 + Display::composerBoxBarHeight() + 34); }); }); @@ -952,7 +953,8 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []): ScrollEdge::onIos('18.5', function (): void { $screen = Native::visit('/log/commits/c2', platform: 'ios'); - expect(childRefs($screen, 'reply-bar'))->toBe(['reply-fade', 'reply-rows']); + expect(childRefs($screen, 'reply-bar'))->toBe(['reply-fade', 'reply-rows']) + ->and(nodeByRef($screen, 'reply-box')['props']['glass'] ?? null)->toBeNull(); }); }); diff --git a/tests/Feature/Screens/RemotesComposerTest.php b/tests/Feature/Screens/RemotesComposerTest.php index eb0c0be8..353b0cec 100644 --- a/tests/Feature/Screens/RemotesComposerTest.php +++ b/tests/Feature/Screens/RemotesComposerTest.php @@ -349,12 +349,13 @@ function threadWithAda(string $platform = 'ios'): TestableComponent $screen = threadWithAda(); $bottomBar = findNode($screen->tree(), fn (array $node): bool => ($node['type'] ?? null) === 'bottom_bar'); - expect($bottomBar['props']['scroll_edge'] ?? null)->toBe(1) + expect($bottomBar['props']['edge_blur'] ?? null)->toBe(Display::ComposerEdgeBlur) + ->and(nodeByRef($screen, 'message-box')['props']['glass'] ?? null)->toBe(Display::ComposerInGlassBox ? 1 : null) ->and(childRefs($screen, 'composer-bar'))->toBe(['composer-rows']) ->and(nodeByRef($screen, 'composer-bar')['style']['bg_color'] ?? null)->toBeNull() ->and(nodeByRef($screen, 'composer-rows')['style']['bg_color'] ?? null)->toBeNull() ->and(findNode($screen->tree(), fn (array $node): bool => ($node['ref'] ?? null) === 'composer-fade'))->toBeNull() - ->and(nodeByRef($screen, 'composer-clearance')['layout']['height'] ?? null)->toEqual(Conversation::ComposerBarHeight + 8); + ->and(nodeByRef($screen, 'composer-clearance')['layout']['height'] ?? null)->toEqual(Display::composerBoxBarHeight() + 8); }); }); diff --git a/tests/Support/ScrollEdge.php b/tests/Support/ScrollEdge.php index a6d073b3..13616b6f 100644 --- a/tests/Support/ScrollEdge.php +++ b/tests/Support/ScrollEdge.php @@ -2,11 +2,11 @@ namespace Tests\Support; -use Native\Mobile\Edge\TailwindParser; +use Native\Mobile\Edge\Elements\BottomBar; use Native\Mobile\System; /** - * Whether the installed mobile-air draws iOS 26's scroll edge effect under a bottom bar (scroll-edge-soft) and says + * Whether the installed mobile-air draws iOS 26's scroll edge effect under a bottom bar (edge-blur) and says * which iOS the phone runs (System::osVersion()). Without them the composer bars keep their fade on every iOS, so the * tests of the scroll edge effect skip. */ @@ -15,13 +15,13 @@ final class ScrollEdge public static function supported(): bool { return method_exists(System::class, 'rememberOsVersion') - && array_key_exists('scrollEdge', TailwindParser::parse('scroll-edge-soft')); + && method_exists(BottomBar::class, 'edgeBlurStyle'); } public static function skipUnlessSupported(): void { if (! self::supported()) { - test()->markTestSkipped('Needs a mobile-air with scroll-edge-soft on a bottom bar and System::osVersion()'); + test()->markTestSkipped('Needs a mobile-air with edge-blur on a bottom bar and System::osVersion()'); } } From e4b24f4d31744d28bb0b5260af20abca777e3832 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Sun, 22 Nov 2026 11:23:50 +0000 Subject: [PATCH 07/11] Leave a gap under the mention list on iOS The suggestions now sit 8pt above the composer's glass box on the commit page and in Remotes, instead of touching it. Co-Authored-By: Claude Opus 5.5 --- resources/views/native/commit-detail.blade.php | 2 +- resources/views/native/conversation.blade.php | 2 +- tests/Feature/Screens/CommitMentionsTest.php | 6 ++++++ tests/Feature/Screens/ConversationTest.php | 9 +++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/resources/views/native/commit-detail.blade.php b/resources/views/native/commit-detail.blade.php index 50b8f2c4..2096768d 100644 --- a/resources/views/native/commit-detail.blade.php +++ b/resources/views/native/commit-detail.blade.php @@ -166,7 +166,7 @@ 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) diff --git a/resources/views/native/conversation.blade.php b/resources/views/native/conversation.blade.php index aa77c391..1de1c92f 100644 --- a/resources/views/native/conversation.blade.php +++ b/resources/views/native/conversation.blade.php @@ -103,7 +103,7 @@ h-[0.1]: on iOS an empty one otherwise takes 10 points of the bar, and EDGE drops a height of 0. --}} @php($mentioning = ($mention['field'] ?? null) === 'draft' && ($mentionPeople !== [] || $mentionOrganizations !== [])) - + @include('native.partials.mention-suggestions', ['field' => 'draft', 'heading' => ($mention['query'] ?? null) === '' ? 'Members' : null]) diff --git a/tests/Feature/Screens/CommitMentionsTest.php b/tests/Feature/Screens/CommitMentionsTest.php index 471b2886..1d8b3ffc 100644 --- a/tests/Feature/Screens/CommitMentionsTest.php +++ b/tests/Feature/Screens/CommitMentionsTest.php @@ -277,3 +277,9 @@ function mentionsComposer(bool $quoting = false, ?array $mentions = null): Testa expect($overlay['props'])->not->toHaveKey('glass') ->and(strtolower($overlay['style']['bg_color']))->toBe(strtolower(config('native-ui.theme.light.surface'))); }); + +it('leaves a gap between the suggestions and the reply box under them on iOS', function () { + $screen = mentionsCommitPage()->input('reply-input', 'thanks @ad', 10); + + expect(nodeByRef($screen, 'reply-mention-slot')['layout']['padding'][2])->toBe(8.0); +}); diff --git a/tests/Feature/Screens/ConversationTest.php b/tests/Feature/Screens/ConversationTest.php index 4a22b9cc..542dfe4e 100644 --- a/tests/Feature/Screens/ConversationTest.php +++ b/tests/Feature/Screens/ConversationTest.php @@ -1390,3 +1390,12 @@ function orgWithMembers(array $people): array ->tap('mention-ada') ->assertSet('draft', 'hi'); }); + +it('leaves a gap between the suggestions and the message box under them on iOS', function () { + serveOrgThread(orgWithMembers([['ada', 'Ada Lovelace']])); + + $screen = finishRefreshes(Native::visit('/remotes/orgs/org-1', platform: 'ios'))->input('message-input', '@ADA', 4); + + expect(childRefs($screen, 'mention-suggestions'))->not->toBe([]) + ->and(nodeByRef($screen, 'mention-slot')['layout']['padding'][2])->toBe(8.0); +}); From a0ea9bcf44a42c6184314775d430356b3feea876 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Sun, 22 Nov 2026 12:22:15 +0000 Subject: [PATCH 08/11] Leave a gap under the Replying to card in Remotes on iOS It sat flush on the composer's glass box. Now there's 8pt between them, as there is under the mention list. Co-Authored-By: Claude Opus 5.5 --- resources/views/native/conversation.blade.php | 2 +- tests/Feature/Screens/RemotesComposerTest.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/resources/views/native/conversation.blade.php b/resources/views/native/conversation.blade.php index 1de1c92f..e60c8a90 100644 --- a/resources/views/native/conversation.blade.php +++ b/resources/views/native/conversation.blade.php @@ -106,7 +106,7 @@ @include('native.partials.mention-suggestions', ['field' => 'draft', 'heading' => ($mention['query'] ?? null) === '' ? 'Members' : null]) - + @if ($replyTo) diff --git a/tests/Feature/Screens/RemotesComposerTest.php b/tests/Feature/Screens/RemotesComposerTest.php index 353b0cec..5678df20 100644 --- a/tests/Feature/Screens/RemotesComposerTest.php +++ b/tests/Feature/Screens/RemotesComposerTest.php @@ -486,3 +486,11 @@ function threadWithAda(string $platform = 'ios'): TestableComponent expect(sentTo('POST', 'remotes/orgs/org-1/ping'))->toBe(['']); }); + +it('leaves a gap between what you are replying to and the message box under it on iOS', function () { + serveThreadWithAda([remoteMessageJson(['id' => 1])], ['read_through_id' => 1]); + + $screen = threadWithAda()->trigger('swipe-1')->assertSee('Replying to Ada Lovelace'); + + expect(nodeByRef($screen, 'replying-slot')['layout']['padding'][2])->toBe(8.0); +}); From 59988ed55bf458619861888b52d303f0b802229f Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Sun, 22 Nov 2026 13:14:51 +0000 Subject: [PATCH 09/11] Keep a quoted commit clear of the composer sheet's toolbar What sits under the field (the quoted commit, photos, the poll, "Submit at") had padding above it but none below, so the quote card ran into the toolbar's line. It now leaves 12pt there, the same gap the field leaves under "Replying to". Co-Authored-By: Claude Opus 5.5 --- resources/views/native/partials/commit-sheet.blade.php | 4 ++-- tests/Feature/Screens/QuoteTest.php | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/resources/views/native/partials/commit-sheet.blade.php b/resources/views/native/partials/commit-sheet.blade.php index 752f5022..66fea73d 100644 --- a/resources/views/native/partials/commit-sheet.blade.php +++ b/resources/views/native/partials/commit-sheet.blade.php @@ -36,7 +36,7 @@ The sheet doesn't scroll. The field fills the space between the author row and the toolbar, less what's under it: the photos as a strip of 80pt squares, the poll editor, the commit being quoted, or "Submit at", each at its own - height. Only the field scrolls its text. A toolbar is pinned to the bottom of the sheet, so + height, with 12pt clear of the toolbar, as the field leaves under "Replying to". Only the field scrolls its text. A toolbar is pinned to the bottom of the sheet, so it stays just above the keyboard: the tools on the left, photos, the camera, a poll (not on a reply) and the preview, which shows the draft as the commit it would become in place of the field (see AttachesToCommits), and stash@{0} and the counter on the right. An issue draft has no tools, as on the web. With photos, Commit spins while @@ -152,7 +152,7 @@ class="w-full h-full text-theme-ink" /> @php($hasBelow = $linkTooLong || $sheetImages !== [] || $pollShown || $quoting || $scheduling || $issueCommands !== [] || $issueHint !== null) - + @if ($linkTooLong) Each link must not be greater than {{ \App\Devnull\Data\BodyLink::MaxLength }} characters. @endif diff --git a/tests/Feature/Screens/QuoteTest.php b/tests/Feature/Screens/QuoteTest.php index e9a1eb92..cc716537 100644 --- a/tests/Feature/Screens/QuoteTest.php +++ b/tests/Feature/Screens/QuoteTest.php @@ -220,5 +220,7 @@ function quoteButtonDisabled(TestableComponent $screen): bool expect(childRefs($screen, 'sheet-below'))->toBe(['quote-card']) ->and(childRefs($screen, 'sheet-body-area'))->toBe(['sheet-field-slot', 'sheet-below']) - ->and(nodeByRef($screen, 'sheet-body')['props']['fills_height'] ?? null)->toBeTrue(); + ->and(nodeByRef($screen, 'sheet-body')['props']['fills_height'] ?? null)->toBeTrue() + // [top, right, bottom, left]: the card keeps clear of the toolbar, as the field does of "Replying to". + ->and(nodeByRef($screen, 'sheet-below')['layout']['padding'])->toEqual([12, 20, 12, 20]); }); From 5f19776c30f338c389a53984a7c0ba1c54ef5895 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Tue, 24 Nov 2026 19:02:56 +0000 Subject: [PATCH 10/11] Drop the mobile-ui#227 test guard now the lock has it The base's dependency update moved mobile-ui to 633ebed, which is #227 merged at aaf451e, so the field fills and reports its caret on every install. Tests\Support\TextFieldFill only skipped tests on a mobile-ui without it, so it goes and those tests always run. ComposerSheet's mention row height and row count now come from Display, which #196 brought in with the same values. That keeps the sheet's sums in step with the rows the partial draws. Co-Authored-By: Claude Opus 5.5 --- app/Devnull/ComposerSheet.php | 8 +++---- tests/Feature/Screens/CommitMentionsTest.php | 7 ------ tests/Feature/Screens/ComposeSheetTest.php | 5 ---- tests/Feature/Screens/QuoteTest.php | 3 --- tests/Support/TextFieldFill.php | 25 -------------------- tests/Unit/Devnull/ComposerSheetTest.php | 3 --- 6 files changed, 4 insertions(+), 47 deletions(-) delete mode 100644 tests/Support/TextFieldFill.php diff --git a/app/Devnull/ComposerSheet.php b/app/Devnull/ComposerSheet.php index 80a3ccf7..8f08c2b6 100644 --- a/app/Devnull/ComposerSheet.php +++ b/app/Devnull/ComposerSheet.php @@ -25,12 +25,12 @@ final class ComposerSheet public const int MinFieldLines = 2; /** - * The mention list's rows, and how many show before the rest scroll inside it. The same as - * Display::MentionRowHeight and Display::MentionRowsShown, which cap the lists by the other fields. + * The mention list's rows, and how many show before the rest scroll inside it. The same as the lists by the other + * fields (see Display), whose row height partials/mention-suggestions draws. */ - public const int MentionRowHeight = 44; + public const int MentionRowHeight = Display::MentionRowHeight; - public const int MentionRowsShown = 6; + public const int MentionRowsShown = Display::MentionRowsShown; /** The list's own padding above and under its rows (py-1), and its heading's height (one line of text-xs, py-1). */ public const int MentionPadding = 8; diff --git a/tests/Feature/Screens/CommitMentionsTest.php b/tests/Feature/Screens/CommitMentionsTest.php index 314f1760..69c2e0b0 100644 --- a/tests/Feature/Screens/CommitMentionsTest.php +++ b/tests/Feature/Screens/CommitMentionsTest.php @@ -7,7 +7,6 @@ use Native\Mobile\Testing\TestableComponent; use Native\Mobile\UI\Caret; use Tests\Support\LayoutAnimation; -use Tests\Support\TextFieldFill; beforeEach(function () { config(['devnull.url' => 'http://devnull.test']); @@ -212,8 +211,6 @@ function mentionsComposer(bool $quoting = false, ?array $mentions = null): Testa }); it('floats the suggestions over the quoted commit on glass, just under the caret line and as tall as their rows', function () { - TextFieldFill::skipUnlessSupported(); - $screen = mentionsComposer(quoting: true) ->input('sheet-body', "see\n@a", 6) ->moveCaretTo('sheet-body', new Caret(x: 20, y: 22, width: 2, height: 22, line: 1, fieldWidth: 350, fieldHeight: 240)); @@ -239,8 +236,6 @@ function mentionsComposer(bool $quoting = false, ?array $mentions = null): Testa }); it('scrolls a long list of suggestions in the sheet with one scroll view, its own', function () { - TextFieldFill::skipUnlessSupported(); - $people = array_map(fn (int $n): array => userJson(['id' => "u{$n}", 'handle' => "ada{$n}", 'name' => "Ada {$n}"]), range(1, 9)); $screen = mentionsComposer(mentions: [['data' => $people]]) ->input('sheet-body', "see\n\n\n\n\n\n@a", 12) @@ -256,8 +251,6 @@ function mentionsComposer(bool $quoting = false, ?array $mentions = null): Testa }); it('shortens the field to end on the caret line when the suggestions would not fit under it, and fills it again once they go', function () { - TextFieldFill::skipUnlessSupported(); - $screen = mentionsComposer(quoting: true)->input('sheet-body', "see\n\n\n\n\n\n\n\n@a", 14); $field = idsDownTo($screen->tree(), 'sheet-body'); diff --git a/tests/Feature/Screens/ComposeSheetTest.php b/tests/Feature/Screens/ComposeSheetTest.php index d7fdc3cd..9a5af929 100644 --- a/tests/Feature/Screens/ComposeSheetTest.php +++ b/tests/Feature/Screens/ComposeSheetTest.php @@ -8,7 +8,6 @@ use Native\Mobile\Testing\Native; use Native\Mobile\Testing\TestableComponent; use Native\Mobile\UI\Caret; -use Tests\Support\TextFieldFill; beforeEach(function () { config(['devnull.url' => 'http://devnull.test']); @@ -285,8 +284,6 @@ function sheetCommitDisabled(TestableComponent $screen): bool }); it('fills the sheet with the field, with nothing scrolling around it', function () { - TextFieldFill::skipUnlessSupported(); - $screen = composeSheetOnLog(); $field = nodeByRef($screen, 'sheet-body')['props']; @@ -308,8 +305,6 @@ function sheetCommitDisabled(TestableComponent $screen): bool }); it('keeps where the field says its caret is until the sheet goes', function () { - TextFieldFill::skipUnlessSupported(); - $screen = composeSheetOnLog() ->moveCaretTo('sheet-body', new Caret(y: 48, height: 24, line: 2, fieldWidth: 350, fieldHeight: 240)) ->assertSet('sheetCaret', ['bottom' => 72.0, 'line_height' => 24.0, 'field_height' => 240.0]); diff --git a/tests/Feature/Screens/QuoteTest.php b/tests/Feature/Screens/QuoteTest.php index cc716537..38d28c21 100644 --- a/tests/Feature/Screens/QuoteTest.php +++ b/tests/Feature/Screens/QuoteTest.php @@ -5,7 +5,6 @@ use Illuminate\Support\Facades\Http; use Native\Mobile\Testing\Native; use Native\Mobile\Testing\TestableComponent; -use Tests\Support\TextFieldFill; beforeEach(function () { config(['devnull.url' => 'http://devnull.test']); @@ -214,8 +213,6 @@ function quoteButtonDisabled(TestableComponent $screen): bool }); it('puts the quoted commit right under the field, which gives up the room it takes', function () { - TextFieldFill::skipUnlessSupported(); - $screen = quoteSheetOnLog(); expect(childRefs($screen, 'sheet-below'))->toBe(['quote-card']) diff --git a/tests/Support/TextFieldFill.php b/tests/Support/TextFieldFill.php deleted file mode 100644 index d714743c..00000000 --- a/tests/Support/TextFieldFill.php +++ /dev/null @@ -1,25 +0,0 @@ -markTestSkipped('Needs a mobile-ui whose multiline field fills and reports its caret (NativePHP/mobile-ui#227)'); - } - } -} diff --git a/tests/Unit/Devnull/ComposerSheetTest.php b/tests/Unit/Devnull/ComposerSheetTest.php index 8832a306..c5cdf23f 100644 --- a/tests/Unit/Devnull/ComposerSheetTest.php +++ b/tests/Unit/Devnull/ComposerSheetTest.php @@ -2,9 +2,6 @@ use App\Devnull\ComposerSheet; use Native\Mobile\UI\Caret; -use Tests\Support\TextFieldFill; - -beforeEach(fn () => TextFieldFill::skipUnlessSupported()); /** A field 360pt tall, as on a phone with the keyboard up, with its caret's line ending at $bottom. */ function composerCaret(float $bottom, float $fieldHeight = 360): array From ab4dca5701cddb4e7df7ef5ceeef85b81847aa0b Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Tue, 24 Nov 2026 19:13:51 +0000 Subject: [PATCH 11/11] Put the draft stash comment back on updatedSheetBody() sheetCaretMoved() landed between the comment and the method it describes, so it sat above another docblock and updatedSheetBody() had none. Co-Authored-By: Claude Opus 5.5 --- app/NativeComponents/Concerns/OpensCommitSheet.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/NativeComponents/Concerns/OpensCommitSheet.php b/app/NativeComponents/Concerns/OpensCommitSheet.php index b71a7ba4..9f771335 100644 --- a/app/NativeComponents/Concerns/OpensCommitSheet.php +++ b/app/NativeComponents/Concerns/OpensCommitSheet.php @@ -338,9 +338,6 @@ public function openScheduledCommits(): void $this->sheetOpen = false; } - /** - * Stashes the draft as it changes (see stashSheetDraft()). - */ /** * The sheet's field drew its caret somewhere else: it moved, the text wrapped differently, or the field scrolled. */ @@ -368,6 +365,9 @@ public function sheetMentionLayout(): ?array ); } + /** + * Stashes the draft as it changes (see stashSheetDraft()). + */ public function updatedSheetBody(): void { $this->typeIssueCommand();