Skip to content

Auto-Reloading doesn't run gr.render(input=state_object) #10199

Closed
@cliffxuan

Description

@cliffxuan

Describe the bug

Auto-Reloading doesn't run the @gr.render(...) decorated function if the input is a gr.State object.

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

  1. Run this official doc's example on dynamic event listeners
    https://www.gradio.app/guides/dynamic-apps-with-render-decorator#dynamic-event-listeners
import gradio as gr

with gr.Blocks() as demo:
    text_count = gr.State(1)
    add_btn = gr.Button("Add Box")
    add_btn.click(lambda x: x + 1, text_count, text_count)

    @gr.render(inputs=text_count)
    def render_count(count):
        boxes = []
        for i in range(count):
            box = gr.Textbox(key=i, label=f"Box {i}")
            boxes.append(box)

        def merge(*args):
            return " ".join(args)

        merge_btn.click(merge, boxes, output)

    merge_btn = gr.Button("Merge")
    output = gr.Textbox(label="Merged Output")

demo.launch()

it should render correctly like this:
image

  1. Now change the code slightly, e.g. change the button text to Add a Box and wait for auto-reloading to re-render
    image

Screenshot

No response

Logs

No response

System Info

gradio environment  
Gradio Environment Information:
------------------------------
Operating System: Linux
gradio version: 5.3.0
gradio_client version: 1.4.2

Severity

I can work around it by refreshing the page, however, if it works as expected, it will be more ergonomic and make the development experience more enjoyable and less disruptive.

Metadata

Metadata

Assignees

Labels

PriorityHigh priority issuesbugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions