Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { CgRedo } from "react-icons/cg";
import { useDagServiceGetDagDetails } from "openapi/queries";
import type { DAGRunResponse } from "openapi/requests/types.gen";
import { ActionAccordion } from "src/components/ActionAccordion";
import { getRunOnLatestVersionState } from "src/components/Clear/TaskInstance/runOnLatestVersion";
import { useRerunWithLatestVersion } from "src/components/Clear/useRerunWithLatestVersion";
import { Checkbox, Dialog } from "src/components/ui";
import SegmentedControl from "src/components/ui/SegmentedControl";
Expand Down Expand Up @@ -91,14 +92,16 @@ const ClearRunDialog = ({ dagRun, onClose, open }: Props) => {
onSuccessConfirm: handleClose,
});

// Check if DAG versions differ (works for both bundle-versioned and local bundles)
const latestDagVersionNumber = dagDetails?.latest_dag_version?.version_number;
const dagRunVersionNumber = dagRun.dag_versions.at(-1)?.version_number;
const versionsDiffer =
latestDagVersionNumber !== undefined &&
dagRunVersionNumber !== undefined &&
latestDagVersionNumber !== dagRunVersionNumber;
const shouldShowBundleVersionOption = versionsDiffer && !onlyNew;
// Non-versioned bundles (e.g. LocalDagBundle) always leave bundle_version null and
// resolve to the latest serialized Dag at run time, so "run on latest" is a no-op there.
// Only offer it when the run is pinned to an older bundle version, where it actually changes the outcome.
const { shouldShowRunOnLatestOption } = getRunOnLatestVersionState({
latestBundleVersion: dagDetails?.bundle_version,
latestDagVersionNumber: dagDetails?.latest_dag_version?.version_number,
selectedBundleVersion: dagRun.dag_versions.at(-1)?.bundle_version,
selectedDagVersionNumber: dagRun.dag_versions.at(-1)?.version_number,
});
const shouldShowBundleVersionOption = shouldShowRunOnLatestOption && !onlyNew;

return (
<Dialog.Root
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ describe("getRunOnLatestVersionState", () => {
it.each([
{
expectedDagVersionsDiffer: true,
expectedShouldShowRunOnLatestOption: true,
expectedShouldShowRunOnLatestOption: false,
latestDagVersionNumber: 3,
name: "shows and defaults on when DAG version numbers differ",
name: "does not show when DAG versions differ but no bundle version is present (non-versioned bundle)",
selectedDagVersionNumber: 2,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ export const getRunOnLatestVersionState = ({

return {
dagVersionsDiffer,
shouldShowRunOnLatestOption: dagVersionsDiffer || shouldShowForBundleVersion,
shouldShowRunOnLatestOption: shouldShowForBundleVersion,
};
};