Skip to content

Commit 0230256

Browse files
raidos23cursoragent
andcommitted
fix: correction du blocage BCASL et centralisation des helpers de runtime
- Centralise is_noninteractive et is_cli_mode dans Ui/Cli/runtime.py. - Corrige le blocage de la compilation en GUI quand BCASL est désactivé. - Nettoyage des importations et de la logique redondante dans le SDK et l'UI. - Amélioration de la gestion des rapports 'désactivés' dans le Loader BCASL. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent a07e986 commit 0230256

9 files changed

Lines changed: 93 additions & 55 deletions

File tree

Plugins_SDK/GeneralContext/Dialog.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@
2323
from rich.console import Console
2424

2525
# Import des classes et fonctions de Core.dialogs
26+
from Ui.Cli.runtime import is_cli_mode, is_noninteractive
2627
from Ui.Gui.WidgetsCreator import (
2728
InstallAuth,
2829
ProgressDialog,
29-
_is_cli_mode,
30-
_is_noninteractive,
3130
_redact_secrets,
3231
show_msgbox,
3332
sys_msgbox_for_installing,
@@ -43,7 +42,7 @@ def __init__(self):
4342
colorama.init()
4443
self.console = Console()
4544
self.plugin_id: Optional[str] = None
46-
if not _is_cli_mode() and not _is_noninteractive():
45+
if not is_cli_mode() and not is_noninteractive():
4746
self._ensure_qt_context()
4847

4948
def _ensure_qt_context(self) -> None:
@@ -53,7 +52,7 @@ def _ensure_qt_context(self) -> None:
5352
import os
5453

5554
# CLI and headless runs must stay on Rich, never bootstrap Qt here.
56-
if _is_cli_mode() or _is_noninteractive():
55+
if is_cli_mode() or is_noninteractive():
5756
return
5857

5958
# Skip if already initialized or in explicit headless mode
@@ -184,7 +183,7 @@ def progress(
184183
Uses Core.dialogs.ProgressDialog when GUI is available,
185184
otherwise returns a Rich-based console fallback.
186185
"""
187-
use_rich = _is_cli_mode() or _is_noninteractive()
186+
use_rich = is_cli_mode() or is_noninteractive()
188187
if not use_rich:
189188
try:
190189
from PySide6.QtWidgets import QApplication

Ui/Cli/helpers.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,17 @@ def append(self, msg: str):
555555
# report is None if BCASL is disabled or failed silently
556556
return True
557557

558+
if isinstance(report, dict):
559+
try:
560+
from bcasl.Loader import is_bcasl_disabled_report
561+
562+
if is_bcasl_disabled_report(report):
563+
return True
564+
except Exception:
565+
pass
566+
if "ok" in report:
567+
return bool(report.get("ok"))
568+
558569
if hasattr(report, "ok"):
559570
if not getattr(report, "ok"):
560571
error("BCASL reported security or validation failures.")

Ui/Cli/interactive.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414

1515
def _is_noninteractive_env() -> bool:
1616
try:
17-
v = os.environ.get("PYCOMPILER_NONINTERACTIVE")
18-
if v is None:
19-
return False
20-
return str(v).strip().lower() not in ("", "0", "false", "no")
17+
from Ui.Cli.runtime import is_noninteractive
18+
19+
return is_noninteractive()
2120
except Exception:
2221
return False
2322

Ui/Cli/runtime.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,22 @@ def is_cli_mode() -> bool:
262262
return False
263263

264264

265+
def is_noninteractive() -> bool:
266+
"""True when prompts must not block (CI, headless plugin workers, etc.)."""
267+
try:
268+
v = os.environ.get("PYCOMPILER_NONINTERACTIVE")
269+
if v is None:
270+
return False
271+
return str(v).strip().lower() not in ("", "0", "false", "no")
272+
except Exception:
273+
return False
274+
275+
276+
def use_rich_dialogs() -> bool:
277+
"""Use Rich console dialogs instead of Qt message boxes."""
278+
return is_cli_mode() or is_noninteractive()
279+
280+
265281
def install_runtime(app_version: str, enable_qt: bool = True) -> None:
266282
ensure_sys_path()
267283
configure_logging()

Ui/Gui/Compilation/helpers.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@ def bcasl_report_allows_compile(gui_instance, report) -> bool:
8787
"""Return True when BCASL pre-compile report allows compilation to continue."""
8888
try:
8989
if report is None:
90+
try:
91+
from pathlib import Path
92+
93+
from bcasl.Loader import _is_bcasl_enabled
94+
95+
ws = getattr(gui_instance, "workspace_dir", None)
96+
if ws and not _is_bcasl_enabled(Path(ws).resolve()):
97+
return True
98+
except Exception:
99+
pass
90100
log_i18n_level(
91101
gui_instance,
92102
"error",
@@ -96,9 +106,15 @@ def bcasl_report_allows_compile(gui_instance, report) -> bool:
96106
return False
97107

98108
if isinstance(report, dict):
99-
status = str(report.get("status", "")).strip().lower()
100-
if status in {"disabled", "skipped"}:
101-
return True
109+
try:
110+
from bcasl.Loader import is_bcasl_disabled_report
111+
112+
if is_bcasl_disabled_report(report):
113+
return True
114+
except Exception:
115+
status = str(report.get("status", "")).strip().lower()
116+
if status in {"disabled", "skipped"}:
117+
return True
102118
if "ok" in report:
103119
ok = bool(report.get("ok"))
104120
if not ok:

Ui/Gui/Dialogs/BcaslDialog.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,7 @@ def request_cancel(self) -> None:
876876
def run(self) -> None:
877877
try:
878878
from bcasl.Loader import (
879+
BCASL_DISABLED_REPORT,
879880
_is_bcasl_enabled,
880881
_load_workspace_config,
881882
_run_bcasl_sync,
@@ -884,7 +885,7 @@ def run(self) -> None:
884885
# 1. Vérifier si BCASL est activé (en arrière-plan)
885886
if not _is_bcasl_enabled(self.workspace_root):
886887
self.log.emit("BCASL disabled in ark.yml. Skipping execution\n")
887-
self.finished.emit({"status": "disabled"})
888+
self.finished.emit(dict(BCASL_DISABLED_REPORT))
888889
return
889890

890891
# 2. Charger la config si non fournie (en arrière-plan)
@@ -927,7 +928,17 @@ def on_log(self, s: str) -> None:
927928
@Slot(object)
928929
def on_finished(self, rep) -> None:
929930
try:
930-
if rep and hasattr(self._gui, "log") and self._gui.log is not None:
931+
try:
932+
from bcasl.Loader import is_bcasl_disabled_report
933+
except Exception:
934+
is_bcasl_disabled_report = lambda _r: False # type: ignore[assignment,misc]
935+
936+
if (
937+
rep
938+
and not is_bcasl_disabled_report(rep)
939+
and hasattr(self._gui, "log")
940+
and self._gui.log is not None
941+
):
931942
self._gui.log.append("BCASL - Rapport:\n")
932943
for item in rep:
933944
try:
@@ -1154,8 +1165,13 @@ def run_pre_compile_async(
11541165
return
11551166
workspace_root = Path(self.workspace_dir).resolve()
11561167

1157-
from bcasl.Loader import (_get_plugins_dir, _is_bcasl_enabled,
1158-
_run_bcasl_sync, _load_workspace_config)
1168+
from bcasl.Loader import (
1169+
BCASL_DISABLED_REPORT,
1170+
_get_plugins_dir,
1171+
_is_bcasl_enabled,
1172+
_load_workspace_config,
1173+
_run_bcasl_sync,
1174+
)
11591175

11601176
# Étape 0: Vérifier si BCASL est activé globalement via ark.yml
11611177
if not _is_bcasl_enabled(workspace_root):
@@ -1166,7 +1182,7 @@ def run_pre_compile_async(
11661182
pass
11671183
if callable(on_done):
11681184
try:
1169-
on_done(None)
1185+
on_done(dict(BCASL_DISABLED_REPORT))
11701186
except Exception:
11711187
pass
11721188
return

Ui/Gui/WidgetsCreator.py

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -130,38 +130,23 @@ def _redact_secrets(text: str) -> str:
130130

131131
def _is_noninteractive() -> bool:
132132
"""Check if running in non-interactive mode."""
133-
try:
134-
import os
133+
from Ui.Cli.runtime import is_noninteractive
135134

136-
v = os.environ.get("PYCOMPILER_NONINTERACTIVE")
137-
if v is None:
138-
return False
139-
return str(v).strip().lower() not in ("", "0", "false", "no")
140-
except Exception:
141-
return False
135+
return is_noninteractive()
142136

143137

144138
def _is_cli_mode() -> bool:
145139
"""True when ARK CLI is active: plugins/dialogs must use Rich, not Qt."""
146-
try:
147-
from Ui.Cli.runtime import is_cli_mode
140+
from Ui.Cli.runtime import is_cli_mode
148141

149-
return is_cli_mode()
150-
except Exception:
151-
try:
152-
import os
153-
154-
v = os.environ.get("PYCOMPILER_CLI")
155-
if v is None:
156-
return False
157-
return str(v).strip().lower() not in ("", "0", "false", "no")
158-
except Exception:
159-
return False
142+
return is_cli_mode()
160143

161144

162145
def _use_rich_dialogs() -> bool:
163146
"""Use Rich console dialogs instead of Qt message boxes."""
164-
return _is_cli_mode() or _is_noninteractive()
147+
from Ui.Cli.runtime import use_rich_dialogs
148+
149+
return use_rich_dialogs()
165150

166151

167152
def _qt_active_parent():

bcasl/Loader.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@
3838
from .executor import BCASL
3939
from .tagging import compute_tag_order
4040

41+
BCASL_DISABLED_REPORT: dict[str, Any] = {"status": "disabled", "ok": True}
42+
43+
44+
def is_bcasl_disabled_report(report: Any) -> bool:
45+
"""Return True when BCASL was skipped because it is disabled in ark.yml."""
46+
if not isinstance(report, dict):
47+
return False
48+
return str(report.get("status", "")).strip().lower() in {"disabled", "skipped"}
49+
50+
4151
# --- Utilitaires ---
4252

4353

@@ -483,7 +493,7 @@ def run_pre_compile(self, build_context: Optional[Any] = None) -> Optional[objec
483493
self.log.append("BCASL désactivé dans ark.yml. Exécution ignorée\n")
484494
except Exception:
485495
pass
486-
return None
496+
return dict(BCASL_DISABLED_REPORT)
487497

488498
Plugins_dir = _get_plugins_dir()
489499
cfg = _load_workspace_config(workspace_root)

todo.md

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,4 @@
55
- [x] ecrire des tests unitaires.
66
- [x] renforcement et blocage immédiat du build en cas d'absence d'Internet lors de l'installation des outils.
77

8-
- [] [INFO] Thème appliqué : Mint Light (mint_light.qss)
9-
[INFO] Langue appliquée : Français
10-
[INFO] Language applied: Deutsch
11-
[INFO] Theme applied: Dark (dark.qss)
12-
[INFO] Theme applied: Light (light.qss)
13-
[STATE] Exclusion applied: 402 file(s) excluded according to ark.yml
14-
[INFO] 🔒 Generating build lock file...
15-
[INFO] Starting pre-compilation phase (BCASL)...
16-
[INFO] Pre-compilation (BCASL) if enabled...
17-
18-
BCASL désactivé dans ark.yml. Exécution ignorée
19-
[ERROR] BCASL failed or returned no report. Compilation blocked.
20-
[ERROR] BCASL validation failed. Compilation cannot continue.
21-
22-
ce probleme c'est produit en gui, normalemnt comme il est desactiver la compialtion doit ce lancer sans bcasl mais ici il bloque.
8+
- [x] GUI : ne plus bloquer la compilation quand BCASL est désactivé dans ark.yml (rapport `disabled` au lieu de `None`).

0 commit comments

Comments
 (0)