( runtime: AgentDeviceRuntime, options: WaitCommandOptions, text: string, timeoutMs: number | null | undefined, )
| 478 | } |
| 479 | |
| 480 | async function waitForText( |
| 481 | runtime: AgentDeviceRuntime, |
| 482 | options: WaitCommandOptions, |
| 483 | text: string, |
| 484 | timeoutMs: number | null | undefined, |
| 485 | ): Promise<WaitCommandResult> { |
| 486 | const timeout = timeoutMs ?? DEFAULT_TIMEOUT_MS; |
| 487 | const start = now(runtime); |
| 488 | while (now(runtime) - start < timeout) { |
| 489 | const found = runtime.backend.findText |
| 490 | ? (await runtime.backend.findText(toBackendContext(runtime, options), text)).found |
| 491 | : await snapshotContainsText(runtime, options, text); |
| 492 | if (found) return { kind: 'text', text, waitedMs: now(runtime) - start }; |
| 493 | await sleep(runtime, POLL_INTERVAL_MS); |
| 494 | } |
| 495 | throw new AppError('COMMAND_FAILED', `wait timed out for text: ${text}`); |
| 496 | } |
| 497 | |
| 498 | async function snapshotContainsText( |
| 499 | runtime: AgentDeviceRuntime, |
no test coverage detected
searching dependent graphs…