Skip to content

Commit 4b43236

Browse files
committed
fix(shell-docs): wire generative-ui pages with framework-aware demo content
The four pages all had the same shape problem: prose followed by <IntegrationGrid>, which hides on framework-scoped routes via useFramework() -> null. On /<framework>/<slug> URLs the picker disappears and the page truncates to a content-less heading. Add InlineDemo + Snippet + FeatureIntegrations blocks above the picker so framework-scoped routes still render demo content: - interactive.mdx: cell gen-ui-interrupt, regions frontend-useinterrupt-render and backend-interrupt-tool. - state-rendering.mdx: cell shared-state-streaming, regions frontend-use-coagent-state and state-streaming-middleware. - display.mdx: cell gen-ui-tool-based, region bar-chart-renderer. Drop the hardcoded '## Choose your Integration' heading (IntegrationGrid renders its own '<h2>Choose your AI backend</h2>'). - your-components/display-only.mdx: same fix as display.mdx. Mirrors the wiring pattern in frontend-tools.mdx and the slot-2 fix for shared-state.mdx.
1 parent 43d62e3 commit 4b43236

4 files changed

Lines changed: 63 additions & 1 deletion

File tree

showcase/shell-docs/src/content/docs/generative-ui/display.mdx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ title: Display components
33
icon: "lucide/Eye"
44
description: Register React components that your agent can render in the chat.
55
hideTOC: true
6+
snippet_cell: gen-ui-tool-based
67
---
78

89
## What is this?
910

1011
Render-only generative UI lets you register React components as tools your agent can invoke. When the agent calls the tool, CopilotKit renders your component directly in the chat with the tool's arguments as props; no handler logic or user interaction required.
1112

13+
<InlineDemo demo="gen-ui-tool-based" />
14+
1215
<Tabs items={['page.tsx', 'chart.tsx']}>
1316
<Tab value="page.tsx">
1417
```tsx
@@ -57,6 +60,14 @@ Use render-only generative UI when you want to:
5760
- Render previews, status indicators, or visual feedback
5861
- Let the agent present information beyond plain text
5962

60-
## Choose your Integration
63+
## How it works in code
64+
65+
The renderer component receives the tool's arguments as typed props and
66+
mounts inline in the chat. Below is the chart renderer wired up in the
67+
canonical demothe agent emits the data, the component draws it.
68+
69+
<Snippet region="bar-chart-renderer" title="frontend/src/app/page.tsx — bar chart renderer" />
70+
71+
<FeatureIntegrations feature="gen-ui-tool-based" />
6172

6273
<IntegrationGrid path="render-only" />

showcase/shell-docs/src/content/docs/generative-ui/interactive.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ title: Interactive components
33
icon: "lucide/CirclePause"
44
description: Create approval flows where the agent pauses and waits for human input.
55
hideTOC: true
6+
snippet_cell: gen-ui-interrupt
67
---
78

89
## What is this?
910

1011
Interactive generative UI creates flows where the agent pauses execution and waits for user input before continuing. This enables approval workflows, confirmation dialogs, and any scenario where human judgment is needed mid-execution.
1112

13+
<InlineDemo demo="gen-ui-interrupt" />
14+
1215
## When should I use this?
1316

1417
Use interactive generative UI when you need:
@@ -18,4 +21,19 @@ Use interactive generative UI when you need:
1821
- Confirmation dialogs with structured responses
1922
- Any flow where the agent pauses for human judgment
2023

24+
## How it works in code
25+
26+
On the frontend, register an interrupt renderer with `useInterrupt`. When the
27+
agent pauses, your component mounts inline in the chat, captures the user's
28+
choice, and resumes the run with that input.
29+
30+
<Snippet region="frontend-useinterrupt-render" title="frontend/src/app/page.tsx — useInterrupt" />
31+
32+
On the backend, the agent calls into the interrupt primitive and waits for
33+
the resumed response before continuing the graph.
34+
35+
<Snippet region="backend-interrupt-tool" title="backend — interrupt tool" />
36+
37+
<FeatureIntegrations feature="gen-ui-interrupt" />
38+
2139
<IntegrationGrid path="human-in-the-loop" />

showcase/shell-docs/src/content/docs/generative-ui/state-rendering.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: State Rendering
33
icon: "lucide/Bot"
44
description: Render your agent's state with custom UI components in real-time.
55
hideTOC: true
6+
snippet_cell: shared-state-streaming
67
---
78

89
## What is this?
@@ -13,6 +14,8 @@ State rendering lets you build UI that reflects your agent's state in real-time.
1314
**Free course:** See this pattern built end-to-end in [Build Interactive Agents with Generative UI](https://www.deeplearning.ai/short-courses/build-interactive-agents-with-generative-ui/) — a free DeepLearning.AI short course taught by CopilotKit's CEO covering the full Generative UI spectrum (Controlled, Declarative, and Open-Ended).
1415
</Callout>
1516

17+
<InlineDemo demo="shared-state-streaming" />
18+
1619
## When should I use this?
1720

1821
Use state rendering when you want to:
@@ -22,6 +25,23 @@ Use state rendering when you want to:
2225
- Build dashboards that reflect agent state
2326
- Render structured output outside of the chat
2427

28+
## How it works in code
29+
30+
On the frontend, subscribe to the agent's state. Each time the backend
31+
forwards a fresh value, your component re-renders with the latest partial
32+
output.
33+
34+
<Snippet region="frontend-use-coagent-state" title="frontend/src/app/page.tsx — agent state subscription" />
35+
36+
On the backend, a state-streaming middleware forwards a specific tool
37+
argument straight into a state key *as it's being generated*, so the UI can
38+
watch the answer assemble token-by-token rather than appearing in one burst
39+
between node transitions.
40+
41+
<Snippet region="state-streaming-middleware" title="backend — StateStreamingMiddleware" />
42+
43+
<FeatureIntegrations feature="shared-state-streaming" />
44+
2545
<IntegrationGrid
2646
path="generative-ui/state-rendering"
2747
exclude={["agno", "agent-spec"]}

showcase/shell-docs/src/content/docs/generative-ui/your-components/display-only.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: Display Components
33
icon: "lucide/Eye"
44
description: Register React components that your agent can render in the chat.
55
hideTOC: true
6+
snippet_cell: gen-ui-tool-based
67
---
78

89
## What is this?
@@ -13,6 +14,8 @@ Display-only generative UI lets you register React components as tools your agen
1314
**Free course:** See this pattern built end-to-end in [Build Interactive Agents with Generative UI](https://www.deeplearning.ai/short-courses/build-interactive-agents-with-generative-ui/) — a free DeepLearning.AI short course taught by CopilotKit's CEO covering the full Generative UI spectrum (Controlled, Declarative, and Open-Ended).
1415
</Callout>
1516

17+
<InlineDemo demo="gen-ui-tool-based" />
18+
1619
<Tabs items={['page.tsx', 'chart.tsx']}>
1720
<Tab value="page.tsx">
1821
```tsx
@@ -61,4 +64,14 @@ Use display-only generative UI when you want to:
6164
- Render previews, status indicators, or visual feedback
6265
- Let the agent present information beyond plain text
6366

67+
## How it works in code
68+
69+
The renderer component receives the tool's arguments as typed props and
70+
mounts inline in the chat. Below is the chart renderer wired up in the
71+
canonical demothe agent emits the data, the component draws it.
72+
73+
<Snippet region="bar-chart-renderer" title="frontend/src/app/page.tsx — bar chart renderer" />
74+
75+
<FeatureIntegrations feature="gen-ui-tool-based" />
76+
6477
<IntegrationGrid path="generative-ui/your-components/display-only" />

0 commit comments

Comments
 (0)