Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ai/rsc): Add experimental_textRender #1195

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/swift-donkeys-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'ai': patch
---

feat(ai/rsc): add async iterator based experimental_textRender
280 changes: 261 additions & 19 deletions packages/core/rsc/__snapshots__/streamable.ui.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`rsc - render() > should emit React Nodes with async render function 1`] = `
{
"children": {
"children": {},
"props": {
"c": undefined,
"n": {
"done": true,
"value": <div>
Weather
</div>,
},
},
"type": "",
},
"props": {
"fallback": undefined,
},
"type": "Symbol(react.suspense)",
}
`;

exports[`rsc - render() > should emit React Nodes with generator render function 1`] = `
{
"children": {
"children": {},
Expand All @@ -14,6 +36,28 @@ exports[`rsc - render() > should emit React Nodes with async render function 1`]
Weather
</div>,
},
"value": <div>
Loading...
</div>,
},
},
"type": "",
},
"props": {
"fallback": undefined,
},
"type": "Symbol(react.suspense)",
}
`;

exports[`rsc - render() > should emit React Nodes with sync render function 1`] = `
{
"children": {
"children": {},
"props": {
"c": undefined,
"n": {
"done": true,
"value": <div>
Weather
</div>,
Expand All @@ -28,7 +72,7 @@ exports[`rsc - render() > should emit React Nodes with async render function 1`]
}
`;

exports[`rsc - render() > should emit React Nodes with generator render function 1`] = `
exports[`rsc - render() > should support text generation 1`] = `
{
"children": {
"children": {},
Expand All @@ -39,18 +83,48 @@ exports[`rsc - render() > should emit React Nodes with generator render function
"next": {
"done": false,
"next": {
"done": true,
"value": <div>
Weather
</div>,
"done": false,
"next": {
"done": false,
"next": {
"done": false,
"next": {
"done": true,
"value": <p>
true
:
Hello, world.
</p>,
},
"value": <p>
true
:
Hello, world.
</p>,
},
"value": <p>
false
:
Hello, world.
</p>,
},
"value": <p>
false
:
Hello, world
</p>,
},
"value": <div>
Weather
</div>,
"value": <p>
false
:
Hello,
</p>,
},
"value": <div>
Loading...
</div>,
"value": <p>
false
:
Hello
</p>,
},
},
"type": "",
Expand All @@ -62,7 +136,7 @@ exports[`rsc - render() > should emit React Nodes with generator render function
}
`;

exports[`rsc - render() > should emit React Nodes with sync render function 1`] = `
exports[`rsc - render() > should support textRender 1`] = `
{
"children": {
"children": {},
Expand All @@ -71,14 +145,182 @@ exports[`rsc - render() > should emit React Nodes with sync render function 1`]
"n": {
"done": false,
"next": {
"done": true,
"value": <div>
Weather
</div>,
"done": false,
"next": {
"done": false,
"next": {
"done": false,
"next": {
"done": false,
"next": {
"done": true,
"value": <div>
done.
</div>,
},
"value": <p>
true
:
Hello, world.
:

</p>,
},
"value": <p>
false
:
Hello, world.
:
.
</p>,
},
"value": <p>
false
:
Hello, world
:
world
</p>,
},
"value": <p>
false
:
Hello,
:
,
</p>,
},
"value": <div>
Weather
</div>,
"value": <p>
false
:
Hello
:
Hello
</p>,
},
},
"type": "",
},
"props": {
"fallback": undefined,
},
"type": "Symbol(react.suspense)",
}
`;

exports[`rsc - render() > should support textRender with a direct return 1`] = `
{
"children": {
"children": {},
"props": {
"c": undefined,
"n": {
"done": true,
"value": <React.Suspense
fallback={
<p>
initial
</p>
}
>
<Unknown
c={
<p>
initial
</p>
}
n={
{
"done": false,
"next": {
"done": false,
"next": {
"done": false,
"next": {
"done": false,
"next": {
"done": false,
"next": {
"done": true,
"value": <p>
{"content":"Hello, world.","done":true,"delta":""}
</p>,
},
"value": <p>
{"content":"Hello, world.","done":true,"delta":""}
</p>,
},
"value": <p>
{"content":"Hello, world.","done":false,"delta":"."}
</p>,
},
"value": <p>
{"content":"Hello, world","done":false,"delta":" world"}
</p>,
},
"value": <p>
{"content":"Hello,","done":false,"delta":","}
</p>,
},
"value": <p>
{"content":"Hello","done":false,"delta":"Hello"}
</p>,
}
}
/>
</React.Suspense>,
},
},
"type": "",
},
"props": {
"fallback": undefined,
},
"type": "Symbol(react.suspense)",
}
`;

exports[`rsc - render() > should support textRender without return value 1`] = `
{
"children": {
"children": {},
"props": {
"c": undefined,
"n": {
"done": false,
"next": {
"done": false,
"next": {
"done": false,
"next": {
"done": false,
"next": {
"done": false,
"next": {
"done": true,
"value": <p>
{"content":"Hello, world.","done":true,"delta":""}
</p>,
},
"value": <p>
{"content":"Hello, world.","done":true,"delta":""}
</p>,
},
"value": <p>
{"content":"Hello, world.","done":false,"delta":"."}
</p>,
},
"value": <p>
{"content":"Hello, world","done":false,"delta":" world"}
</p>,
},
"value": <p>
{"content":"Hello,","done":false,"delta":","}
</p>,
},
"value": <p>
{"content":"Hello","done":false,"delta":"Hello"}
</p>,
},
},
"type": "",
Expand Down
Loading
Loading