Skip to content

cleanup workspace machine #4160

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

Merged
merged 7 commits into from
Sep 23, 2022

Conversation

Kira-Pilot
Copy link
Member

We shouldn't send events from actions! This refactor fixes our workspace machine.

@Kira-Pilot Kira-Pilot requested a review from a team as a code owner September 22, 2022 20:15
@Kira-Pilot Kira-Pilot requested review from presleyp and removed request for a team September 22, 2022 20:15
@presleyp
Copy link
Contributor

Screen Shot 2022-09-22 at 4 40 42 PM

I don't see a reason to nest `idle` inside `loadedBuilds`. It's just one state. Also, I'm concerned that we have a state called `idle` that has no outgoing arrows. I'm not sure what the best resolution is (do we want to be able to retry? was it intended to lead to the other `idle`?).

@presleyp
Copy link
Contributor

Screen Shot 2022-09-22 at 4 55 20 PM

There are two `refreshingTemplate` states, one at the top level, and one inside the `build` submachine. The inner one has no incoming arrows, so I don't think it will ever happen. Not sure if it should happen or just needs to be cleaned up.

@presleyp
Copy link
Contributor

Okay I'm a jerk for not telling you this before but, despite the "don't send in an action" rule, there is a send action, which gets around the rule because it's one of those special pure actions that the interpreter knows what to do with. I'm noticing that we're sending REFRESH_TIMELINE every time we go into build.idle. Putting sends inside of services makes it less obvious that they're happening (like, they don't show up on the diagram) and doesn't capture that pattern.

So I'm wondering if we can add an entry action to build.idle to send (this is imported from xstate, like assign) REFRESH_TIMELINE. I'm also wondering if we really do want to refresh the timeline whether the service succeeds or fails. If we don't want to do it in case of failure, I'm not sure we can make actions conditional the way we can make transitions conditional with guards. So in that case I might just add the send action to the end of the action lists for each onDone. At least that way we can see in the diagram that they exist.

@Kira-Pilot
Copy link
Member Author

I don't see a reason to nest idle inside loadedBuilds. It's just one state. Also, I'm concerned that we have a state called idle that has no outgoing arrows. I'm not sure what the best resolution is (do we want to be able to retry? was it intended to lead to the other idle?).

Sure, I can take idle out of loadedBuilds.

Regarding the second idle (the one we transition to after error): I think perhaps it would be best to get rid of that and, in the case of an error, transition right back to loadedBuilds. This will give the user to ability to retry loading timeline. In the future, if we want to build a more concrete UI around the error case, we can.

The machine will be simplified like:
Screen Shot 2022-09-23 at 10 29 00 AM

@Kira-Pilot
Copy link
Member Author

Kira-Pilot commented Sep 23, 2022

If we don't want to do it in case of failure, I'm not sure we can make actions conditional the way we can make transitions conditional with guards. So in that case I might just add the send action to the end of the action lists for each onDone. At least that way we can see in the diagram that they exist.

I'm a fan of this approach but I'm having a hard time using that send action pattern within an onDone:

Types of property ‘onDone’ are incompatible.
  Type ‘{ actions: string; target: SendAction<unknown, EventObject, EventObject>; }[]’ is not assignable to type ‘string | SingleOrArray<TransitionConfig<WorkspaceContext, DoneInvokeEvent<any>>> | undefined’.

Screen Shot 2022-09-23 at 11 04 33 AM

@Kira-Pilot
Copy link
Member Author

There are two refreshingTemplate states, one at the top level, and one inside the build submachine. The inner one has no incoming arrows, so I don't think it will ever happen. Not sure if it should happen or just needs to be cleaned up.

I can clean this up. I got rid of the stale one, and renamed the other one to getTemplate since we aren't refreshing.

Copy link
Contributor

@presleyp presleyp left a comment

Choose a reason for hiding this comment

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

I'm out today so I'm unblocking this, you'll make great decisions!

@Kira-Pilot Kira-Pilot merged commit 8cd5aea into main Sep 23, 2022
@Kira-Pilot Kira-Pilot deleted the cleanup-workspace-machine-actions/kira-pilot branch September 23, 2022 17:06
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