|
1 | 1 | import { dispatchCommand, resolveTargetDevice } from '../../core/dispatch.ts'; |
2 | | -import { findBestMatchesByLocator, findNodeByLocator, type FindLocator } from '../../utils/finders.ts'; |
| 2 | +import { findBestMatchesByLocator, type FindLocator } from '../../utils/finders.ts'; |
3 | 3 | import { attachRefs, centerOfRect, type RawSnapshotNode, type SnapshotState } from '../../utils/snapshot.ts'; |
4 | 4 | import { AppError } from '../../utils/errors.ts'; |
5 | 5 | import type { DaemonRequest, DaemonResponse } from '../types.ts'; |
@@ -97,7 +97,7 @@ export async function handleFindCommands(params: { |
97 | 97 | const start = Date.now(); |
98 | 98 | while (Date.now() - start < timeout) { |
99 | 99 | const { nodes } = await fetchNodes(); |
100 | | - const match = findNodeByLocator(nodes, locator, query, { requireRect: false }); |
| 100 | + const match = findBestMatchesByLocator(nodes, locator, query, { requireRect: false }).matches[0]; |
101 | 101 | if (match) { |
102 | 102 | if (session) { |
103 | 103 | sessionStore.recordAction(session, { |
@@ -134,7 +134,7 @@ export async function handleFindCommands(params: { |
134 | 134 | }, |
135 | 135 | }; |
136 | 136 | } |
137 | | - const node = findNodeByLocator(nodes, locator, query, { requireRect: requiresRect }); |
| 137 | + const node = bestMatches.matches[0] ?? null; |
138 | 138 | if (!node) { |
139 | 139 | return { ok: false, error: { code: 'COMMAND_FAILED', message: 'find did not match any element' } }; |
140 | 140 | } |
|
0 commit comments