fix hotkeys on uitars and openai provider

This commit is contained in:
Dillon DuPont
2025-04-29 12:00:09 -07:00
parent 8b939e7890
commit 1df8194de1
3 changed files with 10 additions and 9 deletions

View File

@@ -240,11 +240,7 @@ class ComputerTool(BaseComputerTool, BaseOpenAITool):
if len(mapped_keys) > 1:
# For key combinations (like Ctrl+C)
for k in mapped_keys:
await self.computer.interface.press_key(k)
await asyncio.sleep(0.1)
for k in reversed(mapped_keys):
await self.computer.interface.press_key(k)
await self.computer.interface.hotkey(*mapped_keys)
else:
# Single key press
await self.computer.interface.press_key(mapped_keys[0])

View File

@@ -173,9 +173,13 @@ class ComputerTool(BaseComputerTool):
elif action == "hotkey":
if "keys" in kwargs:
keys = kwargs["keys"]
for key in keys:
await self.computer.interface.press_key(key)
if len(keys) > 1:
await self.computer.interface.hotkey(*keys)
else:
# Single key press
await self.computer.interface.press_key(keys[0])
# Wait for UI to update
await asyncio.sleep(0.3)

View File

@@ -8,7 +8,7 @@ NavigationKey = Literal['pagedown', 'pageup', 'home', 'end', 'left', 'right', 'u
SpecialKey = Literal['enter', 'esc', 'tab', 'space', 'backspace', 'del']
# Modifier key literals
ModifierKey = Literal['ctrl', 'shift', 'win', 'command', 'option']
ModifierKey = Literal['ctrl', 'alt', 'shift', 'win', 'command', 'option']
# Function key literals
FunctionKey = Literal['f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12']
@@ -39,6 +39,7 @@ class Key(Enum):
DELETE = 'del'
# Modifier keys
ALT = 'alt'
CTRL = 'ctrl'
SHIFT = 'shift'
WIN = 'win'
@@ -85,6 +86,7 @@ class Key(Enum):
'delete': cls.DELETE,
'del': cls.DELETE,
# Modifier key mappings
'alt': cls.ALT,
'ctrl': cls.CTRL,
'control': cls.CTRL,
'shift': cls.SHIFT,
@@ -95,7 +97,6 @@ class Key(Enum):
'cmd': cls.COMMAND,
'': cls.COMMAND,
'option': cls.OPTION,
'alt': cls.OPTION,
'': cls.OPTION,
}