@danhachuel/thunderbolt 0.7.17 → 0.7.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/main.py +43 -6
- package/package.json +1 -1
package/app/main.py
CHANGED
|
@@ -35,7 +35,6 @@ from typing import Any
|
|
|
35
35
|
|
|
36
36
|
import requests
|
|
37
37
|
import streamlit as st
|
|
38
|
-
import streamlit.components.v1 as components
|
|
39
38
|
|
|
40
39
|
ROOT = Path(__file__).resolve().parents[1]
|
|
41
40
|
if str(ROOT) not in sys.path:
|
|
@@ -268,8 +267,8 @@ ensure_storage()
|
|
|
268
267
|
st.set_page_config(page_title="Thunderbolt", page_icon="T", layout="wide", initial_sidebar_state="expanded")
|
|
269
268
|
|
|
270
269
|
theme_base = (st.get_option("theme.base") or "dark").lower()
|
|
271
|
-
|
|
272
|
-
"""
|
|
270
|
+
st.iframe(
|
|
271
|
+
srcdoc="""
|
|
273
272
|
<script>
|
|
274
273
|
(() => {
|
|
275
274
|
const STYLE_ID = "thunderbolt-light-theme-style";
|
|
@@ -698,6 +697,46 @@ def blueprint_for_channel(channel: dict) -> dict[str, Any]:
|
|
|
698
697
|
return {"id": blueprint_id, "name": blueprint_id}
|
|
699
698
|
|
|
700
699
|
|
|
700
|
+
def _resolve_saved_script_blueprint(record: dict[str, Any], channel: dict[str, Any]) -> tuple[str, str]:
|
|
701
|
+
"""Resolve legacy script Blueprint metadata from channel fields or its saved name."""
|
|
702
|
+
blueprint_id = str(
|
|
703
|
+
channel.get("default_blueprint_id")
|
|
704
|
+
or channel.get("blueprint_id")
|
|
705
|
+
or record.get("blueprint_id")
|
|
706
|
+
or ""
|
|
707
|
+
).strip()
|
|
708
|
+
blueprint_name = str(
|
|
709
|
+
channel.get("default_blueprint_name")
|
|
710
|
+
or channel.get("blueprint_name")
|
|
711
|
+
or channel.get("blueprint")
|
|
712
|
+
or record.get("blueprint_name")
|
|
713
|
+
or record.get("blueprint")
|
|
714
|
+
or ""
|
|
715
|
+
).strip()
|
|
716
|
+
resolved = blueprint_for_channel(channel) if blueprint_id else {}
|
|
717
|
+
resolved_name = str(resolved.get("name") or "").strip()
|
|
718
|
+
if resolved_name and (resolved_name.casefold() != blueprint_id.casefold() or not blueprint_name):
|
|
719
|
+
blueprint_name = resolved_name
|
|
720
|
+
wanted = {value.casefold() for value in (blueprint_id, blueprint_name) if value}
|
|
721
|
+
if wanted:
|
|
722
|
+
for path in list_blueprint_files():
|
|
723
|
+
try:
|
|
724
|
+
data = load_blueprint_file(path)
|
|
725
|
+
except (OSError, ValueError, json.JSONDecodeError):
|
|
726
|
+
continue
|
|
727
|
+
display_name = get_display_name("blueprints", path, str(data.get("name") or data.get("title") or path.stem)).strip()
|
|
728
|
+
identifiers = {
|
|
729
|
+
str(data.get("id") or "").strip(),
|
|
730
|
+
path.stem.strip(),
|
|
731
|
+
str(data.get("name") or "").strip(),
|
|
732
|
+
str(data.get("title") or "").strip(),
|
|
733
|
+
display_name,
|
|
734
|
+
}
|
|
735
|
+
if wanted.intersection({value.casefold() for value in identifiers if value}):
|
|
736
|
+
return str(data.get("id") or path.stem).strip(), display_name
|
|
737
|
+
return blueprint_id, blueprint_name or (blueprint_id if blueprint_id else "SEM BLUEPRINT CONFIGURADO")
|
|
738
|
+
|
|
739
|
+
|
|
701
740
|
def _script_channel(record: dict[str, Any], channels: list[dict[str, Any]]) -> dict[str, Any]:
|
|
702
741
|
channel_id = str(record.get("channel_id") or "").strip()
|
|
703
742
|
channel_name = str(record.get("channel_name") or record.get("channel") or "").strip().casefold()
|
|
@@ -725,9 +764,7 @@ def _backfill_saved_script_blueprints(records: list[dict[str, Any]] | None = Non
|
|
|
725
764
|
channel = _script_channel(record, channels)
|
|
726
765
|
if not channel:
|
|
727
766
|
continue
|
|
728
|
-
blueprint_id =
|
|
729
|
-
blueprint = blueprint_for_channel(channel)
|
|
730
|
-
blueprint_name = str(blueprint.get("name") or blueprint_id or "SEM BLUEPRINT CONFIGURADO").strip()
|
|
767
|
+
blueprint_id, blueprint_name = _resolve_saved_script_blueprint(record, channel)
|
|
731
768
|
current_id = str(record.get("blueprint_id") or "").strip()
|
|
732
769
|
current_name = str(record.get("blueprint_name") or record.get("blueprint") or "").strip()
|
|
733
770
|
if current_id == blueprint_id and current_name == blueprint_name:
|
package/package.json
CHANGED