tenseleyflow/loader / d66908d

Browse files

Handle Y/n keys at app level for approval, bypassing widget focus issues

Authored by espadonne
SHA
d66908dfc4dba316b74c47855bc95ee41c23530d
Parents
79dc7fb
Tree
c65d2f6

1 changed file

StatusFile+-
M src/loader/ui/app.py 20 0
src/loader/ui/app.pymodified
@@ -432,6 +432,26 @@ class LoaderApp(App):
432432
         finally:
433433
             self._pending_question = None
434434
 
435
+    def on_key(self, event) -> None:
436
+        """Intercept Y/n/e keys at app level when a confirmation is pending.
437
+
438
+        This bypasses the approval bar focus issue — the bar may not receive
439
+        focus reliably, so we handle the keys here instead.
440
+        """
441
+        if self._pending_confirmation is None or self._pending_confirmation.done():
442
+            return
443
+        key = event.key
444
+        if key in ("y", "Y"):
445
+            event.prevent_default()
446
+            event.stop()
447
+            self._pending_confirmation.set_result(True)
448
+            self.query_one("#approval-bar", ApprovalBar).hide_approval()
449
+        elif key in ("n", "N", "escape"):
450
+            event.prevent_default()
451
+            event.stop()
452
+            self._pending_confirmation.set_result(False)
453
+            self.query_one("#approval-bar", ApprovalBar).hide_approval()
454
+
435455
     def on_approval_bar_approved(self, event: ApprovalBar.Approved) -> None:
436456
         """Handle approval from the bar."""
437457
         try: