@danhachuel/thunderbolt 0.4.3 → 0.4.5

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 CHANGED
@@ -62,7 +62,7 @@ from hermes_ui.logs import list_logs, logs_to_rows
62
62
  from hermes_ui.languages import LANGUAGE_CODES, VIDEO_LANGUAGE_CODES, LANGUAGE_FLAG_DATA_URIS, language_code, language_label, ui_language_menu_label, ui_text, video_language_label, video_language_options
63
63
  from hermes_ui.api_key_tests import test_apify_credentials, test_influencer_database, test_innertube_api_key, test_kaggle_credentials, test_material_source_credentials, test_media_provider_card, test_nano_banana_credentials, test_postiz_credentials, test_telegram_credentials, test_tiktok_credentials, test_upload_post_credentials, test_voice_provider
64
64
  from hermes_ui.tutorials import tutorial_body, tutorial_caption, tutorial_title
65
- from hermes_ui.update_manager import check_version, update_to_latest
65
+ from hermes_ui.update_manager import check_version, restart_current_process, update_to_latest
66
66
 
67
67
  from hermes_ui.script_documents import list_script_documents, read_script_document, save_script_document, script_storage_path
68
68
  from hermes_ui.script_generation import generate_script_document
@@ -1303,11 +1303,15 @@ def render_home_update_controls() -> None:
1303
1303
  """,
1304
1304
  unsafe_allow_html=True,
1305
1305
  )
1306
- if st.button("Atualizar Versão", key="home_update_version", use_container_width=True, type="primary", icon=":material/system_update:"):
1306
+ if st.button("Atualizar Versão", key="home_update_version", type="primary", icon=":material/system_update:"):
1307
1307
  with st.spinner("A instalar a versão mais recente…"):
1308
- st.session_state["home_update_result"] = update_to_latest(APP_VERSION)
1308
+ update_result = update_to_latest(APP_VERSION)
1309
+ st.session_state["home_update_result"] = update_result
1309
1310
  st.session_state["home_update_notice_dismissed"] = False
1310
- st.rerun()
1311
+ if update_result.ok and update_result.restart_required:
1312
+ st.success("Actualização concluída. A reiniciar o Thunderbolt para aplicar a nova versão…")
1313
+ time.sleep(0.8)
1314
+ restart_current_process()
1311
1315
  with version_area:
1312
1316
  cache_key = "home_update_version_check"
1313
1317
  checked_at_key = "home_update_version_checked_at"
@@ -8,6 +8,7 @@ from __future__ import annotations
8
8
 
9
9
  import os
10
10
  import subprocess
11
+ import sys
11
12
  from dataclasses import dataclass
12
13
  from typing import Any, Callable
13
14
 
@@ -39,6 +40,13 @@ class UpdateResult:
39
40
  ok: bool
40
41
  latest_version: str = ""
41
42
  message: str = ""
43
+ restart_required: bool = False
44
+
45
+
46
+ def restart_current_process(*, exec_fn: Callable[..., Any] = os.execv) -> None:
47
+ """Replace the running Streamlit process with the same command line."""
48
+ executable = sys.executable
49
+ exec_fn(executable, [executable, *sys.argv])
42
50
 
43
51
 
44
52
  def latest_package_version(*, timeout: int = 8, get: Callable[..., Any] = requests.get) -> str:
@@ -101,6 +109,7 @@ def update_to_latest(
101
109
  return UpdateResult(
102
110
  True,
103
111
  latest_version=status.latest_version,
112
+ restart_required=True,
104
113
  message=(
105
114
  f"A versão {status.latest_version} foi instalada. Reinicie o Thunderbolt para abrir a versão nova; "
106
115
  "os dados e configurações locais foram preservados."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danhachuel/thunderbolt",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "Thunderbolt — interface local para operação de canais faceless e motor MoneyPrinterTurbo",
5
5
  "license": "MIT",
6
6
  "main": "scripts/cli.mjs",