Skip to content

Allow ListView as a nested widget component - #137

Open
saloni-garg wants to merge 1 commit into
openai:mainfrom
saloni-garg:fix/listview-nested-component
Open

saloni-garg wants to merge 1 commit into
openai:mainfrom
saloni-garg:fix/listview-nested-component

Conversation

@saloni-garg

Copy link
Copy Markdown

Fixes #47.

ListView is missing from the StrictWidgetComponent union in chatkit/widgets.py. It is only in StrictWidgetRoot, so a ListView works at the top level but not nested, even though ListViewItem is a strict component and containers like Card take list[WidgetComponent] children. The Widget Builder emits Card > ListView structures (example in the issue), and parsing one silently downgrades the list to a DynamicWidgetComponent: its typed fields (children: list[ListViewItem], limit, status, theme) are not validated and isinstance(child, ListView) is False for anything walking the tree.

This adds ListView to StrictWidgetComponent, next to ListViewItem, plus a regression test that parses the nested structure from the issue and checks the child comes back as a ListView with ListViewItem children.

Reproduced on current main:

  • TypeAdapter(StrictWidgetComponent) rejects a valid ListView payload
  • TypeAdapter(WidgetRoot) on a Card containing a valid ListView returns the child as DynamicWidgetComponent, not ListView

Tests: pytest tests/ is 130 passed on unpatched main (the new test fails), and 131 passed with this change.

@saloni-garg
saloni-garg marked this pull request as ready for review October 26, 2026 05:12

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ListView should be allowed among the children of Card (pydantic)

1 participant