🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(chat-input): send pasted text verbatim instead of reformatting it as markdown (#22189)
Inneibb79ff331482
diff --git a/package.json b/package.jsonindex 9ac005be38f..f9488a27c39 100644--- a/package.json+++ b/package.json@@ -328,7 +328,7 @@"@lobehub/analytics": "^1.6.4","@lobehub/charts": "^6.0.0","@lobehub/desktop-ipc-typings": "workspace:*",- "@lobehub/editor": "7.1.0",+ "@lobehub/editor": "7.2.0","@lobehub/icons": "^6.13.0","@lobehub/market-sdk": "0.46.0","@lobehub/ui": "^6.9.0",diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yamlindex 55bb8902eb2..a5b43712ee9 100644--- a/pnpm-workspace.yaml+++ b/pnpm-workspace.yaml@@ -67,7 +67,7 @@ overrides:'@lobehub/icons': ^6.0.0# Exact: an editor release can move its lexical version, and the root pins# lexical; lift both together.- '@lobehub/editor': 7.1.0+ '@lobehub/editor': 7.2.0'@lobehub/charts': ^6.0.0'@lobehub/fluent-emoji': ^5.0.0# Stay on the latest 1.9.x: @opentelemetry/*@2.x peers reject 1.10.0, and mixing both splits drizzle-orm into duplicate peer variants.diff --git a/src/features/ChatInput/editorDocument.ts b/src/features/ChatInput/editorDocument.tsindex 4dd013edc0c..9140deda798 100644--- a/src/features/ChatInput/editorDocument.ts+++ b/src/features/ChatInput/editorDocument.ts@@ -6,10 +6,14 @@ import type { IEditor } from '@lobehub/editor';// failure as an empty composer — persisting that emptiness deletes the draft.export const canSerialize = (editor?: IEditor) => !!editor?.getLexicalEditor();-export const readDocument = (editor: IEditor | undefined, type: string): unknown => {+export const readDocument = (+ editor: IEditor | undefined,+ type: string,+ options?: Parameters<IEditor['getDocument']>[1],+): unknown => {if (!canSerialize(editor)) return undefined;try {- return editor!.getDocument(type);+ return editor!.getDocument(type, options);} catch {return undefined;}diff --git a/src/features/ChatInput/store/action.test.ts b/src/features/ChatInput/store/action.test.tsindex 7b0df93012b..af4dfbbfb78 100644--- a/src/features/ChatInput/store/action.test.ts+++ b/src/features/ChatInput/store/action.test.ts@@ -1,5 +1,6 @@import type { IEditor } from '@lobehub/editor';-import { KEY_ESCAPE_COMMAND } from 'lexical';+import { CommonPlugin, Kernel, MarkdownPlugin } from '@lobehub/editor';+import { $createParagraphNode, $createTextNode, $getRoot, KEY_ESCAPE_COMMAND } from 'lexical';import { beforeEach, describe, expect, it, vi } from 'vitest';import { useAgentStore } from '@/store/agent';@@ -289,4 +290,36 @@ describe('ChatInput store actions', () => {expect(getInputHistory()).toEqual([]);});++ it('sends a prompt pasted as plain text verbatim instead of reformatting it as markdown', () => {+ const prompt = [+ '# Role',+ 'You are a **terse** reviewer.',+ '* Compute 2 * 3 and cite [the answer]',+ ' keep this indented line',+ '1. Read the diff.',+ ].join('\n');+ const editor = new Kernel();+ editor.registerPlugins([CommonPlugin, MarkdownPlugin]);+ editor.initNodeEditor();+ editor.getLexicalEditor()!.update(+ () => {+ const paragraph = $createParagraphNode();+ paragraph.append($createTextNode(prompt));+ $getRoot().clear().append(paragraph);+ },+ { discrete: true },+ );+ let sent: string | undefined;+ const store = createStore({+ editor: editor as unknown as IEditor,+ onSend: ({ getMarkdownContent }) => {+ sent = getMarkdownContent();+ },+ });++ store.getState().handleSendButton();++ expect(sent).toBe(prompt);+ });});diff --git a/src/features/ChatInput/store/action.ts b/src/features/ChatInput/store/action.tsindex 6171bce08fc..5c7248b2d4e 100644--- a/src/features/ChatInput/store/action.ts+++ b/src/features/ChatInput/store/action.ts@@ -57,7 +57,7 @@ export const store: CreateStore = (publicState) => (set, get) => ({return readDocument(get().editor, 'json') as Record<string, any> | undefined;},getMarkdownContent: () => {- return String(readDocument(get().editor, 'markdown') || '').trimEnd();+ return String(readDocument(get().editor, 'markdown', { format: false }) || '').trimEnd();},handleSendButton: () => {const editor = get().editor;