MCPcopy Create free account
hub / github.com/callstack/agent-device / waitForText

Function waitForText

src/commands/interaction/runtime/selector-read.ts:480–496  ·  view source on GitHub ↗
(
  runtime: AgentDeviceRuntime,
  options: WaitCommandOptions,
  text: string,
  timeoutMs: number | null | undefined,
)

Source from the content-addressed store, hash-verified

478}
479
480async 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
498async function snapshotContainsText(
499 runtime: AgentDeviceRuntime,

Callers 1

waitCommandFunction · 0.85

Calls 4

nowFunction · 0.90
toBackendContextFunction · 0.90
sleepFunction · 0.90
snapshotContainsTextFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…