From 978307ac476591d40ccffa4d02b0b39d4c076d4f Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Sat, 28 Nov 2026 02:15:13 +1030 Subject: [PATCH] Update chat bubble appearance in Remotes --- .../native/partials/message-images.blade.php | 14 ++++-- .../native/partials/message-item.blade.php | 18 ++++--- .../partials/message-reactions.blade.php | 24 +++++++--- .../native/partials/message-voice.blade.php | 13 +++-- tests/Feature/Screens/ConversationTest.php | 48 +++++++++++++++++-- 5 files changed, 89 insertions(+), 28 deletions(-) diff --git a/resources/views/native/partials/message-images.blade.php b/resources/views/native/partials/message-images.blade.php index 94557fed..06e554c4 100644 --- a/resources/views/native/partials/message-images.blade.php +++ b/resources/views/native/partials/message-images.blade.php @@ -1,15 +1,19 @@ {{-- - A message's images. A long press on them opens the message's menu, as on its bubble ($photosMenu). A tap on one - opens the message's images full-screen from that one (see Conversation::openMessageImage), once devnull has the - message: a message still being pushed has its images only on the phone. + A message's images, on the wash and edged in their sender's colour like a bubble (see partials/message-item), so a + dark image doesn't melt into a dark thread. A long press on them opens the message's menu, as on its bubble + ($photosMenu). A tap on one opens the message's images full-screen from that one (see + Conversation::openMessageImage), once devnull has the message: a message still being pushed has its images only on + the phone. --}} @if ($message->images !== []) @foreach ($message->images as $index => $image) + @php($shape = $image->width > 0 && $image->height > 0 ? $image->width / $image->height : $image->ratio()) + @php($imageWidth = (int) round(min(240, 240 * $shape))) @if ($message->isPending()) - + @else - + @endif @endforeach diff --git a/resources/views/native/partials/message-item.blade.php b/resources/views/native/partials/message-item.blade.php index 1944691a..fda89a0a 100644 --- a/resources/views/native/partials/message-item.blade.php +++ b/resources/views/native/partials/message-item.blade.php @@ -1,6 +1,6 @@ {{-- - One message in a thread, as the web draws it: yours on the right in your lane, everyone else's on the left on - the wash. In an org, a run of someone else's messages starts with their avatar and name, a tap on which opens their profile. Above the bubble, the + One message in a thread: every bubble on the wash, edged in its sender's colour, yours on the right and everyone + else's on the left. In an org, a run of someone else's messages starts with their avatar and name, a tap on which opens their profile. Above the bubble, the ghost of the message it replies to; beside it its images and link card; under it its reactions, one chip per emoji, yours outlined in your lane and a tap to take it back or add yours. A run ends in the time, or for the message the web gives a status, in that status. @@ -20,18 +20,22 @@ --}} @php($key = $message->id > 0 ? $message->id : $message->clientId) @php($laneToken = \App\Devnull\Lane::token(($author ?? null)?->lane())) +@php($bubble = 'bg-theme-wash border border-theme-'.($mine ? $myColour : $laneToken)) +@php($tighten = fn (bool $above, bool $below): string => ($above ? 'rounded-t'.($mine ? 'r' : 'l').'-[4] ' : '').($below ? 'rounded-b'.($mine ? 'r' : 'l').'-[4]' : '')) @php($replyAuthor = $message->replyTo === null ? null : ($message->replyTo['user_id'] === $viewer?->id ? 'You' : ($authors[$message->replyTo['user_id']]->name ?? 'Someone'))) @php($replyLane = $message->replyTo === null ? 'primary' : \App\Devnull\Lane::token(($authors[$message->replyTo['user_id']] ?? null)?->lane())) @php($replyable = ($canPush ?? false) && ! $message->isPending()) @php($pull = \App\NativeComponents\Conversation::ReplyPull) @php($swipeHint = $replyable ? ($mine ? 'Swipe right to reply' : 'Swipe left to reply') : '') @php($reactionsAnchor = 'absolute top-0 bottom-0 w-[44] '.($mine ? 'right-0' : 'left-0')) +@php($hasChips = $message->reactionChips($viewer?->id) !== []) +@php($chipsHang = $hasChips && ! $endsRun && $status === null) @if ($replyable) @endif {{-- A set width, not a max: a column that only hugs its bubble measures the text on one line and clips it. --}} - + @if ($isOrg && ! $mine && $startsRun && $author) @@ -84,14 +88,14 @@ @endif @if ($message->isPending()) - - @include('native.partials.message-body', ['ink' => $message->status === 'rejected' ? 'text-theme-ink' : 'text-theme-on-'.$myColour, 'mentionInk' => 'text-theme-on-'.$myColour, 'quoteRule' => $message->status === 'rejected' ? 'border-theme-lane-5' : 'border-theme-on-'.$myColour, 'linkPrefixInk' => $message->status === 'rejected' ? 'text-theme-ink-muted' : 'text-theme-on-'.$myColour.'/70']) + + @include('native.partials.message-body', ['ink' => 'text-theme-ink', 'mentionInk' => 'text-theme-primary', 'quoteRule' => 'border-theme-lane-5']) @else - - @include('native.partials.message-body', ['ink' => $mine ? 'text-theme-on-'.$myColour : 'text-theme-ink', 'mentionInk' => $mine ? 'text-theme-on-'.$myColour : 'text-theme-primary', 'quoteRule' => $mine ? 'border-theme-on-'.$myColour : 'border-theme-lane-5', 'linkPrefixInk' => $mine ? 'text-theme-on-'.$myColour.'/70' : 'text-theme-ink-muted']) + + @include('native.partials.message-body', ['ink' => 'text-theme-ink', 'mentionInk' => 'text-theme-primary', 'quoteRule' => 'border-theme-lane-5']) @endif diff --git a/resources/views/native/partials/message-reactions.blade.php b/resources/views/native/partials/message-reactions.blade.php index 183c4e5f..bf0cce80 100644 --- a/resources/views/native/partials/message-reactions.blade.php +++ b/resources/views/native/partials/message-reactions.blade.php @@ -1,17 +1,29 @@ {{-- - A message's reactions, one chip per emoji in the order it was first left, with how many left it: yours outlined in - your lane, and a tap to take yours back or add it. + A message's reactions in one pill with the fill and edge of the bubble they sit on: each emoji in the order it was + first left, with how many left it, the count in your lane where one is yours, and a tap to take yours back or add it. + The pinned sheet has no bubble, so there the pill is on the surface with a hairline edge. The reactions mostly + overlap the bottom of what they react to, 8pt hanging below it, set in from its side on a solid fill; a text or voice + bubble with reactions has room for them under its content (see partials/message-item). They can run wider than a + short message. Android draws a negative margin without giving its space back (see ComposeFlexLayout), so within a run + ($chipsHang) they're pinned to the bottom of the message's column, whose padding holds only the 8pt that hangs + below, and the next message comes up close. Otherwise they're a row drawn 19pt higher, with the time or status under + them. --}} +@php($chipsHang ??= false) +@php($mine ??= false) +@php($pill = $bubble ?? 'bg-theme-surface border border-theme-hairline') @php($chips = $message->reactionChips($viewer?->id)) @if ($chips !== []) - + + @foreach ($chips as $chip) - - {{ $chip['emoji'] }} - {{ $chip['count'] }} + + {{ $chip['emoji'] }} + {{ $chip['count'] }} @endforeach + @endif diff --git a/resources/views/native/partials/message-voice.blade.php b/resources/views/native/partials/message-voice.blade.php index abb7b577..ec59924f 100644 --- a/resources/views/native/partials/message-voice.blade.php +++ b/resources/views/native/partials/message-voice.blade.php @@ -1,25 +1,24 @@ {{-- A message's voice note, in a bubble of its own as the web draws it, with the message's pin and Reply beside it as a - text bubble has them (see partials/message-item). Yours is in your lane, staged in it faded until devnull has it, or - outlined in red once it turned the note down; everyone else's is on the wash. The player is partials/voice-note. + text bubble has them (see partials/message-item). Each is on the wash, edged in its sender's colour, yours faded + until devnull has it, or outlined in red once it turned the note down. The player is partials/voice-note. A long press opens the message's menu, as on a text bubble, without Copy text, and React's quick reactions point at the bubble. --}} @if ($message->voice !== null) - @php($voiceInk = $message->status === 'rejected' ? 'ink' : ($mine ? 'on-'.$myColour : 'ink')) @if ($mine) @include('native.partials.message-pin') @endif @if ($message->isPending()) - - @include('native.partials.voice-note', ['voice' => $message->voice, 'voiceKey' => $message->voiceKey(), 'ref' => 'voice-'.$key, 'ink' => $voiceInk]) + + @include('native.partials.voice-note', ['voice' => $message->voice, 'voiceKey' => $message->voiceKey(), 'ref' => 'voice-'.$key, 'ink' => 'ink']) @else - - @include('native.partials.voice-note', ['voice' => $message->voice, 'voiceKey' => $message->voiceKey(), 'ref' => 'voice-'.$key, 'ink' => $voiceInk]) + + @include('native.partials.voice-note', ['voice' => $message->voice, 'voiceKey' => $message->voiceKey(), 'ref' => 'voice-'.$key, 'ink' => 'ink']) @endif diff --git a/tests/Feature/Screens/ConversationTest.php b/tests/Feature/Screens/ConversationTest.php index c5d0eab9..695b5ecd 100644 --- a/tests/Feature/Screens/ConversationTest.php +++ b/tests/Feature/Screens/ConversationTest.php @@ -74,7 +74,7 @@ function serveRemoteThread(array $thread, ?array $poll = null, int $pushStatus = ->and(nodeByRef($screen, 'thread')['props']['scroll_anchor'] ?? null)->toBe('bottom'); }); -it('draws quotes in messages behind a rule, amber in theirs and in the label colour in yours', function () { +it('draws quotes in messages behind an amber rule, in theirs and in yours', function () { serveRemoteThread(threadJson([ remoteMessageJson(['id' => 1, 'body' => "> did you see the PR?\nnot yet"]), remoteMessageJson(['id' => 2, 'user_id' => RemotesViewerId, 'body' => "> not yet\nlooking now"]), @@ -87,8 +87,50 @@ function serveRemoteThread(array $thread, ?array $poll = null, int $pushStatus = $rule = fn (string $ref): ?string => findNode(nodeByRef($screen, $ref), fn (array $node): bool => (float) ($node['props']['border_l'] ?? 0) === 2.0)['style']['border_color'] ?? null; expect(strtolower((string) $rule('bubble-1')))->toBe(strtolower((string) theme('lane-5'))) - ->and(strtolower((string) $rule('bubble-2')))->not->toBe(strtolower((string) theme('lane-5'))) - ->and($rule('bubble-2'))->not->toBeNull(); + ->and(strtolower((string) $rule('bubble-2')))->toBe(strtolower((string) theme('lane-5'))); +}); + +it('tightens the corners where a run of bubbles from the same person meet, on their side', function () { + serveRemoteThread(threadJson([ + remoteMessageJson(['id' => 1, 'body' => 'first']), + remoteMessageJson(['id' => 2, 'body' => 'second']), + remoteMessageJson(['id' => 3, 'body' => 'third']), + remoteMessageJson(['id' => 4, 'user_id' => RemotesViewerId, 'body' => 'only mine']), + ])); + + $screen = finishRefreshes(Native::visit('/remotes/conversations/ada')); + $corners = function (string $ref) use ($screen): array { + $props = findNode(nodeByRef($screen, $ref), fn (array $node): bool => isset($node['style']['bg_color']))['props'] ?? []; + + return array_map(fn (string $corner): ?float => isset($props[$corner]) ? (float) $props[$corner] : null, ['tl' => 'radius_tl', 'tr' => 'radius_tr', 'br' => 'radius_br', 'bl' => 'radius_bl']); + }; + + expect($corners('bubble-1'))->toBe(['tl' => 16.0, 'tr' => 16.0, 'br' => 16.0, 'bl' => 4.0]) + ->and($corners('bubble-2'))->toBe(['tl' => 4.0, 'tr' => 16.0, 'br' => 16.0, 'bl' => 4.0]) + ->and($corners('bubble-3'))->toBe(['tl' => 4.0, 'tr' => 16.0, 'br' => 16.0, 'bl' => 16.0]) + ->and($corners('bubble-4'))->toBe(['tl' => null, 'tr' => null, 'br' => null, 'bl' => null]); +}); + +it('tightens the corners where images meet the bubbles and images around them from the same person', function () { + $photo = fn (int $id): array => ['id' => $id, 'width' => 400, 'height' => 300, 'description' => null, 'url' => "http://devnull.test/i/{$id}.png"]; + + serveRemoteThread(threadJson([ + remoteMessageJson(['id' => 1, 'body' => '', 'images' => [$photo(7), $photo(8)]]), + remoteMessageJson(['id' => 2, 'body' => 'the view from here', 'images' => [$photo(9)]]), + ])); + + $screen = finishRefreshes(Native::visit('/remotes/conversations/ada')); + $corners = function (array $node): array { + $props = $node['props'] ?? []; + + return array_map(fn (string $corner): ?float => isset($props[$corner]) ? (float) $props[$corner] : null, ['tl' => 'radius_tl', 'bl' => 'radius_bl']); + }; + $bubble = findNode(nodeByRef($screen, 'bubble-2'), fn (array $node): bool => isset($node['style']['bg_color'])); + + expect($corners(nodeByRef($screen, 'image-1-0')))->toBe(['tl' => 12.0, 'bl' => 4.0]) + ->and($corners(nodeByRef($screen, 'image-1-1')))->toBe(['tl' => 4.0, 'bl' => 4.0]) + ->and($corners(nodeByRef($screen, 'image-2-0')))->toBe(['tl' => 4.0, 'bl' => 4.0]) + ->and($corners($bubble))->toBe(['tl' => 4.0, 'bl' => 16.0]); }); it('marks HEAD where you left off, and pulls what is showing', function () {