Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/desktop/native/computer-use/ComputerUse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,9 @@ final class Snapshot {
if role == kAXMenuItemRole && !entry.menu && !entry.priority {
queue.append(AXTraversalEntry(element: element, parent: entry.parent, depth: entry.depth, menu: true, priority: false)); continue
}
// Closed menus past the cap hide no content: opening a menu lists its items as priority entries.
if isMenu && !entry.priority {
guard menuCount < 80 else { truncated = true; continue }
guard menuCount < 80 else { continue }
menuCount += 1
}
let id = "e\(nodes.count)"; elements[id] = element; index.insert(element, id: id)
Expand Down
8 changes: 7 additions & 1 deletion apps/desktop/native/computer-use/tests/Fixture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ final class FixtureDelegate: NSObject, NSApplicationDelegate {
let editItem = NSMenuItem(title: "Edit", action: nil, keyEquivalent: "")
let editMenu = NSMenu(title: "Edit")
editMenu.addItem(withTitle: "Select All", action: #selector(NSText.selectAll(_:)), keyEquivalent: "a")
editItem.submenu = editMenu; menu.addItem(editItem); NSApplication.shared.mainMenu = menu
editItem.submenu = editMenu; menu.addItem(editItem)
// More closed menu items than a snapshot lists, as most real apps have.
let manyItem = NSMenuItem(title: "Many", action: nil, keyEquivalent: "")
let manyMenu = NSMenu(title: "Many")
for index in 1...120 { manyMenu.addItem(withTitle: "Fixture command \(index)", action: nil, keyEquivalent: "") }
manyItem.submenu = manyMenu; menu.addItem(manyItem)
NSApplication.shared.mainMenu = menu
window = NSWindow(contentRect: NSRect(x: 100, y: 100, width: 600, height: 720), styleMask: [.titled, .closable, .resizable], backing: .buffered, defer: false)
window.title = "Mothership Computer Use Test Fixture"
let stack = NSStackView(); stack.orientation = .vertical; stack.spacing = 16
Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/native/computer-use/tests/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def coordinate(snapshot, node, fx=0.5, fy=0.5):
time.sleep(1)
snapshot = state(screenshot=True)
assert 'fixture-only-secret' not in json.dumps(snapshot), 'Secure value leaked'
assert snapshot['truncated'] is False, 'Closed menu items past the snapshot cap marked the state truncated'
infinite = find(snapshot, label='Fixture infinite frame')
assert not {'x', 'y', 'width', 'height'} & infinite.keys(), f'An infinite frame reached the reply: {infinite}'
image = snapshot.get('screenshot')
Expand Down Expand Up @@ -211,7 +212,7 @@ def batch(snapshot, steps):
assert error['dispatchState'] == 'not_started', error
assert find(state(), role='AXTextField', label='Fixture click-focus field').get('value') == 'replaced', 'A background app was clicked or typed into'
call('activate_app', bundleId=bundle)
print('PASS: real fixture state, secure suppression, an element reported at infinity read without a frame, AX click/set/action, Unicode typing, keyboard chord, coordinate drag and scrolling, text refused by a slider, typing into a date picker, a window target typing into its focused editor, a title-bar click, a batch that applies, stops at a failing step, refuses before dispatch and stops when a sheet opens, click-to-focus for an editor that ignores Accessibility focus (inserting at the end, refusing an unconfirmed caret, and none in the background); every mutation verified in fresh state; screenshot=' + ('verified' if permissions['screenRecording'] else 'BLOCKED'))
print('PASS: real fixture state, a large closed menu not reported as truncation, secure suppression, an element reported at infinity read without a frame, AX click/set/action, Unicode typing, keyboard chord, coordinate drag and scrolling, text refused by a slider, typing into a date picker, a window target typing into its focused editor, a title-bar click, a batch that applies, stops at a failing step, refuses before dispatch and stops when a sheet opens, click-to-focus for an editor that ignores Accessibility focus (inserting at the end, refusing an unconfirmed caret, and none in the background); every mutation verified in fresh state; screenshot=' + ('verified' if permissions['screenRecording'] else 'BLOCKED'))
finally:
if fixture:
fixture.terminate()
Expand Down
Loading