Skip to content

Conversation

@zzstoatzz
Copy link
Collaborator

@zzstoatzz zzstoatzz commented Apr 2, 2025

follow up to #17713 and #17743 that adds a generalized component for changing flow or task run states

flow-run-state-dialogue.mov

@github-actions github-actions bot added the ui-replatform Related to the React UI rewrite label Apr 2, 2025
@zzstoatzz zzstoatzz force-pushed the flow-run-state-dialog branch 5 times, most recently from 6414a7c to d1f5509 Compare April 4, 2025 15:28
@zzstoatzz zzstoatzz changed the title initial flow-run-state-dialogue initial run state change dialog Apr 4, 2025
@zzstoatzz zzstoatzz force-pushed the flow-run-state-dialog branch from d1f5509 to 2fc1660 Compare April 4, 2025 19:34
@zzstoatzz zzstoatzz force-pushed the flow-run-state-dialog branch from 2fc1660 to 586d5c7 Compare April 7, 2025 15:58
@zzstoatzz zzstoatzz force-pushed the flow-run-state-dialog branch 2 times, most recently from 40fc18d to 18dea08 Compare April 7, 2025 17:02
@codspeed-hq
Copy link

codspeed-hq bot commented Apr 7, 2025

CodSpeed Performance Report

Merging #17704 will not alter performance

Comparing flow-run-state-dialog (dfc1083) with main (d13684d)

Summary

✅ 2 untouched benchmarks

@zzstoatzz zzstoatzz marked this pull request as ready for review April 7, 2025 17:09
export const useFlowRunStateDialog = () => {
const [open, setOpen] = useState(false);
const [flowRun, setFlowRun] = useState<FlowRun | null>(null);
const { mutateAsync: setFlowRunState } = useSetFlowRunState();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const { mutateAsync: setFlowRunState } = useSetFlowRunState();
const { setFlowRunState } = useSetFlowRunState();

suggestion: use the mutate version setFlowRunState

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done! 927ee96

@zzstoatzz zzstoatzz force-pushed the flow-run-state-dialog branch from 927ee96 to 38e6e55 Compare April 7, 2025 22:57
setOpen(true);
}, []);

return {
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO this return logic makes it complex because this hook will only work if flowRun.state is truthy, (which makes this hook do nothing.).

IMO it be more straightforward if you do something like:

{open && flowRun.state && flowRun.id && <FlowRunDialog id={flowRun.id} state ={flowRun.state} />}

and declare the mutations in the dialog

Copy link
Collaborator Author

@zzstoatzz zzstoatzz Apr 8, 2025

Choose a reason for hiding this comment

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

disclaimer, just thinking out loud so that if I'm harboring any misunderstanding, it can be corrected!

it seems like this would suggest not having a general run state dialog component, is that right?

I see how using mutate fits if the mutation logic is directly inside the dialog component itself. I had initially separated it out into the reusable RunStateChangeDialog and useFlowRunStateDialog hook after talking w @desertaxle where he suggested a generic RunStateChangeDialog to live in src/components/ui

Since the RunStateChangeDialog awaits the onSubmitChange callback to manage its loading state, I was thinking the hook needed to provide a promise, so i used mutateAsync.

totally possible I'm just too fresh here and I'm only perceiving contention between the suggestions!

Copy link
Member

Choose a reason for hiding this comment

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

I think your use of mutateAsync is valid since react-hook-form needs a promise to handle the isSubmitting state, and I think the form being agnostic to the mutation is important for reuse between flow runs and task runs.

I think we can simplify this return statement, but it'll be easier to talk about than to write it out, so let's sync up offline.

@zzstoatzz zzstoatzz force-pushed the flow-run-state-dialog branch from 38e6e55 to 9c07a77 Compare April 8, 2025 01:57
Comment on lines 11 to 12
const [open, setOpen] = useState(false);
const [flowRun, setFlowRun] = useState<FlowRun | null>(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Isn't the the dialog being open derived from the flowRun state being set? Is the open state redundant?

Copy link
Collaborator Author

@zzstoatzz zzstoatzz Apr 8, 2025

Choose a reason for hiding this comment

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

I did this because onOpenChange (which closes the dialog) just sets open to false without clearing the flowRun state variable inside the hook

Copy link
Contributor

Choose a reason for hiding this comment

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

If you want to use that. Then does flowRun need to be a state? Can't that just be passed as a props?

Copy link
Collaborator Author

@zzstoatzz zzstoatzz Apr 8, 2025

Choose a reason for hiding this comment

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

I kept the flowRun state in the hook to encapsulate all the dialog's context there, in my mind making it simpler for the parent component to just call openDialog but if this

Can't that just be passed as a props

would be preferred, I'm happy to make that change

Copy link
Contributor

Choose a reason for hiding this comment

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

Ya, I think that would help simplify things

Copy link
Collaborator Author

@zzstoatzz zzstoatzz Apr 8, 2025

Choose a reason for hiding this comment

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

cool, should be done in b3ae5d8!

import { RunStateChangeDialog } from "@/components/ui/run-state-change-dialog";
import { useFlowRunStateDialog } from "./use-flow-run-state-dialog";

interface FlowRunStateDialogProps {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
interface FlowRunStateDialogProps {
type FlowRunStateDialogProps {

@zzstoatzz zzstoatzz requested a review from cicdw as a code owner April 8, 2025 16:56
@zzstoatzz zzstoatzz force-pushed the flow-run-state-dialog branch from e5d1761 to 001f822 Compare April 8, 2025 16:57
rm old things
@zzstoatzz zzstoatzz force-pushed the flow-run-state-dialog branch from b26dd05 to 954d814 Compare April 8, 2025 17:03
@zzstoatzz zzstoatzz merged commit 9dc6961 into main Apr 8, 2025
8 checks passed
@zzstoatzz zzstoatzz deleted the flow-run-state-dialog branch April 8, 2025 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ui-replatform Related to the React UI rewrite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants