Skip to content

Commit 845f4cb

Browse files
bloveclaude
andcommitted
build(chat): consume partial-markdown 0.5.2 — streaming table headers
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent b79b667 commit 845f4cb

3 files changed

Lines changed: 34 additions & 6 deletions

File tree

libs/chat/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
"dependencies": {
1212
"@cacheplane/partial-json": ">=0.1.1 <0.3.0",
13-
"@cacheplane/partial-markdown": "^0.5.0"
13+
"@cacheplane/partial-markdown": "^0.5.2"
1414
},
1515
"peerDependencies": {
1616
"zod": "^3.25.0",
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// SPDX-License-Identifier: MIT
2+
//
3+
// Consumer-side guarantee: with the partial-markdown version chat depends on, a
4+
// streaming table header renders as a `table` immediately — before the delimiter
5+
// row and while it is buffered awaiting the delimiter — instead of blanking out.
6+
// Guards against a dependency downgrade reintroducing the table blank/flash.
7+
import { describe, it, expect } from 'vitest';
8+
import { createPartialMarkdownParser, materialize } from '@cacheplane/partial-markdown';
9+
10+
function topType(p: ReturnType<typeof createPartialMarkdownParser>): string | null {
11+
const doc = materialize(p.root) as { children?: Array<{ type: string }> } | null;
12+
return doc?.children?.[0]?.type ?? null;
13+
}
14+
15+
describe('libs/chat consumes streaming table headers', () => {
16+
it('shows a table header immediately, before and during the delimiter wait', () => {
17+
const p = createPartialMarkdownParser();
18+
p.push('| Name | Age |'); // first row, still on the open line (no newline)
19+
expect(topType(p)).toBe('table'); // pre-0.5.2: null (header buffered/blank)
20+
p.push('\n'); // header committed; delimiter not yet streamed
21+
expect(topType(p)).toBe('table'); // pre-0.5.2: null (the blank gap)
22+
p.push('| --- | --- |\n| Ada | 36 |\n'); // delimiter + body commit
23+
const doc = materialize(p.root) as any;
24+
expect(doc.children).toHaveLength(1);
25+
expect(doc.children[0].type).toBe('table');
26+
expect(doc.children[0].children.length).toBeGreaterThanOrEqual(2); // header + body
27+
});
28+
});

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)