Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(rich-answer): report numbering gaps as missing operations

Zhang Yunjin3c637f5f14c5
diff --git a/packages/maker-shared/src/__tests__/richAnswer.test.ts b/packages/maker-shared/src/__tests__/richAnswer.test.ts
index 8a6bfd69d8..38f37e8f2e 100644
--- a/packages/maker-shared/src/__tests__/richAnswer.test.ts
+++ b/packages/maker-shared/src/__tests__/richAnswer.test.ts
@@ -64,10 +64,10 @@ describe('streaming answer documents', () => {
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);
+ expect(doc.issues).toBe(2); // the malformed line itself + the skipped sequence 3
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);
+ expect(skipped.issues).toBe(1);
});
});
it('restores persisted controls without overwriting input entered during a slow load', async () => {
diff --git a/packages/maker-shared/src/richAnswer.ts b/packages/maker-shared/src/richAnswer.ts
index e07f53e82b..dc3a6c8bad 100644
--- a/packages/maker-shared/src/richAnswer.ts
+++ b/packages/maker-shared/src/richAnswer.ts
@@ -182,8 +182,9 @@ export class RichAnswerStream {
throw Error("sequence");
const seq = Number(op.seq);
if (seq <= this.seq) return;
- // A malformed or absent line leaves a numbering gap; committed content stays
- // and later lines still apply instead of being orphaned behind the gap.
+ // A malformed or absent line leaves a numbering gap: committed content stays,
+ // the missing operations are reported, and later lines still apply.
+ this.issues += Math.min(seq - this.seq - 1, MAX_NODES);
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");