Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -91,7 +91,7 @@ def get_current_time_str(tz='UTC'):
|
|
91 |
now_aware = datetime.now(pytz.utc)
|
92 |
return now_aware.strftime('%Y%m%d_%H%M%S')
|
93 |
|
94 |
-
def
|
95 |
if not isinstance(text, str):
|
96 |
text = "invalid_name"
|
97 |
text = re.sub(r'\s+', '_', text)
|
@@ -755,7 +755,6 @@ async def websocket_handler(websocket, path):
|
|
755 |
if tool_type in PRIMITIVE_MAP.values() or tool_type == "None":
|
756 |
st.session_state.selected_object = tool_type
|
757 |
print(f"Tool updated to {tool_type} for {sender_username}")
|
758 |
-
# Broadcast tool selection to update other clients
|
759 |
broadcast_payload = json.dumps({"type": "tool_selected", "payload": {"tool_type": tool_type, "username": sender_username}})
|
760 |
await broadcast_message(broadcast_payload, exclude_id=client_id)
|
761 |
|
@@ -1036,7 +1035,7 @@ def render_main_content():
|
|
1036 |
window.PLOT_DEPTH = {json.dumps(PLOT_DEPTH)};
|
1037 |
console.log("Streamlit State Injected:", {{ username: window.USERNAME, websocketUrl: window.WEBSOCKET_URL, selectedObject: window.SELECTED_OBJECT_TYPE }});
|
1038 |
</script>"""
|
1039 |
-
|
1040 |
components.html(html_content_with_state, height=700, scrolling=False)
|
1041 |
except FileNotFoundError:
|
1042 |
st.error(f"CRITICAL ERROR: Could not find '{html_file_path}'.")
|
|
|
91 |
now_aware = datetime.now(pytz.utc)
|
92 |
return now_aware.strftime('%Y%m%d_%H%M%S')
|
93 |
|
94 |
+
def clean_filename_part(text, max_len=30):
|
95 |
if not isinstance(text, str):
|
96 |
text = "invalid_name"
|
97 |
text = re.sub(r'\s+', '_', text)
|
|
|
755 |
if tool_type in PRIMITIVE_MAP.values() or tool_type == "None":
|
756 |
st.session_state.selected_object = tool_type
|
757 |
print(f"Tool updated to {tool_type} for {sender_username}")
|
|
|
758 |
broadcast_payload = json.dumps({"type": "tool_selected", "payload": {"tool_type": tool_type, "username": sender_username}})
|
759 |
await broadcast_message(broadcast_payload, exclude_id=client_id)
|
760 |
|
|
|
1035 |
window.PLOT_DEPTH = {json.dumps(PLOT_DEPTH)};
|
1036 |
console.log("Streamlit State Injected:", {{ username: window.USERNAME, websocketUrl: window.WEBSOCKET_URL, selectedObject: window.SELECTED_OBJECT_TYPE }});
|
1037 |
</script>"""
|
1038 |
+
`html_content_with_state = html_template.replace('</head>', js_injection_script + '\n</head>', 1)
|
1039 |
components.html(html_content_with_state, height=700, scrolling=False)
|
1040 |
except FileNotFoundError:
|
1041 |
st.error(f"CRITICAL ERROR: Could not find '{html_file_path}'.")
|