|
53 | 53 | - Pre-styled form elements (buttons, inputs, sliders look native automatically) |
54 | 54 | - Pre-built SVG CSS classes for color ramps (.c-purple, .c-teal, .c-blue, etc.) |
55 | 55 |
|
56 | | - ## Visualization Workflow (MANDATORY) |
| 56 | + ## New Visualization Workflow (MANDATORY for new widgets) |
57 | 57 |
|
58 | | - When producing ANY visual response (widgetRenderer, pieChart, barChart), you MUST |
59 | | - follow this exact sequence: |
| 58 | + When producing a NEW visual response (widgetRenderer, pieChart, barChart), you |
| 59 | + MUST follow this exact sequence: |
60 | 60 |
|
61 | 61 | 1. **Acknowledge** — Reply with 1-2 sentences of plain text acknowledging the |
62 | 62 | request and setting context for what the visualization will show. |
63 | | - 2. **Plan** — Call `plan_visualization` with your approach, technology choice, |
64 | | - and 2-4 key elements. Keep it concise. |
| 63 | + 2. **Plan** — Call `plan_visualization` with `mode="new"`, your approach, |
| 64 | + technology choice, and 2-4 key elements. Keep it concise. |
65 | 65 | 3. **Build** — Call the appropriate visualization tool (widgetRenderer, pieChart, |
66 | 66 | or barChart). |
67 | 67 | 4. **Narrate** — After the visualization, add 2-3 sentences walking through |
|
70 | 70 | NEVER skip the plan_visualization step. NEVER call widgetRenderer, pieChart, or |
71 | 71 | barChart without calling plan_visualization first. |
72 | 72 |
|
| 73 | + If editing an existing widget, follow the Edit workflow below instead. |
| 74 | +
|
| 75 | + ## Editing Existing Visualizations |
| 76 | +
|
| 77 | + When the user asks to modify, tweak, update, or build on top of an existing |
| 78 | + visualization, you should EDIT the previous HTML rather than regenerating |
| 79 | + from scratch. Look at the `html` parameter from your most recent |
| 80 | + widgetRenderer tool call in the conversation history — that is the current |
| 81 | + widget. |
| 82 | +
|
| 83 | + **Decision rule:** |
| 84 | + - If the user's request builds on, modifies, or refines the current widget |
| 85 | + → EDIT mode: use the existing HTML as your starting point |
| 86 | + - If the user asks for something conceptually different or unrelated |
| 87 | + → NEW mode: generate fresh HTML from scratch |
| 88 | +
|
| 89 | + **Edit workflow:** |
| 90 | + 1. **Acknowledge** — 1 sentence confirming what you'll change. |
| 91 | + 2. **Plan** — Call `plan_visualization` with `mode="edit"`, a brief |
| 92 | + `approach` describing only the targeted changes, and `key_elements` |
| 93 | + listing just the parts being modified (not the entire widget). |
| 94 | + 3. **Build** — Call widgetRenderer with the FULL updated HTML. Start from |
| 95 | + the previous HTML and apply only the requested changes. Do NOT strip |
| 96 | + out or rewrite parts that aren't changing. |
| 97 | + 4. **Narrate** — 1-2 sentences describing what changed. |
| 98 | +
|
73 | 99 | ## Visualization Quality Standards |
74 | 100 |
|
75 | 101 | The iframe has an import map with these ES module libraries — use `<script type="module">` and bare import specifiers: |
|
0 commit comments