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 @@ -180,6 +180,7 @@
"placeholder": "Add a note...",
"taskInstance": "Task Instance Note"
},
"overallStatus": "Overall Status",
"partitionedDagRun_one": "Partitioned Dag Run",
"partitionedDagRun_other": "Partitioned Dag Runs",
"partitionedDagRunDetail": {
Expand Down Expand Up @@ -267,10 +268,13 @@
"updatedAt": "Updated at"
},
"task": {
"dependsOnPast": "Depends on Past",
"documentation": "Task Documentation",
"lastInstance": "Last Instance",
"operator": "Operator",
"triggerRule": "Trigger Rule"
"retries": "Retries",
"triggerRule": "Trigger Rule",
"waitForDownstream": "Wait for Downstream"
},
"task_one": "Task",
"task_other": "Tasks",
Expand Down
8 changes: 4 additions & 4 deletions airflow-core/src/airflow/ui/src/components/HeaderCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Props = {
readonly actions?: ReactNode;
readonly icon: ReactNode;
readonly state?: TaskInstanceState | null;
readonly stats: Array<{ label: string; value: ReactNode | string }>;
readonly stats: Array<{ key?: string; label: string; value: ReactNode | string }>;
readonly subTitle?: ReactNode | string;
readonly title: ReactNode | string;
};
Expand Down Expand Up @@ -61,9 +61,9 @@ export const HeaderCard = ({ actions, icon, state, stats, subTitle, title }: Pro
</Flex>

<HStack alignItems="flex-start" flexWrap="wrap" gap={5} justifyContent="space-between" my={2}>
{stats.map(({ label, value }) => (
<GridItem key={label}>
<Stat label={label}>{value}</Stat>
{stats.map((stat) => (
<GridItem key={stat.key ?? stat.label}>
<Stat label={stat.label}>{stat.value}</Stat>
</GridItem>
))}
</HStack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ const SharedScrollBox = ({
type Props = {
readonly error?: unknown;
readonly isLoading?: boolean;
/** Value exposed to the active tab via ``useOutletContext`` (so tabs can reuse the parent's data). */
readonly outletContext?: unknown;
readonly tabs: Array<NavTab>;
} & PropsWithChildren;

export const DetailsLayout = ({ children, error, isLoading, tabs }: Props) => {
export const DetailsLayout = ({ children, error, isLoading, outletContext, tabs }: Props) => {
const { t: translate } = useTranslation();
const { dagId = "", runId } = useParams();
const { data: dag } = useDagServiceGetDag({ dagId });
Expand Down Expand Up @@ -406,7 +408,7 @@ export const DetailsLayout = ({ children, error, isLoading, tabs }: Props) => {
<ProgressBar size="xs" visibility={isLoading ? "visible" : "hidden"} />
<NavTabs tabs={tabs} />
<Box flexGrow={1} overflow="auto" px={2}>
<Outlet />
<Outlet context={outletContext} />
</Box>
</Box>
</Panel>
Expand Down
140 changes: 140 additions & 0 deletions airflow-core/src/airflow/ui/src/pages/MappedTaskInstance/Details.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/*!
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { Box, Flex, Table } from "@chakra-ui/react";
import { useTranslation } from "react-i18next";
import { useOutletContext, useParams } from "react-router-dom";

import { useTaskServiceGetTask } from "openapi/queries";
import type { LightGridTaskInstanceSummary } from "openapi/requests/types.gen";
import { StateBadge } from "src/components/StateBadge";
import Time from "src/components/Time";
import { getDuration } from "src/utils";

export const Details = () => {
const { dagId = "", taskId = "" } = useParams();
const { t: translate } = useTranslation("common");

// The aggregate summary (per-state counts, dates) is streamed once by the parent page and
// shared through the router outlet, so this tab does not re-open the TI summaries stream.
const taskInstance = useOutletContext<LightGridTaskInstanceSummary | undefined>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we want to use this hook anywhere else?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, we are only consuming the parent context once, here. (retrieving the TIsummaries provided by the parent page to avoid opening a second stream for that)


const { data: task } = useTaskServiceGetTask({ dagId, taskId }, undefined, { enabled: Boolean(taskId) });

const childStates = Object.entries(taskInstance?.child_states ?? {});

return (
<Box p={2}>
<Table.Root striped>
<Table.Body>
<Table.Row>
<Table.Cell>{translate("overallStatus")}</Table.Cell>
<Table.Cell>
<Flex alignItems="center" gap={1}>
<StateBadge state={taskInstance?.state} />
{taskInstance?.state ?? translate("states.no_status")}
</Flex>
</Table.Cell>
</Table.Row>
{childStates.map(([state, count]) => (
<Table.Row key={state}>
<Table.Cell>{translate("total", { state: translate(`states.${state}`) })}</Table.Cell>
<Table.Cell>
<Flex alignItems="center" gap={2}>
<Box
bg={`${state}.solid`}
border="1px solid"
borderColor="border.emphasized"
borderRadius="2px"
height="10px"
width="10px"
/>
{count}
</Flex>
</Table.Cell>
</Table.Row>
))}
<Table.Row>
<Table.Cell>{translate("taskId")}</Table.Cell>
<Table.Cell>{taskId}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>{translate("task.operator")}</Table.Cell>
<Table.Cell>{task?.operator_name}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>{translate("task.triggerRule")}</Table.Cell>
<Table.Cell>{task?.trigger_rule}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>{translate("dagDetails.owner")}</Table.Cell>
<Table.Cell>{task?.owner}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>{translate("task.retries")}</Table.Cell>
<Table.Cell>{task?.retries}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>{translate("taskInstance.pool")}</Table.Cell>
<Table.Cell>{task?.pool}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>{translate("taskInstance.poolSlots")}</Table.Cell>
<Table.Cell>{task?.pool_slots}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>{translate("taskInstance.queue")}</Table.Cell>
<Table.Cell>{task?.queue}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>{translate("taskInstance.priorityWeight")}</Table.Cell>
<Table.Cell>{task?.priority_weight}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>{translate("task.dependsOnPast")}</Table.Cell>
<Table.Cell>{task === undefined ? undefined : String(task.depends_on_past)}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>{translate("task.waitForDownstream")}</Table.Cell>
<Table.Cell>{task === undefined ? undefined : String(task.wait_for_downstream)}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>{translate("startDate")}</Table.Cell>
<Table.Cell>
<Time datetime={taskInstance?.min_start_date} />
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>{translate("endDate")}</Table.Cell>
<Table.Cell>
<Time datetime={taskInstance?.max_end_date} />
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>{translate("duration")}</Table.Cell>
<Table.Cell>{getDuration(taskInstance?.min_start_date, taskInstance?.max_end_date)}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>{translate("taskInstance.dagVersion")}</Table.Cell>
<Table.Cell>{taskInstance?.dag_version_number}</Table.Cell>
</Table.Row>
</Table.Body>
</Table.Root>
</Box>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { Box } from "@chakra-ui/react";
import { Box, HStack } from "@chakra-ui/react";
import type { ReactNode } from "react";
import { useTranslation } from "react-i18next";
import { MdOutlineTask } from "react-icons/md";
Expand All @@ -31,13 +31,26 @@ import { getDuration } from "src/utils";
export const Header = ({ taskInstance }: { readonly taskInstance: LightGridTaskInstanceSummary }) => {
const { dagId = "", runId = "" } = useParams();
const { t: translate } = useTranslation();
const entries: Array<{ label: string; value: number | ReactNode | string }> = [];
const entries: Array<{ key?: string; label: string; value: number | ReactNode | string }> = [];
let taskCount: number = 0;

Object.entries(taskInstance.child_states ?? {}).forEach(([state, count]) => {
entries.push({
label: translate("total", { state: translate(`states.${state.toLowerCase()}`) }),
value: count,
key: state,
label: translate("total", { state: translate(`states.${state}`) }),
value: (
<HStack gap={2}>
<Box
bg={`${state}.solid`}
border="1px solid"
borderColor="border.emphasized"
borderRadius="2px"
height="10px"
width="10px"
/>
{count}
</HStack>
),
});
taskCount += count;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
import { ReactFlowProvider } from "@xyflow/react";
import { useTranslation } from "react-i18next";
import { MdOutlineTask } from "react-icons/md";
import { MdDetails, MdOutlineTask } from "react-icons/md";
import { useParams } from "react-router-dom";

import { DetailsLayout } from "src/layouts/Details/DetailsLayout";
Expand All @@ -41,11 +41,12 @@ export const MappedTaskInstance = () => {

const tabs = [
{ icon: <MdOutlineTask />, label: `${translate("tabs.taskInstances")} [${taskCount}]`, value: "" },
{ icon: <MdDetails />, label: translate("tabs.details"), value: "details" },
];

return (
<ReactFlowProvider>
<DetailsLayout tabs={tabs}>
<DetailsLayout outletContext={taskInstance} tabs={tabs}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What does this context actually do? We're only using it here and I don't get what its helping us with?

@pierrejeambrun pierrejeambrun Jun 11, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is to re-use the Grid summary. Otherwise the detail tab will have to useGridTiSummariesStream to fetch the TI summary. But since this is a stream, it's a custom implementation, not re-using react query cache and all, so this would open a second stream request to get the TI summaries.

This allow to share the stream from the grid view with the details view, via a context.

Preventing a second call to useGridTiSummariesStream and preventing a second stream request for data we already have.

{taskInstance === undefined ? undefined : <Header taskInstance={taskInstance} />}
</DetailsLayout>
</ReactFlowProvider>
Expand Down
6 changes: 5 additions & 1 deletion airflow-core/src/airflow/ui/src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { GroupTaskInstance } from "src/pages/GroupTaskInstance";
import { HITLTaskInstances } from "src/pages/HITLTaskInstances";
import { Jobs } from "src/pages/Jobs";
import { MappedTaskInstance } from "src/pages/MappedTaskInstance";
import { Details as MappedTaskInstanceDetails } from "src/pages/MappedTaskInstance/Details";
import { Plugins } from "src/pages/Plugins";
import { Pools } from "src/pages/Pools";
import { Providers } from "src/pages/Providers";
Expand Down Expand Up @@ -216,7 +217,10 @@ export const routerConfig = [
path: "dags/:dagId/runs/:runId/tasks/:taskId",
},
{
children: [{ element: <TaskInstances />, index: true }],
children: [
{ element: <TaskInstances />, index: true },
{ element: <MappedTaskInstanceDetails />, path: "details" },
],
element: <MappedTaskInstance />,
path: "dags/:dagId/runs/:runId/tasks/:taskId/mapped",
},
Expand Down
Loading