fix(embed-studio): contextual empty state and input placeholder
Browse filesThe chat panel always said "Describe the chart you want to create"
even when a chart was already rendered in the preview pane next to
it - confusing because the obvious next action is to ask for tweaks,
not to recreate from scratch.
Branch the empty state and the textarea placeholder on three
situations:
- no chart yet (scratch): "Describe the chart you want to create"
+ the original example prompt
- existing chart: "Ask for changes to the chart" + a tweak example
- banner mode: phrase both as "banner" instead of "chart" so the
hint matches the banner system prompt's mood-setter intent
Co-authored-by: Cursor <cursoragent@cursor.com>
frontend/src/components/EmbedStudio.tsx
CHANGED
|
@@ -295,14 +295,34 @@ export function EmbedStudio({
|
|
| 295 |
{/* Left: Chat */}
|
| 296 |
<div className="es-chat">
|
| 297 |
<div className="es-chat__messages">
|
| 298 |
-
{chat.messages.length === 0 && (
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
{chat.messages.map((msg) => (
|
| 307 |
<MessageBubble key={msg.id} message={msg} />
|
| 308 |
))}
|
|
@@ -326,7 +346,15 @@ export function EmbedStudio({
|
|
| 326 |
onChange={(e) => chat.setInput(e.target.value)}
|
| 327 |
onKeyDown={handleKeyDown}
|
| 328 |
onInput={handleTextareaInput}
|
| 329 |
-
placeholder=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
rows={1}
|
| 331 |
className="es-chat__textarea"
|
| 332 |
/>
|
|
|
|
| 295 |
{/* Left: Chat */}
|
| 296 |
<div className="es-chat">
|
| 297 |
<div className="es-chat__messages">
|
| 298 |
+
{chat.messages.length === 0 && (() => {
|
| 299 |
+
const isBanner = src === "banner.html";
|
| 300 |
+
const hasChart = html.trim().length > 0;
|
| 301 |
+
let title: string;
|
| 302 |
+
let hint: string;
|
| 303 |
+
if (isBanner) {
|
| 304 |
+
title = hasChart
|
| 305 |
+
? "Ask for changes to the banner."
|
| 306 |
+
: "Describe the banner you want.";
|
| 307 |
+
hint = hasChart
|
| 308 |
+
? 'Example: "make it slower and more abstract"'
|
| 309 |
+
: 'Example: "abstract flow field in the primary color, very subtle motion"';
|
| 310 |
+
} else if (hasChart) {
|
| 311 |
+
title = "Ask for changes to the chart.";
|
| 312 |
+
hint =
|
| 313 |
+
'Example: "switch to a sequential palette" or "highlight the biggest bar"';
|
| 314 |
+
} else {
|
| 315 |
+
title = "Describe the chart you want to create.";
|
| 316 |
+
hint =
|
| 317 |
+
'Example: "Create a bar chart showing model sizes with categorical colors"';
|
| 318 |
+
}
|
| 319 |
+
return (
|
| 320 |
+
<div className="es-chat__empty">
|
| 321 |
+
<p>{title}</p>
|
| 322 |
+
<p className="es-chat__hint">{hint}</p>
|
| 323 |
+
</div>
|
| 324 |
+
);
|
| 325 |
+
})()}
|
| 326 |
{chat.messages.map((msg) => (
|
| 327 |
<MessageBubble key={msg.id} message={msg} />
|
| 328 |
))}
|
|
|
|
| 346 |
onChange={(e) => chat.setInput(e.target.value)}
|
| 347 |
onKeyDown={handleKeyDown}
|
| 348 |
onInput={handleTextareaInput}
|
| 349 |
+
placeholder={
|
| 350 |
+
html.trim().length > 0
|
| 351 |
+
? src === "banner.html"
|
| 352 |
+
? "Tweak the banner..."
|
| 353 |
+
: "Tweak the chart..."
|
| 354 |
+
: src === "banner.html"
|
| 355 |
+
? "Describe your banner..."
|
| 356 |
+
: "Describe your chart..."
|
| 357 |
+
}
|
| 358 |
rows={1}
|
| 359 |
className="es-chat__textarea"
|
| 360 |
/>
|