Skip to content

[codex] Support Basic roots in build and fix single-child diff traversal#115

Closed
weedon-openai wants to merge 2 commits intomainfrom
codex/basic-root-plus-widget-diff-fix
Closed

[codex] Support Basic roots in build and fix single-child diff traversal#115
weedon-openai wants to merge 2 commits intomainfrom
codex/basic-root-plus-widget-diff-fix

Conversation

@weedon-openai
Copy link
Contributor

Summary

This PR combines two related updates:

  1. Allow WidgetTemplate.build(...) to support Basic roots directly.
  2. Fix widget diff traversal when a component's children is represented as a single object.

User impact

  • Templates rooted at Basic can now be built through the standard build(...) API and used in WidgetItem without requiring a separate build path.
  • Streaming widget updates are more robust for valid runtime shapes where children is a single component object, avoiding missed text delta events.

Root causes

  • Root typing still restricted dynamic/strict root unions to Card and ListView, which prevented build(...) from validating Basic roots.
  • diff_widget traversal only iterated children as lists; it did not recurse when children was a singular component.

Fixes

  • In chatkit/widgets.py:
    • Add BasicRoot to StrictWidgetRoot.
    • Extend DynamicWidgetRoot.type to include "Basic".
    • Deprecate WidgetTemplate.build_basic(...) and direct callers to build(...).
  • In chatkit/server.py:
    • Update recursive child traversal in diff_widget to handle both single-child objects and child lists.
  • In tests/test_widgets.py:
    • Add coverage that WidgetTemplate.build(...) returns a DynamicWidgetRoot with type == "Basic" for basic-root templates and works in WidgetItem.
    • Add coverage that build_basic(...) emits DeprecationWarning while preserving behavior.
    • Add a regression case ensuring streaming text deltas are emitted when children is a single dynamic component object.

Validation

  • make test
  • Result: 122 passed

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.

1 participant