Skip to content

Commit 37aa88e

Browse files
committed
hide templates feature from UI and agent
Remove template library drawer, template chips, template tools registration, and template-related agent state fields. Component files are kept in the codebase for future re-enablement. Closes #59
1 parent 63f502f commit 37aa88e

File tree

5 files changed

+200
-62
lines changed

5 files changed

+200
-62
lines changed

apps/agent/main.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@
1818
from src.query import query_data
1919
from src.todos import AgentState, todo_tools
2020
from src.form import generate_form
21-
from src.templates import template_tools
2221

2322
load_dotenv()
2423

2524
agent = create_deep_agent(
2625
model=ChatOpenAI(model=os.environ.get("LLM_MODEL", "gpt-5.4-2026-03-05")),
27-
tools=[query_data, *todo_tools, generate_form, *template_tools],
26+
tools=[query_data, *todo_tools, generate_form],
2827
middleware=[CopilotKitMiddleware()],
2928
context_schema=AgentState,
3029
skills=[str(Path(__file__).parent / "skills")],
@@ -67,27 +66,6 @@
6766
6867
**Critical**: `<script type="module">` is REQUIRED when using import map libraries. Regular `<script>` tags cannot use `import` statements.
6968
70-
## UI Templates
71-
72-
Users can save generated UIs as reusable templates and apply them later.
73-
You have backend tools: `save_template`, `list_templates`, `apply_template`, `delete_template`.
74-
75-
**When a user asks to apply/recreate a template with new data:**
76-
Check `pending_template` in state — the frontend sets this when the user picks a template.
77-
If `pending_template` is present (has `id` and `name`):
78-
1. Call `apply_template(template_id=pending_template["id"])` to retrieve the HTML
79-
2. Take the returned HTML and COPY IT EXACTLY, only replacing the data values
80-
(names, numbers, dates, labels, amounts) to match the user's message
81-
3. Render the modified HTML using `widgetRenderer`
82-
4. Call `clear_pending_template` to reset the pending state
83-
84-
If no `pending_template` is set but the user mentions a template by name, use
85-
`apply_template(name="...")` instead.
86-
87-
CRITICAL: Do NOT rewrite or generate HTML from scratch. Take the original HTML string,
88-
find-and-replace ONLY the data values, and pass the result to widgetRenderer.
89-
This preserves the exact layout and styling of the original template.
90-
For bar/pie chart templates, use `barChart` or `pieChart` component instead.
9169
""",
9270
)
9371

apps/agent/src/todos.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,18 @@
22
from langchain.tools import ToolRuntime, tool
33
from langchain.messages import ToolMessage
44
from langgraph.types import Command
5-
from typing import Optional, TypedDict, Literal
5+
from typing import TypedDict, Literal
66
import uuid
77

8-
from src.templates import UITemplate
9-
108
class Todo(TypedDict):
119
id: str
1210
title: str
1311
description: str
1412
emoji: str
1513
status: Literal["pending", "completed"]
1614

17-
class PendingTemplate(TypedDict, total=False):
18-
id: str
19-
name: str
20-
2115
class AgentState(BaseAgentState):
2216
todos: list[Todo]
23-
templates: list[UITemplate]
24-
pending_template: Optional[PendingTemplate]
2517

2618
@tool
2719
def manage_todos(todos: list[Todo], runtime: ToolRuntime) -> Command:

apps/app/src/app/page.tsx

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
"use client";
22

3-
import { useEffect, useState } from "react";
3+
import { useEffect } from "react";
44
import { ExampleLayout } from "@/components/example-layout";
55
import { useGenerativeUIExamples, useExampleSuggestions } from "@/hooks";
66
import { ExplainerCardsPortal } from "@/components/explainer-cards";
7-
import { TemplateLibrary } from "@/components/template-library";
8-
import { TemplateChip } from "@/components/template-library/template-chip";
97

108
import { CopilotChat } from "@copilotkit/react-core/v2";
119

1210
export default function HomePage() {
1311
useGenerativeUIExamples();
1412
useExampleSuggestions();
1513

16-
const [templateDrawerOpen, setTemplateDrawerOpen] = useState(false);
17-
1814
// Widget bridge: handle messages from widget iframes
1915
useEffect(() => {
2016
const handler = (e: MessageEvent) => {
@@ -60,23 +56,6 @@ export default function HomePage() {
6056
</p>
6157
</div>
6258
<div className="flex items-center gap-2">
63-
{/* Template Library toggle */}
64-
<button
65-
onClick={() => setTemplateDrawerOpen(true)}
66-
className="inline-flex items-center gap-1.5 px-3 py-2 rounded-full text-sm font-medium no-underline whitespace-nowrap transition-all duration-150 hover:-translate-y-px"
67-
style={{
68-
color: "var(--text-secondary)",
69-
border: "1px solid var(--color-border-glass, rgba(0,0,0,0.1))",
70-
background: "var(--surface-primary, rgba(255,255,255,0.6))",
71-
fontFamily: "var(--font-family)",
72-
}}
73-
title="Open Template Library"
74-
>
75-
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
76-
<path d="m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z" />
77-
</svg>
78-
Templates
79-
</button>
8059
<a
8160
href="https://github.com/CopilotKit/OpenGenerativeUI"
8261
target="_blank"
@@ -105,14 +84,6 @@ export default function HomePage() {
10584
</div>
10685
</div>
10786

108-
{/* Template chip — portal renders above chat input */}
109-
<TemplateChip />
110-
111-
{/* Template Library Drawer */}
112-
<TemplateLibrary
113-
open={templateDrawerOpen}
114-
onClose={() => setTemplateDrawerOpen(false)}
115-
/>
11687
</>
11788
);
11889
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
export type DemoCategory =
2+
| "3D / Animation"
3+
| "Data Visualization"
4+
| "Diagrams"
5+
| "Interactive"
6+
| "UI Components";
7+
8+
export interface DemoItem {
9+
id: string;
10+
title: string;
11+
description: string;
12+
category: DemoCategory;
13+
emoji: string;
14+
prompt: string;
15+
html?: string;
16+
}
17+
18+
export const DEMO_EXAMPLES: DemoItem[] = [
19+
{
20+
id: "demo-pitch-roll-yaw",
21+
title: "Pitch, Roll & Yaw",
22+
description:
23+
"Interactive 3D airplane in Three.js explaining pitch, roll, and yaw with control buttons",
24+
category: "3D / Animation",
25+
emoji: "✈️",
26+
prompt:
27+
"Create a 3D plane in Three.js to explain how pitch, roll, and yaw work. Give me buttons to control each axis. Add labels showing which rotation is which.",
28+
},
29+
{
30+
id: "demo-weather",
31+
title: "Weather Card",
32+
description:
33+
"Current weather conditions with temperature, humidity, wind, and UV index",
34+
category: "UI Components",
35+
emoji: "🌤️",
36+
prompt:
37+
"Create a beautiful weather card showing current conditions for San Francisco with temperature, humidity, wind speed, UV index, and a 5-day mini forecast.",
38+
},
39+
{
40+
id: "demo-binary-search",
41+
title: "Binary Search",
42+
description:
43+
"Step-by-step visualization of binary search on a sorted array",
44+
category: "Diagrams",
45+
emoji: "🔍",
46+
prompt:
47+
"Visualize how binary search works on a sorted list. Step by step with animation. Show the high, low, and mid pointers moving.",
48+
},
49+
{
50+
id: "demo-solar-system",
51+
title: "Solar System",
52+
description:
53+
"3D solar system with orbiting planets you can click for facts",
54+
category: "3D / Animation",
55+
emoji: "🪐",
56+
prompt:
57+
"Build a 3D solar system with orbiting planets using Three.js. Let me click on each planet to see facts about it. Include realistic relative sizes and orbital speeds.",
58+
},
59+
{
60+
id: "demo-dashboard",
61+
title: "KPI Dashboard",
62+
description:
63+
"Quarterly performance dashboard with metrics cards and bar chart",
64+
category: "Data Visualization",
65+
emoji: "📊",
66+
prompt:
67+
"Create a KPI dashboard showing Q1 2026 performance with revenue, active users, and conversion rate. Include a monthly revenue bar chart and trend indicators.",
68+
},
69+
{
70+
id: "demo-sorting",
71+
title: "Sorting Comparison",
72+
description:
73+
"Animated side-by-side comparison of bubble sort vs quicksort",
74+
category: "Diagrams",
75+
emoji: "📶",
76+
prompt:
77+
"Create an animated comparison of bubble sort vs quicksort running side by side on the same random array. Add speed controls and a step counter.",
78+
},
79+
{
80+
id: "demo-pomodoro",
81+
title: "Pomodoro Timer",
82+
description:
83+
"Focus timer with circular progress ring, session counter, and controls",
84+
category: "Interactive",
85+
emoji: "🍅",
86+
prompt:
87+
"Build a Pomodoro timer with a circular progress ring, start/pause/reset buttons, and a session counter. Use 25 min work / 5 min break intervals. Make it look clean and minimal.",
88+
},
89+
{
90+
id: "demo-neural-network",
91+
title: "Neural Network",
92+
description:
93+
"Interactive neural network diagram with animated forward pass",
94+
category: "Diagrams",
95+
emoji: "🧠",
96+
prompt:
97+
"Visualize a simple neural network with input, hidden, and output layers. Animate the forward pass showing data flowing through the network. Let me adjust the number of neurons per layer.",
98+
},
99+
{
100+
id: "demo-invoice",
101+
title: "Invoice Card",
102+
description:
103+
"Compact invoice card with amount, client info, and action buttons",
104+
category: "UI Components",
105+
emoji: "🧾",
106+
prompt:
107+
"Create an invoice card showing a monthly billing summary with client name, amount due, invoice number, and send/expand action buttons.",
108+
},
109+
{
110+
id: "demo-music-visualizer",
111+
title: "Music Equalizer",
112+
description:
113+
"Audio equalizer visualization with animated frequency bars and controls",
114+
category: "3D / Animation",
115+
emoji: "🎵",
116+
prompt:
117+
"Create a music equalizer visualization with animated bars that respond to frequency sliders. Add controls for bass, mid, and treble. Use a gradient color scheme.",
118+
},
119+
];
120+
121+
export const DEMO_CATEGORIES: DemoCategory[] = [
122+
"3D / Animation",
123+
"Data Visualization",
124+
"Diagrams",
125+
"Interactive",
126+
"UI Components",
127+
];
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
"use client";
2+
3+
import { useState } from "react";
4+
import { DEMO_EXAMPLES, type DemoCategory, type DemoItem } from "./demo-data";
5+
import { DemoCard } from "./demo-card";
6+
import { CategoryFilter } from "./category-filter";
7+
8+
interface DemoGalleryProps {
9+
onTryDemo: (demo: DemoItem) => void;
10+
}
11+
12+
export function DemoGallery({ onTryDemo }: DemoGalleryProps) {
13+
const [selectedCategory, setSelectedCategory] =
14+
useState<DemoCategory | null>(null);
15+
16+
const filtered = selectedCategory
17+
? DEMO_EXAMPLES.filter((d) => d.category === selectedCategory)
18+
: DEMO_EXAMPLES;
19+
20+
return (
21+
<div className="flex flex-col gap-4 h-full overflow-hidden">
22+
{/* Header */}
23+
<div className="flex flex-col gap-3 px-6 pt-6 shrink-0">
24+
<div>
25+
<h2
26+
className="text-lg font-semibold"
27+
style={{ color: "var(--text-primary, #1a1a1a)" }}
28+
>
29+
Demo Gallery
30+
</h2>
31+
<p
32+
className="text-xs mt-0.5"
33+
style={{ color: "var(--text-secondary, #666)" }}
34+
>
35+
Click any demo to try it with the AI agent
36+
</p>
37+
</div>
38+
<CategoryFilter
39+
selected={selectedCategory}
40+
onSelect={setSelectedCategory}
41+
/>
42+
</div>
43+
44+
{/* Grid */}
45+
<div className="flex-1 overflow-y-auto px-6 pb-6">
46+
<div
47+
className="grid gap-4"
48+
style={{
49+
gridTemplateColumns: "repeat(auto-fill, minmax(260px, 1fr))",
50+
}}
51+
>
52+
{filtered.map((demo) => (
53+
<DemoCard key={demo.id} demo={demo} onTry={onTryDemo} />
54+
))}
55+
</div>
56+
57+
{filtered.length === 0 && (
58+
<div className="flex flex-col items-center justify-center py-16 gap-2">
59+
<p
60+
className="text-sm font-medium"
61+
style={{ color: "var(--text-secondary, #666)" }}
62+
>
63+
No demos in this category
64+
</p>
65+
</div>
66+
)}
67+
</div>
68+
</div>
69+
);
70+
}

0 commit comments

Comments
 (0)