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(protocol-designer): retain timeline data when overwriting protocol via import #17476

Merged

Conversation

shlokamin
Copy link
Member

@shlokamin shlokamin commented Feb 9, 2025

Overview

This PR moves redux-thunk to get applied to actions AFTER timeline middleware so that if timeline middleware ever depends on a thunk action our logic will still work as expected. This PR also explicitly regenerates the timeline and substeps whenever a protocol is imported into PD.

This fixes a bug where importing a protocol (when you already have a protocol loaded into application state) does not trigger timeline computation, which means that sub steps, liquid tracking, and commands never get loaded into application state.

closes AUTH-1429

Test Plan and Hands on Testing

Import a protocol into PD (like the one attached to this PR), import it again, and make sure that exported protocol you get back out has liquid handling commands. Also make sure the starting deck state and ending deck state are different.

Reagent-transfer-10.json

Changelog

  • Reorder redux middleware
  • Always regenerate timeline and substeps when a protocol is imported into PD

Review requests

See test plan

Risk assessment

Medium/high

@shlokamin shlokamin requested a review from a team as a code owner February 9, 2025 19:35
@shlokamin
Copy link
Member Author

closing this for now because this doesn't actually fix the bug i described. i think this may have always been in PD because if you import the same protocol over and over, the logic in timeline middleware that determines whether or not we need to recompute the timeline will not get triggered since there is no difference in application state (since the protocols are identical).

i still think the reordering i have is more correct but i don't think this change is necessary

@shlokamin shlokamin closed this Feb 10, 2025
@shlokamin shlokamin reopened this Feb 10, 2025
@shlokamin
Copy link
Member Author

okay, i reopened because i think this is what we actually want now:

  1. reorder middleware so that thunk goes after timeline middleware. this is so that if timeline middleware ever depends on a thunk action the timeline will still get recomputed
  2. (this actually fixes the bug) explicitly regenerate the timeline and substeps whenever a protocol is imported into PD

@@ -63,10 +66,13 @@ export const makeTimelineMiddleware: () => Middleware<BaseState, any> = () => {
const needsRecompute = hasChanged(nextSelectorResults, prevTimelineArgs)
// update memoized values
prevTimelineArgs = nextSelectorResults
return needsRecompute
return needsRecompute || actionType === 'LOAD_FILE'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need to explicitly recompute when you load a file now? previously, did hasChanged() return true when you upload a file?

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh wait, seeing your comments, i guess this was always broken??

Copy link
Member Author

Choose a reason for hiding this comment

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

it returns true when you upload a new file. this is because the protocol actually contains different information. if you upload the same exact protocol the timeline does not get recomputed. the problem though is that the load file action wipes out timeline data, so you're left with a step forms but no timeline

Copy link
Collaborator

Choose a reason for hiding this comment

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

its crazy to me that we never noticed this before. i guess its not common for someone to reimport the same protocol that is currently loaded

Copy link
Member Author

Choose a reason for hiding this comment

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

i know right lol

Copy link
Collaborator

@jerader jerader left a comment

Choose a reason for hiding this comment

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

thanks shlok!

@shlokamin shlokamin merged commit b032c4a into chore_release-pd-8.4.0 Feb 10, 2025
14 of 19 checks passed
@shlokamin shlokamin deleted the protocol-designer_reorder-middleware branch February 10, 2025 16:55
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