Skip to content

macOS engine: name a window off screen or on another Space, answer an app there at once, and refuse a Raise that cannot reach it (#367) - #401

Merged
SSFSKIM merged 8 commits into
mainfrom
fix/367-offscreen-reason
Nov 17, 2026

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Nov 17, 2026

Copy link
Copy Markdown
Owner

What changes

On macOS, an app whose window was off every display or on another Space gave an observation with no reason in it. In the dogfood case, MAWS showed an empty tree, and the screenshot said only "Screenshot unavailable". Now:

  • The observation names the placement. When the primary window lies outside every display, or is on another Space, getApp and getAXState add one line, [window off screen: …] or [window on another Space: …], and take no screenshot (meta cua/screenshotOmitted: windowOffScreen / windowOnAnotherSpace). getScreenshot fails naming the reason and the remedy. The line survives a no-change diff. Detection (native/engine/Sources/Engine/Placement.swift):
    • off every display is pure geometry: the AX frame overlaps no screen;
    • another Space is a window on a display that the window server doesn't list as on screen, while not minimized and its app not hidden.
  • An app whose windows are all on another Space, with no AX window, is answered at once (ruling 1ea561bc:782). Electron lists no AX windows while it's on another Space. There, getApp, getAXState and getScreenshot used to wait out the 5 s primary-window wait and fail timeoutReached; now they fail windowOnAnotherSpace in about 3 ms.
    • The check runs only after the window read comes back absent, so an app with a window pays nothing.
    • It claims another Space only on positive reads: the app's layer-0 windows are listed and none is on screen, at least one is on a Space no display shows, no window is on a current Space, and the app isn't hidden.
    • Space membership is read through SkyLight (SLSCopySpacesForWindows, looked up with dlsym). If those calls are missing, nothing is claimed.
  • Raise on a window on another Space is refused (windowOnAnotherSpace) before anything is sent (SecondaryAction.swift). Live, it answered success and did nothing (below). Off-display Raise is unchanged.
  • The remedies no longer offer Raise. Off every display: "Ask the user to move it onto a display." Another Space: "Ask the user to bring it here or switch to its Space." agent-cursor.md and its two copies say the same.

Unchanged: an on-screen window's tree and screenshot are byte-identical to main's, and so are a partly visible window, a minimized window and a hidden app.

Evidence

docs/evidence/2026-11-17-367-hosted/README.md; per-run files are on probe/367-live (f69cd90). Everything ran on GitHub-hosted macOS with owned TextEdit and Electron fixtures. Each fix head was paired with the main of its day.

  • Raise is a no-op on another Space (44122922177, fix 2b7804b against main 15acf09): on both heads, 4/4 public Raises answered success, but the active Space stayed 1→1, the window's Space was unchanged, the frame was unchanged and Finder stayed frontmost. The runner can create and switch Spaces (AX full screen, System Events key codes). The same run checked the plan's other steps:
    • on screen: the text and JPEG bytes are identical on both heads;
    • partly off (110 px visible): it is still captured, with no line;
    • hidden: noCapturableWindow on both heads;
    • walk p50: TextEdit 22.1 / 22.6 ms, Electron 28.2 / 21.8 ms.
  • The final head, two repetitions (44135587845, 44136447268), fix a7c2fcc against main 136183a:
on another Space main fix
Electron getApp / getAXState / getScreenshot timeoutReached, 5015–5075 ms (6/6) windowOnAnotherSpace, 2.6–3.1 ms (6/6)
TextEdit getApp / getAXState noCapturableWindow tree plus the another-Space line and meta
TextEdit getScreenshot noCapturableWindow the named reason and remedy
Raise, both apps success, nothing moved (4/4) windowOnAnotherSpace, 2.8–3.9 ms, nothing moved (4/4)
Raise on an on-screen window (control) 4/4 ok 4/4 ok

Independent before/after reads (active Space, window Spaces, CG frame, frontmost) were unchanged in every Raise cell, and all 16 surrounding observations succeeded.

  • An interim run, 44133515588, verified the Raise refusal, but its control ran before the Space cell and Electron's no-AX state didn't arise. It is kept separate and not pooled.
  • Three earlier runs (44101305953, 44106077029, 44111743279) were setup rounds that scored no placement cell. They are kept as records.

Limits

  • Off every display wasn't reproduced live. On hosted runners, AX moves keep 40 px visible, shrinking keeps 24 px, and the app's own Electron setBounds(-5000,…) is clamped to x=-860. The off-screen line and error are covered by unit tests only, and off-display Raise is unmeasured, so the remedy doesn't offer it (ruling 782).
  • The Space detection uses private SkyLight calls for membership. It claims nothing if they are absent.
  • Two repetitions per head: no latency distribution, and endpoint samples taken 1.6 s apart don't exclude a transient Space change between them.
  • Restoring after full screen doesn't give byte-identical screenshots on either head (TextEdit's scrollbar value changes). That isn't a macOS engine: an off-screen window gives an empty tree and 'Screenshot unavailable' with no reason; say so and suggest Raise #367 effect.

Verification

  • swift test (native/engine), on the merged head: 1,262 tests, 0 failures, 1 skipped (pre-existing).
  • Node: the doc set (core-documentation, docs-oracle, docs-source-behavior, inventory, package-contents) and every services-engine-* test, 220 tests: 219 pass, 1 skipped (hosted-only).
  • Mutation check on ruling 782's predicates: 14/14 killed, including dropping the current-Space veto.
  • Review: the original build was reviewed by doperpowers:reviewer-medium until it converged. For ruling 782, doperpowers:reviewer-medium on 2b7804b..d778455 found one P2: a window opening on the current Space was refused when another window was on another Space. It was fixed at d83bf16 with a veto, and the re-review came back correct.
  • ci-gate on cf2963a, gates plugin, test and engine-swift: GREEN, https://github.com/SSFSKIM/cua/actions/runs/44139726242. The sandbox and browser-parity gates were not run: the change touches neither the sandbox nor the browser path.

Plugin 0.28.8.

Closes #367

Sminos-Session: cursor235#b93055dd (cua on macbook)

…s observation, and getScreenshot gives the reason (refs #367)

The macOS engine reads the primary window's placement (Placement.swift). It is off screen when its AX frame
overlaps no screen frame. It is on another Space when it lies on a display but its CGWindow has no
kCGWindowIsOnscreen and its app is not hidden. Such a window is not captured, as a minimized window is not
(screenshotOmitted "windowOffScreen" | "windowOnAnotherSpace"). Its Skyshot window carries `placement`, which
the renderer prints as one line after the tree, the no-change diff included. The service adds
`screenshotUnavailable`, and the facade's getScreenshot error appends it.

A window on screen is observed byte for byte as before, pinned in the service test. A window on another Space
used to fail its whole observation with noCapturableWindow and now succeeds with the line. Every other
noCapturableWindow cause is unchanged (PlacementTests). The remedy names Raise with cua's host rule. The
truncation paragraph of agent-cursor.md gains one sentence (surface inventory, PROVENANCE row). Decision Log
entry #367.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…t, AXMinimized or AXHidden (refs #367)

The review of 8355f1d found that the another-Space branch ran without the geometry guard. With no frame, a
frame under one point, or no screens read, plus an absent on-screen flag, it answered anotherSpace. That
skipped a capture that used to fail noCapturableWindow. An unreadable AXMinimized or AXHidden also read as
false. Now both claims need a usable frame and the screens, and another Space needs AXMinimized and AXHidden
read false. Tests cover each unknown with the flag both present and absent.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…reason (refs #367)

Sminos-Session: cursor235#b93055dd (cua on macbook)
…Space where Raise or a reopen would do nothing, and neither remedy offers Raise (refs #367)

Ruling 1ea561bc:782 on the hosted measurement (run 44122922177):
- The off-display and another-Space remedies drop Raise and ask the user
  (move it onto a display; bring it here or switch to its Space), in the
  observation's line, the screenshot error and agent-cursor.md.
- A running app with no accessible window whose windows CoreGraphics and
  SkyLight place only on another Space (Electron) is refused at once,
  before the reopen and the 5 s window wait.
- A Raise on a window read as on another Space is refused before anything
  is sent; off-display Raise is unchanged.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…ther-Space refusal, so an app opening its window here is still reopened and waited for (refs #367)

The review of d778455 (P2): windowsOnAnotherSpace claimed another Space
when any one layer-0 window was there, even with another window of the app
on a Space shown now. Now any window whose membership meets the current
Spaces vetoes the claim, whatever the app's other windows are on.

Sminos-Session: cursor235#b93055dd (cua on macbook)
…367)

Sminos-Session: cursor235#b93055dd (cua on macbook)
…er Space, and refuses what cannot reach one on another Space (refs #367)

Sminos-Session: cursor235#b93055dd (cua on macbook)
…ther Space and then refused, and the fast another-Space answer (refs #367)

Sminos-Session: cursor235#b93055dd (cua on macbook)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T17:57:45.523426Z cf2963a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@SSFSKIM
SSFSKIM merged commit 466409b into main Nov 17, 2026
7 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.

macOS engine: an off-screen window gives an empty tree and 'Screenshot unavailable' with no reason; say so and suggest Raise

1 participant