Repository navigation
feat: show emoji-only commits and remotes large, like iMessage and Slack #1675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: production
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Document the non-RGI ZWJ exception in the API count description. The server counts any emoji joined by zero-width joiners as one emoji. The web counts only recommended (RGI) sequences. For a non-RGI sequence such as Describe the exception in the documentation: Documentation fix
If parity is required for these sequences, align the server rule with the web instead. In that case, this documentation note no longer applies. Committable suggestion
|
||||||
|
|
||||||
| 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. | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace App\Services; | ||
|
|
||
| /** | ||
| * Whether a body is nothing but a few emoji, so it shows them large: the rule resources/js/lib/emoji.ts applies on the | ||
| * web, sent to API clients so every surface agrees. tests/Fixtures/jumbo-emoji.json holds the cases both must pass. | ||
| */ | ||
| final readonly class JumboEmoji | ||
| { | ||
| /** | ||
| * The most emoji a body shows large; more show at their normal size. | ||
| */ | ||
| public const int MAX = 3; | ||
|
|
||
| /** | ||
| * Longer than any body of only emoji worth telling apart, counted in UTF-16 code units as the web counts it. | ||
| */ | ||
| private const int MAX_LENGTH = 128; | ||
|
|
||
| /** | ||
| * One emoji as it shows by default (π₯), a text symbol asked to show as one (β€οΈ), or either with a skin tone (ππ½). | ||
| * A lone regional indicator is half a flag, never an emoji of its own. | ||
| */ | ||
| private const string ELEMENT = '(?:(?![\x{1F1E6}-\x{1F1FF}])\p{Emoji_Presentation}\p{Emoji_Modifier}?|\p{Extended_Pictographic}\x{FE0F}|\p{Emoji_Modifier_Base}\p{Emoji_Modifier})'; | ||
|
|
||
| /** | ||
| * One whole emoji: a flag (π΅πΉ), a keycap (1οΈβ£), a subdivision flag (π΄σ §σ ’σ ³σ £σ ΄σ Ώ), or emoji joined by ZWJ (π©βπ»). | ||
| * Bare `1`, `#` or `Β©` aren't. | ||
| */ | ||
| private const string SINGLE_EMOJI = '/^(?:[\x{1F1E6}-\x{1F1FF}]{2}|[0-9#*]\x{FE0F}\x{20E3}|\x{1F3F4}[\x{E0061}-\x{E007A}]+\x{E007F}|'.self::ELEMENT.'(?:\x{200D}'.self::ELEMENT.')*)$/u'; | ||
|
|
||
| public function __construct(private EmojiShortcodes $shortcodes) | ||
| { | ||
| // | ||
| } | ||
|
|
||
| /** | ||
| * How many emoji a body shows large: one to three when it is nothing but them, 0 otherwise. | ||
| */ | ||
| public function count(string $body): int | ||
| { | ||
| $count = $this->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; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep emoji-only translation suppression independent of large-emoji support.
When a browser lacks
Intl.Segmenteror the regexvflag,emojiOnlyCountreturns0.commit-translation.tsxuses that result asisEmojiOnly, so the emoji-only check that suppresses translation also fails in these browsers. With automatic translation enabled, a commit or reply whose body is only emoji can then show a stored translation, and the Translate button can appear. The documentation states that such content always shows as written.The large-emoji fallback is a sizing decision. Translation suppression is a separate requirement. Either the translation gate must detect emoji-only bodies in every browser that renders them, or KNOWLEDGE_BASE.md:270 must state the unsupported-browser exception. Keep the documented behavior and the code in agreement.