Skip to content

[codex] fix component load event target#13360

Open
thomwolf wants to merge 7 commits into
gradio-app:mainfrom
thomwolf:codex/fix-component-load-target
Open

[codex] fix component load event target#13360
thomwolf wants to merge 7 commits into
gradio-app:mainfrom
thomwolf:codex/fix-component-load-target

Conversation

@thomwolf
Copy link
Copy Markdown

@thomwolf thomwolf commented May 3, 2026

Summary

  • keep component-attached load events targeted at the root load event instead of serializing a null target
  • add regression coverage for component load-event targets

Root cause

BlocksConfig.attach_load_events() was passing no_target=not has_target for component-attached startup load events, producing targets=[(None, "load")]. The null-target load dependency can freeze the frontend renderer in Gradio 6.x for apps with a nonempty Dataframe and empty Row/Column layout; demo.load uses (0, "load") and does not freeze.

Fixes #13359

Validation

  • sfw uv run --with pytest --with pytest-asyncio python -m pytest test/test_blocks.py::TestComponentsInBlocks::test_component_load_events_target_root test/test_blocks.py::TestComponentsInBlocks::test_slider_random_value_config test/test_blocks.py::TestComponentsInBlocks::test_io_components_attach_load_events_when_value_is_fn test/test_blocks.py::TestComponentsInBlocks::test_get_load_events -q
  • git diff --check
  • LOGIN_KIND=login /tmp/check_min_login_dataframe.sh 7998 1 false false false false true 0 false false true
  • /tmp/check_gaia_variant.sh 7996

Note

Medium Risk
Touches BlocksConfig.attach_load_events() dependency target serialization, which can affect how startup load events fire and render in the frontend. Change is small and covered by a regression test, but it impacts core event wiring.

Overview
Fixes component-attached startup load events to always serialize with an explicit root load target (avoiding targets=[(None, "load")]), preventing frontend hangs in certain layouts.

Adds a regression test asserting load dependencies target load correctly and tweaks the thread-close test timing/marks it flaky. Also includes a patch changeset entry for the fix.

Reviewed by Cursor Bugbot for commit bcf05f4. Bugbot is set up for automated code reviews on this repo. Configure here.

@gradio-pr-bot
Copy link
Copy Markdown
Collaborator

gradio-pr-bot commented May 7, 2026

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website building...
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://huggingface.co/buckets/gradio/pypi-previews/resolve/daba09a8ccec17bcbd0f4682e925dcba6a5f685d/gradio-6.14.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@daba09a8ccec17bcbd0f4682e925dcba6a5f685d#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/daba09a8ccec17bcbd0f4682e925dcba6a5f685d/gradio-client-2.2.0.tgz

@gradio-pr-bot
Copy link
Copy Markdown
Collaborator

gradio-pr-bot commented May 7, 2026

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
gradio patch

  • [codex] fix component load event target

✅ Changeset approved by @freddyaboulton

  • Maintainers can remove approval by unchecking this checkbox.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@freddyaboulton freddyaboulton added v: patch A change that requires a patch release t: fix A change that implements a fix labels May 7, 2026
@freddyaboulton freddyaboulton marked this pull request as ready for review May 14, 2026 14:58
@freddyaboulton freddyaboulton enabled auto-merge (squash) May 14, 2026 14:59
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default mode and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit daba09a. Configure here.

Comment thread test/test_blocks.py
]
assert len(load_dependencies) == 1
assert load_dependencies[0]["targets"][0][1] == "load"
assert load_dependencies[0]["outputs"] == [button._id]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regression test doesn't assert target ID is non-null

Medium Severity

The new regression test test_component_load_events_target_root is meant to verify that component load events target the root block (not None), but it never asserts that targets[0][0] is non-null or equals the root block's _id. The test only checks the event name (targets[0][1] == "load") and outputs. If the fix in blocks.py were reverted, this test would still pass because a (None, "load") target satisfies all three assertions. The key assertion — that the target component ID points to the root block — is missing.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit daba09a. Configure here.

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

Labels

t: fix A change that implements a fix v: patch A change that requires a patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Component-attached load events with null load target can freeze the frontend

3 participants