feat(api): Expand API hooks with drag and right_click actions

This commit is contained in:
2026-05-12 19:06:54 -04:00
parent d92361b025
commit a3b117dabd
4 changed files with 72 additions and 2 deletions
+12
View File
@@ -190,6 +190,18 @@ class ApiHookClient:
"""
return self.set_value(item, value)
def drag(self, src_item: str, dst_item: str) -> dict[str, Any]:
"""
Simulates a drag and drop operation.
"""
return self.push_event("drag", {"src_item": src_item, "dst_item": dst_item})
def right_click(self, item: str) -> dict[str, Any]:
"""
Simulates a right-click on an item.
"""
return self.push_event("right_click", {"item": item})
def get_gui_state(self) -> dict[str, Any]:
"""
Returns the full GUI state available via the hook API.
+13
View File
@@ -682,6 +682,8 @@ class AppController:
'btn_rebuild_rag_index': self._rebuild_rag_index,
'btn_clear_summary_cache': self._handle_clear_summary_cache,
}
self._drag_actions: dict[str, Callable[..., Any]] = {}
self._right_clickable_actions: dict[str, Callable[..., Any]] = {}
self._predefined_callbacks: dict[str, Callable[..., Any]] = {
'_test_callback_func_write_to_file': self._test_callback_func_write_to_file,
'_set_env_var': lambda k, v: os.environ.update({k: v}),
@@ -910,6 +912,17 @@ class AppController:
func()
except Exception:
func()
elif action == "drag":
src_item = task.get("src_item")
dst_item = task.get("dst_item")
if src_item in self._drag_actions:
func = self._drag_actions[src_item]
func(dst_item=dst_item)
elif action == "right_click":
item = task.get("item")
if item in self._right_clickable_actions:
func = self._right_clickable_actions[item]
func()
elif action == "select_list_item":
item = task.get("listbox", task.get("item"))
value = task.get("item_value", task.get("value"))