> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# UITree

This page documents the `UITree` CDP domain supported by Lynx DevTool.



:::warning Experimental reference
This generated reference is still being completed.

- CDP events are not included yet.
- Some Lynx extensions are listed but do not yet have detailed documentation.
- Method descriptions are not automatically verified against the implementation and may be incomplete or inaccurate.

Verify behavior against the implementation and the linked upstream CDP reference before relying on it.
:::

## Overview

- Scope: `instance`
- CDP domain: Lynx-specific

## Lynx Extensions

### `UITree.disable`

Disables Lynx UI tree inspection methods on the current target.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_ui_tree_agent.cc`

###### Parameters

No parameters.

###### Returns

No return fields.

###### Notes

- Dispatches through LynxDevToolMediator to InspectorUIExecutor on the UI thread.
- Clears the UI tree enabled flag used by UITree.getLynxUITree, UITree.getUIInfoForNode, and UITree.setUIStyle.
- Returns an empty result object.
- The native implementation does not read request params.
- If the mediator has no UI task runner, the current handler does not send an explicit CDP response.

###### Examples

**Disable UI tree inspection**

Request:

```json
{
  "id": 1,
  "method": "UITree.disable"
}
```

Response:

```json
{
  "id": 1,
  "result": {}
}
```

### `UITree.enable`

Enables Lynx UI tree inspection methods on the current target.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_ui_tree_agent.cc`

###### Parameters

| Name                   | Type      | Required | Description                                                                                              |
| ---------------------- | --------- | -------- | -------------------------------------------------------------------------------------------------------- |
| `useCompression`       | `boolean` | No       | Whether UITree.getLynxUITree should compress a large root payload before returning it.                   |
| `compressionThreshold` | `boolean` | No       | Current native code reads this field as a boolean. true stores threshold 1 and false stores threshold 0. |

###### Returns

No return fields.

###### Notes

- Dispatches through LynxDevToolMediator to InspectorUIExecutor on the UI thread.
- Sets the UI tree enabled flag used by UITree.getLynxUITree, UITree.getUIInfoForNode, and UITree.setUIStyle.
- Returns an empty result object.
- The default compression threshold before this method changes it is 10240 bytes.
- If the mediator has no UI task runner, the current handler does not send an explicit CDP response.

###### Examples

**Enable UI tree inspection**

Request:

```json
{
  "id": 1,
  "method": "UITree.enable",
  "params": {
    "useCompression": true,
    "compressionThreshold": true
  }
}
```

Response:

```json
{
  "id": 1,
  "result": {}
}
```

### `UITree.getLynxUITree`

Returns the platform Lynx UI tree for the current page.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_ui_tree_agent.cc`

###### Parameters

No parameters.

###### Returns

| Name             | Type                   | Description                                                                                                                                                        |
| ---------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `root`           | `object\|string\|null` | Parsed platform UI tree root when uncompressed, a base64-encoded compressed string when result.compress is true, or null when the platform returns no tree string. |
| `compress`       | `boolean`              | Whether result.root was zlib-compressed and base64-encoded by the native handler.                                                                                  |
| `root.name`      | `string`               | Platform UI class or tag name.                                                                                                                                     |
| `root.id`        | `integer`              | Platform UI node id.                                                                                                                                               |
| `root.tagName`   | `string`               | Lynx tag name. Present on Android and Darwin tree payloads.                                                                                                        |
| `root.nodeIndex` | `integer`              | Lynx node index. Present on Android and Darwin tree payloads.                                                                                                      |
| `root.props`     | `object`               | Platform serialized Lynx props. Present on Android and Darwin tree payloads.                                                                                       |
| `root.label`     | `string`               | Accessibility label when the platform includes it.                                                                                                                 |
| `root.frame`     | `array`                | Four numeric values for the UI frame. The order is left, top, width, and height.                                                                                   |
| `root.children`  | `array`                | Child UI nodes serialized with the same platform-owned shape.                                                                                                      |

###### Notes

- Requires UITree.enable first. If UI tree inspection is not enabled, the current handler returns without sending a CDP response.
- Dispatches through LynxDevToolMediator to InspectorUIExecutor on the UI thread.
- The platform facade returns a JSON string, and the executor parses that string into result.root.
- Android and Darwin include name, id, tagName, nodeIndex, props, label, frame, and children. Harmony includes name, id, frame, and children.
- If compression is enabled and the serialized root exceeds the stored threshold, result.compress is true and result.root is a compressed base64 string.
- The native implementation does not read request params.
- If the mediator has no UI task runner or the platform facade is unavailable, the current handler does not send an explicit CDP response.

###### Examples

**Read the Lynx UI tree**

Request:

```json
{
  "id": 1,
  "method": "UITree.getLynxUITree"
}
```

Response:

```json
{
  "id": 1,
  "result": {
    "compress": false,
    "root": {
      "name": "com.lynx.tasm.behavior.ui.view.UIView",
      "id": 1,
      "tagName": "view",
      "nodeIndex": 0,
      "props": {},
      "label": "",
      "frame": [0, 0, 390, 844],
      "children": []
    }
  }
}
```

### `UITree.getUIInfoForNode`

Returns detailed platform UI information for one Lynx UI node.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_ui_tree_agent.cc`

###### Parameters

| Name       | Type      | Required | Description                     |
| ---------- | --------- | -------- | ------------------------------- |
| `UINodeId` | `integer` | Yes      | Platform UI node id to inspect. |

###### Returns

| Name                    | Type               | Description                                                                                                              |
| ----------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------ |
| `id`                    | `integer`          | Platform UI node id returned by the platform helper.                                                                     |
| `isFlatten`             | `boolean`          | Android-only flag indicating whether the UI node is flattened.                                                           |
| `editableProps`         | `object`           | Editable UI properties exposed by the platform helper.                                                                   |
| `editableProps.border`  | `array`            | Four border-width values in the order top, right, bottom, and left.                                                      |
| `editableProps.margin`  | `array`            | Four margin values in the order top, right, bottom, and left.                                                            |
| `editableProps.frame`   | `array`            | Four frame values in the order left, top, width, and height.                                                             |
| `editableProps.visible` | `boolean\|integer` | Platform visibility value.                                                                                               |
| `readonlyProps`         | `object`           | Android root-level readonly properties such as location, clickability, scrollability, text, test id, and event metadata. |
| `ui`                    | `object`           | Platform UI object metadata.                                                                                             |
| `ui.name`               | `string`           | Platform UI class or tag name.                                                                                           |
| `ui.readonlyProps`      | `object`           | Reflection-derived platform UI fields.                                                                                   |
| `view`                  | `object`           | Platform view metadata when the platform exposes a backing view object.                                                  |
| `view.name`             | `string`           | Platform view class name.                                                                                                |
| `view.readonlyProps`    | `object`           | Reflection-derived platform view fields.                                                                                 |
| `layers`                | `object`           | Darwin-only layer metadata for the view and Lynx background or border layers.                                            |

###### Notes

- Requires UITree.enable first. If UI tree inspection is not enabled, the current handler returns without sending a CDP response.
- Dispatches through LynxDevToolMediator to InspectorUIExecutor on the UI thread.
- The platform facade returns a JSON string, and the executor parses that string directly into result.
- If the platform returns an empty string or the node id cannot be resolved, the current handler returns an empty result object.
- Android, Darwin, and Harmony expose different platform-owned details. Consumers should tolerate missing optional fields.
- If the mediator has no UI task runner or the platform facade is unavailable, the current handler does not send an explicit CDP response.

###### Examples

**Read UI information for one node**

Request:

```json
{
  "id": 1,
  "method": "UITree.getUIInfoForNode",
  "params": {
    "UINodeId": 42
  }
}
```

Response:

```json
{
  "id": 1,
  "result": {
    "id": 42,
    "editableProps": {
      "border": [0, 0, 0, 0],
      "margin": [0, 0, 0, 0],
      "frame": [0, 0, 100, 50],
      "visible": true
    },
    "ui": {
      "name": "com.lynx.tasm.behavior.ui.view.UIView",
      "readonlyProps": {}
    },
    "view": {
      "name": "android.view.View",
      "readonlyProps": {}
    }
  }
}
```

### `UITree.setUIStyle`

Applies an editable style value to a Lynx UI node through the platform helper.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_ui_tree_agent.cc`

###### Parameters

| Name           | Type                                                                                | Required | Description                                                                                                                                                                                                                               |
| -------------- | ----------------------------------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `UINodeId`     | `integer`                                                                           | Yes      | Platform UI node id to mutate.                                                                                                                                                                                                            |
| `styleName`    | `string (frame \| margin \| border \| visible \| background-color \| border-color)` | Yes      | Editable style name.                                                                                                                                                                                                                      |
| `styleContent` | `string`                                                                            | Yes      | Style value string. frame, margin, and border use four comma or whitespace separated numbers. color styles use eight-digit RGBA hex values. visible uses true or false on Android and Darwin, while Harmony treats false and 0 as hidden. |

###### Returns

| Name            | Type      | Description                                                |
| --------------- | --------- | ---------------------------------------------------------- |
| `error`         | `object`  | Present inside result when the platform helper returns -1. |
| `error.code`    | `integer` | Always -32000 when present.                                |
| `error.message` | `string`  | Always set ui style fail when present.                     |

###### Notes

- Requires UITree.enable first. If UI tree inspection is not enabled, the current handler returns without sending a CDP response.
- Dispatches through LynxDevToolMediator to InspectorUIExecutor on the UI thread.
- The handler forwards params.UINodeId, params.styleName, and params.styleContent to DevToolPlatformFacade::SetUIStyle.
- The response is an empty result object when the platform return value is not -1.
- When the platform return value is -1, the response still uses result.error rather than a top-level CDP error.
- Android, Darwin, and Harmony support frame, margin, border, visible, background-color, and border-color, but unsupported or invalid inputs do not produce identical platform return values.
- If the mediator has no UI task runner or the platform facade is unavailable, the current handler does not send an explicit CDP response.

###### Examples

**Update a UI frame**

Request:

```json
{
  "id": 1,
  "method": "UITree.setUIStyle",
  "params": {
    "UINodeId": 42,
    "styleName": "frame",
    "styleContent": "0,0,100,50"
  }
}
```

Response:

```json
{
  "id": 1,
  "result": {}
}
```

**Failed style update**

Request:

```json
{
  "id": 2,
  "method": "UITree.setUIStyle",
  "params": {
    "UINodeId": 42,
    "styleName": "frame",
    "styleContent": "invalid"
  }
}
```

Response:

```json
{
  "id": 2,
  "result": {
    "error": {
      "code": -32000,
      "message": "set ui style fail"
    }
  }
}
```

