# ui_wait

Wait until an element, text or window appears or is gone, or the screen is stable, for at most 30 s. A timeout is an answer (`met: false`), not an error.

**In short:** Risk class [`screen`](https://docs.cmdop.ai/reference/tools.md#risk-classes). Over MCP call `ui_wait`; over HTTP send `"tool": "ui_wait"` to [`POST /api/v1/call`](https://docs.cmdop.ai/reference/http/post-call.md).

## Arguments

Over MCP every tool also takes `machine`: the machine's name or id, optional when only one machine is online.

| Name | Type | Required | Meaning |
| --- | --- | --- | --- |
| `timeout_ms` | `integer` | no | Give up after this long (default 5000, at most 30000). |
| `until` | `"element_gone" | "text_gone" | "element_appears" | "text_appears" | "window_appears" | "screen_stable"` | yes |  |
| `value` | `string` | no | What to look for, for the first five conditions. |

## Result

| Name | Type | Required | Meaning |
| --- | --- | --- | --- |
| `met` | `boolean` | yes | The condition held before the timeout. |
| `waited_ms` | `integer` | yes |  |

## Examples

**MCP**

```json
{
  "name": "ui_wait",
  "arguments": {
    "machine": "<machine>",
    "until": "<until>"
  }
}
```

**HTTP**

```bash
curl -sS -X POST "https://<contour>.cmdop.ai/api/v1/call" \
  -H "Authorization: Bearer $CMDOP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"machine":"<machine>","tool":"ui_wait","args":{"until":"<until>"}}'
```

## Limits

The call times out after 35 s (`timed_out`). Available since version 0.0.2. A refused or failed call returns one of the [error codes](https://docs.cmdop.ai/reference/errors.md).
