Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add refresh button to remote (lazy) widgets #2494

Merged
merged 15 commits into from
Feb 11, 2025
Merged

Conversation

christian-byrne
Copy link
Collaborator

@christian-byrne christian-byrne commented Feb 10, 2025

Updates remote widgets to support refresh button option. Additionally, adds max_retries, timeout, and control_after_refresh options. There are also changes to improve memory management.

The hook has also been refactored so that it can work with any widget type instead of just COMBO. The hook is designed to proxy any property of the widget.

refresh-button-lazy-widget.mp4

Node from video:

class LoadImageOutputRefresh(LoadImage):
    @classmethod
    def INPUT_TYPES(s):
        return {"required":
                    {"image": ("COMBO", {
                        "image_upload": True,
                        "image_folder": "output",
                        "remote" : {
                            "route": "/internal/files/output",
                            "refresh_button": True,
                            "control_after_refresh": "first",
                        }
                    })},
                }

    @classmethod
    def VALIDATE_INPUTS(s, image):
        return True

    CATEGORY = "image"

    RETURN_TYPES = ("IMAGE", "MASK")
    FUNCTION = "load_image_output"

    def load_image_output(self, image):
        return self.load_image(f"{image} [output]")

┆Issue is synchronized with this Notion page by Unito

@christian-byrne
Copy link
Collaborator Author

1) [chromium] › remoteWidgets.spec.ts:212:5 › Remote COMBO Widget › Refresh Behavior › retries failed requests with backoff 

    Error: expect(received).toBeGreaterThan(expected)

    Matcher error: received value must be a number or bigint

    Received has value: undefined

      [22](https://github.com/Comfy-Org/ComfyUI_frontend/actions/runs/13238967000/job/36949864898?pr=2494#step:4:23)8 |       // Verify exponential backoff between retries
      229 |       const intervals = timestamps.slice(1).map((t, i) => t - timestamps[i])
    > [23](https://github.com/Comfy-Org/ComfyUI_frontend/actions/runs/13238967000/job/36949864898?pr=2494#step:4:24)0 |       expect(intervals[1]).toBeGreaterThan(intervals[0])
          |                            ^
      231 |     })
      232 |   })
      233 |

This test now fails because timeout and max_retries are handled manually. The test will be adjusted to force re-fetch in accordance with timeout of test nodes.

@christian-byrne christian-byrne marked this pull request as ready for review February 11, 2025 04:36
@christian-byrne christian-byrne requested review from a team as code owners February 11, 2025 04:36
@ltdrdata
Copy link
Member

How about adding a refresh icon to the combo widget instead of using a refresh button?

@christian-byrne
Copy link
Collaborator Author

How about adding a refresh icon to the combo widget instead of using a refresh button?

That's a great idea. I think this was what was envisioned in the RFC originally. There's a draft PR that implements this as well:

I can add support on litegraph side and simply change this function:

/**
* Add a refresh button to the node that, when clicked, will force the widget to refresh
*/
function addRefreshButton() {
node.addWidget('button', 'refresh', 'refresh', refreshValue)
}

Right now, the litegraph code is being refactored and is somewhat volatile.

@huchenlei huchenlei merged commit cd8c0d2 into main Feb 11, 2025
10 checks passed
@huchenlei huchenlei deleted the lazy-widgets-refresh-button branch February 11, 2025 15:31
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.

3 participants