Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat: make emoji-only messages big (#1180)

Peter Chinmand1e1790c39a5
diff --git a/js/app/packages/block-channel/component/Message/MessageContainer.tsx b/js/app/packages/block-channel/component/Message/MessageContainer.tsx
index 950b2a2242..983dc4b5bc 100644
--- a/js/app/packages/block-channel/component/Message/MessageContainer.tsx
+++ b/js/app/packages/block-channel/component/Message/MessageContainer.tsx
@@ -21,6 +21,7 @@ import {
STATIC_VIDEO,
} from '@core/store/cacheChannelInput';
import { tryMacroId, useDisplayName } from '@core/user';
+import { isEmojiOnly } from '@core/util/string';
import { formatRelativeDate, isSameDay } from '@core/util/time';
import { ContextMenu } from '@kobalte/core/context-menu';
import { usePatchMessageMutation } from '@queries/channel/message';
@@ -463,6 +464,10 @@ export function MessageContainer(props: MessageProps) {
return message.content.trim() === '';
});
+ const isEmojiOnlyMessage = createMemo(() => {
+ return isEmojiOnly(message.content ?? '');
+ });
+
const handleThreadToggle = () => {
if (!message.thread_id) return;
const threadState_ = threadState();
@@ -570,11 +575,13 @@ export function MessageContainer(props: MessageProps) {
>
<MessageComponent.Body isDeleted={!!message.deleted_at}>
<Show when={!isEmptyMessage()}>
- <StaticMarkdown
- markdown={message.content ?? ''}
- theme={channelTheme}
- target="internal"
- />
+ <div classList={{ 'text-3xl': isEmojiOnlyMessage() }}>
+ <StaticMarkdown
+ markdown={message.content ?? ''}
+ theme={channelTheme}
+ target="internal"
+ />
+ </div>
</Show>
</MessageComponent.Body>
</Show>
diff --git a/js/app/packages/core/util/string.test.ts b/js/app/packages/core/util/string.test.ts
new file mode 100644
index 0000000000..de5659e62a
--- /dev/null
+++ b/js/app/packages/core/util/string.test.ts
@@ -0,0 +1,61 @@
+import { describe, expect, it } from 'vitest';
+import { isEmojiOnly } from './string';
+
+describe('isEmojiOnly', () => {
+ it('returns true for single emoji', () => {
+ expect(isEmojiOnly('🎉')).toBe(true);
+ expect(isEmojiOnly('👍')).toBe(true);
+ expect(isEmojiOnly('❤️')).toBe(true);
+ });
+
+ it('returns true for multiple emojis', () => {
+ expect(isEmojiOnly('🎉🎊🎈')).toBe(true);
+ expect(isEmojiOnly('👍👍👍')).toBe(true);
+ });
+
+ it('returns true for emojis with spaces', () => {
+ expect(isEmojiOnly('🎉 🎊 🎈')).toBe(true);
+ expect(isEmojiOnly(' 🎉 ')).toBe(true);
+ });
+
+ it('returns true for composite emojis (ZWJ sequences)', () => {
+ expect(isEmojiOnly('👨‍👩‍👧‍👦')).toBe(true); // family emoji
+ expect(isEmojiOnly('👩‍💻')).toBe(true); // woman technologist
+ });
+
+ it('returns true for flag emojis', () => {
+ expect(isEmojiOnly('🇺🇸')).toBe(true);
+ expect(isEmojiOnly('🇬🇧')).toBe(true);
+ });
+
+ it('returns true for skin tone variants', () => {
+ expect(isEmojiOnly('👍🏻')).toBe(true);
+ expect(isEmojiOnly('👍🏿')).toBe(true);
+ });
+
+ it('returns false for text with emojis', () => {
+ expect(isEmojiOnly('Hello 👋')).toBe(false);
+ expect(isEmojiOnly('🎉 party!')).toBe(false);
+ expect(isEmojiOnly('Great job 👍')).toBe(false);
+ });
+
+ it('returns false for plain text', () => {
+ expect(isEmojiOnly('Hello')).toBe(false);
+ expect(isEmojiOnly('hello world')).toBe(false);
+ });
+
+ it('returns false for empty string', () => {
+ expect(isEmojiOnly('')).toBe(false);
+ expect(isEmojiOnly(' ')).toBe(false);
+ });
+
+ it('returns false for numbers', () => {
+ expect(isEmojiOnly('123')).toBe(false);
+ expect(isEmojiOnly('🎉 123')).toBe(false);
+ });
+
+ it('returns false for punctuation', () => {
+ expect(isEmojiOnly('!')).toBe(false);
+ expect(isEmojiOnly('🎉!')).toBe(false);
+ });
+});
diff --git a/js/app/packages/core/util/string.ts b/js/app/packages/core/util/string.ts
index bcd861edba..51c4c6ee51 100644
--- a/js/app/packages/core/util/string.ts
+++ b/js/app/packages/core/util/string.ts
@@ -42,3 +42,35 @@ export function plural(singular: string, length: number, suffix = 's') {
return `${singular}${suffix}`;
}
+
+/**
+ * Regex pattern to match emoji-only strings.
+ * Uses alternation to match:
+ * - Extended pictographic characters (most emojis)
+ * - Emoji presentation characters
+ * - Variation selectors (\uFE0F)
+ * - Zero-width joiners (\u200D) for composite emojis (e.g., family emoji)
+ * - Whitespace
+ */
+const EMOJI_ONLY_REGEX =
+ /^(?:\p{Extended_Pictographic}|\p{Emoji_Presentation}|\uFE0F|\u200D|\s)+$/u;
+
+/**
+ * Checks if a string contains only emoji characters (and whitespace).
+ * Returns true for messages like "🎉", "👍👍👍", "🎊 🎉", etc.
+ * Returns false for messages with any text, links, or other content.
+ *
+ * @param text - the string to check
+ * @returns true if the string contains only emojis (and whitespace)
+ *
+ * @example
+ * isEmojiOnly('🎉'); // true
+ * isEmojiOnly('👨‍👩‍👧‍👦'); // true (family emoji)
+ * isEmojiOnly('Hello 👋'); // false
+ * isEmojiOnly(''); // false
+ */
+export function isEmojiOnly(text: string): boolean {
+ const trimmed = text.trim();
+ if (trimmed.length === 0) return false;
+ return EMOJI_ONLY_REGEX.test(trimmed);
+}