Fix ListRef handling in streaming data — list from SX is ListRef in OCaml
The streaming render matched `List items` but SX's `(list ...)` produces `ListRef` (mutable list) in the OCaml runtime. Data items were rejected with "returned list, expected dict or list" — 0 resolve chunks sent. Fixed both streaming render and AJAX paths to handle ListRef. Added sandbox test for streaming-demo-data return type validation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -263,6 +263,34 @@ test.describe('Streaming sandbox', () => {
|
||||
await expect(page.locator('[data-suspense="stream-slow"]')).toContainText('Slow resolved!');
|
||||
});
|
||||
|
||||
test('streaming-demo-data returns iterable list of dicts with stream-ids', async ({ page }) => {
|
||||
const errors = await bootSandbox(page);
|
||||
expect(errors).toEqual([]);
|
||||
|
||||
// Verify the data function returns a list that can be iterated
|
||||
// (catches ListRef vs List type mismatch)
|
||||
const result = await page.evaluate(() => {
|
||||
const K = window.SxKernel;
|
||||
try {
|
||||
const type = K.eval('(type-of (streaming-demo-data))');
|
||||
const len = K.eval('(len (streaming-demo-data))');
|
||||
const ids = K.eval('(join "," (map (fn (item) (get item "stream-id")) (streaming-demo-data)))');
|
||||
const delays = K.eval('(join "," (map (fn (item) (str (get item "delay"))) (streaming-demo-data)))');
|
||||
return { type, len, ids, delays };
|
||||
} catch(e) {
|
||||
return { error: e.message };
|
||||
}
|
||||
});
|
||||
|
||||
expect(result.error || '').toBe('');
|
||||
expect(result.type).toBe('list');
|
||||
expect(result.len).toBe(3);
|
||||
expect(result.ids).toContain('stream-fast');
|
||||
expect(result.ids).toContain('stream-medium');
|
||||
expect(result.ids).toContain('stream-slow');
|
||||
expect(result.delays).toContain('1000');
|
||||
});
|
||||
|
||||
test('streaming shell renders with outer layout gutters', async ({ page }) => {
|
||||
const errors = await bootSandbox(page);
|
||||
expect(errors).toEqual([]);
|
||||
|
||||
Reference in New Issue
Block a user