Skip to content

Open HTML files in browser instead of rendering inline in Streamlit reports#182

Draft
enryH with Copilot wants to merge 2 commits into
mainfrom
copilot/add-links-to-html-files
Draft

Open HTML files in browser instead of rendering inline in Streamlit reports#182
enryH with Copilot wants to merge 2 commits into
mainfrom
copilot/add-links-to-html-files

Conversation

Copilot AI commented Apr 29, 2026

Copy link
Copy Markdown

Viewing complex HTML files (e.g., MultiQC reports, interactive plots) inline via st.components.v1.html() is constrained by fixed height, sandboxed rendering, and poor UX for large files. This replaces inline rendering with a link button that opens the HTML in a new browser tab.

Changes

  • _generate_html_content: Replaces st.components.v1.html() with st.link_button("Open in browser", ...):
    • Local files: Base64-encodes content into a data:text/html;base64,... URI; emits st.warning for files >5MB that may not open in all browsers
    • URLs: Links directly to the URL — no longer fetches and embeds content
  • _generate_component_imports: Adds import base64 for HTML components
  • Test fixtures in tests/report_examples/ regenerated to match new output

Generated code example (local file)

file_path = (section_dir / 'path/to/report.html').resolve().as_posix()
with open(file_path, 'r', encoding='utf-8') as f:
    html_content = f.read()
html_bytes = html_content.encode()
if len(html_bytes) > 5 * 1024 * 1024:
    st.warning(
        "This HTML file is large (>5MB) and may not open "
        "correctly in all browsers via the link below."
    )
html_b64 = base64.b64encode(html_bytes).decode()
st.link_button("Open in browser", f"data:text/html;base64,{html_b64}")

Note: Interactive network plots (component_type: plot, plot_type: interactive_network) are unaffected — they continue to use st.components.v1.html().

Copilot AI linked an issue Apr 29, 2026 that may be closed by this pull request
Instead of rendering HTML files inline with st.components.v1.html(),
generate a st.link_button that opens the HTML in a new browser tab.

For local files: base64-encode content and use data URI.
For URLs: use the URL directly in the link button.
Includes a warning for files >5MB that may not open in all browsers.

Update test example files to match new generated output.

Agent-Logs-Url: https://github.com/Multiomics-Analytics-Group/vuegen/sessions/92f41025-236f-4474-b854-d26531b1d33d

Co-authored-by: enryH <2833836+enryH@users.noreply.github.com>
Copilot AI changed the title [WIP] Add links to open HTML files from VueGen report Open HTML files in browser instead of rendering inline in Streamlit reports Apr 29, 2026
Copilot AI requested a review from enryH April 29, 2026 20:10
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.

Open html files from vuegen report in browser

2 participants