Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 保留列表编号与圆点输入
zhangyongjie949210355139
diff --git a/apps/desktop/src/renderer/__tests__/composerListDocument.test.ts b/apps/desktop/src/renderer/__tests__/composerListDocument.test.tsindex 1bc4e52561..d91dce7ac2 100644--- a/apps/desktop/src/renderer/__tests__/composerListDocument.test.ts+++ b/apps/desktop/src/renderer/__tests__/composerListDocument.test.ts@@ -87,6 +87,48 @@ describe('composer list document normalization', () => {});});+ it('keeps non-contiguous ordered rows as separate lists', () => {+ expect(+ normalizeComposerDocumentJSON({+ type: 'doc',+ content: [+ {+ type: 'paragraph',+ content: [+ { type: 'text', text: '1. first' },+ { type: 'hardBreak' },+ { type: 'text', text: '3. third' },+ ],+ },+ ],+ }),+ ).toEqual({+ type: 'doc',+ content: [+ {+ type: 'orderedList',+ attrs: { start: 1, marker: '.' },+ content: [+ {+ type: 'listItem',+ content: [{ type: 'paragraph', content: [{ type: 'text', text: 'first' }] }],+ },+ ],+ },+ {+ type: 'orderedList',+ attrs: { start: 3, marker: '.' },+ content: [+ {+ type: 'listItem',+ content: [{ type: 'paragraph', content: [{ type: 'text', text: 'third' }] }],+ },+ ],+ },+ ],+ });+ });+it('leaves existing structured content unchanged', () => {const document = {type: 'doc' as const,diff --git a/apps/desktop/src/renderer/__tests__/composerStructuredLists.test.ts b/apps/desktop/src/renderer/__tests__/composerStructuredLists.test.tsindex 1daf96a6a0..505f2efeae 100644--- a/apps/desktop/src/renderer/__tests__/composerStructuredLists.test.ts+++ b/apps/desktop/src/renderer/__tests__/composerStructuredLists.test.ts@@ -105,6 +105,11 @@ describe('composer structured list input rules', () => {listType: 'bulletList',attrs: {},},+ {+ typed: '• ',+ listType: 'bulletList',+ attrs: {},+ },{typed: '1. ',listType: 'orderedList',@@ -549,6 +554,23 @@ describe('composer live plain-list promotion', () => {expect(promoteTrailingPlainListParagraph(editor.view)).toBe(false);expect(editor.state.doc.lastChild?.type.name).toBe('paragraph');});++ it('promotes a trailing bullet-glyph row inserted outside input rules', () => {+ const editor = makeEditor({+ type: 'doc',+ content: [+ {+ type: 'paragraph',+ content: [{ type: 'text', text: '• item' }],+ },+ ],+ });+ selectDocumentEnd(editor);++ expect(promoteTrailingPlainListParagraph(editor.view)).toBe(true);+ expect(editor.state.doc.firstChild?.type.name).toBe('bulletList');+ expect(editor.state.doc.firstChild?.firstChild?.textContent).toBe('item');+ });});describe('composer structured list serialization', () => {diff --git a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsxindex f26b412c68..178659cd80 100644--- a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx+++ b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx@@ -5004,7 +5004,7 @@ export function ChatInput({{/* Browser comment chip:页面评论收敛为一个「N 条注释」胶囊,hover 浮出逐条预览(截图缩略 + 目标标签 + 评论文字,可逐条删),- X 清空全部。发送时序化为 `# Browser comments:` 段 + 截图附件。 */}+ X 清空全部。发送时序列化为 `# Browser comments:` 段 + 截图附件。 */}{browserComments.length > 0 && (<div className="pb-1.5"><div className="group/bcomment relative inline-flex">diff --git a/apps/desktop/src/renderer/components/new-chat/ComposerListNodes.ts b/apps/desktop/src/renderer/components/new-chat/ComposerListNodes.tsindex 3e6b90a756..442cac6a83 100644--- a/apps/desktop/src/renderer/components/new-chat/ComposerListNodes.ts+++ b/apps/desktop/src/renderer/components/new-chat/ComposerListNodes.ts@@ -142,10 +142,10 @@ export const ComposerBulletList = Node.create({addInputRules() {return [wrappingInputRule({- find: /^\s*([-+*])\s$/,+ find: /^\s*([-+*•])\s$/,type: this.type,}),- hardBreakListInputRule(/^\s*([-+*])\s$/, this.type),+ hardBreakListInputRule(/^\s*([-+*•])\s$/, this.type),];},});diff --git a/apps/desktop/src/renderer/lib/composerListDocument.ts b/apps/desktop/src/renderer/lib/composerListDocument.tsindex 149e2a8f3c..045b7c3024 100644--- a/apps/desktop/src/renderer/lib/composerListDocument.ts+++ b/apps/desktop/src/renderer/lib/composerListDocument.ts@@ -135,6 +135,16 @@ function sameListMarker(left: ListMarker, right: ListMarker): boolean {return left.kind === right.kind && left.marker === right.marker;}+function canAppendListLine(+ current: ListMarker,+ currentLineCount: number,+ next: ListMarker,+): boolean {+ if (!sameListMarker(current, next)) return false;+ if (current.kind === 'bullet') return true;+ return next.start === (current.start ?? 1) + currentLineCount;+}+function paragraphToBlocks(paragraph: JSONContent): JSONContent[] {const lines = splitParagraphLines(paragraph);if (!lines.some((line) => parseListMarker(line.text))) return [paragraph];@@ -169,7 +179,7 @@ function paragraphToBlocks(paragraph: JSONContent): JSONContent[] {plainLines.push(line);continue;}- if (listMarker && !sameListMarker(listMarker, marker)) flushList();+ if (listMarker && !canAppendListLine(listMarker, listLines.length, marker)) flushList();flushPlain();listMarker ??= marker;listLines.push(line);