#2929·a2ui

[BUG]: ComponentModel.componentTree lets a component's own type prop replace its type (web_core, Python core)

Author: retz8Created Oct 1, 2026Updated Oct 1, 2026
Labelstype: bugP2status: needs reviewstatus: first-line-handled
  • I have searched the existing issues to make sure this bug has not already been reported.

Describe the Bug

ComponentModel keeps a component's name (type) apart from its props. Its componentTree getter joins them back into one object, with the props spread last (typescript/web_core/src/state/component-model.ts):

typescript
get componentTree(): any {
  return {
    id: this.id,
    type: this.type,
    ...this._properties,
  };
}

A prop named type therefore overwrites the component's name. Two things go wrong at once: the name is gone, and the prop's value reads as the name.

type is an ordinary prop name, and nothing in the spec reserves it. On the wire the name travels as component, and the message processor strips only id and component before storing the rest as props, so a type prop reaches the model untouched. Upstream's own sample catalogs declare one:

  • rizzcharts' Chart: type, "doughnut" or "pie"
  • gemini_enterprise's MaterialInput: type, "text", "number", "email", "tel" or "date"

The Python core port repeats the getter in ComponentModel.component_tree (python/a2ui_core/src/a2ui/core/state/component_model.py):

python
tree = {"id": self.id, "type": self.type}
tree.update(self._properties)

The Dart core port's ComponentModel.toJson writes the name under component and is not affected.

In-repo, only the getters' own unit tests read the tree; the renderers read type and properties apart. A consumer that takes a component's name from componentTree, for instance to copy a surface and render it again, looks up "pie" in the catalog instead of "Chart" and draws an unknown component.

Steps to Reproduce

typescript
import {ComponentModel} from '@a2ui/web_core/state';

const chart = new ComponentModel('chart1', 'Chart', {type: 'pie', title: 'Sales'});
chart.type;          // 'Chart'
chart.componentTree; // {id: 'chart1', type: 'pie', title: 'Sales'}
python
from a2ui.core.state import ComponentModel

chart = ComponentModel("chart1", "Chart", properties={"type": "pie", "title": "Sales"})
chart.type            # 'Chart'
chart.component_tree  # {'id': 'chart1', 'type': 'pie', 'title': 'Sales'}

Expected Behavior

The tree keeps both the component's name and its type prop:

json
{"id": "chart1", "component": "Chart", "type": "pie", "title": "Sales"}

Screenshots / Video / Logs

n/a

Environment Details

  • OS: macOS
  • Browser/Platform: Node 22 (web_core), Python 3.14 (a2ui_core)
  • SDK/Package Name & Version: @a2ui/web_core 0.12.0 and python/a2ui_core, main @ 102ec1a0
  • Protocol Version: v0.9
  • Agent Framework & LLM Model: n/a

Additional Context

Suggested fix: return the wire shape, with the props spread first and the identity keys written after them:

typescript
get componentTree(): any {
  return {
    ...this._properties,
    id: this.id,
    component: this.type,
  };
}

The tree then has the same shape as the component in the updateComponents message that created it, so it can be sent back as-is; no prop can collide with component, because the processor strips that key on the way in; and it matches the Dart port's toJson. The Python component_tree takes the same change.

This renames the tree's type key to component, which breaks readers of tree.type. The getter returns any, so nothing fails to compile; tree.type becomes undefined for a component without a type prop. In-repo it changes only the tree assertions in each port's own tests (component-model.test.ts, tests/test_state.py).

If renaming the key is not wanted, writing id and type after the spread restores the name, but the type prop is then dropped from the tree.

Related: #2859 (open) adds a metadata key to this getter, also before the props spread, so a prop named metadata would replace it the same way.