8000 focus_window returns silent false negative; handle param accepted but ignored · Issue #8 · Mnehmos/mnehmos.ooda.mcp · GitHub
[go: up one dir, main page]

Skip to content

focus_window returns silent false negative; handle param accepted but ignored #8

Open

Description

@Mnehmos

Two problems in src/tools/window.ts:389-419.

1. Silent false negative

focus_window returned {"focused": false} for a window that was provably foreground — get_active_window returned the identical pid/title/handle immediately before and after. Failed by both pid and title.

launch_application("notepad.exe") -> { pid: 23348, title: "Untitled - Notepad" }
get_active_window()               -> { pid: 23348, title: "Untitled - Notepad" }   <- IS foreground
focus_window(pid: 23348)          -> { focused: false }
focus_window(title: "Untitled - Notepad") -> { focused: false }

2. handle is dead

The schema advertises handle, the handler destructures it, and it is never passed — focusWindowWin32(args.title, args.pid).

Impact

Highest-severity bug in the server for computer-use work: focus is the precondition for every keystroke. A silently-false focus call means an agent either aborts valid work or, worse, proceeds to type into whatever window actually has focus.

Fix

  • Honor handle.
  • Use AttachThreadInput + SetForegroundWindow (plus restore-if-minimized) to defeat the Windows foreground lock.
  • Treat "already foreground" as success.
  • On failure, return the actual foreground window in the response instead of a bare false, so the caller can diagnose rather than guess.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0