mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 00:57:45 +00:00
* feat(computer): send tree diffs after actions and add get-app-state --query Action results now carry only the accessibility-tree lines that changed since the caller's last view of the same window (~ changed, + added, - removed as index ranges, or an explicit no-change line), plus the focused element. The runtime sidecar keeps the last tree per session/worktree and app, so all three providers get it. The CLI opts in with treeDiff; older runtimes strip the param and keep returning the full tree, and --full-tree opts out. The macOS helper now keeps an element's index across snapshots of a window: AX identity first, then the next unclaimed index with the same signature for views that rebuild their AX objects, and never reuses a removed index. get-app-state --query prints matching elements with their ancestors and --max-elements caps the output, both in the CLI over the rendered tree. Custom action names with raw newlines no longer split an element over lines. * fix(computer): preserve parent changes in snapshot diffs * fix(computer): refuse stale index reuse for lookalike controls * fix(computer): print full trees in action replies * fix(computer): keep controls located in snapshot replies
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { queryComputerTreeText } from './computer-tree-query'
|
|
|
|
const TREE = [
|
|
'App=com.apple.TextEdit (pid 96320)',
|
|
'Window: "Untitled", App: TextEdit.',
|
|
'',
|
|
'0 standard window Untitled',
|
|
'\t1 scroll area, Secondary Actions: scroll up, scroll down',
|
|
'\t\t2 text entry area (settable) base zed',
|
|
'\t21 container Formatting',
|
|
'\t\t22 checkbox bold, Value: 0',
|
|
'\t\t23 checkbox italic, Value: 0',
|
|
'',
|
|
'The focused UI element is 2 text entry area (settable) base zed.'
|
|
].join('\n')
|
|
|
|
describe('queryComputerTreeText', () => {
|
|
it('caps the printed elements with maxElements and says how many were left out', () => {
|
|
expect(queryComputerTreeText(TREE, { maxElements: 2 })).toBe(
|
|
[
|
|
'App=com.apple.TextEdit (pid 96320)',
|
|
'Window: "Untitled", App: TextEdit.',
|
|
'',
|
|
'Showing the first 2 of 6 elements.',
|
|
'0 standard window Untitled',
|
|
'\t1 scroll area, Secondary Actions: scroll up, scroll down',
|
|
'',
|
|
'The focused UI element is 2 text entry area (settable) base zed.'
|
|
].join('\n')
|
|
)
|
|
})
|
|
|
|
it('says when nothing matches instead of printing an empty tree', () => {
|
|
expect(queryComputerTreeText(TREE, { query: 'underline' })).toContain(
|
|
'\n\nNo elements match "underline".\n\nThe focused UI element is'
|
|
)
|
|
})
|
|
})
|