From c16224834861391410049c96e141f716e4765b0a Mon Sep 17 00:00:00 2001 From: "Bobby Abellana (aider)" Date: Tue, 18 Feb 2025 09:44:04 -0800 Subject: [PATCH] feat: Implement JavaScript-based clipboard copy for error log --- src/streamlit_app.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/streamlit_app.py b/src/streamlit_app.py index 1cc58f7..2378779 100644 --- a/src/streamlit_app.py +++ b/src/streamlit_app.py @@ -1,4 +1,5 @@ import streamlit as st +from streamlit import components import os import logging import warnings @@ -521,10 +522,27 @@ if st.session_state.error_log: error_text = "\n\n".join([f"File: {path}\nError: {error}" for path, error in st.session_state.error_log.items()]) st.text_area("Error Details", error_text, height=200) - # Add copy button - if st.button("Copy Error Log"): - st.write("Error log copied to clipboard!") - st.session_state.error_log_copied = error_text + # Add copy button with JavaScript to copy to clipboard + copy_button = st.button("Copy Error Log") + if copy_button: + # Create a JavaScript function to copy the text + js_code = f""" + + """ + st.components.v1.html(js_code, height=0) + st.success("✅ Error log copied to clipboard!") # Add clear button if st.button("Clear Error Log"):