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.

🐛 fix(home): blank user bubble when sending the placeholder hint (#14678)

Arvin Xufc275ca4dc07
diff --git a/src/routes/(main)/home/features/InputArea/useSend.test.ts b/src/routes/(main)/home/features/InputArea/useSend.test.ts
index b92c68b9405..b76ee0fd6c0 100644
--- a/src/routes/(main)/home/features/InputArea/useSend.test.ts
+++ b/src/routes/(main)/home/features/InputArea/useSend.test.ts
@@ -62,10 +62,21 @@ const globalState = vi.hoisted(() => ({
updateSystemStatus: vi.fn(),
}));
+const homeDailyBriefState = vi.hoisted(() => ({
+ advance: vi.fn(),
+ currentIndex: 0,
+ currentPair: undefined as { hint: string; welcome: string } | undefined,
+ pairs: [] as { hint: string; welcome: string }[],
+}));
+
vi.mock('@/hooks/useQueryRoute', () => ({
useQueryRoute: () => routerMock,
}));
+vi.mock('@/hooks/useHomeDailyBrief', () => ({
+ useHomeDailyBrief: () => homeDailyBriefState,
+}));
+
vi.mock('@/store/agent', () => ({
useAgentStore: Object.assign(
(selector: (state: typeof agentState) => unknown) => selector(agentState),
@@ -126,6 +137,9 @@ describe('Home InputArea useSend', () => {
clearContentMock.mockReset();
clearChatUploadFileListMock.mockReset();
clearChatContextSelectionsMock.mockReset();
+ homeDailyBriefState.advance.mockReset();
+ homeDailyBriefState.currentPair = undefined;
+ chatState.inputMessage = 'hello';
});
it('routes cold homepage sends to the created topic instead of relying on ChatHydration timing', async () => {
@@ -158,4 +172,33 @@ describe('Home InputArea useSend', () => {
expect(routerMock.replace).toHaveBeenCalledWith('/agent/agt_inbox/tpc_created');
});
+
+ it('drops editorData when sending the placeholder hint so the user message renders the markdown content', async () => {
+ homeDailyBriefState.currentPair = {
+ hint: '看下 Bug #14153 + #14112 Agent 手机端不同步/不显示...',
+ welcome: 'welcome',
+ };
+ chatState.inputMessage = '';
+
+ const { result } = renderHook(() => useSend());
+ const params: Parameters<SendButtonHandler>[0] = {
+ clearContent: vi.fn(),
+ editor: {} as Parameters<SendButtonHandler>[0]['editor'],
+ // Empty editor still returns a non-null JSON state; this would
+ // previously be forwarded as editorData and blank the rendered
+ // user bubble.
+ getEditorData: () => ({ type: 'doc' }),
+ getMarkdownContent: () => '',
+ };
+
+ await act(async () => {
+ await result.current.send(params);
+ });
+
+ expect(sendMessageMock).toHaveBeenCalledTimes(1);
+ const sentPayload = sendMessageMock.mock.calls[0][0];
+ expect(sentPayload.message).toBe('看下 Bug #14153 + #14112 Agent 手机端不同步/不显示');
+ expect(sentPayload.editorData).toBeUndefined();
+ expect(homeDailyBriefState.advance).toHaveBeenCalledTimes(1);
+ });
});
diff --git a/src/routes/(main)/home/features/InputArea/useSend.ts b/src/routes/(main)/home/features/InputArea/useSend.ts
index 10bb2863720..a97cb8b19a8 100644
--- a/src/routes/(main)/home/features/InputArea/useSend.ts
+++ b/src/routes/(main)/home/features/InputArea/useSend.ts
@@ -61,7 +61,6 @@ export const useSend = () => {
// `onChange`, so a fast type-then-Enter sequence can fire before the
// cache catches up and the empty-message guard would bail incorrectly.
const typed = (getMarkdownContent?.() ?? inputMessage ?? '').trim();
- const editorData = getEditorData?.() ?? mainInputEditor?.getJSONState();
const fileList = fileChatSelectors.chatUploadFileList(useFileStore.getState());
const contextList = fileChatSelectors.chatContextSelections(useFileStore.getState());
const { sendAsAgent, sendAsGroup, sendAsWrite, sendAsResearch, inputActiveMode } =
@@ -76,6 +75,17 @@ export const useSend = () => {
const message = typed || hint;
if (usedHint) advance();
+ // When falling back to the hint, the editor is empty — but its JSON
+ // state still contains root nodes (e.g. `{ type: 'doc' }`), which is
+ // truthy under `Object.keys(editorData).length > 0`. That makes the
+ // user-message renderer take the RichTextMessage branch and draw
+ // nothing, so the chat shows a blank user bubble while the agent
+ // happily processes the hint text. Skip editorData in that case so
+ // the renderer falls back to the markdown `content`.
+ const editorData = usedHint
+ ? undefined
+ : (getEditorData?.() ?? mainInputEditor?.getJSONState());
+
// Require input content (except for default inbox which can have files/context)
if (!message && fileList.length === 0 && contextList.length === 0) return;