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

fix(app): ApiHostProvider in protocols page run #16208

Merged

Conversation

sfoster1
Copy link
Member

@sfoster1 sfoster1 commented Sep 6, 2024

So, we indicate that a robot is connected via USB by setting its ip to 'opentrons-usb'. However, this doesn't do anything on its own, beyond making http requests to https://opentrons-usb:31950 fail in a funny way. It only works if you're making a request inside a mounted component, which will provide a react context provider for all the useHost hooks mounted underneath it to go look up the right request function to use.

This generally works on anything under the devices page. Where it most certainly didn't work was anything under the Protocols page, including the CHooseRobotToRunProtocolSlideout component, which is the menu you get when you start a protocol from the protocols page.

This only wasn't comprehensively broken because at various times various people had noticed the problem for various HTTP requests and added a specific host override to the mutations used there... but nobody had gotten around to doing that for the queries that get old runs and scrape LPC data for them, and therefore that would never happen.

Instead, let's put an ApiHostProvider with the appropriate parameters over the component, rip out the per-query/per-mutation host overries, and have them all work through the magic of nonlocal state.

Closes RQA-2723

So, we indicate that a robot is connected via USB by setting its ip to
'opentrons-usb'. However, this doesn't do anything on its own, beyond
making http requests to https://opentrons-usb:31950 fail in a funny way.
It only works if you're making a request inside a mounted
<ApiHostProvider> component, which will provide a react context provider
for all the useHost hooks mounted underneath it to go look up the right
request function to use.

This generally works on anything under the devices page. Where it most
certainly didn't work was anything under the Protocols page, including
the CHooseRobotToRunProtocolSlideout component, which is the menu you
get when you start a protocol from the protocols page.

This only wasn't _comprehensively_ broken because at various times
various people had noticed the problem for various HTTP requests and
added a specific host override to the mutations used there... but nobody
had gotten around to doing that for the queries that get old runs and
scrape LPC data for them, and therefore that would never happen.

Instead, let's put an ApiHostProvider with the appropriate parameters
over the component, rip out the per-query/per-mutation host overries,
and have them all work through the magic of nonlocal state.

Closes RQA-2723
@sfoster1 sfoster1 requested a review from a team as a code owner September 6, 2024 18:48
Copy link
Contributor

@mjhuff mjhuff left a comment

Choose a reason for hiding this comment

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

🧠

}
: null
)
const { uploadCsvFile } = useUploadCsvFileMutation({}, {})
Copy link
Contributor

Choose a reason for hiding this comment

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

Question/nit, can we just pass nothing here?

Suggested change
const { uploadCsvFile } = useUploadCsvFileMutation({}, {})
const { uploadCsvFile } = useUploadCsvFileMutation()

@sfoster1 sfoster1 merged commit aadc65e into edge Sep 6, 2024
20 checks passed
@sfoster1 sfoster1 deleted the rqa-2723-add-api-host-context-to-choose-robot-to-run-protocol branch September 6, 2024 20:46
y3rsh pushed a commit that referenced this pull request Sep 10, 2024
So, we indicate that a robot is connected via USB by setting its ip to
'opentrons-usb'. However, this doesn't do anything on its own, beyond
making http requests to https://opentrons-usb:31950 fail in a funny way.
It only works if you're making a request inside a mounted
<ApiHostProvider> component, which will provide a react context provider
for all the useHost hooks mounted underneath it to go look up the right
request function to use.

This generally works on anything under the devices page. Where it most
certainly didn't work was anything under the Protocols page, including
the CHooseRobotToRunProtocolSlideout component, which is the menu you
get when you start a protocol from the protocols page.

This only wasn't _comprehensively_ broken because at various times
various people had noticed the problem for various HTTP requests and
added a specific host override to the mutations used there... but nobody
had gotten around to doing that for the queries that get old runs and
scrape LPC data for them, and therefore that would never happen.

Instead, let's put an ApiHostProvider with the appropriate parameters
over the component, rip out the per-query/per-mutation host overries,
and have them all work through the magic of nonlocal state.

Closes RQA-2723
y3rsh added a commit that referenced this pull request Sep 10, 2024
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.

2 participants