You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "sujitha-saranam (via GitHub)" <gi...@apache.org> on 2025/08/13 09:49:26 UTC
[PR] Default to latest logs and fix scroll bar jump performance #54174 [airflow]
sujitha-saranam opened a new pull request, #54447:
URL: https://github.com/apache/airflow/pull/54447
#### Overview
This PR addresses https://github.com/apache/airflow/issues/54174. It fixes the default scroll to the most recent logs and ensures that jump-to-start/end buttons scroll instantly.
#### Root Cause:
Jumping to the end is slow because the virtualizer has to compute/measure positions for a large number of rows before it can accurately place the scroll. For very long logs, this causes the temporary slow scroll effect.
#### Solution
- Reversed the log order so that newest entries appear first, making default display show the most recent logs.
- Implemented precise offset calculation for hash-based navigation to jump directly to a target log.
- Enhanced jump-to-start and jump-to-end logic to bypass gradual virtualizer measurement, allowing instant scrolling.
- Updated highlight calculation to work correctly with the reversed order, ensuring the selected log is always visually marked.
#### Changes Made
- Reversed the logs array for newest-first display.
- Updated useLayoutEffect to compute exact scroll offsets based on virtual item positions.
- Modified handleScrollTo to combine scrollToIndex with scrollTop via requestAnimationFrame for instant jumps.
- Adjusted the bgColor calculation for virtualized items to correctly highlight the log matching the hash.
- Tweak Code and VStack container styling to match virtualized content height and improve scroll behavior.
closes: #54174
related: #54174
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Default to latest logs and fix scroll bar jump performance #54174 [airflow]
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #54447:
URL: https://github.com/apache/airflow/pull/54447#discussion_r2300269378
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/log.py:
##########
@@ -146,7 +146,9 @@ def get_log(
if accept == Mimetype.NDJSON: # only specified application/x-ndjson will return streaming response
# LogMetadata(TypedDict) is used as type annotation for log_reader; added ignore to suppress mypy error
- log_stream = task_log_reader.read_log_stream(ti, try_number, metadata) # type: ignore[arg-type]
+ ndjson_log_stream = list(task_log_reader.read_log_stream(ti, try_number, metadata)) # type: ignore[arg-type]
+ reversed_stream = reversed(ndjson_log_stream)
+ log_stream = (line for line in reversed_stream)
Review Comment:
Isn’t this just `iter(reversed_stream)`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Default to latest logs and fix scroll bar jump performance #54174 [airflow]
Posted by "sujitha-saranam (via GitHub)" <gi...@apache.org>.
sujitha-saranam commented on code in PR #54447:
URL: https://github.com/apache/airflow/pull/54447#discussion_r2300619240
##########
airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/TaskLogContent.tsx:
##########
@@ -94,16 +90,114 @@ export const TaskLogContent = ({ error, isLoading, logError, parsedLogs, wrap }:
return parsedLogs.length > 1 && contentHeight > containerHeight;
}, [rowVirtualizer, parsedLogs]);
+ // Precise jump to hash index
useLayoutEffect(() => {
- if (location.hash && !isLoading) {
- rowVirtualizer.scrollToIndex(Math.min(Number(hash) + 5, parsedLogs.length - 1));
+ if (!location.hash || isLoading || parsedLogs.length === 0) {
+ return;
+ }
+
+ const targetIndex = Math.max(0, Math.min(parsedLogs.length - 1, Number(hash) || 0));
+ const el = parentRef.current;
+
+ // Prefer exact offset if we already have the virtual item measured
+ const total = rowVirtualizer.getTotalSize();
+ const clientH = el?.clientHeight ?? 0;
+
+ // If the item is currently virtualized, use its start; otherwise approximate
+ const vItem = rowVirtualizer.getVirtualItems().find((virtualRow) => virtualRow.index === targetIndex);
+ const approxPerItem = 20; // same as estimateSize
+ const anchor = vItem?.start ?? targetIndex * approxPerItem;
+
+ const offset = Math.max(0, Math.min(total - clientH, anchor));
+
+ if (el) {
+ // Force both virtualizer and DOM to the exact offset to avoid slow incremental scrolling
+ if (typeof rowVirtualizer.scrollToOffset === "function") {
+ try {
+ rowVirtualizer.scrollToOffset(offset);
+ } catch {
+ rowVirtualizer.scrollToIndex(targetIndex, { align: "start" });
+ }
+ } else {
+ rowVirtualizer.scrollToIndex(targetIndex, { align: "start" });
+ }
+
+ el.scrollTop = offset;
+
+ // One more frame to settle measurements for large lists
+ requestAnimationFrame(() => {
+ el.scrollTop = offset;
+ });
+ } else {
+ rowVirtualizer.scrollToIndex(targetIndex, { align: "start" });
}
}, [isLoading, rowVirtualizer, hash, parsedLogs]);
+ // Robust, instant jump-to handler
const handleScrollTo = (to: "bottom" | "top") => {
- if (parsedLogs.length > 0) {
- rowVirtualizer.scrollToIndex(to === "bottom" ? parsedLogs.length - 1 : 0);
+ if (parsedLogs.length === 0) {
+ return;
+ }
+
+ const el = rowVirtualizer.scrollElement ?? parentRef.current;
+
+ if (!el) {
+ return;
+ }
+
+ if (to === "top") {
+ // Jump instantly to top
+ if (typeof rowVirtualizer.scrollToOffset === "function") {
+ try {
+ rowVirtualizer.scrollToOffset(0);
+ } catch {
+ rowVirtualizer.scrollToIndex(0, { align: "start" });
+ }
+ } else {
+ rowVirtualizer.scrollToIndex(0, { align: "start" });
+ }
+ el.scrollTop = 0;
+ requestAnimationFrame(() => {
+ el.scrollTop = 0;
+ });
+
+ return;
}
+
+ // === bottom === (instant jump even for huge lists)
+ const total = rowVirtualizer.getTotalSize();
+ const clientH = el.clientHeight || 0;
+ const offset = Math.max(0, Math.floor(total - clientH));
+
+ // First tell the virtualizer where we want to be
+ if (typeof rowVirtualizer.scrollToOffset === "function") {
+ try {
+ rowVirtualizer.scrollToOffset(offset);
+ } catch {
+ rowVirtualizer.scrollToIndex(parsedLogs.length - 1, { align: "end" });
+ }
+ } else {
+ rowVirtualizer.scrollToIndex(parsedLogs.length - 1, { align: "end" });
+ }
+
+ // Then force the DOM to that exact pixel offset
+ el.scrollTop = offset;
+
+ // A couple of RAFs to ensure post-measurement settling for very large lists
+ requestAnimationFrame(() => {
+ el.scrollTop = offset;
+ requestAnimationFrame(() => {
+ // final nudge + fallback to last item visibility if needed
+ el.scrollTop = offset;
+ const lastItem = el.querySelector<HTMLElement>(
+ `[data-testid="virtualized-item-${parsedLogs.length - 1}"]`,
+ );
+
+ if (lastItem) {
+ lastItem.scrollIntoView({ behavior: "auto", block: "end" });
+ }
+ });
+ });
Review Comment:
hi @pierrejeambrun
Thank you for the feedback. I’m still new to React, so I’d really appreciate any suggestions on a simpler or more idiomatic way to achieve this behavior. I tried a few other approaches earlier, but this one gave the best results, so I went ahead with it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Default to latest logs and fix scroll bar jump performance #54174 [airflow]
Posted by "sujitha-saranam (via GitHub)" <gi...@apache.org>.
sujitha-saranam commented on PR #54447:
URL: https://github.com/apache/airflow/pull/54447#issuecomment-3206362964
Hi @pierrejeambrun
https://github.com/user-attachments/assets/0dd12db3-2e0d-42f2-83db-109bfbd74cca
I have fixed the logs reversal from the backend and also addressed the UI issues. I’ve attached a screen recording of my local setup showing these updates. Could you please check and let me know if everything looks fine, or if there are any external changes I should also make?
Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Default to latest logs and fix scroll bar jump performance #54174 [airflow]
Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on code in PR #54447:
URL: https://github.com/apache/airflow/pull/54447#discussion_r2297997860
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/log.py:
##########
@@ -160,11 +162,11 @@ def get_log(
# LogMetadata(TypedDict) is used as type annotation for log_reader; added ignore to suppress mypy error
structured_log_stream, out_metadata = task_log_reader.read_log_chunks(ti, try_number, metadata) # type: ignore[arg-type]
encoded_token = None
+ log_chunks = list(structured_log_stream)
+ log_chunks.reverse()
Review Comment:
If we really need this feature, would it be better to add a new UI endpoint for this behavior.
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/log.py:
##########
@@ -146,7 +146,9 @@ def get_log(
if accept == Mimetype.NDJSON: # only specified application/x-ndjson will return streaming response
# LogMetadata(TypedDict) is used as type annotation for log_reader; added ignore to suppress mypy error
- log_stream = task_log_reader.read_log_stream(ti, try_number, metadata) # type: ignore[arg-type]
+ ndjson_log_stream = list(task_log_reader.read_log_stream(ti, try_number, metadata)) # type: ignore[arg-type]
+ reversed_stream = reversed(ndjson_log_stream)
+ log_stream = (line for line in reversed_stream)
Review Comment:
Reversing logs will be breaking change behavior on public core API.
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/log.py:
##########
@@ -160,11 +162,11 @@ def get_log(
# LogMetadata(TypedDict) is used as type annotation for log_reader; added ignore to suppress mypy error
structured_log_stream, out_metadata = task_log_reader.read_log_chunks(ti, try_number, metadata) # type: ignore[arg-type]
encoded_token = None
+ log_chunks = list(structured_log_stream)
+ log_chunks.reverse()
Review Comment:
If we really need this feature, would it be better to add a new UI endpoint for this behavior?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Default to latest logs and fix scroll bar jump performance #54174 [airflow]
Posted by "jscheffl (via GitHub)" <gi...@apache.org>.
jscheffl commented on PR #54447:
URL: https://github.com/apache/airflow/pull/54447#issuecomment-3221398910
Iactually would not like to read logs in reverse order. I this is made then it would need to be an optional feature, should not require all users to read logs in reverse order.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Default to latest logs and fix scroll bar jump performance #54174 [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on code in PR #54447:
URL: https://github.com/apache/airflow/pull/54447#discussion_r2315894759
##########
airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/TaskLogContent.tsx:
##########
@@ -95,15 +96,103 @@ export const TaskLogContent = ({ error, isLoading, logError, parsedLogs, wrap }:
}, [rowVirtualizer, parsedLogs]);
useLayoutEffect(() => {
- if (location.hash && !isLoading) {
- rowVirtualizer.scrollToIndex(Math.min(Number(hash) + 5, parsedLogs.length - 1));
+ if (!location.hash || isLoading || parsedLogs.length === 0) {
+ return;
+ }
+
+ const targetIndex = Math.max(0, Math.min(parsedLogs.length - 1, Number(hash) || 0));
+ const el = parentRef.current;
+
+ const total = rowVirtualizer.getTotalSize();
+ const clientH = el?.clientHeight ?? 0;
Review Comment:
Both clicking on a log line, or refreshing the page with a URL with a line number specified will not land where we want. http://localhost:28080/dags/big_logs/runs/manual__2025-09-02T12:02:44.060539+00:00/tasks/my_task?try_number=1#4806
##########
airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/TaskLogContent.tsx:
##########
@@ -95,15 +96,103 @@ export const TaskLogContent = ({ error, isLoading, logError, parsedLogs, wrap }:
}, [rowVirtualizer, parsedLogs]);
useLayoutEffect(() => {
- if (location.hash && !isLoading) {
- rowVirtualizer.scrollToIndex(Math.min(Number(hash) + 5, parsedLogs.length - 1));
+ if (!location.hash || isLoading || parsedLogs.length === 0) {
+ return;
+ }
+
+ const targetIndex = Math.max(0, Math.min(parsedLogs.length - 1, Number(hash) || 0));
+ const el = parentRef.current;
+
+ const total = rowVirtualizer.getTotalSize();
+ const clientH = el?.clientHeight ?? 0;
+
+ const vItem = rowVirtualizer.getVirtualItems().find((virtualRow) => virtualRow.index === targetIndex);
+ const approxPerItem = 20;
+ const anchor = vItem?.start ?? targetIndex * approxPerItem;
+
+ const offset = Math.max(0, Math.min(total - clientH, anchor));
+
+ if (el) {
+ if (typeof rowVirtualizer.scrollToOffset === "function") {
+ try {
+ rowVirtualizer.scrollToOffset(offset);
+ } catch {
+ rowVirtualizer.scrollToIndex(targetIndex, { align: "start" });
+ }
+ } else {
+ rowVirtualizer.scrollToIndex(targetIndex, { align: "start" });
+ }
+
+ el.scrollTop = offset;
+
+ requestAnimationFrame(() => {
+ el.scrollTop = offset;
+ });
+ } else {
+ rowVirtualizer.scrollToIndex(targetIndex, { align: "start" });
}
}, [isLoading, rowVirtualizer, hash, parsedLogs]);
const handleScrollTo = (to: "bottom" | "top") => {
- if (parsedLogs.length > 0) {
- rowVirtualizer.scrollToIndex(to === "bottom" ? parsedLogs.length - 1 : 0);
+ if (parsedLogs.length === 0) {
+ return;
+ }
+
+ const el = rowVirtualizer.scrollElement ?? parentRef.current;
+
+ if (!el) {
+ return;
}
+
+ if (to === "top") {
+ if (typeof rowVirtualizer.scrollToOffset === "function") {
+ try {
+ rowVirtualizer.scrollToOffset(0);
+ } catch {
+ rowVirtualizer.scrollToIndex(0, { align: "start" });
+ }
+ } else {
+ rowVirtualizer.scrollToIndex(0, { align: "start" });
+ }
+ el.scrollTop = 0;
+ requestAnimationFrame(() => {
+ el.scrollTop = 0;
+ });
+
+ return;
+ }
+
+ // === bottom === (instant jump even for huge lists)
+ const total = rowVirtualizer.getTotalSize();
+ const clientH = el.clientHeight || 0;
+ const offset = Math.max(0, Math.floor(total - clientH));
+
+ // First tell the virtualizer where we want to be
+ if (typeof rowVirtualizer.scrollToOffset === "function") {
+ try {
+ rowVirtualizer.scrollToOffset(offset);
+ } catch {
+ rowVirtualizer.scrollToIndex(parsedLogs.length - 1, { align: "end" });
+ }
+ } else {
+ rowVirtualizer.scrollToIndex(parsedLogs.length - 1, { align: "end" });
+ }
+
+ el.scrollTop = offset;
+
+ requestAnimationFrame(() => {
+ el.scrollTop = offset;
+ requestAnimationFrame(() => {
+ el.scrollTop = offset;
+ const lastItem = el.querySelector<HTMLElement>(
+ `[data-testid="virtualized-item-${parsedLogs.length - 1}"]`,
+ );
+
+ if (lastItem) {
+ lastItem.scrollIntoView({ behavior: "auto", block: "end" });
+ }
+ });
+ });
Review Comment:
What are those `requestAnimationFrame` achieving? I Tried without them and it still look fine.
##########
airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/TaskLogContent.tsx:
##########
@@ -95,15 +96,103 @@ export const TaskLogContent = ({ error, isLoading, logError, parsedLogs, wrap }:
}, [rowVirtualizer, parsedLogs]);
useLayoutEffect(() => {
- if (location.hash && !isLoading) {
- rowVirtualizer.scrollToIndex(Math.min(Number(hash) + 5, parsedLogs.length - 1));
+ if (!location.hash || isLoading || parsedLogs.length === 0) {
+ return;
+ }
+
+ const targetIndex = Math.max(0, Math.min(parsedLogs.length - 1, Number(hash) || 0));
+ const el = parentRef.current;
+
+ const total = rowVirtualizer.getTotalSize();
+ const clientH = el?.clientHeight ?? 0;
Review Comment:
This breaks the direct link to lines. We used to add 5 more lines so it wouldn't be on the `edge` of the container, f screenshot.
<img width="1893" height="807" alt="Screenshot 2025-09-02 at 14 06 18" src="https://github.com/user-attachments/assets/3f5921e7-17bb-4b84-9bff-bb1976ed5fa2" />
##########
airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/TaskLogContent.tsx:
##########
@@ -95,15 +96,103 @@ export const TaskLogContent = ({ error, isLoading, logError, parsedLogs, wrap }:
}, [rowVirtualizer, parsedLogs]);
useLayoutEffect(() => {
- if (location.hash && !isLoading) {
- rowVirtualizer.scrollToIndex(Math.min(Number(hash) + 5, parsedLogs.length - 1));
+ if (!location.hash || isLoading || parsedLogs.length === 0) {
+ return;
+ }
+
+ const targetIndex = Math.max(0, Math.min(parsedLogs.length - 1, Number(hash) || 0));
+ const el = parentRef.current;
+
+ const total = rowVirtualizer.getTotalSize();
+ const clientH = el?.clientHeight ?? 0;
+
+ const vItem = rowVirtualizer.getVirtualItems().find((virtualRow) => virtualRow.index === targetIndex);
+ const approxPerItem = 20;
+ const anchor = vItem?.start ?? targetIndex * approxPerItem;
+
+ const offset = Math.max(0, Math.min(total - clientH, anchor));
+
+ if (el) {
+ if (typeof rowVirtualizer.scrollToOffset === "function") {
+ try {
+ rowVirtualizer.scrollToOffset(offset);
+ } catch {
+ rowVirtualizer.scrollToIndex(targetIndex, { align: "start" });
+ }
+ } else {
+ rowVirtualizer.scrollToIndex(targetIndex, { align: "start" });
+ }
+
+ el.scrollTop = offset;
+
+ requestAnimationFrame(() => {
+ el.scrollTop = offset;
+ });
+ } else {
+ rowVirtualizer.scrollToIndex(targetIndex, { align: "start" });
}
}, [isLoading, rowVirtualizer, hash, parsedLogs]);
const handleScrollTo = (to: "bottom" | "top") => {
- if (parsedLogs.length > 0) {
- rowVirtualizer.scrollToIndex(to === "bottom" ? parsedLogs.length - 1 : 0);
+ if (parsedLogs.length === 0) {
+ return;
+ }
+
+ const el = rowVirtualizer.scrollElement ?? parentRef.current;
+
+ if (!el) {
+ return;
}
+
+ if (to === "top") {
+ if (typeof rowVirtualizer.scrollToOffset === "function") {
+ try {
+ rowVirtualizer.scrollToOffset(0);
+ } catch {
+ rowVirtualizer.scrollToIndex(0, { align: "start" });
+ }
+ } else {
+ rowVirtualizer.scrollToIndex(0, { align: "start" });
+ }
+ el.scrollTop = 0;
+ requestAnimationFrame(() => {
+ el.scrollTop = 0;
+ });
+
+ return;
+ }
+
+ // === bottom === (instant jump even for huge lists)
Review Comment:
There's a comment for bottom, but not for top. Remove it
```suggestion
```
##########
airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/TaskLogContent.tsx:
##########
@@ -95,15 +96,103 @@ export const TaskLogContent = ({ error, isLoading, logError, parsedLogs, wrap }:
}, [rowVirtualizer, parsedLogs]);
useLayoutEffect(() => {
- if (location.hash && !isLoading) {
- rowVirtualizer.scrollToIndex(Math.min(Number(hash) + 5, parsedLogs.length - 1));
+ if (!location.hash || isLoading || parsedLogs.length === 0) {
+ return;
+ }
+
+ const targetIndex = Math.max(0, Math.min(parsedLogs.length - 1, Number(hash) || 0));
+ const el = parentRef.current;
+
+ const total = rowVirtualizer.getTotalSize();
+ const clientH = el?.clientHeight ?? 0;
+
+ const vItem = rowVirtualizer.getVirtualItems().find((virtualRow) => virtualRow.index === targetIndex);
+ const approxPerItem = 20;
+ const anchor = vItem?.start ?? targetIndex * approxPerItem;
+
+ const offset = Math.max(0, Math.min(total - clientH, anchor));
+
+ if (el) {
+ if (typeof rowVirtualizer.scrollToOffset === "function") {
+ try {
+ rowVirtualizer.scrollToOffset(offset);
+ } catch {
+ rowVirtualizer.scrollToIndex(targetIndex, { align: "start" });
+ }
+ } else {
+ rowVirtualizer.scrollToIndex(targetIndex, { align: "start" });
+ }
+
+ el.scrollTop = offset;
+
+ requestAnimationFrame(() => {
+ el.scrollTop = offset;
+ });
+ } else {
+ rowVirtualizer.scrollToIndex(targetIndex, { align: "start" });
}
}, [isLoading, rowVirtualizer, hash, parsedLogs]);
const handleScrollTo = (to: "bottom" | "top") => {
- if (parsedLogs.length > 0) {
- rowVirtualizer.scrollToIndex(to === "bottom" ? parsedLogs.length - 1 : 0);
+ if (parsedLogs.length === 0) {
+ return;
+ }
+
+ const el = rowVirtualizer.scrollElement ?? parentRef.current;
+
+ if (!el) {
+ return;
}
+
+ if (to === "top") {
+ if (typeof rowVirtualizer.scrollToOffset === "function") {
+ try {
+ rowVirtualizer.scrollToOffset(0);
+ } catch {
+ rowVirtualizer.scrollToIndex(0, { align: "start" });
+ }
+ } else {
+ rowVirtualizer.scrollToIndex(0, { align: "start" });
+ }
+ el.scrollTop = 0;
+ requestAnimationFrame(() => {
+ el.scrollTop = 0;
+ });
+
+ return;
+ }
+
+ // === bottom === (instant jump even for huge lists)
+ const total = rowVirtualizer.getTotalSize();
+ const clientH = el.clientHeight || 0;
+ const offset = Math.max(0, Math.floor(total - clientH));
+
+ // First tell the virtualizer where we want to be
+ if (typeof rowVirtualizer.scrollToOffset === "function") {
+ try {
+ rowVirtualizer.scrollToOffset(offset);
+ } catch {
+ rowVirtualizer.scrollToIndex(parsedLogs.length - 1, { align: "end" });
+ }
Review Comment:
This should be enough. We can remove the `typeof` check. (undefined is not callable) (same above)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Default to latest logs and fix scroll bar jump performance #54174 [airflow]
Posted by "sujitha-saranam (via GitHub)" <gi...@apache.org>.
sujitha-saranam commented on PR #54447:
URL: https://github.com/apache/airflow/pull/54447#issuecomment-3223739965
I am reverting the back-end changes as they were optional.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Default to latest logs and fix scroll bar jump performance #54174 [airflow]
Posted by "sujitha-saranam (via GitHub)" <gi...@apache.org>.
sujitha-saranam commented on PR #54447:
URL: https://github.com/apache/airflow/pull/54447#issuecomment-3223740665
I am reverting the back-end changes as they were optional.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Default to latest logs and fix scroll bar jump performance #54174 [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on code in PR #54447:
URL: https://github.com/apache/airflow/pull/54447#discussion_r2293851940
##########
airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/TaskLogContent.tsx:
##########
@@ -54,14 +54,8 @@ const ScrollToButton = ({
openDelay={100}
>
<IconButton
- _ltr={{
- left: "auto",
- right: 4,
- }}
- _rtl={{
- left: 4,
- right: "auto",
- }}
+ _ltr={{ left: "auto", right: 4 }}
+ _rtl={{ left: 4, right: "auto" }}
Review Comment:
Not needed, to change formatting there.
##########
airflow-core/src/airflow/ui/src/pages/TaskInstance/Logs/TaskLogContent.tsx:
##########
@@ -94,16 +90,114 @@ export const TaskLogContent = ({ error, isLoading, logError, parsedLogs, wrap }:
return parsedLogs.length > 1 && contentHeight > containerHeight;
}, [rowVirtualizer, parsedLogs]);
+ // Precise jump to hash index
useLayoutEffect(() => {
- if (location.hash && !isLoading) {
- rowVirtualizer.scrollToIndex(Math.min(Number(hash) + 5, parsedLogs.length - 1));
+ if (!location.hash || isLoading || parsedLogs.length === 0) {
+ return;
+ }
+
+ const targetIndex = Math.max(0, Math.min(parsedLogs.length - 1, Number(hash) || 0));
+ const el = parentRef.current;
+
+ // Prefer exact offset if we already have the virtual item measured
+ const total = rowVirtualizer.getTotalSize();
+ const clientH = el?.clientHeight ?? 0;
+
+ // If the item is currently virtualized, use its start; otherwise approximate
+ const vItem = rowVirtualizer.getVirtualItems().find((virtualRow) => virtualRow.index === targetIndex);
+ const approxPerItem = 20; // same as estimateSize
+ const anchor = vItem?.start ?? targetIndex * approxPerItem;
+
+ const offset = Math.max(0, Math.min(total - clientH, anchor));
+
+ if (el) {
+ // Force both virtualizer and DOM to the exact offset to avoid slow incremental scrolling
+ if (typeof rowVirtualizer.scrollToOffset === "function") {
+ try {
+ rowVirtualizer.scrollToOffset(offset);
+ } catch {
+ rowVirtualizer.scrollToIndex(targetIndex, { align: "start" });
+ }
+ } else {
+ rowVirtualizer.scrollToIndex(targetIndex, { align: "start" });
+ }
+
+ el.scrollTop = offset;
+
+ // One more frame to settle measurements for large lists
+ requestAnimationFrame(() => {
+ el.scrollTop = offset;
+ });
+ } else {
+ rowVirtualizer.scrollToIndex(targetIndex, { align: "start" });
}
}, [isLoading, rowVirtualizer, hash, parsedLogs]);
+ // Robust, instant jump-to handler
const handleScrollTo = (to: "bottom" | "top") => {
- if (parsedLogs.length > 0) {
- rowVirtualizer.scrollToIndex(to === "bottom" ? parsedLogs.length - 1 : 0);
+ if (parsedLogs.length === 0) {
+ return;
+ }
+
+ const el = rowVirtualizer.scrollElement ?? parentRef.current;
+
+ if (!el) {
+ return;
+ }
+
+ if (to === "top") {
+ // Jump instantly to top
+ if (typeof rowVirtualizer.scrollToOffset === "function") {
+ try {
+ rowVirtualizer.scrollToOffset(0);
+ } catch {
+ rowVirtualizer.scrollToIndex(0, { align: "start" });
+ }
+ } else {
+ rowVirtualizer.scrollToIndex(0, { align: "start" });
+ }
+ el.scrollTop = 0;
+ requestAnimationFrame(() => {
+ el.scrollTop = 0;
+ });
+
+ return;
}
+
+ // === bottom === (instant jump even for huge lists)
+ const total = rowVirtualizer.getTotalSize();
+ const clientH = el.clientHeight || 0;
+ const offset = Math.max(0, Math.floor(total - clientH));
+
+ // First tell the virtualizer where we want to be
+ if (typeof rowVirtualizer.scrollToOffset === "function") {
+ try {
+ rowVirtualizer.scrollToOffset(offset);
+ } catch {
+ rowVirtualizer.scrollToIndex(parsedLogs.length - 1, { align: "end" });
+ }
+ } else {
+ rowVirtualizer.scrollToIndex(parsedLogs.length - 1, { align: "end" });
+ }
+
+ // Then force the DOM to that exact pixel offset
+ el.scrollTop = offset;
+
+ // A couple of RAFs to ensure post-measurement settling for very large lists
+ requestAnimationFrame(() => {
+ el.scrollTop = offset;
+ requestAnimationFrame(() => {
+ // final nudge + fallback to last item visibility if needed
+ el.scrollTop = offset;
+ const lastItem = el.querySelector<HTMLElement>(
+ `[data-testid="virtualized-item-${parsedLogs.length - 1}"]`,
+ );
+
+ if (lastItem) {
+ lastItem.scrollIntoView({ behavior: "auto", block: "end" });
+ }
+ });
+ });
Review Comment:
This looks overly complicated to achieve what we want (maybe hinted by an AI agent?). Can we trim this down to the bare minimum to achieve the feature please.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Default to latest logs and fix scroll bar jump performance #54174 [airflow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #54447:
URL: https://github.com/apache/airflow/pull/54447#issuecomment-3555171208
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Default to latest logs and fix scroll bar jump performance #54174 [airflow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #54447: Default to latest logs and fix scroll bar jump performance #54174
URL: https://github.com/apache/airflow/pull/54447
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Default to latest logs and fix scroll bar jump performance #54174 [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on PR #54447:
URL: https://github.com/apache/airflow/pull/54447#issuecomment-3290383372
@sujitha-saranam can you address above comments?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org