Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 style(chat-input): render @-mentions as plain colored text (#19935)

Arvin Xucc87ef4a7093
diff --git a/src/features/AgentTasks/AgentTaskDetail/CommentCard.tsx b/src/features/AgentTasks/AgentTaskDetail/CommentCard.tsx
index 4beee24ca4f..0c854856f6e 100644
--- a/src/features/AgentTasks/AgentTaskDetail/CommentCard.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/CommentCard.tsx
@@ -9,7 +9,7 @@ import { memo, useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { AttachmentUploadButton } from '@/features/AttachmentInput';
-import { mentionFilledClassName } from '@/features/ChatInput/InputEditor/mentionStyle';
+import { mentionPlainClassName } from '@/features/ChatInput/InputEditor/mentionStyle';
import { richTextImageRenderers } from '@/features/Conversation/Messages/User/components/richTextImageRenderers';
import { EditorCanvas } from '@/features/EditorCanvas';
import { seedAttachments } from '@/features/EditorCanvas/attachmentRegistry';
@@ -160,7 +160,7 @@ const CommentCard = memo<CommentCardProps>(({ activity }) => {
{isEditing && (
<>
- <div className={mentionFilledClassName}>
+ <div className={mentionPlainClassName}>
<EditorCanvas
editor={editor}
editorData={editorData}
@@ -185,7 +185,7 @@ const CommentCard = memo<CommentCardProps>(({ activity }) => {
)}
{!isEditing && Boolean(activity.editorData) && (
<LexicalRenderer
- className={mentionFilledClassName}
+ className={mentionPlainClassName}
overrides={rendererOverrides}
value={activity.editorData as Parameters<typeof LexicalRenderer>[0]['value']}
variant={'chat'}
diff --git a/src/features/AgentTasks/AgentTaskDetail/CommentInput.tsx b/src/features/AgentTasks/AgentTaskDetail/CommentInput.tsx
index 79909b9c5d1..3a3e025c58b 100644
--- a/src/features/AgentTasks/AgentTaskDetail/CommentInput.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/CommentInput.tsx
@@ -6,7 +6,7 @@ import { memo, useCallback, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { AttachmentUploadButton } from '@/features/AttachmentInput';
-import { mentionFilledClassName } from '@/features/ChatInput/InputEditor/mentionStyle';
+import { mentionPlainClassName } from '@/features/ChatInput/InputEditor/mentionStyle';
import { EditorCanvas } from '@/features/EditorCanvas';
import {
getAttachmentFileIdsFromEditor,
@@ -76,7 +76,7 @@ const CommentInput = memo<{ taskId: string }>(({ taskId }) => {
<Flexbox horizontal align={'center'} gap={8} style={{ minWidth: 0, width: '100%' }}>
<Avatar avatar={userAvatar} size={24} style={{ flexShrink: 0 }} />
<div
- className={mentionFilledClassName}
+ className={mentionPlainClassName}
style={{ flex: '1 1 0', minWidth: 0, overflow: 'hidden' }}
>
<EditorCanvas
diff --git a/src/features/ChatInput/InputEditor/index.tsx b/src/features/ChatInput/InputEditor/index.tsx
index a733976c8b3..21b86d14b50 100644
--- a/src/features/ChatInput/InputEditor/index.tsx
+++ b/src/features/ChatInput/InputEditor/index.tsx
@@ -50,7 +50,7 @@ import {
import { createInputCompletionError, isInputCompletionAbortError } from './inputCompletionError';
import InputHistoryPopup, { getHistoryPreviewText } from './InputHistoryPopup';
import { INSERT_LOCAL_FILE_TAG_COMMAND } from './LocalFileTag';
-import { mentionFilledClassName } from './mentionStyle';
+import { mentionPlainClassName } from './mentionStyle';
import Placeholder, { type PlaceholderVariant } from './Placeholder';
import { CHAT_INPUT_EMBED_PLUGINS, createChatInputRichPlugins } from './plugins';
import { INSERT_REFER_TOPIC_COMMAND } from './ReferTopic';
@@ -63,7 +63,7 @@ const className = cx(
margin-block-end: 0;
}
`,
- mentionFilledClassName,
+ mentionPlainClassName,
);
// Single-line dimmed preview of the highlighted history entry, shown through the
diff --git a/src/features/ChatInput/InputEditor/mentionStyle.ts b/src/features/ChatInput/InputEditor/mentionStyle.ts
index dc48cc321c2..2022511d4b9 100644
--- a/src/features/ChatInput/InputEditor/mentionStyle.ts
+++ b/src/features/ChatInput/InputEditor/mentionStyle.ts
@@ -1,10 +1,19 @@
import { css, cx } from 'antd-style';
-// Override the default outlined chip style from `@lobehub/editor`'s mention
-// plugin so @-mentions render as a flat filled chip, matching the look of
-// other inline references (ActionMention, ReferTopic) in the chat UI.
-export const mentionFilledClassName = cx(css`
+// Override the default chip style from `@lobehub/editor`'s mention plugin so
+// @-mentions render as plain colored text, matching the look of other inline
+// tags (skills, tools, commands) in the chat UI.
+// The outline and fill live on the Lexical decorator span (themed `mention`
+// class), which wraps the inner `.editor_mention` span — so target the
+// wrapper. The yellow `.selected` highlight is kept so a mention picked for
+// deletion stays visible.
+export const mentionPlainClassName = cx(css`
+ span:has(> .editor_mention),
.editor_mention {
border: none;
}
+
+ span:has(> .editor_mention):not(.selected) {
+ background: none;
+ }
`);
diff --git a/src/features/Conversation/Messages/User/components/RichTextMessage.tsx b/src/features/Conversation/Messages/User/components/RichTextMessage.tsx
index 25db91fbd7a..bc55fe7e06e 100644
--- a/src/features/Conversation/Messages/User/components/RichTextMessage.tsx
+++ b/src/features/Conversation/Messages/User/components/RichTextMessage.tsx
@@ -6,7 +6,7 @@ import { memo, useMemo } from 'react';
import { ActionTagNode } from '@/features/ChatInput/InputEditor/ActionTag/ActionTagNode';
import { LocalFileTagNode } from '@/features/ChatInput/InputEditor/LocalFileTag';
-import { mentionFilledClassName } from '@/features/ChatInput/InputEditor/mentionStyle';
+import { mentionPlainClassName } from '@/features/ChatInput/InputEditor/mentionStyle';
import { ReferTopicNode } from '@/features/ChatInput/InputEditor/ReferTopic/ReferTopicNode';
import { downloadPreviewImage } from '../../components/downloadPreviewImage';
@@ -34,7 +34,7 @@ const RichTextMessage = memo<RichTextMessageProps>(({ editorState, variant = 'ch
return (
<PreviewGroup preview={PREVIEW_OPTIONS}>
<LexicalRenderer
- className={mentionFilledClassName}
+ className={mentionPlainClassName}
extraNodes={EXTRA_NODES}
overrides={richTextImageRenderers}
style={style}
diff --git a/src/features/PageEditor/DocumentComments/DocumentCommentEditor.tsx b/src/features/PageEditor/DocumentComments/DocumentCommentEditor.tsx
index 0df8545c5f7..8e30c52105b 100644
--- a/src/features/PageEditor/DocumentComments/DocumentCommentEditor.tsx
+++ b/src/features/PageEditor/DocumentComments/DocumentCommentEditor.tsx
@@ -6,7 +6,7 @@ import { cx } from 'antd-style';
import type { Ref } from 'react';
import { memo, useCallback, useImperativeHandle } from 'react';
-import { mentionFilledClassName } from '@/features/ChatInput/InputEditor/mentionStyle';
+import { mentionPlainClassName } from '@/features/ChatInput/InputEditor/mentionStyle';
import { EditorCanvas } from '@/features/EditorCanvas';
import {
readTopicCommentEditorValue,
@@ -96,7 +96,7 @@ const DocumentCommentEditor = memo<DocumentCommentEditorProps>(
className={cx(
styles.commentEditor,
flush && styles.commentEditorFlush,
- mentionFilledClassName,
+ mentionPlainClassName,
)}
>
<EditorCanvas
diff --git a/src/features/PageEditor/EditorCanvas/index.tsx b/src/features/PageEditor/EditorCanvas/index.tsx
index 8653f51afc3..61f1379280c 100644
--- a/src/features/PageEditor/EditorCanvas/index.tsx
+++ b/src/features/PageEditor/EditorCanvas/index.tsx
@@ -6,7 +6,7 @@ import { type CSSProperties, useMemo } from 'react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
-import { mentionFilledClassName } from '@/features/ChatInput/InputEditor/mentionStyle';
+import { mentionPlainClassName } from '@/features/ChatInput/InputEditor/mentionStyle';
import type { ComposerTarget } from '@/features/Conversation/types';
import { EditorCanvas as SharedEditorCanvas } from '@/features/EditorCanvas';
@@ -46,7 +46,7 @@ const EditorCanvas = memo<EditorCanvasProps>(({ askCopilotTarget, placeholder, s
return (
<SharedEditorCanvas
- className={mentionFilledClassName}
+ className={mentionPlainClassName}
documentId={documentId}
editable={editable}
editor={editor}