You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by as...@apache.org on 2025/09/15 17:47:52 UTC
(airflow) branch log-groups-ux-tweaks updated (ff51cea469d -> 579a83e785d)
This is an automated email from the ASF dual-hosted git repository.
ash pushed a change to branch log-groups-ux-tweaks
in repository https://gitbox.apache.org/repos/asf/airflow.git
discard ff51cea469d Tweak the layout and display of groups in Task Logs
new 579a83e785d Tweak the layout and display of groups in Task Logs
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (ff51cea469d)
\
N -- N -- N refs/heads/log-groups-ux-tweaks (579a83e785d)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
(airflow) 01/01: Tweak the layout and display of groups in Task Logs
Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ash pushed a commit to branch log-groups-ux-tweaks
in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 579a83e785dc1c5e28887fa0a6e45d8b6dc21e84
Author: Ash Berlin-Taylor <as...@apache.org>
AuthorDate: Mon Sep 15 18:27:15 2025 +0100
Tweak the layout and display of groups in Task Logs
- Show the timestamp of the log start of group log message
- Add an explicit end of group marker, that when clicked collapses the group.
Since the "source" message is an empty group and every log has this group,
we don't include the end of group if there is only one thing in the group
- Don't show "other properties" on the group header, only when they are
expanded.
This fixes the wart where the "Log message source details" was expandable,
but contained nothing.
It now has a shorter message to start with and expands to show more info
- Don't get the innertext, but instead look at the already-parsed data we have
(It's silly to go from structured data, to React/HTML elements, to then get
it back as unstructured plain text again)
This also removes the react-innertext dep as this was the only use of it
---
airflow-core/src/airflow/ui/package.json | 1 -
airflow-core/src/airflow/ui/pnpm-lock.yaml | 14 -----
.../ui/src/components/renderStructuredLog.tsx | 12 ++--
.../src/airflow/ui/src/queries/useLogs.tsx | 69 +++++++++++++++-------
4 files changed, 56 insertions(+), 40 deletions(-)
diff --git a/airflow-core/src/airflow/ui/package.json b/airflow-core/src/airflow/ui/package.json
index 9eef5758807..a08aa89ab50 100644
--- a/airflow-core/src/airflow/ui/package.json
+++ b/airflow-core/src/airflow/ui/package.json
@@ -53,7 +53,6 @@
"react-hotkeys-hook": "^4.6.1",
"react-i18next": "^15.5.1",
"react-icons": "^5.5.0",
- "react-innertext": "^1.1.5",
"react-json-view": "^1.21.3",
"react-markdown": "^9.1.0",
"react-resizable-panels": "^2.1.7",
diff --git a/airflow-core/src/airflow/ui/pnpm-lock.yaml b/airflow-core/src/airflow/ui/pnpm-lock.yaml
index a46bf6e3a11..8826e702c3b 100644
--- a/airflow-core/src/airflow/ui/pnpm-lock.yaml
+++ b/airflow-core/src/airflow/ui/pnpm-lock.yaml
@@ -110,9 +110,6 @@ importers:
react-icons:
specifier: ^5.5.0
version: 5.5.0(react@19.1.1)
- react-innertext:
- specifier: ^1.1.5
- version: 1.1.5(@types/react@18.3.19)(react@19.1.1)
react-json-view:
specifier: ^1.21.3
version: 1.21.3(@types/react@18.3.19)(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
@@ -3848,12 +3845,6 @@ packages:
peerDependencies:
react: '*'
- react-innertext@1.1.5:
- resolution: {integrity: sha512-PWAqdqhxhHIv80dT9znP2KvS+hfkbRovFp4zFYHFFlOoQLRiawIic81gKb3U1wEyJZgMwgs3JoLtwryASRWP3Q==}
- peerDependencies:
- '@types/react': '>=0.0.0 <=99'
- react: '>=0.0.0 <=99'
-
react-is@16.13.1:
resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==}
@@ -9374,11 +9365,6 @@ snapshots:
dependencies:
react: 19.1.1
- react-innertext@1.1.5(@types/react@18.3.19)(react@19.1.1):
- dependencies:
- '@types/react': 18.3.19
- react: 19.1.1
-
react-is@16.13.1: {}
react-is@17.0.2: {}
diff --git a/airflow-core/src/airflow/ui/src/components/renderStructuredLog.tsx b/airflow-core/src/airflow/ui/src/components/renderStructuredLog.tsx
index f56c8072897..e3c8c00afb8 100644
--- a/airflow-core/src/airflow/ui/src/components/renderStructuredLog.tsx
+++ b/airflow-core/src/airflow/ui/src/components/renderStructuredLog.tsx
@@ -178,11 +178,13 @@ export const renderStructuredLog = ({
});
}
- elements.push(
- <chakra.span className="event" key={2} whiteSpace="pre-wrap">
- {addLinks(event)}
- </chakra.span>,
- );
+ if (!event.startsWith("::group::")) {
+ elements.push(
+ <chakra.span className="event" key={2} whiteSpace="pre-wrap">
+ {addLinks(event)}
+ </chakra.span>,
+ );
+ }
for (const key in reStructured) {
if (Object.hasOwn(reStructured, key)) {
diff --git a/airflow-core/src/airflow/ui/src/queries/useLogs.tsx b/airflow-core/src/airflow/ui/src/queries/useLogs.tsx
index f2390554ae6..e11118e7df3 100644
--- a/airflow-core/src/airflow/ui/src/queries/useLogs.tsx
+++ b/airflow-core/src/airflow/ui/src/queries/useLogs.tsx
@@ -20,13 +20,13 @@ import { chakra, Box } from "@chakra-ui/react";
import type { UseQueryOptions } from "@tanstack/react-query";
import dayjs from "dayjs";
import type { TFunction } from "i18next";
-import { useMemo } from "react";
+import { MouseEvent, useMemo } from "react";
import { useTranslation } from "react-i18next";
-import innerText from "react-innertext";
import { useTaskInstanceServiceGetLog } from "openapi/queries";
import type { TaskInstanceResponse, TaskInstancesLogResponse } from "openapi/requests/types.gen";
import { renderStructuredLog } from "src/components/renderStructuredLog";
+import Time from "src/components/Time";
import { isStatePending, useAutoRefresh } from "src/utils";
import { getTaskInstanceLink } from "src/utils/links";
import { parseStreamingLogContent } from "src/utils/logs";
@@ -108,36 +108,65 @@ const parseLogs = ({
}
parsedLines = (() => {
- type Group = { level: number; lines: Array<JSX.Element | "">; name: string };
+ type Group = { level: number; lines: Array<JSX.Element | "">; name: string, timestamp?: string };
const groupStack: Array<Group> = [];
const result: Array<JSX.Element | ""> = [];
parsedLines.forEach((line) => {
- const text = innerText(line);
+ const parsed = data[line.key];
- if (text.includes("::group::")) {
- const groupName = text.split("::group::")[1] as string;
+ if (parsed?.event.includes("::group::")) {
+ const groupName = parsed.event.split("::group::")[1] as string;
- groupStack.push({ level: groupStack.length, lines: [], name: groupName });
+ const group: Group = { level: groupStack.length, lines: [], name: groupName };
- return;
+ if (parsed !== undefined && Object.hasOwn(parsed, "timestamp")) {
+ group.timestamp = parsed.timestamp;
+ }
+ groupStack.push(group)
+
+ // return;
}
- if (text.includes("::endgroup::")) {
+ if (parsed?.event.includes("::endgroup::")) {
const finishedGroup = groupStack.pop();
+ const elements: Array<JSX.Element | string> = [];
if (finishedGroup) {
+
+ if (Boolean(finishedGroup.timestamp) && showTimestamp) {
+ elements.push("[", <Time datetime={finishedGroup.timestamp} key={0} />, "] ");
+ }
+ elements.push(finishedGroup.name)
+
+ if (finishedGroup.lines.length > 1) {
+ const handleClick = (e: MouseEvent<HTMLElement>) => {
+ // Close the details when the End of Group line is clicked
+ const details = e.target?.closest("details");
+
+ if (details) {
+ details.open = false;
+ }
+ }
+
+ const endTimestamp = (Boolean(parsed.timestamp) && showTimestamp) ? ["[", <Time datetime={parsed.timestamp} key={0} />, "] "] : undefined;
+
+ finishedGroup.lines.push(
+ <Box key={finishedGroup.name} ml={3} pl={finishedGroup.level * 2}>
+ <chakra.span color="fg.info" cursor="pointer" onClick={handleClick}>{endTimestamp}End of {finishedGroup.name}</chakra.span>
+ </Box>
+ )
+ }
+
const groupElement = (
- <Box key={finishedGroup.name} mb={2} pl={finishedGroup.level * 2}>
- <chakra.details open={open} w="100%">
- <chakra.summary data-testid={`summary-${finishedGroup.name}`}>
- <chakra.span color="fg.info" cursor="pointer">
- {finishedGroup.name}
- </chakra.span>
- </chakra.summary>
- {finishedGroup.lines}
- </chakra.details>
- </Box>
+ <chakra.details css={{ '&[open]': { 'margin-bottom': 0 } }} key={finishedGroup.name} mb={2} open={open} pl={finishedGroup.level * 2} w="100%">
+ <chakra.summary data-testid={`summary-${finishedGroup.name}`}>
+ <chakra.span color="fg.info" cursor="pointer">
+ {elements}
+ </chakra.span>
+ </chakra.summary>
+ {finishedGroup.lines}
+ </chakra.details>
);
const lastGroup = groupStack[groupStack.length - 1];
@@ -213,7 +242,7 @@ export const useLogs = (
enabled: Boolean(taskInstance),
refetchInterval: (query) =>
isStatePending(taskInstance?.state) ||
- dayjs(query.state.dataUpdatedAt).isBefore(taskInstance?.end_date)
+ dayjs(query.state.dataUpdatedAt).isBefore(taskInstance?.end_date)
? refetchInterval
: false,
...options,