Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(maker-shared): 隐式正文子节点只在仍是容器末子时复用
Zhang Yunjin82c77599ed31
diff --git a/packages/maker-shared/src/__tests__/richAnswer.test.ts b/packages/maker-shared/src/__tests__/richAnswer.test.tsindex 363c73e901..39c966e36d 100644--- a/packages/maker-shared/src/__tests__/richAnswer.test.ts+++ b/packages/maker-shared/src/__tests__/richAnswer.test.ts@@ -512,6 +512,23 @@ describe('append to a container stays readable', () => {expect(doc.nodes.get('card-1')?.props.text).toBe('onetwo');expect(doc.issues).toBe(0);});++ // 维护者 zqchris:append → create 子节点 → 再 append 时,第二段正文不能并进+ // 排在子节点之前的隐式子节点,否则读者看到的顺序与模型写的顺序不一致。+ it('keeps appended prose in the order the model wrote it', () => {+ const doc = new RichAnswerStream().update(+ line(1, { op: 'create', id: 'card', kind: 'stack' }) ++ line(2, { op: 'append', id: 'card', text: 'before' }) ++ line(3, { op: 'create', id: 'table', kind: 'markdown', parent: 'card', props: { text: '| a |' } }) ++ line(4, { op: 'append', id: 'card', text: 'after' }),+ );+ const children = doc.nodes.get('card')?.children ?? [];+ expect(children).toHaveLength(3);+ expect(doc.nodes.get(children[0])?.props.text).toBe('before');+ expect(doc.nodes.get(children[1])?.props.text).toBe('| a |');+ expect(doc.nodes.get(children[2])?.props.text).toBe('after');+ expect(doc.issues).toBe(0);+ });});describe('inline draft limits', () => {it('caps nested inline drafts at the depth limit', () => {diff --git a/packages/maker-shared/src/richAnswer.ts b/packages/maker-shared/src/richAnswer.tsindex 47adc5121c..bd0b868416 100644--- a/packages/maker-shared/src/richAnswer.ts+++ b/packages/maker-shared/src/richAnswer.ts@@ -281,13 +281,16 @@ export class RichAnswerStream {// container instead of being dropped, like the #7627 salvages.const existing = this.implicitText.get(current.id);const child = existing ? this.nodes.get(existing) : undefined;- // Reuse only the implicit markdown child this container owns: a- // rebuilt container may already hold a different node under the same- // id, and prose written into e.g. a stat would never be displayed.+ // Reuse only the implicit markdown child this container owns, and+ // only while it is still the last child: a rebuilt container may hold+ // a different node under the same id, and prose written into e.g. a+ // stat would never be displayed. Reusing a child that sits before+ // later children would also reorder the answer against the order the+ // model wrote it in.if (child &&child.kind === "markdown" &&- current.children.includes(existing!)+ current.children.at(-1) === existing) {this.nodes.set(child.id, {...child,