Skip to content

Hardcode AC_mouse_* aliases and sync executor command surface#179

Merged
JE-Chen merged 3 commits intodevfrom
fix/executor-cleanup
Apr 25, 2026
Merged

Hardcode AC_mouse_* aliases and sync executor command surface#179
JE-Chen merged 3 commits intodevfrom
fix/executor-cleanup

Conversation

@JE-Chen
Copy link
Copy Markdown
Member

@JE-Chen JE-Chen commented Apr 25, 2026

Summary

  • AC_mouse_left/right/middle now hardcode their button. Previously they delegated to click_mouse and still required mouse_keycode, so the alias name was misleading and stop_record() recorded {"mouse_keycode": "AC_mouse_left", ...} — a value not present in the mouse keycode table, which made recorded JSON unreplayable.
  • Both action executor and callback executor now share the existing default_shell_manager singleton instead of each constructing a fresh ShellManager at import time.
  • Removed the unused duplicate screenshot() in wrapper/auto_control_image.py (the canonical one lives in wrapper/auto_control_screen.py).
  • README command tables (EN / zh-TW / zh-CN) gained the ~25 commands that were registered but undocumented: window management, flow control, run history, MCP server, AC_set_record_enable, AC_get_*_table, AC_add_package_to_*.
  • Updated the smoke-test scripts and JSON fixtures under test/unit_test/ to match the new alias signature; also fixed a latent bug in those fixtures that passed the AC-prefixed name as a keycode to AC_press_mouse / AC_release_mouse.

Test plan

  • py -m pytest test/unit_test/headless/ test/unit_test/flow_control/ — 278 passed
  • py -m ruff check on the changed je_auto_control/ files — zero warnings
  • import je_auto_control keeps the package Qt-free (no PySide6 modules loaded)
  • Both executors confirmed to share default_shell_manager (event_dict['AC_shell_command'].__self__ is default_shell_manager)
  • Executor command count unchanged at 66

The AC_mouse_left/right/middle aliases all delegated to click_mouse and
required mouse_keycode anyway, so the alias name was misleading. Worse,
stop_record() recorded them as {"mouse_keycode": "AC_mouse_left", ...},
which is not a valid keycode in the mouse table — recorded JSON could
not be replayed. Bind each alias to its hardcoded button and drop the
keycode from the recorder output so record/replay round-trips cleanly.

Other cleanups:
- Use default_shell_manager singleton in both action and callback
  executors instead of constructing a fresh ShellManager per import.
- Remove the duplicate screenshot() in auto_control_image.py — it was
  never imported and shadowed the canonical one in auto_control_screen.
- Add the ~25 commands that were registered but missing from the README
  command tables (window, flow control, history, MCP, etc.).
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Apr 25, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · -38 duplication

Metric Results
Complexity 0
Duplication -38

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

JE-Chen added 2 commits April 26, 2026 00:15
Sonar flagged 39.8% duplication on the previous commit because the
three single-button click adapters were defined identically in both
action_executor.py and callback_function_executor.py. Generate them
once in utils/executor/mouse_aliases.py via a small factory and have
both executors import the same callables.
Sonar's per-file view on PR 179 showed two clusters of duplication:

- The three AC_mouse_* registration lines were duplicated between
  action_executor.py and callback_function_executor.py. Move the
  three name->callable bindings into a MOUSE_BUTTON_COMMANDS dict on
  mouse_aliases.py and spread it (**) into both executors so the
  registration block exists in exactly one place.
- The html / json / xml report smoke scripts were near-100% copies
  of each other. Extract the shared driver into report_smoke.py and
  reduce each script to a one-liner that names its report command.
@sonarqubecloud
Copy link
Copy Markdown

@JE-Chen JE-Chen merged commit d13b115 into dev Apr 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant