import streamlit as st from datetime import datetime import os st.header("Report a bug or request a feature") st.write("Use the box below to submit a short report. Submissions are saved locally to `reports.txt`.") report_type = st.selectbox("Type", ["Bug", "Feature request", "Other"]) report_email = st.text_input("Your name (optional)") report_text = st.text_area("Describe the issue or request", height=160) if st.button("Submit report"): if not report_text.strip(): st.error("Please enter a description before submitting.") else: timestamp = datetime.utcnow().isoformat() + "Z" entry = f"[{timestamp}]\t{report_type}\t{report_email}\t{report_text.replace('\n', ' ')}\n" try: base = os.path.dirname(__file__) path = os.path.join(base, "reports.txt") with open(path, "a", encoding="utf-8") as f: f.write(entry) st.success("Thanks — your report was saved.") st.write("Saved to:", path) st.markdown("---") except Exception as e: st.error(f"Could not save report: {e}")