diff --git a/KNOWLEDGE_BASE.md b/KNOWLEDGE_BASE.md
index 6965f9e74b..840921bc9e 100644
--- a/KNOWLEDGE_BASE.md
+++ b/KNOWLEDGE_BASE.md
@@ -263,6 +263,18 @@ Sources: [translation endpoint](app/Http/Controllers/CommitTranslationController
Commit and reply text supports inline code in backticks and fenced code blocks with syntax highlighting, a **Wrap lines** toggle, and a copy control. A title after the language, as in ```` ```php title="app/Models/User.php" ````, labels the block in place of the language. Text outside code supports emoji shortcodes, clickable URLs, `@username` mentions, and `#hashtags`, which open commit search for signed-in members and stay plain text for guests. This is developer-oriented text formatting, not a full rich-text editor.
+A commit, reply, or remotes message made of only one to three emoji, shortcodes included, shows them large, as Apple's iMessage and Slack do: about three times the text size for one emoji, twice the text size for two or three emoji.
+
+In remotes, a message that only contains one to three emoji also drops its bubble, unless images or a voice note come with it. A quoted commit that only contains one to three emoji also shows those emoji large inside the quote. Notifications and pinned-message previews always show emoji at their normal size.
+
+A commit or reply that only contains emoji, however many, has no **Translate** button, because there is nothing to translate. On the website, a commit or reply that only contains emoji always shows its emoji as written, even for a reader who has automatic translation turned on.
+
+Large emoji are on by default. To show emoji at their normal size instead, open Settings → Appearance → **Large emoji** and choose **Off**. This choice is saved in that browser only, so other browsers and devices keep their own setting. The mobile apps don't follow this setting; each app decides whether it shows large emoji and whether it offers its own switch.
+
+Older browsers that lack the requirements to support this feature (Safari before 17, Firefox before 125) show the emoji at their normal size.
+
+The signed and public APIs send the count of emoji as `jumbo_emoji` (0 to 3, 0 meaning normal size) on commits and messages, so the apps can match the web.
+
The smiley button in the commit, reply and quote composers opens the same searchable emoji picker as reactions in remotes. Picking an emoji inserts it where the caret was, or over the selected text, and puts the caret right after it.
In commits, replies, and remotes, start a line with `>` to render a quote block. Consecutive quoted lines stay together; an unquoted line ends the block. Quotes keep inline code, links, mentions, and emoji formatting. A `>` inside code or in the middle of a line stays literal.
@@ -273,7 +285,7 @@ Typing **#123** in a composer looks up that exact issue or pull request in the /
Write `color(#ff8a4c)` or `color(#fff)` outside code to show the hex value with a small color swatch. The `color(...)` markup stays in the draft and is hidden in the rendered commit. It accepts 3, 4, 6 or 8 hex digits. A bare `#` followed by a letter is a hashtag. On the web, if the text of a commit, reply, quote, or Remotes message contains a hashtag that could be a color, the composer shows the swatch syntax and offers to apply it. Colors that start with a digit can still show a swatch without the markup: `#000`, `#000000` and `#333333` are colors, while `#123` and `#333` stay plain text. The full-width `#` also works for automatic swatches, as in `#fff`. A swatch written with `color(...)` does not add the commit to a guild.
-Sources: [body renderer](resources/js/components/commit-body.tsx), [emoji picker button](resources/js/components/emoji-picker.tsx), [colors](resources/js/lib/colors.ts), [code blocks](resources/js/components/code-block.tsx), [mention suggestions](app/Http/Controllers/MentionSuggestionController.php), [mention parsing](app/Services/Mentions.php).
+Sources: [body renderer](resources/js/components/commit-body.tsx), [jumbo emoji](resources/js/lib/emoji.ts), [jumbo emoji for the API](app/Services/JumboEmoji.php), [emoji picker button](resources/js/components/emoji-picker.tsx), [colors](resources/js/lib/colors.ts), [code blocks](resources/js/components/code-block.tsx), [mention suggestions](app/Http/Controllers/MentionSuggestionController.php), [mention parsing](app/Services/Mentions.php).
### Draft previews
@@ -512,6 +524,7 @@ Settings → Appearance offers:
- **Theme:** Light, Dark, or System.
- **Navigation:** expanded or collapsed, on wide screens. The navigation also has its own collapse button.
- **Lane dimming:** on by default; other commits fade while the pointer rests on a commit or its author.
+- **Large emoji:** on by default. A commit, reply, or remotes message made of only one to three emoji shows those emoji [large](#code-emoji-and-mentions). Choose **Off** to show them at their normal size.
- **Replies:** how many replies show under a commit before "Show more": 1, 3, 5, 10, 15, 20, or 25 (3 by default).
- **Who to follow:** show or hide the suggestions.
diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php
index 65ebb458d9..1b9c045ec3 100644
--- a/app/Http/Middleware/HandleInertiaRequests.php
+++ b/app/Http/Middleware/HandleInertiaRequests.php
@@ -179,6 +179,8 @@ public function share(Request $request): array
'eventYear' => EventTheme::greetedYear($request),
'eventThemeChoice' => EventTheme::choiceFrom(is_string($request->cookie('event_theme')) ? $request->cookie('event_theme') : null),
'dimsLanes' => $request->cookie('lane_dimming') !== 'false',
+ // Messages of only a few emoji show them large unless this device turned it off in Appearance.
+ 'showsLargeEmoji' => $request->cookie('large_emoji') !== 'false',
'repliesPerPage' => RepliesPerPage::of($request)->value,
'clock' => ReaderClock::of($request)->toArray(),
// Relative times count from it on the server and while the browser hydrates the page, so both agree.
diff --git a/app/Http/Resources/CommitResource.php b/app/Http/Resources/CommitResource.php
index f531915c8d..7886dd2b47 100644
--- a/app/Http/Resources/CommitResource.php
+++ b/app/Http/Resources/CommitResource.php
@@ -11,6 +11,7 @@
use App\Models\Poll;
use App\Models\User;
use App\Services\CommitBodies;
+use App\Services\JumboEmoji;
use App\Services\Mentions;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Http\Request;
@@ -65,6 +66,8 @@ public function toArray(Request $request): array
'id' => $this->id,
'short_hash' => mb_substr(str_replace('-', '', $this->id), -7),
'body' => $this->body,
+ // How many emoji the body shows large, as the web does: 1 to 3 when it is nothing but them, 0 otherwise.
+ 'jumbo_emoji' => resolve(JumboEmoji::class)->count($this->body),
'guild_handle' => $this->whenLoaded('guild', fn (Guild $guild): string => $guild->handle),
'guild' => $this->whenLoaded('guild', fn (Guild $guild): array => [
'handle' => $guild->handle,
diff --git a/app/Http/Resources/MessageResource.php b/app/Http/Resources/MessageResource.php
index 28fac1ab87..34f0e5c53a 100644
--- a/app/Http/Resources/MessageResource.php
+++ b/app/Http/Resources/MessageResource.php
@@ -9,6 +9,7 @@
use App\Models\MessageVoice;
use App\Models\User;
use App\Services\CodeSpans;
+use App\Services\JumboEmoji;
use App\Services\Mentions;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
@@ -46,6 +47,7 @@ public function toArray(Request $request): array
'client_id' => $this->client_id,
'body' => $this->body,
'body_segments' => resolve(CodeSpans::class)->highlight($this->body),
+ 'jumbo_emoji' => $this->jumboEmoji(),
'mentions' => collect(resolve(Mentions::class)->positions($this->body, users: $this->mentions ?? []))
->filter(fn (array $mention): bool => $mention['id'] !== null)
->values(),
@@ -88,4 +90,22 @@ public function toArray(Request $request): array
return $this->withGuildMentions ? ShownGuildMentions::of($shown, $request->user()) : $shown;
}
+
+ /**
+ * How many emoji the message shows large, as the web's thread does: 1 to 3 when its body is nothing but them and no
+ * images or voice note come with it, 0 otherwise. Its attachments are only looked up for such a body.
+ */
+ private function jumboEmoji(): int
+ {
+ $count = resolve(JumboEmoji::class)->count($this->body);
+
+ if ($count === 0) {
+ return 0;
+ }
+
+ $hasImages = $this->relationLoaded('images') ? $this->images->isNotEmpty() : $this->images()->exists();
+ $hasVoice = $this->relationLoaded('voice') ? $this->voice instanceof MessageVoice : $this->voice()->exists();
+
+ return $hasImages || $hasVoice ? 0 : $count;
+ }
}
diff --git a/app/Services/JumboEmoji.php b/app/Services/JumboEmoji.php
new file mode 100644
index 0000000000..cb6206f03d
--- /dev/null
+++ b/app/Services/JumboEmoji.php
@@ -0,0 +1,82 @@
+emojiOnlyCount($body);
+
+ return $count <= self::MAX ? $count : 0;
+ }
+
+ /**
+ * How many emoji a body is made of when it is nothing but emoji, with shortcodes counted as theirs; 0 otherwise.
+ */
+ public function emojiOnlyCount(string $body): int
+ {
+ if (
+ // UTF-16 counts a character past U+FFFF, as most emoji are, twice.
+ mb_strlen($body) + preg_match_all('/[\x{10000}-\x{10FFFF}]/u', $body) > self::MAX_LENGTH
+ || preg_match('/[a-z]/i', (string) preg_replace('/:[a-z0-9_+-]+:/i', '', $body)) === 1
+ ) {
+ return 0;
+ }
+
+ // \X takes one grapheme at a time, the way the web's Intl.Segmenter splits text: a whole flag or ZWJ family each.
+ preg_match_all('/\X/u', $this->shortcodes->replace($body), $graphemes);
+
+ $count = 0;
+
+ foreach ($graphemes[0] as $grapheme) {
+ if (preg_match('/^[\s\p{Z}\x{FEFF}]+$/u', $grapheme) === 1) {
+ continue;
+ }
+
+ if (preg_match(self::SINGLE_EMOJI, $grapheme) !== 1) {
+ return 0;
+ }
+
+ $count++;
+ }
+
+ return $count;
+ }
+}
diff --git a/bootstrap/app.php b/bootstrap/app.php
index a795fad12b..147c4252d3 100644
--- a/bootstrap/app.php
+++ b/bootstrap/app.php
@@ -47,7 +47,7 @@
$middleware->trimStrings(except: ['sdp', 'signals.*.sdp']);
$middleware->append(PreventFraming::class);
- $middleware->encryptCookies(except: ['appearance', 'sidebar_state', 'who_to_follow', 'who_to_follow_round', 'lane_dimming', 'event_theme', 'replies_per_page', 'time_zone', 'hour_cycle']);
+ $middleware->encryptCookies(except: ['appearance', 'sidebar_state', 'who_to_follow', 'who_to_follow_round', 'lane_dimming', 'large_emoji', 'event_theme', 'replies_per_page', 'time_zone', 'hour_cycle']);
// Approving the app is the one page a guest should leave for GitHub, then return to. Every other page
// they open while signed out stays the log. Locally, sign-in is the modal on that log.
diff --git a/resources/js/components/chat/conversation-thread.tsx b/resources/js/components/chat/conversation-thread.tsx
index dd6e51d58f..6f92ea4439 100644
--- a/resources/js/components/chat/conversation-thread.tsx
+++ b/resources/js/components/chat/conversation-thread.tsx
@@ -25,6 +25,7 @@ import {
import { MentionsBell } from '@/components/chat/mentions-bell';
import {
LiftedMessage,
+ isJumboMessage,
MessageImages,
MessageLinkCard,
MessageText,
@@ -67,6 +68,7 @@ import { UserAvatar } from '@/components/user-avatar';
import { UserPreview } from '@/components/user-preview';
import { useChat, useThread } from '@/hooks/use-chat';
import { useImageAttachments } from '@/hooks/use-image-attachments';
+import { useLargeEmoji } from '@/hooks/use-large-emoji';
import { useLinkCard } from '@/hooks/use-link-card';
import { moveCaretToEnd, useStash } from '@/hooks/use-stash';
import { useVoiceNote } from '@/hooks/use-voice-note';
@@ -1325,7 +1327,18 @@ function BubbleWithMeta({
? target.partner.lane
: (pulledBy[0]?.lane ?? user.lane);
- const isOnPrimary = isMine && status !== 'staged' && status !== 'rejected';
+ const showsLargeEmoji = useLargeEmoji();
+ const isJumboEmoji =
+ showsLargeEmoji &&
+ isJumboMessage({
+ body: message.body,
+ body_segments:
+ 'body_segments' in message ? message.body_segments : null,
+ images,
+ voice,
+ });
+ const isOnPrimary =
+ isMine && !isJumboEmoji && status !== 'staged' && status !== 'rejected';
const side = isMine ? 'mine' : 'theirs';
const replyToThis =
onReply !== null && bubble.kind === 'message'
@@ -1479,11 +1492,17 @@ function BubbleWithMeta({
? bubble.message.id
: undefined
}
- className={bubbleClass}
+ className={cn(
+ bubbleClass,
+ // A few emoji alone stand on their own, without the bubble behind them.
+ isJumboEmoji &&
+ 'bg-transparent text-foreground',
+ )}
>
{bubbleActions}
diff --git a/resources/js/components/chat/message-parts.tsx b/resources/js/components/chat/message-parts.tsx
index 56060772fb..41ca82c582 100644
--- a/resources/js/components/chat/message-parts.tsx
+++ b/resources/js/components/chat/message-parts.tsx
@@ -11,7 +11,9 @@ import { CommitImages } from '@/components/commit-images';
import type { ShownImage } from '@/components/commit-images';
import { ImageViewer } from '@/components/image-viewer';
import { LinkPreview } from '@/components/link-preview';
+import { useLargeEmoji } from '@/hooks/use-large-emoji';
import { bodySegments } from '@/lib/code';
+import { jumboEmojiCount } from '@/lib/emoji';
import { isReplySwipe, replyPull, replyThreshold } from '@/lib/reply-swipe';
import { cn, laneTextColor } from '@/lib/utils';
import type {
@@ -33,15 +35,38 @@ export type Author = { name: string; lane: Lane; isMe: boolean };
const onPrimary =
'[&_a]:text-primary-foreground [&_a]:underline [&_a]:decoration-primary-foreground/50 [&_a]:underline-offset-2 [&_.text-muted-foreground]:text-primary-foreground/70 [&_.fill-foreground]:fill-primary-foreground [&_blockquote]:border-neutral-200 [&_code]:bg-primary-foreground/15';
+/**
+ * Whether a message is nothing but one to three emoji, with no images or voice note beside them, so it shows them large
+ * and without its bubble.
+ */
+export function isJumboMessage(message: {
+ body: string;
+ body_segments?: BodySegment[] | null;
+ // Sent images and voice notes, or the files of ones still being pushed.
+ images?: readonly unknown[] | null;
+ voice?: unknown;
+}): boolean {
+ return (
+ (message.images ?? []).length === 0 &&
+ (message.voice ?? null) === null &&
+ jumboEmojiCount(message.body_segments ?? bodySegments(message.body)) > 0
+ );
+}
+
export function MessageText({
message,
isMine,
+ isJumboable = true,
}: {
message: Pick<
Message,
'body' | 'body_segments' | 'mentions' | 'guild_mentions'
>;
isMine: boolean;
+ /**
+ * Whether a few emoji alone show large: not beside images or a voice note, nor in a small preview.
+ */
+ isJumboable?: boolean;
}) {
const segments: BodySegment[] =
message.body_segments ?? bodySegments(message.body);
@@ -53,6 +78,7 @@ export function MessageText({
guildMentions={message.guild_mentions}
linksEveryMention={false}
className={cn('flow-root leading-snug', { [onPrimary]: isMine })}
+ isJumboable={isJumboable}
/>
);
}
@@ -86,26 +112,39 @@ export function LiftedMessage({
message: Message;
isMine: boolean;
}) {
+ const showsLargeEmoji = useLargeEmoji();
const voice = message.voice ?? null;
if (voice === null && message.body === '') {
return null;
}
+ // A few emoji alone lift as they show in the thread: large, without a bubble.
+ const isJumbo = showsLargeEmoji && isJumboMessage(message);
+
return (
{voice === null ? (
-
+
) : (
)}
diff --git a/resources/js/components/chat/pinned-messages.tsx b/resources/js/components/chat/pinned-messages.tsx
index 26801fb32c..b28ebb2724 100644
--- a/resources/js/components/chat/pinned-messages.tsx
+++ b/resources/js/components/chat/pinned-messages.tsx
@@ -842,7 +842,12 @@ function PinnedText({ message }: { message: Message }) {
'max-h-[3lh] overflow-hidden': !isExpanded,
})}
>
-
+ {/* A clipped preview, like a notification: a few emoji stay at their normal size. */}
+