Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(rich-answer): commit later component ops after a malformed line
Zhang Yunjin140908e7af9d
diff --git a/packages/maker-shared/src/__tests__/richAnswer.test.ts b/packages/maker-shared/src/__tests__/richAnswer.test.tsindex 1d092c5b07..8a6bfd69d8 100644--- a/packages/maker-shared/src/__tests__/richAnswer.test.ts+++ b/packages/maker-shared/src/__tests__/richAnswer.test.ts@@ -56,6 +56,19 @@ describe('streaming answer documents', () => {expect(doc.nodes.get('text')?.props.text).toBe('Readable');expect(doc.issues).toBe(1);});+ it('commits later operations after a malformed or skipped sequence instead of orphaning them', () => {+ // Real-world regression (session 3c876950): one unescaped quote in a props.text+ // used to reject every following line via the strict +1 gate, dropping 9 of 13 ops.+ const heading = (seq: number, id: string) => line(seq, { op: 'create', id, kind: 'heading', props: { text: id } });+ const malformed = '{"seq":3,"op":"create","id":"bad","kind":"markdown","props":{"text":"记了"注入"缺陷"}}\n';+ const doc = new RichAnswerStream().update(heading(1, 'a') + heading(2, 'b') + malformed + heading(4, 'c') + heading(5, 'd'));+ expect(doc.roots).toEqual(['a', 'b', 'c', 'd']);+ expect(doc.nodes.has('bad')).toBe(false);+ expect(doc.issues).toBe(1);+ const skipped = new RichAnswerStream().update(heading(1, 'a') + heading(3, 'c') + heading(4, 'd'));+ expect(skipped.roots).toEqual(['a', 'c', 'd']);+ expect(skipped.issues).toBe(0);+ });});it('restores persisted controls without overwriting input entered during a slow load', async () => {let release!: (value: string | null) => void;diff --git a/packages/maker-shared/src/richAnswer.ts b/packages/maker-shared/src/richAnswer.tsindex c8a9689293..e07f53e82b 100644--- a/packages/maker-shared/src/richAnswer.ts+++ b/packages/maker-shared/src/richAnswer.ts@@ -182,7 +182,8 @@ export class RichAnswerStream {throw Error("sequence");const seq = Number(op.seq);if (seq <= this.seq) return;- if (seq !== this.seq + 1) throw Error("gap");+ // A malformed or absent line leaves a numbering gap; committed content stays+ // and later lines still apply instead of being orphaned behind the gap.this.seq = seq;if (op.version !== undefined && op.version !== 1) throw Error("version");if (typeof op.id !== "string" || !ID.test(op.id)) throw Error("id");