Skip to content

Add exact window modes to App#331

Open
zengfanfan wants to merge 1 commit into
CursorTouch:mainfrom
zengfanfan:feature/exact-window-control
Open

Add exact window modes to App#331
zengfanfan wants to merge 1 commit into
CursorTouch:mainfrom
zengfanfan:feature/exact-window-control

Conversation

@zengfanfan

@zengfanfan zengfanfan commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Description

Add deterministic native window operations as explicit modes of the existing App tool:

App(mode="find_window", title="Target", title_match="exact")
App(mode="activate_window", handle=12345, process_id=6789)
App(mode="set_window_bounds", handle=12345, outer=[100, 120, 800, 600])
  • find_window filters by exact HWND, PID, process basename, and exact or contains title matching. It returns native identity plus outer and client geometry.
  • activate_window requires an HWND, accepts optional identity assertions, and verifies the foreground HWND after activation.
  • set_window_bounds requires an HWND and exactly one outer or client rectangle. Client bounds are corrected against the actual Win32 readback to account for non-client frame differences.
  • Existing launch, launch_executable, resize, and switch behavior is unchanged. Parameters for exact modes and convenience modes are explicitly isolated so invalid combinations fail before desktop access.

The Win32 implementation lives in an internal ExactWindowController; no additional public MCP tool is registered. Documentation and manifest text now describe the consolidated App interface.

Motivation

The existing name-based modes are useful for convenient interactive automation, but fuzzy selection is unsuitable when callers already have stable native identity. Explicit modes keep both workflows in one application/window tool while making exact operations deterministic and verifiable.

Testing

  • ruff check on all changed Python files and related tests
  • ruff format --check on all changed Python files and related tests
  • Focused App and exact-window tests: 64 passed
  • Full effective suite: 431 passed, 3 deselected
  • Full unmodified suite: 431 passed, 3 failed; the three failures are local environment limitations in unchanged upstream areas (worktree temp-directory permissions, scheduled-task privileges, and an occupied system clipboard)
  • Real Windows smoke test with a disposable Tk window: exact HWND lookup, foreground activation readback, outer bounds, and client bounds all passed

No installed application or persistent user data was modified by the smoke test.

@zengfanfan
zengfanfan marked this pull request as ready for review July 13, 2026 12:06
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@zengfanfan
zengfanfan force-pushed the feature/exact-window-control branch from 866f2aa to 7358578 Compare July 18, 2026 13:21
@zengfanfan zengfanfan changed the title Add exact window discovery, activation, and bounds control Add exact window modes to App Jul 18, 2026
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