Skip to content

Migrate ITables Streamlit component to st.components.v2#521

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/update-itables-to-streamlit-v2
Draft

Migrate ITables Streamlit component to st.components.v2#521
Copilot wants to merge 2 commits intomainfrom
copilot/update-itables-to-streamlit-v2

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 7, 2026

ITables' Streamlit integration was using the v1 custom component API. This migrates it to st.components.v2, which renders inline (no iframe) and uses a cleaner function-based lifecycle.

Frontend (packages/itables_for_streamlit/)

  • Build: Replaced Create React App with esbuild (matching the anywidget package pattern); CSS extracted to src/index.css
  • Dependency: streamlit-component-lib@streamlit/component-v2-lib (types only — v2 runtime is provided by the Streamlit host)
  • API: Rewrote index.tsx from event-based v1 (RENDER_EVENT / setComponentValue / setFrameHeight) to a v2 FrontendRenderer default export that creates the table on mount and returns a cleanup function
const ITableForStreamlit: FrontendRenderer<ITableState, ITableData> = (component) => {
  const { data, parentElement, setStateValue } = component;
  // ... create DataTable, wire select/deselect → setStateValue('selected_rows', ...)
  return () => { dt.destroy(); span.remove(); };
};
export default ITableForStreamlit;

Python (src/itables/streamlit.py)

  • declare_component(name, path=...)components.v2.component(name, js=..., css=..., isolate_styles=False)
  • JS/CSS loaded as inline strings at import time (avoids Streamlit runtime dependency during manifest discovery)
  • isolate_styles=False keeps styles in the main DOM — required for DataTables popups/fixed-header elements that are appended to document.body
  • Arguments now passed via data={"dt_args": ..., "other_args": ...}; return type is BidiComponentResult (dict-like, backwards-compatible access via result["selected_rows"] or result.selected_rows)

Config

  • pyproject.toml: Added [tool.streamlit.component] manifest entry; updated ensured-targets for the new output filenames
  • apps/streamlit/itables_app.py: Replaced MarshallComponentException (v1-only) with StreamlitAPIException

Note on CSS build: The CSS is built without --minify intentionally. Minified single-line CSS containing * selectors is misclassified as a glob pattern by Streamlit's inline-content heuristic, causing registration to fail.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • docs.streamlit.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Transition ITables' streamlit component to st.components.v2</issue_title>
<issue_description>ITables currently uses streamlit's v1 component, but v2 has shipped. Can we upgrade our component to v2?</issue_description>

<agent_instructions>Our ITable component for Streamlit was developped using Streamlit's custom component in v1. Now a version 2 is available.

A template for custom v2 components is available here: https://github.com/streamlit/component-template

The options offered by V2 are compared to V1 on this page: https://docs.streamlit.io/develop/api-reference/custom-components</agent_instructions>

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


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.71%. Comparing base (953241a) to head (ca5e27e).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #521      +/-   ##
==========================================
- Coverage   94.06%   93.71%   -0.35%     
==========================================
  Files          47       47              
  Lines        2560     2563       +3     
==========================================
- Hits         2408     2402       -6     
- Misses        152      161       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 7, 2026

Thank you for making this pull request.

Did you know? You can try it on Binder: Binder:lab.

Also, the version of ITables developed in this PR is available as a wheel artifact 📦 for easy installation.
Download it here, unzip it and then run pip install itables-xxx.whl in the unzipped directory.

A conda package is also available for easy installation:
Download it here, and then run conda install itables-xxx.tar.bz2 in the directory where you downloaded the file.

Co-authored-by: mwouts <29915202+mwouts@users.noreply.github.com>
Copilot AI changed the title [WIP] Transition ITables' streamlit component to st.components.v2 Migrate ITables Streamlit component to st.components.v2 Mar 7, 2026
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.

Transition ITables' streamlit component to st.components.v2

3 participants