fix(app): ApiHostProvider in protocols page run #16208
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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