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

Response Pagination with Browser Scripts #202

Open
hyphus opened this issue Mar 26, 2022 · 2 comments
Open

Response Pagination with Browser Scripts #202

hyphus opened this issue Mar 26, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@hyphus
Copy link

hyphus commented Mar 26, 2022

I'm not sure if this is a bug or a misunderstanding on my part about how the task output is intended to work.

My download task returns user_output with every chunk that includes the current chunk and total_chunks.
{ "current_chunk": "1", "total_chunks": 17}

However, if more than 10 responses are sent, only the first ten are available to the browser script.

image

It took me a bit but I found that the additional responses are recorded but the browser script only sees them if you go to the next page.

image

In the old UI all of the responses are available as there isn't any pagination.

image

Is there a way via a browser script in the new UI to always get the latest response regardless of which page of output the UI is set to?

I'm using a slightly modified version of the example download browser script where I added console.log for task/response at the top.

@its-a-feature
Copy link
Owner

Hey! Great question!

The pagination is a new feature to help speed up page response times. We noticed in the old UI, since everything is streamed whenever you click to expand the task, that if the task had a lot of output, it could get very slow and make the entire page sluggish.

I see your use case though. Let's see if there's a way we can solve this. Is it always the latest response you'd need? I could see about adding that as a separate field in the browser script function definition. That way it wouldn't break any of the current browserscripts, but would allow you to see the latest response. I can see a lot of cases like this where there's some sort of streamed status and the completion state being in the final section.

In the meantime, one way to fix this would be to flip the order of your messages. So, your first user_output message would give the file_id (or they all could) and you could determine if the task is done not by looking for that specific message, but by checking task["completed"] as true or even task["status"] as either "error" or "completed", both of which would mean that the task is done.

@hyphus
Copy link
Author

hyphus commented Mar 28, 2022

In this case having the latest response would work great since I'm using it to give updates in the UI and really only care about the current one. Alternatively, if there was a way to access the additional pages that'd work too.

I've currently got my browser script checking for task status so that would work. For now I'll probably just remove the status updates and use static messages.

Thanks for taking a look!

@its-a-feature its-a-feature added the enhancement New feature or request label Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants