Skip to content

Commit 87ee7cc

Browse files
committed
fix: dynamic HDP-P checkbox label ON/OFF + blocked arm for any rejected action
1 parent 2941f30 commit 87ee7cc

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

apps/hdp-physical-hf/app.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,8 @@ def _guard_action(action: RobotAction, hdp_enabled: bool) -> dict[str, Any]:
549549
function applyState(last){
550550
if (!last) return;
551551
// reset frames carry no approved/attack — don't flash red/orange
552-
arm.blocked = last.reset ? false : (!!last.attack && !last.approved);
553-
arm.attacking = last.reset ? false : (!!last.attack && !!last.approved);
552+
arm.blocked = last.reset ? false : !last.approved;
553+
arm.attacking = last.reset ? false : (!!last.attack && !!last.approved);
554554
555555
if (last.reset) {
556556
// reset to home, box stays where it was
@@ -629,10 +629,14 @@ def _guard_action(action: RobotAction, hdp_enabled: bool) -> dict[str, Any]:
629629

630630
# ── Gradio callbacks ──────────────────────────────────────────────────────────
631631

632-
def toggle_hdp(enabled: bool) -> str:
632+
def toggle_hdp(enabled: bool):
633633
if enabled:
634-
return "**[GUARD] HDP-P ON** — PreExecutionGuard verifies every Gemma action."
635-
return "**[WARN] HDP-P OFF** — Gemma outputs execute directly, no safety check."
634+
label = "[GUARD] HDP-P Protection: ON"
635+
md = "**[GUARD] HDP-P ON** — PreExecutionGuard verifies every Gemma action."
636+
else:
637+
label = "[WARN] HDP-P Protection: OFF"
638+
md = "**[WARN] HDP-P OFF** — Gemma outputs execute directly, no safety check."
639+
return gr.update(label=label), md
636640

637641

638642
def run_safe_routine(hdp_enabled: bool) -> Generator:
@@ -919,7 +923,7 @@ def _edt_json() -> str:
919923

920924
# ── event wiring ──
921925

922-
hdp_toggle.change(fn=toggle_hdp, inputs=[hdp_toggle], outputs=[hdp_label])
926+
hdp_toggle.change(fn=toggle_hdp, inputs=[hdp_toggle], outputs=[hdp_toggle, hdp_label])
923927

924928
run_btn.click(
925929
fn=run_safe_routine,

0 commit comments

Comments
 (0)