Skip to content

feat: report which windows a menu command, launch or open created - #56

Merged
iamnbutler merged 1 commit into
mainfrom
feat/new-windows
Oct 17, 2026
Merged

iamnbutler merged 1 commit into
mainfrom
feat/new-windows

Conversation

@iamnbutler

Copy link
Copy Markdown
Contributor

Closes #17.

When two agents run File → New in the same app, neither can tell which new window is its own. desktop_menu, desktop_launch and desktop_open now report the windows of the receiving process that appeared after the request was sent.

Change

  • Before dispatch. Just before sending, the native client reads every window ID WindowServer knows (CGWindowListCopyWindowInfo(.optionAll), on and off screen, all processes). The new code is in created.swift.
  • After dispatch. When the native outcome says the request was dispatched, the client waits for a new layer-0 window of the receipt's process. The wait is up to about 1 s for a menu command and 2 s for a launch or open. Once one appears, the client waits 250 ms more so windows opening in quick succession land too.
  • Reading the result. The client then reads the app's window mutation inventory once. It keeps windows of the same process generation whose IDs weren't in the before set. Each row has the same shape as a desktop_windows row, including its target.
  • created_windows is { windows, attribution, note }:
    • exclusive: exactly one window appeared.
    • ambiguous: several appeared, and nothing says which came from this request.
    • none: nothing appeared in time.
  • Limit of exclusive. It is "very likely", not proof. Another agent's window can appear in the same interval while ours appears later. The note says so, and suggests desktop_inspect when it matters.
  • Exact IDs, not an ordering assumption. It relies on WindowServer IDs not being reused within the interval. It doesn't assume IDs increase.
  • Surfacing.
    • The menu result carries it directly. Launch and open carry it inside action, next to the refreshed inventory.
    • actionResult's overflow fallback keeps created_windows.
    • The tool descriptions and docs/tools.md explain it.
  • Not covered: window-creating keys (Send keys to windows whose focus isn't a text field #13). feat: send keys to windows whose focus isn't an observed control #51 isn't merged yet. A follow-up can add the same before/after diff to desktop_key (Command-N) once it is.

Tests

npm run check passes, and the native build is green on top of 6f2391b. The repo has no client-side Swift tests.

Live checks (pending: screen locked)

While the session is locked, menu, launch and open refuse before dispatch, so created_windows can't be produced here. To run:

  • TextEdit File → New via desktop_menu → one window, exclusive. Its target inspects.
  • Two File → New calls about 0.3 s apart (two clients) → the later call reports ambiguous if both windows land in its interval.
  • desktop_menu Format → Font → Show Fonts (a panel) → shows the panel or none, depending on whether the inventory lists panels. Record which.
  • desktop_launch of a not-running app that opens a window (TextEdit with no restore) → exclusive, or none if the open panel is slow. Record the timing.
  • desktop_open of a .txt in TextEdit, already running → the new document window, exclusive.
  • desktop_launch of an app that is already running with no new window → none, or the field is absent when nothing was dispatched (confirmedNoChange).

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
@iamnbutler
iamnbutler merged commit 213fdf8 into main Oct 17, 2026
2 checks passed
@iamnbutler
iamnbutler deleted the feat/new-windows branch October 17, 2026 03:10
@iamnbutler iamnbutler mentioned this pull request Oct 17, 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.

Say which windows a menu command, launch or open created

1 participant