Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 15, 2026

Users need to update base data after creating charts without losing derived transformations. Currently no mechanism exists to refresh data and propagate changes to dependent tables.

Changes

Backend (tables_routes.py)

  • Added /api/tables/recalculate-derived-data endpoint that re-executes Python transformation code in subprocess for security
  • Implemented recalc_derived_data_py() function that processes each affected derived table independently
  • Gathers actual input data for each source table and re-runs transformation code
  • Virtual/DuckDB table refresh not supported - returns 'skipped' status for future implementation

Frontend (DataThread.tsx)

  • Collapsed delete/attach-metadata actions into MoreVert menu (keeps generate-chart button separate per requirements)
  • Added "Refresh data" menu option for original tables only (derived tables excluded)
  • Disabled refresh button for virtual (DuckDB-based) tables with explanatory message "DuckDB tables not supported"
  • Implemented RefreshDataDialog component supporting file upload (CSV/XLSX/JSON) or raw JSON paste
  • Enhanced validation to check all rows for required columns, not just first row
  • Fixed derived table filtering to handle both string and array source types

State Management (dfSlice.tsx)

  • Added updateTableRows action to update table data (columns must be identical)
  • Removed concept shelf update logic since column names remain unchanged

Usage

// User workflow
1. Click MoreVert menu on original Python table  "Refresh data" (grayed out for DuckDB tables)
2. Upload new file or paste JSON (columns must match existing schema)
3. System validates, replaces base table, re-executes Python-based derived table transformations
4. Redux state updates, UI reflects new data across all affected tables

Limitations

  • Only supports Python-based (non-virtual) tables for refresh
  • Virtual/DuckDB tables show disabled refresh option
  • Columns must remain identical (same names and order)

Security

Python transformations execute in subprocess with audit hooks blocking file writes and dangerous operations.

Original prompt

This section details on the original issue you should resolve

<issue_title>Feature request: add an option to refresh data after chart creation</issue_title>
<issue_description>Allow users to make minor updates to data (additional rows, or update some values) after some charts have been created.

Additionally, have an option to auto referesh data if data is streamed from an external source. </issue_description>

<agent_instructions>Add a button in the data thread allowing user to replace an existing data with updated data, requirement: the updated data needs to have the same field names as the current data, and we are only allowed to replace original data (not derived data). When the new data is replaced, automatically re-run generate python code on the server to re-generate new derived data based on the updated table.

requirements:

  1. collapse the new bottom with existing delete/attach metadata buttons into a menu (don't collapse generate chart button) so it's compact in the UI
  2. implement a function in the server for refresh derived data, by providing updated data with their corresponding execution python code, this ececution should be run in subprocess</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: Chenglong-MS <93549116+Chenglong-MS@users.noreply.github.com>
Copilot AI and others added 2 commits January 15, 2026 23:54
…ssues

Co-authored-by: Chenglong-MS <93549116+Chenglong-MS@users.noreply.github.com>
Co-authored-by: Chenglong-MS <93549116+Chenglong-MS@users.noreply.github.com>
Copilot AI changed the title [WIP] Add option to refresh data after chart creation Add data refresh capability for original tables with automatic derived table regeneration Jan 16, 2026
Copilot AI requested a review from Chenglong-MS January 16, 2026 00:02
@Chenglong-MS Chenglong-MS changed the base branch from main to dev January 16, 2026 00:06
Copy link
Collaborator

@Chenglong-MS Chenglong-MS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix issues

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is incorrect we should do this function as recalculate_derived_data, we need to sub functions:

  1. recalc_derived_data_py(): update a table based on python, if this is the case, we will provide a list of input tables, and the derived table code, then return the new derived table by applying the python code on updated inputs
  2. recalc_derived_data_sql(): this will simply rerun the query against duck db

decide which one to call based on whether the derived data is virtual or not in the backend. Call each table update independently (i.e., when a table update, we first find the list of derived table that are affected, and then for each affected table, gather their actual input data, and rerun code to get the new content and update) we don't need to do this recursively)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But for now, let's only do recalc_derived_data_py, as we first only support python data refresh. This simplifies the refresh logic for remote/duckdb data.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to recalculate_derived_data endpoint with recalc_derived_data_py() function. Virtual/SQL table support skipped - returns 'skipped' status. Each affected table is processed independently with actual input data. Fixed in commit f611d1f.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need to update concept shelf, since it requires all columns are the same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed concept shelf update from updateTableRows action since columns must be identical. Fixed in commit f611d1f.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's first only implement refresh for python (local data, skip database refresh for now), and when they need to replace, they can either upload a new data from file, url, or paste.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's gray out the refresh button for virtual tables (duckdb-based)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refresh button now disabled (grayed out) for virtual (DuckDB) tables with message "DuckDB tables not supported". Only Python/local data refresh is supported. Fixed in commit f611d1f.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refresh button disabled for virtual tables with explanatory message. Fixed in commit f611d1f.

…able for virtual tables

Co-authored-by: Chenglong-MS <93549116+Chenglong-MS@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 16, 2026

please fix issues

All issues addressed in commit f611d1f:

  1. Backend refactored - Changed to recalculate_derived_data endpoint with recalc_derived_data_py() function that processes each derived table independently
  2. Python-only support - Virtual/DuckDB tables return 'skipped' status
  3. UI updated - Refresh button disabled for virtual tables with "DuckDB tables not supported" message
  4. State simplified - Removed concept shelf update from updateTableRows action

Build succeeds and Python syntax validated.

Copilot AI changed the title Add data refresh capability for original tables with automatic derived table regeneration Add data refresh capability for Python-based tables with automatic derived table regeneration Jan 16, 2026
Copilot AI requested a review from Chenglong-MS January 16, 2026 21:33
@Chenglong-MS Chenglong-MS marked this pull request as ready for review January 16, 2026 21:34
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.

Feature request: add an option to refresh data after chart creation

2 participants