Skip to content

UI: Pass Dag, DagRun, TaskInstance, and Asset objects to React app plugins#70149

Open
dheerajturaga wants to merge 1 commit into
apache:mainfrom
dheerajturaga:pass-context-objects-to-react-plugins
Open

UI: Pass Dag, DagRun, TaskInstance, and Asset objects to React app plugins#70149
dheerajturaga wants to merge 1 commit into
apache:mainfrom
dheerajturaga:pass-context-objects-to-react-plugins

Conversation

@dheerajturaga

@dheerajturaga dheerajturaga commented Jul 21, 2026

Copy link
Copy Markdown
Member

Follows the pattern established in #69986, which enriched the props passed to React app plugins beyond bare route params by resolving assetUri from the UI's TanStack Query cache. This extends that pattern to the full context objects: React plugins now receive dag, dagRun, taskInstance, and asset as typed props alongside the existing route-id strings.

Each object is resolved from the query cache and gated on the route params it depends on, so it is served from the cache the parent details page already populated (no extra request) where present, and is undefined on routes or destinations that lack those ids (e.g. nav, base, dashboard).

Related: #69148

Screenshots from dummy plugin:
image

image
Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)
    Claude Code Opus 4.8

…ugins

Follows the pattern established in apache#69986, which enriched the props passed
to React app plugins beyond bare route params by resolving assetUri from the
UI's TanStack Query cache. This extends that pattern to the full context
objects: React plugins now receive dag, dagRun, taskInstance, and asset as
typed props alongside the existing route-id strings.

Each object is resolved from the query cache and gated on the route params
it depends on, so it is served from the cache the parent details page
already populated (no extra request) where present, and is undefined on
routes or destinations that lack those ids (e.g. nav, base, dashboard).
@dheerajturaga
dheerajturaga force-pushed the pass-context-objects-to-react-plugins branch from 8642279 to 69a335f Compare July 21, 2026 00:07
@bbovenzi bbovenzi added this to the Airflow 3.4.0 milestone Jul 21, 2026

@bbovenzi bbovenzi left a comment

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.

Let's update the documentation to let plugin developers know this and that its only for react plugins of course.

Comment on lines +125 to +134
asset={asset}
assetId={assetId}
assetUri={assetUri}
dag={dag}
dagId={dagId}
dagRun={dagRun}
mapIndex={mapIndex}
runId={runId}
taskId={taskId}
taskInstance={taskInstance}

@bbovenzi bbovenzi Jul 21, 2026

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.

Let's just make this a const pluginProps = {} and then we can pass the same content to plugin and lazy plugin. <Plugin {...pluginProps} /> A little more DRY

Comment on lines +95 to +114
const { data: dag } = useDagServiceGetDagDetails({ dagId: dagId ?? "" }, undefined, {
enabled: Boolean(dagId),
});

const { data: dagRun } = useDagRunServiceGetDagRun(
{ dagId: dagId ?? "", dagRunId: runId ?? "" },
undefined,
{ enabled: Boolean(dagId) && Boolean(runId) },
);

const { data: taskInstance } = useTaskInstanceServiceGetMappedTaskInstance(
{
dagId: dagId ?? "",
dagRunId: runId ?? "",
mapIndex: mapIndex === undefined ? -1 : parseInt(mapIndex, 10),
taskId: taskId ?? "",
},
undefined,
{ enabled: Boolean(dagId) && Boolean(runId) && Boolean(taskId) },
);

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.

These should be fine and not firing any extra queries since they should already be cached.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:plugins area:UI Related to UI/UX. For Frontend Developers. kind:documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants