-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.html
More file actions
238 lines (218 loc) · 14.4 KB
/
Copy pathdashboard.html
File metadata and controls
238 lines (218 loc) · 14.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ProjectAI Dashboard</title>
<script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
<style>
body { font-family: 'Inter', sans-serif; background-color: #0f172a; color: #f8fafc; }
.mono { font-family: 'JetBrains Mono', monospace; }
.timeline-line { width: 2px; background: #334155; position: absolute; top: 0; bottom: 0; left: 24px; z-index: 0; }
.glass { background: rgba(30, 41, 59, 0.7); backdrop-filter: blur(8px); border: 1px solid rgba(51, 65, 85, 0.5); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.pulsing { animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
</style>
</head>
<body>
<div id="root"></div>
<script type="text/babel">
const { useState, useEffect, useRef } = React;
function App() {
const [idea, setIdea] = useState("");
const [background, setBackground] = useState("");
const [isProjecting, setIsProjecting] = useState(false);
const [events, setEvents] = useState([]);
const [experts, setExperts] = useState(new Set());
const [finalReport, setFinalReport] = useState(null);
const [status, setStatus] = useState("Idle");
const scrollRef = useRef(null);
useEffect(() => {
if (scrollRef.current) {
scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
}
}, [events]);
const startProjection = () => {
if (!idea || !background) return alert("Please fill in both Idea and Background");
setEvents([]);
setExperts(new Set());
setFinalReport(null);
setIsProjecting(true);
setStatus("Initializing...");
const url = `http://localhost:8000/stream?idea=${encodeURIComponent(idea)}&background=${encodeURIComponent(background)}`;
const eventSource = new EventSource(url);
eventSource.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.type === "instruction") {
setStatus(`Manager planning: Next is ${data.next_agent}`);
setEvents(prev => [...prev, data]);
} else if (data.type === "contribution") {
setExperts(prev => new Set(prev).add(data.author));
setEvents(prev => [...prev, data]);
} else if (data.type === "closure") {
setFinalReport({ talents: data.talents, result: data.result });
setStatus("Project Completed");
eventSource.close();
setIsProjecting(false);
} else if (data.type === "error") {
alert("Error: " + data.message);
eventSource.close();
setIsProjecting(false);
}
};
eventSource.onerror = () => {
console.error("EventSource failed.");
eventSource.close();
setIsProjecting(false);
};
};
return (
<div className="flex h-screen overflow-hidden">
{/* Sidebar: Config */}
<div className="w-80 glass p-6 flex flex-col gap-6 border-r border-slate-800">
<div className="flex items-center gap-2 mb-4">
<span className="text-2xl">🚀</span>
<h1 className="text-xl font-bold tracking-tight">ProjectAI</h1>
</div>
<div className="space-y-4">
<div>
<label className="text-xs font-semibold text-slate-400 uppercase tracking-wider">Project Idea</label>
<textarea
className="w-full mt-1 p-3 bg-slate-900 border border-slate-700 rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none h-24 resize-none"
placeholder="e.g. A robotic arm for art..."
value={idea}
onChange={(e) => setIdea(e.target.value)}
disabled={isProjecting}
/>
</div>
<div>
<label className="text-xs font-semibold text-slate-400 uppercase tracking-wider">Team Background</label>
<textarea
className="w-full mt-1 p-3 bg-slate-900 border border-slate-700 rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none h-24 resize-none"
placeholder="e.g. High school students..."
value={background}
onChange={(e) => setBackground(e.target.value)}
disabled={isProjecting}
/>
</div>
<button
onClick={startProjection}
disabled={isProjecting}
className={`w-full py-3 rounded-lg font-bold transition-all ${isProjecting ? 'bg-slate-700 cursor-not-allowed' : 'bg-blue-600 hover:bg-blue-500 shadow-lg shadow-blue-900/20'}`}
>
{isProjecting ? "Projecting..." : "Start Projection"}
</button>
</div>
<div className="mt-auto">
<div className="p-3 bg-slate-900/50 rounded-lg border border-slate-800">
<p className="text-xs text-slate-500 uppercase font-bold mb-2">Active Experts</p>
<div className="flex flex-wrap gap-2">
{Array.from(experts).map(ex => (
<span key={ex} className="px-2 py-1 bg-green-900/30 text-green-400 text-[10px] rounded border border-green-800/50">
{ex}
</span>
))}
{experts.size === 0 && <span className="text-xs text-slate-600 italic">No experts yet</span>}
</div>
</div>
</div>
</div>
{/* Main Feed */}
<div className="flex-1 flex flex-col relative bg-slate-950">
{/* Header */}
<div className="h-16 glass border-b border-slate-800 flex items-center justify-between px-8 z-10">
<div className="flex items-center gap-3">
<div className={`w-2 h-2 rounded-full ${isProjecting ? 'bg-blue-500 pulsing' : 'bg-slate-600'}`}></div>
<span className="text-sm font-medium text-slate-300">{status}</span>
</div>
<div className="text-xs text-slate-500 mono">v1.0.0-projection</div>
</div>
{/* Events Area */}
<div ref={scrollRef} className="flex-1 overflow-y-auto p-8 relative scroll-smooth">
<div className="timeline-line ml-8"></div>
<div className="space-y-12 relative">
{events.map((ev, i) => (
<div key={i} className="flex gap-6 items-start">
<div className="z-10 mt-1">
{ev.type === "instruction" ? (
<div className="w-12 h-12 rounded-full bg-purple-900 flex items-center justify-center border-4 border-slate-950 shadow-xl">
👤
</div>
) : (
<div className="w-12 h-12 rounded-full bg-green-900 flex items-center justify-center border-4 border-slate-950 shadow-xl text-lg">
🤖
</div>
)}
</div>
<div className="flex-1">
<div className="glass p-5 rounded-2xl shadow-2xl space-y-3">
<div className="flex items-center justify-between">
<span className={`text-xs font-bold uppercase tracking-widest ${ev.type === 'instruction' ? 'text-purple-400' : 'text-green-400'}`}>
{ev.type === 'instruction' ? 'Project Manager' : ev.author}
</span>
</div>
{ev.type === 'instruction' ? (
<div className="space-y-2">
<p className="text-slate-200 text-sm leading-relaxed">
{ev.task}
</p>
<div className="inline-flex items-center gap-2 px-3 py-1 bg-purple-900/20 text-purple-300 rounded-full text-[10px] border border-purple-800/30 font-bold">
NEXT: {ev.next_agent}
</div>
</div>
) : (
<div className="space-y-4">
<div className="p-3 bg-slate-900 rounded-lg border border-slate-800 mono text-[11px] text-slate-400 leading-relaxed whitespace-pre-wrap">
<div className="mb-1 text-slate-500 italic uppercase">Internal Thought:</div>
{ev.log}
</div>
<div className="text-slate-200 text-sm leading-relaxed">
{ev.contribution}
</div>
</div>
)}
</div>
</div>
</div>
))}
{finalReport && (
<div className="flex gap-6 items-start">
<div className="z-10 mt-1">
<div className="w-12 h-12 rounded-full bg-yellow-600 flex items-center justify-center border-4 border-slate-950 shadow-xl text-xl">
🏆
</div>
</div>
<div className="flex-1">
<div className="bg-gradient-to-br from-yellow-900/40 to-slate-900 p-8 rounded-3xl border border-yellow-700/30 shadow-2xl space-y-6">
<h2 className="text-2xl font-bold text-yellow-500">Projection Closure Report</h2>
<div className="space-y-2">
<h3 className="text-xs font-bold text-slate-400 uppercase tracking-widest">Talent Archive</h3>
<div className="p-4 bg-slate-900/80 rounded-xl border border-slate-700 text-sm leading-relaxed whitespace-pre-wrap">
{finalReport.talents}
</div>
</div>
<div className="space-y-2">
<h3 className="text-xs font-bold text-slate-400 uppercase tracking-widest">Final Deliverables</h3>
<div className="p-4 bg-slate-900/80 rounded-xl border border-slate-700 text-sm leading-relaxed whitespace-pre-wrap text-blue-100">
{finalReport.result}
</div>
</div>
</div>
</div>
</div>
)}
</div>
</div>
</div>
</div>
);
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);
</script>
</body>
</html>