From 44d54babeb1da7493e1e610ce04f718e6dd1b4e2 Mon Sep 17 00:00:00 2001 From: goodboy Date: Tue, 10 Mar 2026 17:06:46 -0400 Subject: [PATCH] Handle VNC reset-dialog in `vnc_click_hack()` Add TAB + ENTER key presses after the `Ctrl+Alt+` hotkey combo to auto-confirm the "simulate a reset?" dialog that IB gateway sometimes shows. Deats, - press `ISO_Enter` before click to dismiss any prior active dialog window. - add post-hotkey loop sending `Tab` then `KP_Enter` with `asyncio.sleep()` delays to handle the confirmation dialog. - add `asyncio` import. Also, - capture VNC connect error as `vnc_err` and log it instead of falling through to `try_xdo_manual()`. - comment-out `try_xdo_manual()` fallback in VNC error path. - reformat `client.press()` call to multiline style. - reformat `RuntimeError` raise to multiline style with `!r`. (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- piker/brokers/ib/_util.py | 43 +++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/piker/brokers/ib/_util.py b/piker/brokers/ib/_util.py index b9bc020f..66b0704a 100644 --- a/piker/brokers/ib/_util.py +++ b/piker/brokers/ib/_util.py @@ -20,6 +20,7 @@ runnable script-programs. ''' from __future__ import annotations +import asyncio from datetime import ( # noqa datetime, date, @@ -140,7 +141,8 @@ async def data_reset_hack( except ( OSError, # no VNC server avail.. PermissionError, # asyncvnc pw fail.. - ): + ) as _vnc_err: + vnc_err = _vnc_err try: import i3ipc # noqa (since a deps dynamic check) except ModuleNotFoundError: @@ -166,14 +168,22 @@ async def data_reset_hack( # localhost but no vnc-client or it borked.. else: - try_xdo_manual(client) + log.error( + 'VNC CLICK HACK FAILE with,\n' + f'{vnc_err!r}\n' + ) + + # breakpoint() + # try_xdo_manual(client) case 'i3ipc_xdotool': try_xdo_manual(client) # i3ipc_xdotool_manual_click_hack() case _ as tech: - raise RuntimeError(f'{tech} is not supported for reset tech!?') + raise RuntimeError( + f'{tech!r} is not supported for reset tech!?' + ) # we don't really need the ``xdotool`` approach any more B) return True @@ -269,10 +279,35 @@ async def vnc_click_hack( 500, ) ) + # in case a prior dialog win is open/active. + await client.press('ISO_Enter') + # ensure the ib-gw window is active await client.click(MOUSE_BUTTON_LEFT) + # send the hotkeys combo B) - await client.press('Ctrl', 'Alt', key) # keys are stacked + await client.press( + 'Ctrl', + 'Alt', + key, + ) # NOTE, keys are stacked + + # XXX, sometimes a dialog asking if you want to "simulate + # a reset" will show, in which case we want to select + # "Yes" (by tabbing) and then hit enter. + iters: int = 1 + delay: float = 0.3 + await asyncio.sleep(delay) + + for i in range(iters): + log.info(f'Sending TAB {i}') + await client.press('Tab') + await asyncio.sleep(delay) + + for i in range(iters): + log.info(f'Sending ENTER {i}') + await client.press('KP_Enter') + await asyncio.sleep(delay) def i3ipc_fin_wins_titled(