Skip to content

Commit d2affba

Browse files
committed
fix(yutori): map standalone modifier names through MODIFIER_MAP
key_press / hold_key compound keys already consulted MODIFIER_MAP, but the new `modifier` parameter on click and scroll actions passes a bare modifier name ("control", "meta", "command") that bypassed the lookup and went out as-is. Kernel's hold_keys wants "ctrl" and "super" — so ctrl-click and cmd-click silently dropped the modifier. Unify the per-part mapping into a single helper applied to both the compound and single-key paths in TS and Python.
1 parent 23b63f0 commit d2affba

2 files changed

Lines changed: 20 additions & 28 deletions

File tree

pkg/templates/python/yutori/tools/computer.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -374,18 +374,13 @@ def _get_coordinates(
374374
return {"x": int(x), "y": int(y)}
375375

376376
def _map_key(self, key: str) -> str:
377+
def map_part(part: str) -> str:
378+
trimmed = part.strip()
379+
lower = trimmed.lower()
380+
if lower in MODIFIER_MAP:
381+
return MODIFIER_MAP[lower]
382+
return KEY_MAP.get(trimmed, trimmed)
383+
377384
if "+" in key:
378-
parts = key.split("+")
379-
mapped_parts = []
380-
for part in parts:
381-
trimmed = part.strip()
382-
lower = trimmed.lower()
383-
384-
if lower in MODIFIER_MAP:
385-
mapped_parts.append(MODIFIER_MAP[lower])
386-
else:
387-
mapped_parts.append(KEY_MAP.get(trimmed, trimmed))
388-
389-
return "+".join(mapped_parts)
390-
391-
return KEY_MAP.get(key, key)
385+
return "+".join(map_part(p) for p in key.split("+"))
386+
return map_part(key)

pkg/templates/typescript/yutori/tools/computer.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -414,22 +414,19 @@ export class ComputerTool {
414414
}
415415

416416
private mapKey(key: string): string {
417+
const mapPart = (part: string): string => {
418+
const trimmed = part.trim();
419+
const lower = trimmed.toLowerCase();
420+
if (MODIFIER_MAP[lower]) {
421+
return MODIFIER_MAP[lower];
422+
}
423+
return KEY_MAP[trimmed] || trimmed;
424+
};
425+
417426
if (key.includes('+')) {
418-
const parts = key.split('+');
419-
const mappedParts = parts.map(part => {
420-
const trimmed = part.trim();
421-
const lower = trimmed.toLowerCase();
422-
423-
if (MODIFIER_MAP[lower]) {
424-
return MODIFIER_MAP[lower];
425-
}
426-
427-
return KEY_MAP[trimmed] || trimmed;
428-
});
429-
return mappedParts.join('+');
427+
return key.split('+').map(mapPart).join('+');
430428
}
431-
432-
return KEY_MAP[key] || key;
429+
return mapPart(key);
433430
}
434431

435432
private sleep(ms: number): Promise<void> {

0 commit comments

Comments
 (0)