Skip to content

[codex] Fix widget diff traversal for single-child nodes#113

Closed
weedon-openai wants to merge 1 commit intomainfrom
codex/widget-diff-single-child-children
Closed

[codex] Fix widget diff traversal for single-child nodes#113
weedon-openai wants to merge 1 commit intomainfrom
codex/widget-diff-single-child-children

Conversation

@weedon-openai
Copy link
Contributor

Summary

This PR fixes widget diff traversal when a component's children field is represented as a single object instead of a list.

User-visible effect

In streaming updates, some valid widget shapes could silently skip text-delta emission. The UI would then miss incremental updates and treat the widget as unchanged (or defer to later full updates), even when streaming text content changed.

Root cause

diff_widget recursively discovers streaming Text/Markdown nodes by walking children. The previous implementation assumed children was iterable as a list and iterated directly over it. When children was a single WidgetComponentBase object, recursion did not traverse that child, so no streaming node was discovered and no delta was produced.

Fix

Update traversal in chatkit/server.py so recursion handles both valid shapes:

  • children as a single WidgetComponentBase
  • children as a list of components

Tests

Added a regression case in tests/test_widgets.py under test_diff that uses DynamicWidgetRoot with a single-child object and asserts a widget.streaming_text.value_delta event is emitted when text grows.

Validation run:

  • PYTHONPATH=. uv run pytest tests/test_widgets.py (passes)

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