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.

chore: fix follow-up chat input state during message queueing (#14020)

AmAzing-6ddef9524952
diff --git a/.agents/skills/i18n/SKILL.md b/.agents/skills/i18n/SKILL.md
index 828b7868a8d..5009f90fd6d 100644
--- a/.agents/skills/i18n/SKILL.md
+++ b/.agents/skills/i18n/SKILL.md
@@ -5,7 +5,7 @@ description: Internationalization guide using react-i18next. Use when adding tra
# LobeHub Internationalization Guide
-- Default language: Chinese (zh-CN)
+- Default language: English (en-US)
- Framework: react-i18next
- **Only edit files in `src/locales/default/`** - Never edit JSON files in `locales/`
- Run `pnpm i18n` to generate translations (or manually translate zh-CN/en-US for dev preview)
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index c9f96efc2ea..bca45bd299d 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -82,6 +82,7 @@
"extendParams.title": "Model Extension Features",
"extendParams.urlContext.desc": "When enabled, web links will be automatically parsed to retrieve the actual webpage context content",
"extendParams.urlContext.title": "Extract Webpage Link Content",
+ "followUpPlaceholder": "Follow up",
"group.desc": "Move a task forward with multiple Agents in one shared space.",
"group.memberTooltip": "There are {{count}} members in the group",
"group.orchestratorThinking": "Orchestrator is thinking...",
@@ -286,6 +287,7 @@
"searchAgents": "Search agents...",
"selectedAgents": "Selected agents",
"sendPlaceholder": "Ask, create, or start a task, <hotkey><hotkey/>",
+ "sendPlaceholderWithAgentAssignment": "Ask, create, or start a task. @ to assign tasks to other agents.",
"sessionGroup.config": "Category Management",
"sessionGroup.confirmRemoveGroupAlert": "This category is about to be deleted. After deletion, the agents in this category will be moved to the default list. Please confirm your operation.",
"sessionGroup.createAgentSuccess": "Agent created successfully",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index f6e98153d27..8a7ee2834e7 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -82,6 +82,7 @@
"extendParams.title": "模型扩展功能",
"extendParams.urlContext.desc": "开启后会自动解析网页链接,提取网页内容作为上下文",
"extendParams.urlContext.title": "提取网页链接内容",
+ "followUpPlaceholder": "继续追问",
"group.desc": "在同一对话空间,让多个助理一起推进任务",
"group.memberTooltip": "群组内有 {{count}} 名成员",
"group.orchestratorThinking": "主持人思考中…",
@@ -286,6 +287,7 @@
"searchAgents": "搜索助理…",
"selectedAgents": "已选助理",
"sendPlaceholder": "从任何想法开始… <hotkey><hotkey/>",
+ "sendPlaceholderWithAgentAssignment": "提问、创建或发起任务。输入 @ 可将任务分配给其他助理。",
"sessionGroup.config": "分类管理",
"sessionGroup.confirmRemoveGroupAlert": "确认删除该分类吗?分类内的助理会移回默认列表",
"sessionGroup.createAgentSuccess": "助理创建成功",
diff --git a/src/features/ChatInput/Desktop/index.tsx b/src/features/ChatInput/Desktop/index.tsx
index f0dbde78d23..40288345ac3 100644
--- a/src/features/ChatInput/Desktop/index.tsx
+++ b/src/features/ChatInput/Desktop/index.tsx
@@ -20,6 +20,7 @@ import { systemStatusSelectors } from '@/store/global/selectors';
import { type ActionToolbarProps } from '../ActionBar';
import ActionBar from '../ActionBar';
import InputEditor from '../InputEditor';
+import { type PlaceholderVariant } from '../InputEditor/Placeholder';
import RuntimeConfig from '../RuntimeConfig';
import SendArea from '../SendArea';
import TypoBar from '../TypoBar';
@@ -63,6 +64,7 @@ interface DesktopChatInputProps extends ActionToolbarProps {
inputContainerProps?: ChatInputProps;
leftContent?: ReactNode;
placeholder?: ReactNode;
+ placeholderVariant?: PlaceholderVariant;
/**
* Custom node to render in place of the default RuntimeConfig bar.
* When provided, used instead of `<RuntimeConfig />` (ignores `showRuntimeConfig`).
@@ -86,6 +88,7 @@ const DesktopChatInput = memo<DesktopChatInputProps>(
dropdownPlacement,
leftContent,
placeholder,
+ placeholderVariant,
sendAreaPrefix,
}) => {
const { t } = useTranslation('chat');
@@ -168,7 +171,7 @@ const DesktopChatInput = memo<DesktopChatInputProps>(
{...inputContainerProps}
className={cx(expand && styles.inputFullscreen, inputContainerProps?.className)}
>
- <InputEditor placeholder={placeholder} />
+ <InputEditor placeholder={placeholder} placeholderVariant={placeholderVariant} />
</ChatInput>
{runtimeConfigSlot ?? (showRuntimeConfig && <RuntimeConfig />)}
{showFootnote && !expand && (
diff --git a/src/features/ChatInput/InputEditor/Placeholder.tsx b/src/features/ChatInput/InputEditor/Placeholder.tsx
index b80f5caa51f..c17f9f8b8c0 100644
--- a/src/features/ChatInput/InputEditor/Placeholder.tsx
+++ b/src/features/ChatInput/InputEditor/Placeholder.tsx
@@ -6,43 +6,58 @@ import { Trans, useTranslation } from 'react-i18next';
import { useUserStore } from '@/store/user';
import { preferenceSelectors } from '@/store/user/selectors';
-const Placeholder = memo(() => {
- const useCmdEnterToSend = useUserStore(preferenceSelectors.useCmdEnterToSend);
- const wrapperShortcut = useCmdEnterToSend
- ? KeyEnum.Enter
- : combineKeys([KeyEnum.Mod, KeyEnum.Enter]);
-
- // Don't remove this line for i18n reactivity
- void useTranslation('chat');
-
- return (
- <Flexbox horizontal align={'center'} as={'span'} gap={4} wrap={'wrap'}>
- <Trans
- i18nKey={'sendPlaceholder'}
- ns={'chat'}
- components={{
- hotkey: (
- <Trans
- i18nKey={'input.warpWithKey'}
- ns={'chat'}
- components={{
- key: (
- <Hotkey
- as={'span'}
- keys={wrapperShortcut}
- style={{ color: 'inherit' }}
- styles={{ kbdStyle: { color: 'inhert' } }}
- variant={'borderless'}
- />
- ),
- }}
- />
- ),
- }}
- />
- {'...'}
- </Flexbox>
- );
-});
+export type PlaceholderVariant = 'default' | 'followUp';
+
+interface PlaceholderProps {
+ showAgentAssignmentHint?: boolean;
+ variant?: PlaceholderVariant;
+}
+
+const Placeholder = memo<PlaceholderProps>(
+ ({ showAgentAssignmentHint = false, variant = 'default' }) => {
+ const useCmdEnterToSend = useUserStore(preferenceSelectors.useCmdEnterToSend);
+ const wrapperShortcut = useCmdEnterToSend
+ ? KeyEnum.Enter
+ : combineKeys([KeyEnum.Mod, KeyEnum.Enter]);
+ const { t } = useTranslation('chat');
+
+ if (variant === 'followUp') {
+ return <span>{t('followUpPlaceholder')}</span>;
+ }
+
+ const i18nKey = showAgentAssignmentHint
+ ? 'sendPlaceholderWithAgentAssignment'
+ : 'sendPlaceholder';
+
+ return (
+ <Flexbox horizontal align={'center'} as={'span'} gap={4} wrap={'wrap'}>
+ <Trans
+ i18nKey={i18nKey}
+ ns={'chat'}
+ components={{
+ hotkey: (
+ <Trans
+ i18nKey={'input.warpWithKey'}
+ ns={'chat'}
+ components={{
+ key: (
+ <Hotkey
+ as={'span'}
+ keys={wrapperShortcut}
+ style={{ color: 'inherit' }}
+ styles={{ kbdStyle: { color: 'inhert' } }}
+ variant={'borderless'}
+ />
+ ),
+ }}
+ />
+ ),
+ }}
+ />
+ {!showAgentAssignmentHint && '...'}
+ </Flexbox>
+ );
+ },
+);
export default Placeholder;
diff --git a/src/features/ChatInput/InputEditor/index.tsx b/src/features/ChatInput/InputEditor/index.tsx
index 5c55327bec5..74b131d3374 100644
--- a/src/features/ChatInput/InputEditor/index.tsx
+++ b/src/features/ChatInput/InputEditor/index.tsx
@@ -33,7 +33,7 @@ import {
} from './ActionTag';
import { createMentionMenu } from './MentionMenu';
import type { MentionMenuState } from './MentionMenu/types';
-import Placeholder from './Placeholder';
+import Placeholder, { type PlaceholderVariant } from './Placeholder';
import { CHAT_INPUT_EMBED_PLUGINS, createChatInputRichPlugins } from './plugins';
import { INSERT_REFER_TOPIC_COMMAND } from './ReferTopic';
import { useMentionCategories } from './useMentionCategories';
@@ -44,334 +44,339 @@ const className = cx(css`
}
`);
-const InputEditor = memo<{ defaultRows?: number; placeholder?: ReactNode }>(
- ({ defaultRows = 2, placeholder }) => {
- const [editor, slashMenuRef, send, updateMarkdownContent, expand, slashPlacement] =
- useChatInputStore((s) => [
- s.editor,
- s.slashMenuRef,
- s.handleSendButton,
- s.updateMarkdownContent,
- s.expand,
- s.slashPlacement ?? 'top',
- ]);
-
- const storeApi = useStoreApi();
- const state = useEditorState(editor);
- const hotkey = useUserStore(settingsSelectors.getHotkeyById(HotkeyEnum.AddUserMessage));
- const { enableScope, disableScope } = useHotkeysContext();
-
- const { compositionProps, isComposingRef } = useIMECompositionEvent();
-
- const useCmdEnterToSend = useUserStore(preferenceSelectors.useCmdEnterToSend);
-
- // --- Category-based mention system ---
- const categories = useMentionCategories();
- const stateRef = useRef<MentionMenuState>({ isSearch: false, matchingString: '' });
- const categoriesRef = useRef(categories);
- categoriesRef.current = categories;
-
- const allMentionItems = useMemo(() => categories.flatMap((c) => c.items), [categories]);
-
- const fuse = useMemo(
- () =>
- new Fuse(allMentionItems, {
- keys: ['key', 'label', 'metadata.topicTitle'],
- threshold: 0.3,
- }),
- [allMentionItems],
- );
-
- const mentionItemsFn = useCallback(
- async (
- search: { leadOffset: number; matchingString: string; replaceableString: string } | null,
- ) => {
- if (search?.matchingString) {
- stateRef.current = { isSearch: true, matchingString: search.matchingString };
- return fuse.search(search.matchingString).map((r) => r.item);
- }
- stateRef.current = { isSearch: false, matchingString: '' };
- return [...allMentionItems];
- },
- [allMentionItems, fuse],
- );
-
- const MentionMenuComp = useMemo(() => createMentionMenu(stateRef, categoriesRef), []);
-
- const enableMention = allMentionItems.length > 0;
-
- // Get agent's model info for vision support check and handle paste upload
- const agentId = useAgentId();
- const model = useAgentStore((s) => agentByIdSelectors.getAgentModelById(agentId)(s));
- const provider = useAgentStore((s) => agentByIdSelectors.getAgentModelProviderById(agentId)(s));
- const { handleUploadFiles } = useUploadFiles({ model, provider });
-
- // Listen to editor's paste event for file uploads
- usePasteFile(editor, handleUploadFiles);
-
- useEffect(() => {
- const fn = (e: BeforeUnloadEvent) => {
- if (!state.isEmpty) {
- // set returnValue to trigger alert modal
- // Note: No matter what value is set, the browser will display the standard text
- e.returnValue = 'You are typing something, are you sure you want to leave?';
- }
- };
- window.addEventListener('beforeunload', fn);
- return () => {
- window.removeEventListener('beforeunload', fn);
- };
- }, [state.isEmpty]);
-
- const enableRichRender = useUserStore(labPreferSelectors.enableInputMarkdown);
-
- const slashActionItems = useSlashActionItems();
- const slashItems = useCallback(
- async (
- search: { leadOffset: number; matchingString: string; replaceableString: string } | null,
- ) => {
- const actionItems =
- typeof slashActionItems === 'function'
- ? await slashActionItems(search)
- : slashActionItems;
-
- return actionItems;
- },
- [slashActionItems],
- );
-
- // --- Auto-completion ---
- const inputCompletionConfig = useUserStore(systemAgentSelectors.inputCompletion);
- const isAutoCompleteEnabled = inputCompletionConfig.enabled;
-
- const getMessagesRef = useRef(storeApi.getState().getMessages);
- useEffect(() => {
- return storeApi.subscribe((s) => {
- getMessagesRef.current = s.getMessages;
- });
- }, [storeApi]);
-
- const handleAutoComplete = useCallback(
- async ({
- abortSignal,
- afterText,
- input,
- }: {
- abortSignal: AbortSignal;
- afterText: string;
- editor: any;
- input: string;
- selectionType: string;
- }): Promise<string | null> => {
- // Skip autocomplete during IME composition (e.g. Chinese input method)
- if (isComposingRef.current) return null;
-
- if (!input.trim()) return null;
-
- // Skip when cursor is not at end of paragraph — inserting a placeholder
- // mid-text causes nested editor updates that freeze the input
- if (afterText.trim()) return null;
-
- const { enabled: _, ...config } = systemAgentSelectors.inputCompletion(
- useUserStore.getState(),
- );
- const context = getMessagesRef.current?.();
- const chainParams = chainInputCompletion(input, afterText, context);
-
- const abortController = new AbortController();
- abortSignal.addEventListener('abort', () => abortController.abort());
-
- let result = '';
-
- try {
- await chatService.fetchPresetTaskResult({
- abortController,
- onMessageHandle: (chunk) => {
- if (chunk.type === 'text') {
- result += chunk.text;
- }
- },
- params: merge(config, chainParams),
- });
- } catch {
- return null;
- }
-
- if (abortSignal.aborted) return null;
-
- return result.trimEnd() || null;
- },
- [],
- );
-
- const autoCompletePlugin = useMemo(
- () =>
- isAutoCompleteEnabled
- ? Editor.withProps(ReactAutoCompletePlugin, {
- delay: 600,
- onAutoComplete: handleAutoComplete,
- })
- : null,
- [isAutoCompleteEnabled, handleAutoComplete],
- );
-
- // --- Stable mentionOption & slashOption to prevent infinite re-render on paste ---
- const mentionMarkdownWriter = useCallback((mention: any) => {
- if (mention.metadata?.type === 'topic') {
- return `<refer_topic name="${mention.metadata.topicTitle}" id="${mention.metadata.topicId}" />`;
+const InputEditor = memo<{
+ defaultRows?: number;
+ placeholder?: ReactNode;
+ placeholderVariant?: PlaceholderVariant;
+}>(({ defaultRows = 2, placeholder, placeholderVariant }) => {
+ const [editor, slashMenuRef, send, updateMarkdownContent, expand, slashPlacement] =
+ useChatInputStore((s) => [
+ s.editor,
+ s.slashMenuRef,
+ s.handleSendButton,
+ s.updateMarkdownContent,
+ s.expand,
+ s.slashPlacement ?? 'top',
+ ]);
+
+ const storeApi = useStoreApi();
+ const state = useEditorState(editor);
+ const hotkey = useUserStore(settingsSelectors.getHotkeyById(HotkeyEnum.AddUserMessage));
+ const { enableScope, disableScope } = useHotkeysContext();
+
+ const { compositionProps, isComposingRef } = useIMECompositionEvent();
+
+ const useCmdEnterToSend = useUserStore(preferenceSelectors.useCmdEnterToSend);
+
+ // --- Category-based mention system ---
+ const categories = useMentionCategories();
+ const stateRef = useRef<MentionMenuState>({ isSearch: false, matchingString: '' });
+ const categoriesRef = useRef(categories);
+ categoriesRef.current = categories;
+
+ const allMentionItems = useMemo(() => categories.flatMap((c) => c.items), [categories]);
+
+ const fuse = useMemo(
+ () =>
+ new Fuse(allMentionItems, {
+ keys: ['key', 'label', 'metadata.topicTitle'],
+ threshold: 0.3,
+ }),
+ [allMentionItems],
+ );
+
+ const mentionItemsFn = useCallback(
+ async (
+ search: { leadOffset: number; matchingString: string; replaceableString: string } | null,
+ ) => {
+ if (search?.matchingString) {
+ stateRef.current = { isSearch: true, matchingString: search.matchingString };
+ return fuse.search(search.matchingString).map((r) => r.item);
}
- return `<mention name="${mention.label}" id="${mention.metadata.id}" />`;
- }, []);
-
- const mentionOnSelect = useCallback((editor: any, option: any) => {
- if (option.metadata?.type === 'topic') {
- editor.dispatchCommand(INSERT_REFER_TOPIC_COMMAND, {
- topicId: option.metadata.topicId as string,
- topicTitle: String(option.metadata.topicTitle ?? option.label),
- });
- } else if (option.metadata?.type === 'skill' || option.metadata?.type === 'tool') {
- const payload: InsertActionTagPayload = {
- category: option.metadata.actionCategory as 'skill' | 'tool',
- label: String(option.label),
- type: String(option.metadata.actionType),
- };
- editor.dispatchCommand(INSERT_ACTION_TAG_COMMAND, payload);
- } else {
- editor.dispatchCommand(INSERT_MENTION_COMMAND, {
- label: String(option.label),
- metadata: option.metadata,
- });
+ stateRef.current = { isSearch: false, matchingString: '' };
+ return [...allMentionItems];
+ },
+ [allMentionItems, fuse],
+ );
+
+ const MentionMenuComp = useMemo(() => createMentionMenu(stateRef, categoriesRef), []);
+
+ const enableMention = allMentionItems.length > 0;
+ const showAgentAssignmentHint = categories.some((category) => category.id === 'agent');
+
+ // Get agent's model info for vision support check and handle paste upload
+ const agentId = useAgentId();
+ const model = useAgentStore((s) => agentByIdSelectors.getAgentModelById(agentId)(s));
+ const provider = useAgentStore((s) => agentByIdSelectors.getAgentModelProviderById(agentId)(s));
+ const { handleUploadFiles } = useUploadFiles({ model, provider });
+
+ // Listen to editor's paste event for file uploads
+ usePasteFile(editor, handleUploadFiles);
+
+ useEffect(() => {
+ const fn = (e: BeforeUnloadEvent) => {
+ if (!state.isEmpty) {
+ // set returnValue to trigger alert modal
+ // Note: No matter what value is set, the browser will display the standard text
+ e.returnValue = 'You are typing something, are you sure you want to leave?';
}
- }, []);
-
- const mentionOption = useMemo(
- () =>
- enableMention
- ? {
- items: mentionItemsFn,
- markdownWriter: mentionMarkdownWriter,
- maxLength: 50,
- onSelect: mentionOnSelect,
- renderComp: MentionMenuComp,
+ };
+ window.addEventListener('beforeunload', fn);
+ return () => {
+ window.removeEventListener('beforeunload', fn);
+ };
+ }, [state.isEmpty]);
+
+ const enableRichRender = useUserStore(labPreferSelectors.enableInputMarkdown);
+
+ const slashActionItems = useSlashActionItems();
+ const slashItems = useCallback(
+ async (
+ search: { leadOffset: number; matchingString: string; replaceableString: string } | null,
+ ) => {
+ const actionItems =
+ typeof slashActionItems === 'function' ? await slashActionItems(search) : slashActionItems;
+
+ return actionItems;
+ },
+ [slashActionItems],
+ );
+
+ // --- Auto-completion ---
+ const inputCompletionConfig = useUserStore(systemAgentSelectors.inputCompletion);
+ const isAutoCompleteEnabled = inputCompletionConfig.enabled;
+
+ const getMessagesRef = useRef(storeApi.getState().getMessages);
+ useEffect(() => {
+ return storeApi.subscribe((s) => {
+ getMessagesRef.current = s.getMessages;
+ });
+ }, [storeApi]);
+
+ const handleAutoComplete = useCallback(
+ async ({
+ abortSignal,
+ afterText,
+ input,
+ }: {
+ abortSignal: AbortSignal;
+ afterText: string;
+ editor: any;
+ input: string;
+ selectionType: string;
+ }): Promise<string | null> => {
+ // Skip autocomplete during IME composition (e.g. Chinese input method)
+ if (isComposingRef.current) return null;
+
+ if (!input.trim()) return null;
+
+ // Skip when cursor is not at end of paragraph — inserting a placeholder
+ // mid-text causes nested editor updates that freeze the input
+ if (afterText.trim()) return null;
+
+ const { enabled: _, ...config } = systemAgentSelectors.inputCompletion(
+ useUserStore.getState(),
+ );
+ const context = getMessagesRef.current?.();
+ const chainParams = chainInputCompletion(input, afterText, context);
+
+ const abortController = new AbortController();
+ abortSignal.addEventListener('abort', () => abortController.abort());
+
+ let result = '';
+
+ try {
+ await chatService.fetchPresetTaskResult({
+ abortController,
+ onMessageHandle: (chunk) => {
+ if (chunk.type === 'text') {
+ result += chunk.text;
}
- : undefined,
- [enableMention, mentionItemsFn, mentionMarkdownWriter, mentionOnSelect, MentionMenuComp],
- );
-
- const slashOption = useMemo(() => ({ items: slashItems }), [slashItems]);
-
- const richRenderProps = useMemo(() => {
- const basePlugins = !enableRichRender
- ? CHAT_INPUT_EMBED_PLUGINS
- : createChatInputRichPlugins({
- mathPlugin: Editor.withProps(ReactMathPlugin, {
- renderComp: expand
- ? undefined
- : (props) => (
- <FloatMenu
- {...props}
- getPopupContainer={() => (slashMenuRef as any)?.current}
- />
- ),
- }),
- });
+ },
+ params: merge(config, chainParams),
+ });
+ } catch {
+ return null;
+ }
- const plugins = autoCompletePlugin ? [...basePlugins, autoCompletePlugin] : basePlugins;
-
- return !enableRichRender
- ? { enablePasteMarkdown: false, markdownOption: false, plugins }
- : { plugins };
- }, [enableRichRender, expand, slashMenuRef, autoCompletePlugin]);
-
- return (
- <Editor
- autoFocus
- pasteAsPlainText
- className={className}
- content={''}
- editor={editor}
- {...{ slashPlacement }}
- {...richRenderProps}
- mentionOption={mentionOption}
- placeholder={placeholder ?? <Placeholder />}
- slashOption={slashOption}
- type={'text'}
- variant={'chat'}
- style={{
- minHeight: defaultRows > 1 ? defaultRows * 23 : undefined,
- }}
- onCompositionEnd={({ event }) => compositionProps.onCompositionEnd(event)}
- onBlur={() => {
- disableScope(HotkeyEnum.AddUserMessage);
- }}
- onChange={() => {
- updateMarkdownContent();
- }}
- onCompositionStart={({ event }) => {
- compositionProps.onCompositionStart(event);
- // Clear autocomplete placeholder nodes before IME composition starts —
- // composing next to placeholder inline nodes freezes the editor.
- if (isAutoCompleteEnabled) {
- editor?.dispatchCommand(
- KEY_ESCAPE_COMMAND,
- new KeyboardEvent('keydown', { key: 'Escape' }),
- );
+ if (abortSignal.aborted) return null;
+
+ return result.trimEnd() || null;
+ },
+ [isComposingRef],
+ );
+
+ const autoCompletePlugin = useMemo(
+ () =>
+ isAutoCompleteEnabled
+ ? Editor.withProps(ReactAutoCompletePlugin, {
+ delay: 600,
+ onAutoComplete: handleAutoComplete,
+ })
+ : null,
+ [isAutoCompleteEnabled, handleAutoComplete],
+ );
+
+ // --- Stable mentionOption & slashOption to prevent infinite re-render on paste ---
+ const mentionMarkdownWriter = useCallback((mention: any) => {
+ if (mention.metadata?.type === 'topic') {
+ return `<refer_topic name="${mention.metadata.topicTitle}" id="${mention.metadata.topicId}" />`;
+ }
+ return `<mention name="${mention.label}" id="${mention.metadata.id}" />`;
+ }, []);
+
+ const mentionOnSelect = useCallback((editor: any, option: any) => {
+ if (option.metadata?.type === 'topic') {
+ editor.dispatchCommand(INSERT_REFER_TOPIC_COMMAND, {
+ topicId: option.metadata.topicId as string,
+ topicTitle: String(option.metadata.topicTitle ?? option.label),
+ });
+ } else if (option.metadata?.type === 'skill' || option.metadata?.type === 'tool') {
+ const payload: InsertActionTagPayload = {
+ category: option.metadata.actionCategory as 'skill' | 'tool',
+ label: String(option.label),
+ type: String(option.metadata.actionType),
+ };
+ editor.dispatchCommand(INSERT_ACTION_TAG_COMMAND, payload);
+ } else {
+ editor.dispatchCommand(INSERT_MENTION_COMMAND, {
+ label: String(option.label),
+ metadata: option.metadata,
+ });
+ }
+ }, []);
+
+ const mentionOption = useMemo(
+ () =>
+ enableMention
+ ? {
+ items: mentionItemsFn,
+ markdownWriter: mentionMarkdownWriter,
+ maxLength: 50,
+ onSelect: mentionOnSelect,
+ renderComp: MentionMenuComp,
}
- }}
- onContextMenu={async ({ event: e, editor }) => {
- if (isDesktop) {
- e.preventDefault();
- const { electronSystemService } = await import('@/services/electron/system');
+ : undefined,
+ [enableMention, mentionItemsFn, mentionMarkdownWriter, mentionOnSelect, MentionMenuComp],
+ );
+
+ const slashOption = useMemo(() => ({ items: slashItems }), [slashItems]);
+
+ const richRenderProps = useMemo(() => {
+ const basePlugins = !enableRichRender
+ ? CHAT_INPUT_EMBED_PLUGINS
+ : createChatInputRichPlugins({
+ mathPlugin: Editor.withProps(ReactMathPlugin, {
+ renderComp: expand
+ ? undefined
+ : (props) => (
+ <FloatMenu {...props} getPopupContainer={() => (slashMenuRef as any)?.current} />
+ ),
+ }),
+ });
+
+ const plugins = autoCompletePlugin ? [...basePlugins, autoCompletePlugin] : basePlugins;
+
+ return !enableRichRender
+ ? { enablePasteMarkdown: false, markdownOption: false, plugins }
+ : { plugins };
+ }, [enableRichRender, expand, slashMenuRef, autoCompletePlugin]);
+
+ return (
+ <Editor
+ autoFocus
+ pasteAsPlainText
+ className={className}
+ content={''}
+ editor={editor}
+ {...{ slashPlacement }}
+ {...richRenderProps}
+ mentionOption={mentionOption}
+ slashOption={slashOption}
+ type={'text'}
+ variant={'chat'}
+ placeholder={
+ placeholder ?? (
+ <Placeholder
+ showAgentAssignmentHint={showAgentAssignmentHint}
+ variant={placeholderVariant}
+ />
+ )
+ }
+ style={{
+ minHeight: defaultRows > 1 ? defaultRows * 23 : undefined,
+ }}
+ onCompositionEnd={({ event }) => compositionProps.onCompositionEnd(event)}
+ onBlur={() => {
+ disableScope(HotkeyEnum.AddUserMessage);
+ }}
+ onChange={() => {
+ updateMarkdownContent();
+ }}
+ onCompositionStart={({ event }) => {
+ compositionProps.onCompositionStart(event);
+ // Clear autocomplete placeholder nodes before IME composition starts —
+ // composing next to placeholder inline nodes freezes the editor.
+ if (isAutoCompleteEnabled) {
+ editor?.dispatchCommand(
+ KEY_ESCAPE_COMMAND,
+ new KeyboardEvent('keydown', { key: 'Escape' }),
+ );
+ }
+ }}
+ onContextMenu={async ({ event: e, editor }) => {
+ if (isDesktop) {
+ e.preventDefault();
+ const { electronSystemService } = await import('@/services/electron/system');
- const selectionText = editor.getSelectionDocument('markdown') as unknown as string;
+ const selectionText = editor.getSelectionDocument('markdown') as unknown as string;
- await electronSystemService.showContextMenu('editor', {
- selectionText: selectionText || undefined,
- });
- }
- }}
- onFocus={() => {
- enableScope(HotkeyEnum.AddUserMessage);
- }}
- onInit={(editor) => {
- const saved = storeApi.getState()._savedEditorState;
- storeApi.setState({ _savedEditorState: undefined, editor });
- if (saved) {
- requestAnimationFrame(() => {
- editor.setDocument('json', saved);
- });
+ await electronSystemService.showContextMenu('editor', {
+ selectionText: selectionText || undefined,
+ });
+ }
+ }}
+ onFocus={() => {
+ enableScope(HotkeyEnum.AddUserMessage);
+ }}
+ onInit={(editor) => {
+ const saved = storeApi.getState()._savedEditorState;
+ storeApi.setState({ _savedEditorState: undefined, editor });
+ if (saved) {
+ requestAnimationFrame(() => {
+ editor.setDocument('json', saved);
+ });
+ }
+ }}
+ onPressEnter={({ event: e }) => {
+ if (e.shiftKey || isComposingRef.current) return;
+ // when user like alt + enter to add ai message
+ if (e.altKey && hotkey === combineKeys([KeyEnum.Alt, KeyEnum.Enter])) return true;
+ const commandKey = isCommandPressed(e);
+ // In fullscreen mode, Enter inserts newline; only Cmd/Ctrl+Enter sends
+ if (expand) {
+ if (commandKey) {
+ send();
+ return true;
}
- }}
- onPressEnter={({ event: e }) => {
- if (e.shiftKey || isComposingRef.current) return;
- // when user like alt + enter to add ai message
- if (e.altKey && hotkey === combineKeys([KeyEnum.Alt, KeyEnum.Enter])) return true;
- const commandKey = isCommandPressed(e);
- // In fullscreen mode, Enter inserts newline; only Cmd/Ctrl+Enter sends
- if (expand) {
- if (commandKey) {
- send();
- return true;
- }
- return;
+ return;
+ }
+ // when user like cmd + enter to send message
+ if (useCmdEnterToSend) {
+ if (commandKey) {
+ send();
+ return true;
}
- // when user like cmd + enter to send message
- if (useCmdEnterToSend) {
- if (commandKey) {
- send();
- return true;
- }
- } else {
- if (!commandKey) {
- send();
- return true;
- }
+ } else {
+ if (!commandKey) {
+ send();
+ return true;
}
- }}
- />
- );
- },
-);
+ }
+ }}
+ />
+ );
+});
InputEditor.displayName = 'InputEditor';
diff --git a/src/features/ChatInput/SendArea/SendButton.tsx b/src/features/ChatInput/SendArea/SendButton.tsx
index d5bdcf1a4d9..8d59f3a54bb 100644
--- a/src/features/ChatInput/SendArea/SendButton.tsx
+++ b/src/features/ChatInput/SendArea/SendButton.tsx
@@ -20,7 +20,7 @@ const SendButton = memo(() => {
shape={shape}
size={size}
trigger={['hover']}
- onClick={() => send()}
+ onClick={generating ? undefined : () => send()}
onStop={() => handleStop()}
/>
);
diff --git a/src/features/ChatInput/StoreUpdater.test.tsx b/src/features/ChatInput/StoreUpdater.test.tsx
new file mode 100644
index 00000000000..ee5487fdeac
--- /dev/null
+++ b/src/features/ChatInput/StoreUpdater.test.tsx
@@ -0,0 +1,62 @@
+import { type MenuProps } from '@lobehub/ui';
+import { render } from '@testing-library/react';
+import { type PropsWithChildren, useEffect, useRef } from 'react';
+import { describe, expect, it, vi } from 'vitest';
+
+import { createStore, Provider, useChatInputStore } from './store';
+import StoreUpdater from './StoreUpdater';
+
+interface TestHarnessProps {
+ onSendMenuChange: (menu: MenuProps | undefined) => void;
+ sendMenu?: MenuProps;
+}
+
+const Probe = ({
+ onSendMenuChange,
+}: {
+ onSendMenuChange: TestHarnessProps['onSendMenuChange'];
+}) => {
+ const sendMenu = useChatInputStore((s) => s.sendMenu);
+
+ useEffect(() => {
+ onSendMenuChange(sendMenu);
+ }, [onSendMenuChange, sendMenu]);
+
+ return null;
+};
+
+const TestHarness = ({ children }: PropsWithChildren) => {
+ const storeRef = useRef(createStore());
+
+ return <Provider createStore={() => storeRef.current}>{children}</Provider>;
+};
+
+describe('ChatInput StoreUpdater', () => {
+ it('clears sendMenu when the prop becomes undefined', () => {
+ const initialSendMenu = { items: [{ key: 'test', label: 'Test' }] } satisfies MenuProps;
+ const onSendMenuChange = vi.fn();
+
+ const { rerender } = render(
+ <TestHarness>
+ <StoreUpdater
+ leftActions={[]}
+ rightActions={[]}
+ sendMenu={initialSendMenu}
+ onSend={() => {}}
+ />
+ <Probe onSendMenuChange={onSendMenuChange} />
+ </TestHarness>,
+ );
+
+ expect(onSendMenuChange).toHaveBeenLastCalledWith(initialSendMenu);
+
+ rerender(
+ <TestHarness>
+ <StoreUpdater leftActions={[]} rightActions={[]} sendMenu={undefined} onSend={() => {}} />
+ <Probe onSendMenuChange={onSendMenuChange} />
+ </TestHarness>,
+ );
+
+ expect(onSendMenuChange).toHaveBeenLastCalledWith(undefined);
+ });
+});
diff --git a/src/features/ChatInput/StoreUpdater.tsx b/src/features/ChatInput/StoreUpdater.tsx
index 4a5258c0643..b75cca42817 100644
--- a/src/features/ChatInput/StoreUpdater.tsx
+++ b/src/features/ChatInput/StoreUpdater.tsx
@@ -1,7 +1,7 @@
'use client';
import { type ForwardedRef } from 'react';
-import { memo, useImperativeHandle } from 'react';
+import { memo, useEffect, useImperativeHandle } from 'react';
import { createStoreUpdater } from 'zustand-utils';
import { type ChatInputEditor } from './hooks/useChatInputEditor';
@@ -35,7 +35,6 @@ const StoreUpdater = memo<StoreUpdaterProps>(
useStoreUpdater('agentId', agentId);
useStoreUpdater('mobile', mobile!);
- useStoreUpdater('sendMenu', sendMenu!);
useStoreUpdater('mentionItems', mentionItems);
useStoreUpdater('leftActions', leftActions!);
useStoreUpdater('rightActions', rightActions!);
@@ -47,6 +46,12 @@ const StoreUpdater = memo<StoreUpdaterProps>(
useStoreUpdater('onSend', onSend);
useStoreUpdater('onMarkdownContentChange', onMarkdownContentChange);
+ useEffect(() => {
+ // `createStoreUpdater` skips undefined values, but follow-up mode needs to
+ // actively clear any previously injected send menu from the store.
+ storeApi.setState({ sendMenu });
+ }, [sendMenu, storeApi]);
+
useImperativeHandle(chatInputEditorRef, () => editor);
return null;
diff --git a/src/features/Conversation/ChatInput/index.tsx b/src/features/Conversation/ChatInput/index.tsx
index c07d36ee73b..97fb774be14 100644
--- a/src/features/Conversation/ChatInput/index.tsx
+++ b/src/features/Conversation/ChatInput/index.tsx
@@ -27,6 +27,7 @@ import {
useConversationStoreApi,
} from '../store';
import QueueTray from './QueueTray';
+import { getConversationChatInputUiState } from './utils';
/** Max recent messages to feed into auto-complete context (≈10 conversation turns) */
const MAX_CONTEXT_MESSAGES = 25;
@@ -184,8 +185,13 @@ const ChatInput = memo<ChatInputProps>(
// Computed state
const isInputEmpty = !inputMessage.trim() && fileList.length === 0 && contextList.length === 0;
+ const { placeholderVariant, showSendMenu, showStopButton } = getConversationChatInputUiState({
+ isInputEmpty,
+ isInputLoading,
+ });
// Input stays enabled during agent execution — messages are queued
const disabled = isInputEmpty || isUploadingFiles;
+ const shouldUsePlainSendButton = !showSendMenu && !!sendMenu;
// Send handler - gets message, clears editor immediately, then sends
const handleSend: SendButtonHandler = useCallback(
@@ -227,9 +233,12 @@ const ChatInput = memo<ChatInputProps>(
const sendButtonProps: SendButtonProps = {
disabled,
- generating: isInputLoading,
+ generating: showStopButton,
onStop: stopGenerating,
...customSendButtonProps,
+ ...(shouldUsePlainSendButton
+ ? { shape: customSendButtonProps?.shape ?? 'round' }
+ : undefined),
};
const defaultContent = (
@@ -269,6 +278,7 @@ const ChatInput = memo<ChatInputProps>(
borderRadius={12}
extraActionItems={extraActionItems}
leftContent={leftContent}
+ placeholderVariant={placeholderVariant}
runtimeConfigSlot={runtimeConfigSlot}
sendAreaPrefix={sendAreaPrefix}
showRuntimeConfig={showRuntimeConfig}
@@ -287,7 +297,7 @@ const ChatInput = memo<ChatInputProps>(
mentionItems={mentionItems}
rightActions={rightActions}
sendButtonProps={sendButtonProps}
- sendMenu={sendMenu}
+ sendMenu={showSendMenu ? sendMenu : undefined}
slashPlacement="top"
chatInputEditorRef={(instance) => {
if (instance) {
diff --git a/src/features/Conversation/ChatInput/utils.test.ts b/src/features/Conversation/ChatInput/utils.test.ts
new file mode 100644
index 00000000000..ab9c6022f70
--- /dev/null
+++ b/src/features/Conversation/ChatInput/utils.test.ts
@@ -0,0 +1,44 @@
+import { describe, expect, it } from 'vitest';
+
+import { getConversationChatInputUiState } from './utils';
+
+describe('getConversationChatInputUiState', () => {
+ it('shows follow-up placeholder and stop button while loading with an empty composer', () => {
+ expect(
+ getConversationChatInputUiState({
+ isInputEmpty: true,
+ isInputLoading: true,
+ }),
+ ).toEqual({
+ placeholderVariant: 'followUp',
+ showSendMenu: false,
+ showStopButton: true,
+ });
+ });
+
+ it('restores the send button once the user starts a follow-up during loading', () => {
+ expect(
+ getConversationChatInputUiState({
+ isInputEmpty: false,
+ isInputLoading: true,
+ }),
+ ).toEqual({
+ placeholderVariant: 'default',
+ showSendMenu: false,
+ showStopButton: false,
+ });
+ });
+
+ it('keeps the default composer state when not loading', () => {
+ expect(
+ getConversationChatInputUiState({
+ isInputEmpty: true,
+ isInputLoading: false,
+ }),
+ ).toEqual({
+ placeholderVariant: 'default',
+ showSendMenu: true,
+ showStopButton: false,
+ });
+ });
+});
diff --git a/src/features/Conversation/ChatInput/utils.ts b/src/features/Conversation/ChatInput/utils.ts
new file mode 100644
index 00000000000..0111cec17af
--- /dev/null
+++ b/src/features/Conversation/ChatInput/utils.ts
@@ -0,0 +1,25 @@
+import { type PlaceholderVariant } from '@/features/ChatInput/InputEditor/Placeholder';
+
+export interface ConversationChatInputUiState {
+ placeholderVariant: PlaceholderVariant;
+ showSendMenu: boolean;
+ showStopButton: boolean;
+}
+
+export interface GetConversationChatInputUiStateParams {
+ isInputEmpty: boolean;
+ isInputLoading: boolean;
+}
+
+export const getConversationChatInputUiState = ({
+ isInputEmpty,
+ isInputLoading,
+}: GetConversationChatInputUiStateParams): ConversationChatInputUiState => {
+ const showFollowUpComposer = isInputLoading && isInputEmpty;
+
+ return {
+ placeholderVariant: showFollowUpComposer ? 'followUp' : 'default',
+ showSendMenu: !isInputLoading,
+ showStopButton: showFollowUpComposer,
+ };
+};
diff --git a/src/locales/default/chat.ts b/src/locales/default/chat.ts
index 9e5dfe76207..57cc3e2287e 100644
--- a/src/locales/default/chat.ts
+++ b/src/locales/default/chat.ts
@@ -320,7 +320,10 @@ export default {
'searchAgentPlaceholder': 'Search agents...',
'searchAgents': 'Search agents...',
'selectedAgents': 'Selected agents',
+ 'followUpPlaceholder': 'Follow up. @ to assign tasks to other agents.',
'sendPlaceholder': 'Ask, create, or start a task, <hotkey><hotkey/>',
+ 'sendPlaceholderWithAgentAssignment':
+ 'Ask, create, or start a task. @ to assign tasks to other agents.',
'sessionGroup.config': 'Category Management',
'sessionGroup.confirmRemoveGroupAlert':
'This category is about to be deleted. After deletion, the agents in this category will be moved to the default list. Please confirm your operation.',