Skip to content

Enable iterative chart modifications via conversation history#12

Closed
Copilot wants to merge 5 commits intomainfrom
copilot/update-revenue-axis-start
Closed

Enable iterative chart modifications via conversation history#12
Copilot wants to merge 5 commits intomainfrom
copilot/update-revenue-axis-start

Conversation

Copy link
Contributor

Copilot AI commented Dec 13, 2025

Users cannot iterate on charts with follow-up requests like "update the revenue axis to start at 4k" because the LLM receives no conversation context—each request is processed in isolation.

Changes

llmRouter.js

  • Added chatHistory parameter to getUpdatedChartSpec() to pass full conversation context to LLM
  • Updated system prompt with instructions for incremental modifications (preserve existing settings, apply only requested changes)
  • Added error handling for non-serializable objects with descriptive messages
  • Fallback to currentSpec when history unavailable (backward compatible)

main.js

  • Pass state.chatHistory to getUpdatedChartSpec()

Example Flow

// Before: No context between requests
User: "generate chart showing revenue by quarter"
LLM receives: [system, user message]
 Creates chart 

User: "update the revenue axis to start at 4k"  
LLM receives: [system, user message]  // No context!
 Doesn't understand what to update ✗

// After: Full conversation context
User: "generate chart showing revenue by quarter"
LLM receives: [system, user message]
 Creates chart 

User: "update the revenue axis to start at 4k"
LLM receives: [system, previous exchange, user message]
 Modifies yaxis.range while preserving other settings 

The implementation handles edge cases (null values, arrays, circular references) and maintains the existing chat history structure in state.chatHistory.

Original prompt

i noticed that when i ask a follow up about the chart, like "change axis" or start axis at 4k "ou
generate a chart that shows revenue by quarter
Assistant
{
"title": "Revenue by Quarter",
"chartType": "bar",
"x": "Date",
"y": "Revenue",
"groupBy": {
"columns": [
"Date"
],
"aggregations": {
"Revenue": {
"func": "sum"
}
}
},
"layout": {
"xaxis": {
"tickformat": "%Y-Q%q"
}
}
}
You
update the revenue axis to start at 4k
Assistant
{
"title": "Revenue by Quarter",
"chartType": "bar",
"x": "Date",
"y": "Revenue",
"groupBy": {
"columns": [
"Date"
],
"aggregations": {
"Revenue": {
"func": "sum"
}
}
},
"layout": {
"xaxis": {
"tickformat": "%Y-Q%q"
},
"yaxis": {
"range": [
4000,
null
]
}
}
}" it doesnt update the chart, it responds back in chat, i don't think there is a method for the user to iterate on the chart that is in the visualization


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits December 13, 2025 01:22
Co-authored-by: evcatalyst <8740078+evcatalyst@users.noreply.github.com>
Co-authored-by: evcatalyst <8740078+evcatalyst@users.noreply.github.com>
…ogging

Co-authored-by: evcatalyst <8740078+evcatalyst@users.noreply.github.com>
Co-authored-by: evcatalyst <8740078+evcatalyst@users.noreply.github.com>
Copilot AI changed the title [WIP] Update revenue axis to start at 4k Enable iterative chart modifications via conversation history Dec 13, 2025
Copilot AI requested a review from evcatalyst December 13, 2025 01:34
@evcatalyst
Copy link
Collaborator

@copilot Addendum: Vanilla static + browser-local requirements (paste into Update)
Hard constraints

Vanilla static site only:

No React / Vue / Svelte / Next.

Prefer zero build step (plain HTML/CSS/JS).

Use ES modules (type="module") and keep dependencies minimal.

If any dependencies are used, they must be either:

vendored into /vendor/ in the repo, or

loaded via stable CDNs with pinned versions.

Local-first:

App must work fully in-browser, including dataset storage and layout state.

Persist state using:

IndexedDB for datasets / large blobs (CSV, parsed tables, cached samples)

localStorage for lightweight settings (UI prefs, selected model, sampling preset, last layout)

Optional: Service worker for offline + caching static assets (no server required).

UI implementation approach

Use native Web Components (Custom Elements) for modularity instead of framework components:

, , , , , etc.

Keep styling with CSS variables + shadow DOM where useful (or light DOM if easier to theme globally).

Use a vanilla-compatible grid/drag/resize library (pick one and justify):

Grid/tile system candidates (must be framework-agnostic):

Gridstack.js (drag + resize dashboard tiles, widely used)

Muuri (great for draggable grids; pair with resize handling if needed)

Interact.js (low-level drag/resize; build custom grid behavior if needed)

Use a vanilla splitter for resizable chat drawer:

Split.js (simple resizable panes) or equivalent.

Chat drawer requirements (vanilla)

Chat is a toggleable, resizable side drawer:

Drawer open/close state persisted in localStorage

Drawer width persisted

Keyboard accessible (Esc closes, focus trap while open optional)

Chat messages can create/update tiles in the grid:

“Spawn chart tile”, “Spawn text tile”, “Update tile #n”

Natural language settings UI (vanilla)

Implement “natural language form” style controls as a lightweight custom element:

Inline sentence with editable tokens/selects

Styling inspired by Tympanus NaturalLanguageForm interaction pattern, but implemented without heavy dependencies.

Sampling control should be an LED/retro segmented UI:

Presets: 1%, 5%, 10%, 20%, 50%, 100%

Shows estimated token impact and warning states

Persist preset + last custom value in localStorage

Deliverables expected (vanilla-specific)

Provide:

Folder structure for a static site (/components, /styles, /vendor, /data, etc.)

State model for IndexedDB/localStorage (schema + keys)

Recommended grid library choice + rationale for vanilla use

Migration plan from current layout to the new workbench without rewriting the core ChartSpec engine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants