This is an automated email from the ASF dual-hosted git repository.

bbovenzi pushed a commit to branch v3-4-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-4-test by this push:
     new 3ddacbc1e21 [v3-4-test] Audit Log cursor pagination (#76932) (#77413)
3ddacbc1e21 is described below

commit 3ddacbc1e213a8e69f12e147bc8da99c6a2ad790
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Nov 25 13:11:03 2026 +0000

    [v3-4-test] Audit Log cursor pagination (#76932) (#77413)
    
    * UI: Page the audit log without counting every event
    
    On busy installs the Audit Log page took tens of seconds to load, because
    every page counted the whole log table and then skipped rows with OFFSET.
    The Task Instances and Dag Runs lists already avoid that with cursor
    pagination, so the audit log now pages the same way, and it skips the
    count entirely since the page only needs to know whether more rows exist.
    
    The date filter is labeled When because it filters the When column, not
    a logical date.
    
    
    
    * UI: Open a switched task or run on the first page of its table
    
    A table cursor only points into the list it came from. Carrying it to
    another task, run or map index opened that view partway through a list
    the user never paged, with no sign anything was skipped.
    
    
    
    * Keep the audit log cursor on the stored owner name
    
    The response builder replaces an empty owner_display_name with the owner on
    the row itself, so cursors built afterwards pointed at a value the database
    never sorted on, and paging by owner_display_name never ended.
    
    
    
    * Show a capped event count in the audit log
    
    Clients reading total_entries keep getting an integer in cursor mode, so the
    response change stays additive, and the count stops at the cap instead of
    reading the whole log table.
    
    
    
    * Reject cursor pages sorted by the event's extra payload
    
    A cursor carries the row's sort values, so sorting by the unbounded extra
    text could produce tokens too long to send back, and MySQL orders TEXT by a
    prefix only, so keyset pages could skip or repeat rows.
    
    
    
    ---------
    (cherry picked from commit 5288c678669e81049f5b1a28800e2ee3c71a8f96)
    
    Co-authored-by: Brent Bovenzi <[email protected]>
    Co-authored-by: Claude <[email protected]>
---
 .../api_fastapi/core_api/datamodels/event_logs.py  |  23 +++-
 .../core_api/openapi/v2-rest-api-generated.yaml    |  64 ++++++++-
 .../core_api/routes/public/event_logs.py           | 149 ++++++++++++++++-----
 .../src/airflow/ui/openapi-gen/queries/common.ts   |   5 +-
 .../ui/openapi-gen/queries/ensureQueryData.ts      |  16 ++-
 .../src/airflow/ui/openapi-gen/queries/prefetch.ts |  16 ++-
 .../src/airflow/ui/openapi-gen/queries/queries.ts  |  16 ++-
 .../src/airflow/ui/openapi-gen/queries/suspense.ts |  16 ++-
 .../airflow/ui/openapi-gen/requests/schemas.gen.ts |  41 +++++-
 .../ui/openapi-gen/requests/services.gen.ts        |  12 ++
 .../airflow/ui/openapi-gen/requests/types.gen.ts   |  21 ++-
 .../src/airflow/ui/src/constants/filterConfigs.tsx |   2 +-
 .../src/layouts/Details/SearchMapIndexes.test.tsx  |   9 ++
 .../ui/src/layouts/Details/SearchMapIndexes.tsx    |   1 +
 .../airflow/ui/src/pages/Events/Events.test.tsx    |  54 +++++++-
 .../src/airflow/ui/src/pages/Events/Events.tsx     |  10 +-
 .../airflow/ui/src/utils/executionParams.test.ts   |   6 +
 .../src/airflow/ui/src/utils/executionParams.ts    |   4 +-
 .../core_api/routes/public/test_event_logs.py      |  78 +++++++++++
 .../src/airflowctl/api/datamodels/generated.py     |  31 ++++-
 20 files changed, 516 insertions(+), 58 deletions(-)

diff --git 
a/airflow-core/src/airflow/api_fastapi/core_api/datamodels/event_logs.py 
b/airflow-core/src/airflow/api_fastapi/core_api/datamodels/event_logs.py
index acc54847204..6c97f711e38 100644
--- a/airflow-core/src/airflow/api_fastapi/core_api/datamodels/event_logs.py
+++ b/airflow-core/src/airflow/api_fastapi/core_api/datamodels/event_logs.py
@@ -52,7 +52,26 @@ class EventLogResponse(BaseModel):
 
 
 class EventLogCollectionResponse(BaseModel):
-    """Event Log Collection Response."""
+    """Event Log collection response supporting both offset and cursor 
pagination."""
 
     event_logs: Iterable[EventLogResponse]
-    total_entries: int
+    total_entries: int = Field(
+        description="Number of matching items. For offset pagination this is 
the exact total. "
+        "For cursor pagination it is capped at ``total_entries_limit``; a 
value equal to that "
+        "limit means at least that many items match.",
+    )
+    total_entries_limit: int | None = Field(
+        default=None,
+        description="Cap applied to ``total_entries`` under cursor pagination. 
``null`` for offset "
+        "pagination, where ``total_entries`` is exact.",
+    )
+    next_cursor: str | None = Field(
+        default=None,
+        description="Token pointing to the next page. Populated for cursor 
pagination, "
+        "``null`` when using offset pagination or when there is no next page.",
+    )
+    previous_cursor: str | None = Field(
+        default=None,
+        description="Token pointing to the previous page. Populated for cursor 
pagination, "
+        "``null`` when using offset pagination or when on the first page.",
+    )
diff --git 
a/airflow-core/src/airflow/api_fastapi/core_api/openapi/v2-rest-api-generated.yaml
 
b/airflow-core/src/airflow/api_fastapi/core_api/openapi/v2-rest-api-generated.yaml
index f0761e25437..2b2894a1515 100644
--- 
a/airflow-core/src/airflow/api_fastapi/core_api/openapi/v2-rest-api-generated.yaml
+++ 
b/airflow-core/src/airflow/api_fastapi/core_api/openapi/v2-rest-api-generated.yaml
@@ -4816,7 +4816,28 @@ paths:
       tags:
       - Event Log
       summary: Get Event Logs
-      description: Get all Event Logs.
+      description: 'Get all Event Logs.
+
+
+        Supports two pagination modes:
+
+
+        **Offset (default):** use `limit` and `offset` query parameters. 
Returns `total_entries`.
+
+
+        **Cursor:** pass `cursor` (empty string for the first page, then 
`next_cursor`
+        from the response).
+
+        When `cursor` is provided, `offset` is ignored and `total_entries` is 
capped
+        at
+
+        `total_entries_limit` (a value equal to that limit means at least that 
many
+        events match).
+
+        ``next_cursor`` is ``null`` when there are no more pages; 
``previous_cursor``
+        is ``null`` on
+
+        the first page.'
       operationId: get_event_logs
       security:
       - OAuth2PasswordBearer: []
@@ -4840,6 +4861,20 @@ paths:
             minimum: -1
           - type: 'null'
           title: Region Index
+      - name: cursor
+        in: query
+        required: false
+        schema:
+          anyOf:
+          - type: string
+          - type: 'null'
+          description: Cursor for keyset-based pagination. Pass an empty 
string for
+            the first page, then use ``next_cursor`` from the response. When 
``cursor``
+            is provided, ``offset`` is ignored.
+          title: Cursor
+        description: Cursor for keyset-based pagination. Pass an empty string 
for
+          the first page, then use ``next_cursor`` from the response. When 
``cursor``
+          is provided, ``offset`` is ignored.
       - name: limit
         in: query
         required: false
@@ -16336,12 +16371,37 @@ components:
         total_entries:
           type: integer
           title: Total Entries
+          description: Number of matching items. For offset pagination this is 
the
+            exact total. For cursor pagination it is capped at 
``total_entries_limit``;
+            a value equal to that limit means at least that many items match.
+        total_entries_limit:
+          anyOf:
+          - type: integer
+          - type: 'null'
+          title: Total Entries Limit
+          description: Cap applied to ``total_entries`` under cursor 
pagination. ``null``
+            for offset pagination, where ``total_entries`` is exact.
+        next_cursor:
+          anyOf:
+          - type: string
+          - type: 'null'
+          title: Next Cursor
+          description: Token pointing to the next page. Populated for cursor 
pagination,
+            ``null`` when using offset pagination or when there is no next 
page.
+        previous_cursor:
+          anyOf:
+          - type: string
+          - type: 'null'
+          title: Previous Cursor
+          description: Token pointing to the previous page. Populated for 
cursor pagination,
+            ``null`` when using offset pagination or when on the first page.
       type: object
       required:
       - event_logs
       - total_entries
       title: EventLogCollectionResponse
-      description: Event Log Collection Response.
+      description: Event Log collection response supporting both offset and 
cursor
+        pagination.
     EventLogResponse:
       properties:
         event_log_id:
diff --git 
a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/event_logs.py 
b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/event_logs.py
index b2084461909..610ec4b804c 100644
--- a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/event_logs.py
+++ b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/event_logs.py
@@ -17,20 +17,29 @@
 from __future__ import annotations
 
 from datetime import datetime
-from typing import TYPE_CHECKING, Annotated
+from typing import TYPE_CHECKING, Annotated, cast
 from uuid import UUID
 
 from fastapi import Depends, HTTPException, Query, status
 from sqlalchemy import select
 from sqlalchemy.orm import joinedload
 
+from airflow.api_fastapi.common.cursors import (
+    apply_cursor_filter,
+    encode_cursor,
+    make_backward_cursor,
+    parse_cursor,
+)
 from airflow.api_fastapi.common.db.common import (
     SessionDep,
+    apply_filters_to_select,
+    bounded_total_entries,
     paginated_select,
 )
 from airflow.api_fastapi.common.parameters import (
     FilterOptionEnum,
     FilterParam,
+    LimitFilter,
     QueryLimit,
     QueryOffset,
     SortParam,
@@ -56,6 +65,8 @@ from airflow.models import DagModel, Log, TaskInstance
 if TYPE_CHECKING:
     from sqlalchemy.orm.interfaces import LoaderOption
 
+    from airflow.api_fastapi.core_api.base import OrmClause
+
 event_logs_router = AirflowRouter(tags=["Event Log"], prefix="/eventLogs")
 
 
@@ -208,8 +219,28 @@ def get_event_logs(
     readable_event_logs_filter: ReadableEventLogsFilterDep,
     region_id: Annotated[UUID | None, Query()] = None,
     region_index: Annotated[int | None, Query(ge=-1)] = None,
+    cursor: Annotated[
+        str | None,
+        Query(
+            description="Cursor for keyset-based pagination. "
+            "Pass an empty string for the first page, then use ``next_cursor`` 
from the response. "
+            "When ``cursor`` is provided, ``offset`` is ignored.",
+        ),
+    ] = None,
 ) -> EventLogCollectionResponse:
-    """Get all Event Logs."""
+    """
+    Get all Event Logs.
+
+    Supports two pagination modes:
+
+    **Offset (default):** use `limit` and `offset` query parameters. Returns 
`total_entries`.
+
+    **Cursor:** pass `cursor` (empty string for the first page, then 
`next_cursor` from the response).
+    When `cursor` is provided, `offset` is ignored and `total_entries` is 
capped at
+    `total_entries_limit` (a value equal to that limit means at least that 
many events match).
+    ``next_cursor`` is ``null`` when there are no more pages; 
``previous_cursor`` is ``null`` on
+    the first page.
+    """
     query = (
         # Log.dttm is nullable at the DB level, but EventLogResponse.when is a 
non-optional
         # datetime. Rows with dttm=NULL would cause a Pydantic validation 
error (500), so
@@ -228,40 +259,92 @@ def get_event_logs(
         if region_index is not None:
             attempt_ids = attempt_ids.where(attempts.c.region_index == 
region_index)
         query = query.where(Log.task_instance_id.in_(attempt_ids))
+    filters: list[OrmClause] = [
+        # Exact match filters
+        dag_id,
+        task_id,
+        run_id,
+        map_index,
+        try_number,
+        task_instance_id,
+        owner,
+        event,
+        excluded_events,
+        included_events,
+        before,
+        after,
+        # Pattern search filters
+        dag_id_pattern,
+        dag_id_prefix_pattern,
+        task_id_pattern,
+        task_id_prefix_pattern,
+        run_id_pattern,
+        run_id_prefix_pattern,
+        owner_pattern,
+        owner_prefix_pattern,
+        owner_display_name_pattern,
+        owner_display_name_prefix_pattern,
+        event_pattern,
+        event_prefix_pattern,
+        teams,
+        # Permission
+        readable_event_logs_filter,
+    ]
+
+    if cursor is not None:
+        # A cursor carries the row's sort values, and `extra` is unbounded 
text: the token could outgrow
+        # URL limits, and MySQL orders TEXT by a prefix only, so keyset pages 
could skip or repeat rows.
+        if any(value.lstrip("-") == "extra" for value in order_by.value or []):
+            raise HTTPException(
+                status.HTTP_400_BAD_REQUEST, "Sorting by `extra` is not 
supported with cursor pagination"
+            )
+        page_limit = cast("int", limit.value)
+        cursor_limit = LimitFilter().set_value(page_limit + 1)
+        event_logs_select = apply_filters_to_select(statement=query, 
filters=[*filters, cursor_limit])
+        event_logs_select = order_by.to_orm(event_logs_select)
+
+        is_backward = False
+        if cursor:
+            token, is_backward = parse_cursor(cursor)
+            if is_backward:
+                event_logs_select = order_by.to_orm(event_logs_select, 
reversed=True)
+            event_logs_select = apply_cursor_filter(
+                event_logs_select, token, order_by, 
session.get_bind().dialect.name, is_backward=is_backward
+            )
+
+        fetched = list(session.scalars(event_logs_select))
+        has_more = len(fetched) > page_limit
+        page = fetched[:page_limit]
+
+        if is_backward:
+            page.reverse()
+            has_prev = has_more
+            has_next = True
+        else:
+            has_prev = bool(cursor)
+            has_next = has_more
+
+        # Encode before event_log_to_response, which overwrites 
owner_display_name on the row
+        # with a fallback, so a cursor built afterwards would not match the 
stored sort value.
+        next_cursor = encode_cursor(page[-1], order_by) if has_next and page 
else None
+        previous_cursor = (
+            make_backward_cursor(encode_cursor(page[0], order_by)) if has_prev 
and page else None
+        )
+        total_entries, total_entries_limit = bounded_total_entries(
+            statement=query, filters=filters, session=session
+        )
+        return EventLogCollectionResponse(
+            event_logs=[event_log_to_response(event_log=event_log) for 
event_log in page],
+            total_entries=total_entries,
+            total_entries_limit=total_entries_limit,
+            next_cursor=next_cursor,
+            previous_cursor=previous_cursor,
+        )
+
     event_logs_select, total_entries = paginated_select(
         statement=query,
         order_by=order_by,
-        filters=[
-            # Exact match filters
-            dag_id,
-            task_id,
-            run_id,
-            map_index,
-            try_number,
-            task_instance_id,
-            owner,
-            event,
-            excluded_events,
-            included_events,
-            before,
-            after,
-            # Pattern search filters
-            dag_id_pattern,
-            dag_id_prefix_pattern,
-            task_id_pattern,
-            task_id_prefix_pattern,
-            run_id_pattern,
-            run_id_prefix_pattern,
-            owner_pattern,
-            owner_prefix_pattern,
-            owner_display_name_pattern,
-            owner_display_name_prefix_pattern,
-            event_pattern,
-            event_prefix_pattern,
-            teams,
-            # Permission
-            readable_event_logs_filter,
-        ],
+        filters=filters,
         offset=offset,
         limit=limit,
         session=session,
diff --git a/airflow-core/src/airflow/ui/openapi-gen/queries/common.ts 
b/airflow-core/src/airflow/ui/openapi-gen/queries/common.ts
index 755187ecc45..1650926bfba 100644
--- a/airflow-core/src/airflow/ui/openapi-gen/queries/common.ts
+++ b/airflow-core/src/airflow/ui/openapi-gen/queries/common.ts
@@ -517,9 +517,10 @@ export const UseEventLogServiceGetEventLogKeyFn = ({ 
eventLogId }: {
 export type EventLogServiceGetEventLogsDefaultResponse = 
Awaited<ReturnType<typeof EventLogService.getEventLogs>>;
 export type EventLogServiceGetEventLogsQueryResult<TData = 
EventLogServiceGetEventLogsDefaultResponse, TError = unknown> = 
UseQueryResult<TData, TError>;
 export const useEventLogServiceGetEventLogsKey = "EventLogServiceGetEventLogs";
-export const UseEventLogServiceGetEventLogsKeyFn = ({ after, before, dagId, 
dagIdPattern, dagIdPrefixPattern, event, eventPattern, eventPrefixPattern, 
excludedEvents, includedEvents, limit, mapIndex, offset, orderBy, owner, 
ownerDisplayNamePattern, ownerDisplayNamePrefixPattern, ownerPattern, 
ownerPrefixPattern, regionId, regionIndex, runId, runIdPattern, 
runIdPrefixPattern, taskId, taskIdPattern, taskIdPrefixPattern, taskInstanceId, 
teams, tryNumber }: {
+export const UseEventLogServiceGetEventLogsKeyFn = ({ after, before, cursor, 
dagId, dagIdPattern, dagIdPrefixPattern, event, eventPattern, 
eventPrefixPattern, excludedEvents, includedEvents, limit, mapIndex, offset, 
orderBy, owner, ownerDisplayNamePattern, ownerDisplayNamePrefixPattern, 
ownerPattern, ownerPrefixPattern, regionId, regionIndex, runId, runIdPattern, 
runIdPrefixPattern, taskId, taskIdPattern, taskIdPrefixPattern, taskInstanceId, 
teams, tryNumber }: {
   after?: string;
   before?: string;
+  cursor?: string;
   dagId?: string;
   dagIdPattern?: string;
   dagIdPrefixPattern?: string;
@@ -548,7 +549,7 @@ export const UseEventLogServiceGetEventLogsKeyFn = ({ 
after, before, dagId, dagI
   taskInstanceId?: string;
   teams?: string[];
   tryNumber?: number;
-} = {}, queryKey?: Array<unknown>) => [useEventLogServiceGetEventLogsKey, 
...(queryKey ?? [{ after, before, dagId, dagIdPattern, dagIdPrefixPattern, 
event, eventPattern, eventPrefixPattern, excludedEvents, includedEvents, limit, 
mapIndex, offset, orderBy, owner, ownerDisplayNamePattern, 
ownerDisplayNamePrefixPattern, ownerPattern, ownerPrefixPattern, regionId, 
regionIndex, runId, runIdPattern, runIdPrefixPattern, taskId, taskIdPattern, 
taskIdPrefixPattern, taskInstanceId, teams, tryNumber }])];
+} = {}, queryKey?: Array<unknown>) => [useEventLogServiceGetEventLogsKey, 
...(queryKey ?? [{ after, before, cursor, dagId, dagIdPattern, 
dagIdPrefixPattern, event, eventPattern, eventPrefixPattern, excludedEvents, 
includedEvents, limit, mapIndex, offset, orderBy, owner, 
ownerDisplayNamePattern, ownerDisplayNamePrefixPattern, ownerPattern, 
ownerPrefixPattern, regionId, regionIndex, runId, runIdPattern, 
runIdPrefixPattern, taskId, taskIdPattern, taskIdPrefixPattern, taskInstanceId, 
teams,  [...]
 export type ExtraLinksServiceGetExtraLinksDefaultResponse = 
Awaited<ReturnType<typeof ExtraLinksService.getExtraLinks>>;
 export type ExtraLinksServiceGetExtraLinksQueryResult<TData = 
ExtraLinksServiceGetExtraLinksDefaultResponse, TError = unknown> = 
UseQueryResult<TData, TError>;
 export const useExtraLinksServiceGetExtraLinksKey = 
"ExtraLinksServiceGetExtraLinks";
diff --git a/airflow-core/src/airflow/ui/openapi-gen/queries/ensureQueryData.ts 
b/airflow-core/src/airflow/ui/openapi-gen/queries/ensureQueryData.ts
index 6947aba7e41..0690dac2d82 100644
--- a/airflow-core/src/airflow/ui/openapi-gen/queries/ensureQueryData.ts
+++ b/airflow-core/src/airflow/ui/openapi-gen/queries/ensureQueryData.ts
@@ -1034,9 +1034,20 @@ export const ensureUseEventLogServiceGetEventLogData = 
(queryClient: QueryClient
 /**
 * Get Event Logs
 * Get all Event Logs.
+*
+* Supports two pagination modes:
+*
+* **Offset (default):** use `limit` and `offset` query parameters. Returns 
`total_entries`.
+*
+* **Cursor:** pass `cursor` (empty string for the first page, then 
`next_cursor` from the response).
+* When `cursor` is provided, `offset` is ignored and `total_entries` is capped 
at
+* `total_entries_limit` (a value equal to that limit means at least that many 
events match).
+* ``next_cursor`` is ``null`` when there are no more pages; 
``previous_cursor`` is ``null`` on
+* the first page.
 * @param data The data for the request.
 * @param data.regionId
 * @param data.regionIndex
+* @param data.cursor Cursor for keyset-based pagination. Pass an empty string 
for the first page, then use ``next_cursor`` from the response. When ``cursor`` 
is provided, ``offset`` is ignored.
 * @param data.limit
 * @param data.offset
 * @param data.orderBy Attributes to order by, multi criteria sort is 
supported. Prefix with `-` for descending order. Supported attributes: `id, 
dttm, dag_id, task_id, run_id, event, logical_date, owner, owner_display_name, 
extra, when, event_log_id`
@@ -1068,9 +1079,10 @@ export const ensureUseEventLogServiceGetEventLogData = 
(queryClient: QueryClient
 * @returns EventLogCollectionResponse Successful Response
 * @throws ApiError
 */
-export const ensureUseEventLogServiceGetEventLogsData = (queryClient: 
QueryClient, { after, before, dagId, dagIdPattern, dagIdPrefixPattern, event, 
eventPattern, eventPrefixPattern, excludedEvents, includedEvents, limit, 
mapIndex, offset, orderBy, owner, ownerDisplayNamePattern, 
ownerDisplayNamePrefixPattern, ownerPattern, ownerPrefixPattern, regionId, 
regionIndex, runId, runIdPattern, runIdPrefixPattern, taskId, taskIdPattern, 
taskIdPrefixPattern, taskInstanceId, teams, tryNumber }: {
+export const ensureUseEventLogServiceGetEventLogsData = (queryClient: 
QueryClient, { after, before, cursor, dagId, dagIdPattern, dagIdPrefixPattern, 
event, eventPattern, eventPrefixPattern, excludedEvents, includedEvents, limit, 
mapIndex, offset, orderBy, owner, ownerDisplayNamePattern, 
ownerDisplayNamePrefixPattern, ownerPattern, ownerPrefixPattern, regionId, 
regionIndex, runId, runIdPattern, runIdPrefixPattern, taskId, taskIdPattern, 
taskIdPrefixPattern, taskInstanceId, teams, tryNumber }: {
   after?: string;
   before?: string;
+  cursor?: string;
   dagId?: string;
   dagIdPattern?: string;
   dagIdPrefixPattern?: string;
@@ -1099,7 +1111,7 @@ export const ensureUseEventLogServiceGetEventLogsData = 
(queryClient: QueryClien
   taskInstanceId?: string;
   teams?: string[];
   tryNumber?: number;
-} = {}) => queryClient.ensureQueryData({ queryKey: 
Common.UseEventLogServiceGetEventLogsKeyFn({ after, before, dagId, 
dagIdPattern, dagIdPrefixPattern, event, eventPattern, eventPrefixPattern, 
excludedEvents, includedEvents, limit, mapIndex, offset, orderBy, owner, 
ownerDisplayNamePattern, ownerDisplayNamePrefixPattern, ownerPattern, 
ownerPrefixPattern, regionId, regionIndex, runId, runIdPattern, 
runIdPrefixPattern, taskId, taskIdPattern, taskIdPrefixPattern, taskInstanceId, 
teams, tryNu [...]
+} = {}) => queryClient.ensureQueryData({ queryKey: 
Common.UseEventLogServiceGetEventLogsKeyFn({ after, before, cursor, dagId, 
dagIdPattern, dagIdPrefixPattern, event, eventPattern, eventPrefixPattern, 
excludedEvents, includedEvents, limit, mapIndex, offset, orderBy, owner, 
ownerDisplayNamePattern, ownerDisplayNamePrefixPattern, ownerPattern, 
ownerPrefixPattern, regionId, regionIndex, runId, runIdPattern, 
runIdPrefixPattern, taskId, taskIdPattern, taskIdPrefixPattern, taskInstanceId, 
team [...]
 /**
 * Get Extra Links
 * Get extra links for task instance.
diff --git a/airflow-core/src/airflow/ui/openapi-gen/queries/prefetch.ts 
b/airflow-core/src/airflow/ui/openapi-gen/queries/prefetch.ts
index 4050ad9bcb6..a1d917ae729 100644
--- a/airflow-core/src/airflow/ui/openapi-gen/queries/prefetch.ts
+++ b/airflow-core/src/airflow/ui/openapi-gen/queries/prefetch.ts
@@ -1034,9 +1034,20 @@ export const prefetchUseEventLogServiceGetEventLog = 
(queryClient: QueryClient,
 /**
 * Get Event Logs
 * Get all Event Logs.
+*
+* Supports two pagination modes:
+*
+* **Offset (default):** use `limit` and `offset` query parameters. Returns 
`total_entries`.
+*
+* **Cursor:** pass `cursor` (empty string for the first page, then 
`next_cursor` from the response).
+* When `cursor` is provided, `offset` is ignored and `total_entries` is capped 
at
+* `total_entries_limit` (a value equal to that limit means at least that many 
events match).
+* ``next_cursor`` is ``null`` when there are no more pages; 
``previous_cursor`` is ``null`` on
+* the first page.
 * @param data The data for the request.
 * @param data.regionId
 * @param data.regionIndex
+* @param data.cursor Cursor for keyset-based pagination. Pass an empty string 
for the first page, then use ``next_cursor`` from the response. When ``cursor`` 
is provided, ``offset`` is ignored.
 * @param data.limit
 * @param data.offset
 * @param data.orderBy Attributes to order by, multi criteria sort is 
supported. Prefix with `-` for descending order. Supported attributes: `id, 
dttm, dag_id, task_id, run_id, event, logical_date, owner, owner_display_name, 
extra, when, event_log_id`
@@ -1068,9 +1079,10 @@ export const prefetchUseEventLogServiceGetEventLog = 
(queryClient: QueryClient,
 * @returns EventLogCollectionResponse Successful Response
 * @throws ApiError
 */
-export const prefetchUseEventLogServiceGetEventLogs = (queryClient: 
QueryClient, { after, before, dagId, dagIdPattern, dagIdPrefixPattern, event, 
eventPattern, eventPrefixPattern, excludedEvents, includedEvents, limit, 
mapIndex, offset, orderBy, owner, ownerDisplayNamePattern, 
ownerDisplayNamePrefixPattern, ownerPattern, ownerPrefixPattern, regionId, 
regionIndex, runId, runIdPattern, runIdPrefixPattern, taskId, taskIdPattern, 
taskIdPrefixPattern, taskInstanceId, teams, tryNumber }: {
+export const prefetchUseEventLogServiceGetEventLogs = (queryClient: 
QueryClient, { after, before, cursor, dagId, dagIdPattern, dagIdPrefixPattern, 
event, eventPattern, eventPrefixPattern, excludedEvents, includedEvents, limit, 
mapIndex, offset, orderBy, owner, ownerDisplayNamePattern, 
ownerDisplayNamePrefixPattern, ownerPattern, ownerPrefixPattern, regionId, 
regionIndex, runId, runIdPattern, runIdPrefixPattern, taskId, taskIdPattern, 
taskIdPrefixPattern, taskInstanceId, teams, tryNumber }: {
   after?: string;
   before?: string;
+  cursor?: string;
   dagId?: string;
   dagIdPattern?: string;
   dagIdPrefixPattern?: string;
@@ -1099,7 +1111,7 @@ export const prefetchUseEventLogServiceGetEventLogs = 
(queryClient: QueryClient,
   taskInstanceId?: string;
   teams?: string[];
   tryNumber?: number;
-} = {}) => queryClient.prefetchQuery({ queryKey: 
Common.UseEventLogServiceGetEventLogsKeyFn({ after, before, dagId, 
dagIdPattern, dagIdPrefixPattern, event, eventPattern, eventPrefixPattern, 
excludedEvents, includedEvents, limit, mapIndex, offset, orderBy, owner, 
ownerDisplayNamePattern, ownerDisplayNamePrefixPattern, ownerPattern, 
ownerPrefixPattern, regionId, regionIndex, runId, runIdPattern, 
runIdPrefixPattern, taskId, taskIdPattern, taskIdPrefixPattern, taskInstanceId, 
teams, tryNumb [...]
+} = {}) => queryClient.prefetchQuery({ queryKey: 
Common.UseEventLogServiceGetEventLogsKeyFn({ after, before, cursor, dagId, 
dagIdPattern, dagIdPrefixPattern, event, eventPattern, eventPrefixPattern, 
excludedEvents, includedEvents, limit, mapIndex, offset, orderBy, owner, 
ownerDisplayNamePattern, ownerDisplayNamePrefixPattern, ownerPattern, 
ownerPrefixPattern, regionId, regionIndex, runId, runIdPattern, 
runIdPrefixPattern, taskId, taskIdPattern, taskIdPrefixPattern, taskInstanceId, 
teams, [...]
 /**
 * Get Extra Links
 * Get extra links for task instance.
diff --git a/airflow-core/src/airflow/ui/openapi-gen/queries/queries.ts 
b/airflow-core/src/airflow/ui/openapi-gen/queries/queries.ts
index 3889c3830ab..146eb70ded1 100644
--- a/airflow-core/src/airflow/ui/openapi-gen/queries/queries.ts
+++ b/airflow-core/src/airflow/ui/openapi-gen/queries/queries.ts
@@ -1034,9 +1034,20 @@ export const useEventLogServiceGetEventLog = <TData = 
Common.EventLogServiceGetE
 /**
 * Get Event Logs
 * Get all Event Logs.
+*
+* Supports two pagination modes:
+*
+* **Offset (default):** use `limit` and `offset` query parameters. Returns 
`total_entries`.
+*
+* **Cursor:** pass `cursor` (empty string for the first page, then 
`next_cursor` from the response).
+* When `cursor` is provided, `offset` is ignored and `total_entries` is capped 
at
+* `total_entries_limit` (a value equal to that limit means at least that many 
events match).
+* ``next_cursor`` is ``null`` when there are no more pages; 
``previous_cursor`` is ``null`` on
+* the first page.
 * @param data The data for the request.
 * @param data.regionId
 * @param data.regionIndex
+* @param data.cursor Cursor for keyset-based pagination. Pass an empty string 
for the first page, then use ``next_cursor`` from the response. When ``cursor`` 
is provided, ``offset`` is ignored.
 * @param data.limit
 * @param data.offset
 * @param data.orderBy Attributes to order by, multi criteria sort is 
supported. Prefix with `-` for descending order. Supported attributes: `id, 
dttm, dag_id, task_id, run_id, event, logical_date, owner, owner_display_name, 
extra, when, event_log_id`
@@ -1068,9 +1079,10 @@ export const useEventLogServiceGetEventLog = <TData = 
Common.EventLogServiceGetE
 * @returns EventLogCollectionResponse Successful Response
 * @throws ApiError
 */
-export const useEventLogServiceGetEventLogs = <TData = 
Common.EventLogServiceGetEventLogsDefaultResponse, TError = unknown, TQueryKey 
extends Array<unknown> = unknown[]>({ after, before, dagId, dagIdPattern, 
dagIdPrefixPattern, event, eventPattern, eventPrefixPattern, excludedEvents, 
includedEvents, limit, mapIndex, offset, orderBy, owner, 
ownerDisplayNamePattern, ownerDisplayNamePrefixPattern, ownerPattern, 
ownerPrefixPattern, regionId, regionIndex, runId, runIdPattern, 
runIdPrefixPatte [...]
+export const useEventLogServiceGetEventLogs = <TData = 
Common.EventLogServiceGetEventLogsDefaultResponse, TError = unknown, TQueryKey 
extends Array<unknown> = unknown[]>({ after, before, cursor, dagId, 
dagIdPattern, dagIdPrefixPattern, event, eventPattern, eventPrefixPattern, 
excludedEvents, includedEvents, limit, mapIndex, offset, orderBy, owner, 
ownerDisplayNamePattern, ownerDisplayNamePrefixPattern, ownerPattern, 
ownerPrefixPattern, regionId, regionIndex, runId, runIdPattern, runIdPre [...]
   after?: string;
   before?: string;
+  cursor?: string;
   dagId?: string;
   dagIdPattern?: string;
   dagIdPrefixPattern?: string;
@@ -1099,7 +1111,7 @@ export const useEventLogServiceGetEventLogs = <TData = 
Common.EventLogServiceGet
   taskInstanceId?: string;
   teams?: string[];
   tryNumber?: number;
-} = {}, queryKey?: TQueryKey, options?: Omit<UseQueryOptions<TData, TError>, 
"queryKey" | "queryFn">) => useQuery<TData, TError>({ queryKey: 
Common.UseEventLogServiceGetEventLogsKeyFn({ after, before, dagId, 
dagIdPattern, dagIdPrefixPattern, event, eventPattern, eventPrefixPattern, 
excludedEvents, includedEvents, limit, mapIndex, offset, orderBy, owner, 
ownerDisplayNamePattern, ownerDisplayNamePrefixPattern, ownerPattern, 
ownerPrefixPattern, regionId, regionIndex, runId, runIdPattern, ru [...]
+} = {}, queryKey?: TQueryKey, options?: Omit<UseQueryOptions<TData, TError>, 
"queryKey" | "queryFn">) => useQuery<TData, TError>({ queryKey: 
Common.UseEventLogServiceGetEventLogsKeyFn({ after, before, cursor, dagId, 
dagIdPattern, dagIdPrefixPattern, event, eventPattern, eventPrefixPattern, 
excludedEvents, includedEvents, limit, mapIndex, offset, orderBy, owner, 
ownerDisplayNamePattern, ownerDisplayNamePrefixPattern, ownerPattern, 
ownerPrefixPattern, regionId, regionIndex, runId, runIdPat [...]
 /**
 * Get Extra Links
 * Get extra links for task instance.
diff --git a/airflow-core/src/airflow/ui/openapi-gen/queries/suspense.ts 
b/airflow-core/src/airflow/ui/openapi-gen/queries/suspense.ts
index 6d17db89303..33c91ac6867 100644
--- a/airflow-core/src/airflow/ui/openapi-gen/queries/suspense.ts
+++ b/airflow-core/src/airflow/ui/openapi-gen/queries/suspense.ts
@@ -1034,9 +1034,20 @@ export const useEventLogServiceGetEventLogSuspense = 
<TData = Common.EventLogSer
 /**
 * Get Event Logs
 * Get all Event Logs.
+*
+* Supports two pagination modes:
+*
+* **Offset (default):** use `limit` and `offset` query parameters. Returns 
`total_entries`.
+*
+* **Cursor:** pass `cursor` (empty string for the first page, then 
`next_cursor` from the response).
+* When `cursor` is provided, `offset` is ignored and `total_entries` is capped 
at
+* `total_entries_limit` (a value equal to that limit means at least that many 
events match).
+* ``next_cursor`` is ``null`` when there are no more pages; 
``previous_cursor`` is ``null`` on
+* the first page.
 * @param data The data for the request.
 * @param data.regionId
 * @param data.regionIndex
+* @param data.cursor Cursor for keyset-based pagination. Pass an empty string 
for the first page, then use ``next_cursor`` from the response. When ``cursor`` 
is provided, ``offset`` is ignored.
 * @param data.limit
 * @param data.offset
 * @param data.orderBy Attributes to order by, multi criteria sort is 
supported. Prefix with `-` for descending order. Supported attributes: `id, 
dttm, dag_id, task_id, run_id, event, logical_date, owner, owner_display_name, 
extra, when, event_log_id`
@@ -1068,9 +1079,10 @@ export const useEventLogServiceGetEventLogSuspense = 
<TData = Common.EventLogSer
 * @returns EventLogCollectionResponse Successful Response
 * @throws ApiError
 */
-export const useEventLogServiceGetEventLogsSuspense = <TData = 
Common.EventLogServiceGetEventLogsDefaultResponse, TError = unknown, TQueryKey 
extends Array<unknown> = unknown[]>({ after, before, dagId, dagIdPattern, 
dagIdPrefixPattern, event, eventPattern, eventPrefixPattern, excludedEvents, 
includedEvents, limit, mapIndex, offset, orderBy, owner, 
ownerDisplayNamePattern, ownerDisplayNamePrefixPattern, ownerPattern, 
ownerPrefixPattern, regionId, regionIndex, runId, runIdPattern, runIdPre [...]
+export const useEventLogServiceGetEventLogsSuspense = <TData = 
Common.EventLogServiceGetEventLogsDefaultResponse, TError = unknown, TQueryKey 
extends Array<unknown> = unknown[]>({ after, before, cursor, dagId, 
dagIdPattern, dagIdPrefixPattern, event, eventPattern, eventPrefixPattern, 
excludedEvents, includedEvents, limit, mapIndex, offset, orderBy, owner, 
ownerDisplayNamePattern, ownerDisplayNamePrefixPattern, ownerPattern, 
ownerPrefixPattern, regionId, regionIndex, runId, runIdPattern,  [...]
   after?: string;
   before?: string;
+  cursor?: string;
   dagId?: string;
   dagIdPattern?: string;
   dagIdPrefixPattern?: string;
@@ -1099,7 +1111,7 @@ export const useEventLogServiceGetEventLogsSuspense = 
<TData = Common.EventLogSe
   taskInstanceId?: string;
   teams?: string[];
   tryNumber?: number;
-} = {}, queryKey?: TQueryKey, options?: Omit<UseQueryOptions<TData, TError>, 
"queryKey" | "queryFn">) => useSuspenseQuery<TData, TError>({ queryKey: 
Common.UseEventLogServiceGetEventLogsKeyFn({ after, before, dagId, 
dagIdPattern, dagIdPrefixPattern, event, eventPattern, eventPrefixPattern, 
excludedEvents, includedEvents, limit, mapIndex, offset, orderBy, owner, 
ownerDisplayNamePattern, ownerDisplayNamePrefixPattern, ownerPattern, 
ownerPrefixPattern, regionId, regionIndex, runId, runIdPat [...]
+} = {}, queryKey?: TQueryKey, options?: Omit<UseQueryOptions<TData, TError>, 
"queryKey" | "queryFn">) => useSuspenseQuery<TData, TError>({ queryKey: 
Common.UseEventLogServiceGetEventLogsKeyFn({ after, before, cursor, dagId, 
dagIdPattern, dagIdPrefixPattern, event, eventPattern, eventPrefixPattern, 
excludedEvents, includedEvents, limit, mapIndex, offset, orderBy, owner, 
ownerDisplayNamePattern, ownerDisplayNamePrefixPattern, ownerPattern, 
ownerPrefixPattern, regionId, regionIndex, runId,  [...]
 /**
 * Get Extra Links
 * Get extra links for task instance.
diff --git a/airflow-core/src/airflow/ui/openapi-gen/requests/schemas.gen.ts 
b/airflow-core/src/airflow/ui/openapi-gen/requests/schemas.gen.ts
index c4be2450de3..976e9b934e3 100644
--- a/airflow-core/src/airflow/ui/openapi-gen/requests/schemas.gen.ts
+++ b/airflow-core/src/airflow/ui/openapi-gen/requests/schemas.gen.ts
@@ -5709,13 +5709,50 @@ export const $EventLogCollectionResponse = {
         },
         total_entries: {
             type: 'integer',
-            title: 'Total Entries'
+            title: 'Total Entries',
+            description: 'Number of matching items. For offset pagination this 
is the exact total. For cursor pagination it is capped at 
``total_entries_limit``; a value equal to that limit means at least that many 
items match.'
+        },
+        total_entries_limit: {
+            anyOf: [
+                {
+                    type: 'integer'
+                },
+                {
+                    type: 'null'
+                }
+            ],
+            title: 'Total Entries Limit',
+            description: 'Cap applied to ``total_entries`` under cursor 
pagination. ``null`` for offset pagination, where ``total_entries`` is exact.'
+        },
+        next_cursor: {
+            anyOf: [
+                {
+                    type: 'string'
+                },
+                {
+                    type: 'null'
+                }
+            ],
+            title: 'Next Cursor',
+            description: 'Token pointing to the next page. Populated for 
cursor pagination, ``null`` when using offset pagination or when there is no 
next page.'
+        },
+        previous_cursor: {
+            anyOf: [
+                {
+                    type: 'string'
+                },
+                {
+                    type: 'null'
+                }
+            ],
+            title: 'Previous Cursor',
+            description: 'Token pointing to the previous page. Populated for 
cursor pagination, ``null`` when using offset pagination or when on the first 
page.'
         }
     },
     type: 'object',
     required: ['event_logs', 'total_entries'],
     title: 'EventLogCollectionResponse',
-    description: 'Event Log Collection Response.'
+    description: 'Event Log collection response supporting both offset and 
cursor pagination.'
 } as const;
 
 export const $EventLogResponse = {
diff --git a/airflow-core/src/airflow/ui/openapi-gen/requests/services.gen.ts 
b/airflow-core/src/airflow/ui/openapi-gen/requests/services.gen.ts
index 495e9d7856a..ad506c081b0 100644
--- a/airflow-core/src/airflow/ui/openapi-gen/requests/services.gen.ts
+++ b/airflow-core/src/airflow/ui/openapi-gen/requests/services.gen.ts
@@ -2509,9 +2509,20 @@ export class EventLogService {
     /**
      * Get Event Logs
      * Get all Event Logs.
+     *
+     * Supports two pagination modes:
+     *
+     * **Offset (default):** use `limit` and `offset` query parameters. 
Returns `total_entries`.
+     *
+     * **Cursor:** pass `cursor` (empty string for the first page, then 
`next_cursor` from the response).
+     * When `cursor` is provided, `offset` is ignored and `total_entries` is 
capped at
+     * `total_entries_limit` (a value equal to that limit means at least that 
many events match).
+     * ``next_cursor`` is ``null`` when there are no more pages; 
``previous_cursor`` is ``null`` on
+     * the first page.
      * @param data The data for the request.
      * @param data.regionId
      * @param data.regionIndex
+     * @param data.cursor Cursor for keyset-based pagination. Pass an empty 
string for the first page, then use ``next_cursor`` from the response. When 
``cursor`` is provided, ``offset`` is ignored.
      * @param data.limit
      * @param data.offset
      * @param data.orderBy Attributes to order by, multi criteria sort is 
supported. Prefix with `-` for descending order. Supported attributes: `id, 
dttm, dag_id, task_id, run_id, event, logical_date, owner, owner_display_name, 
extra, when, event_log_id`
@@ -2550,6 +2561,7 @@ export class EventLogService {
             query: {
                 region_id: data.regionId,
                 region_index: data.regionIndex,
+                cursor: data.cursor,
                 limit: data.limit,
                 offset: data.offset,
                 order_by: data.orderBy,
diff --git a/airflow-core/src/airflow/ui/openapi-gen/requests/types.gen.ts 
b/airflow-core/src/airflow/ui/openapi-gen/requests/types.gen.ts
index 5031b528018..de23bc7ee04 100644
--- a/airflow-core/src/airflow/ui/openapi-gen/requests/types.gen.ts
+++ b/airflow-core/src/airflow/ui/openapi-gen/requests/types.gen.ts
@@ -1580,11 +1580,26 @@ export type DryRunBackfillResponse = {
 };
 
 /**
- * Event Log Collection Response.
+ * Event Log collection response supporting both offset and cursor pagination.
  */
 export type EventLogCollectionResponse = {
     event_logs: Array<EventLogResponse>;
+    /**
+     * Number of matching items. For offset pagination this is the exact 
total. For cursor pagination it is capped at ``total_entries_limit``; a value 
equal to that limit means at least that many items match.
+     */
     total_entries: number;
+    /**
+     * Cap applied to ``total_entries`` under cursor pagination. ``null`` for 
offset pagination, where ``total_entries`` is exact.
+     */
+    total_entries_limit?: number | null;
+    /**
+     * Token pointing to the next page. Populated for cursor pagination, 
``null`` when using offset pagination or when there is no next page.
+     */
+    next_cursor?: string | null;
+    /**
+     * Token pointing to the previous page. Populated for cursor pagination, 
``null`` when using offset pagination or when on the first page.
+     */
+    previous_cursor?: string | null;
 };
 
 /**
@@ -4470,6 +4485,10 @@ export type GetEventLogResponse = EventLogResponse;
 export type GetEventLogsData = {
     after?: string | null;
     before?: string | null;
+    /**
+     * Cursor for keyset-based pagination. Pass an empty string for the first 
page, then use ``next_cursor`` from the response. When ``cursor`` is provided, 
``offset`` is ignored.
+     */
+    cursor?: string | null;
     dagId?: string | null;
     /**
      * Case-insensitive substring match (SQL `ILIKE`). Slower than 
`dag_id_prefix_pattern` on large tables — see "Filtering with pattern 
parameters".
diff --git a/airflow-core/src/airflow/ui/src/constants/filterConfigs.tsx 
b/airflow-core/src/airflow/ui/src/constants/filterConfigs.tsx
index 998f5ebc312..af92a2005f7 100644
--- a/airflow-core/src/airflow/ui/src/constants/filterConfigs.tsx
+++ b/airflow-core/src/airflow/ui/src/constants/filterConfigs.tsx
@@ -227,7 +227,7 @@ export const useFilterConfigs = () => {
     [SearchParamsKeys.EVENT_DATE_RANGE]: {
       endKey: SearchParamsKeys.BEFORE,
       icon: <MdDateRange />,
-      label: translate("common:logicalDate"),
+      label: translate("browse:auditLog.columns.when"),
       startKey: SearchParamsKeys.AFTER,
       type: FilterTypes.DATERANGE,
     },
diff --git 
a/airflow-core/src/airflow/ui/src/layouts/Details/SearchMapIndexes.test.tsx 
b/airflow-core/src/airflow/ui/src/layouts/Details/SearchMapIndexes.test.tsx
index 574d0bd237f..4d4e2f23adb 100644
--- a/airflow-core/src/airflow/ui/src/layouts/Details/SearchMapIndexes.test.tsx
+++ b/airflow-core/src/airflow/ui/src/layouts/Details/SearchMapIndexes.test.tsx
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+import "@testing-library/jest-dom/vitest";
 import { fireEvent, render, screen, waitFor } from "@testing-library/react";
 import { MemoryRouter, Route, Routes, useLocation } from "react-router-dom";
 import { afterEach, describe, expect, it, vi } from "vitest";
@@ -131,6 +132,14 @@ describe("SearchMapIndexes", () => {
     
expect(screen.getByTestId("search").textContent).toBe(`?region_id=${REGION_ID}`);
   });
 
+  it("opens all map indexes on their first page", () => {
+    
renderSearch("/dags/my_dag/runs/run_1/tasks/task_1/mapped/2?cursor=page-2", 
MAPPED_ROUTE);
+
+    fireEvent.click(screen.getByRole("button", { name: "allMapIndexes" }));
+
+    expect(screen.getByTestId("search").textContent).toBe("");
+  });
+
   it("switches to the selected instance and closes the panel", () => {
     renderSearch("/dags/my_dag/runs/run_1/tasks/task_1/mapped/2", 
MAPPED_ROUTE);
 
diff --git 
a/airflow-core/src/airflow/ui/src/layouts/Details/SearchMapIndexes.tsx 
b/airflow-core/src/airflow/ui/src/layouts/Details/SearchMapIndexes.tsx
index 3d3065ce140..0d717a65988 100644
--- a/airflow-core/src/airflow/ui/src/layouts/Details/SearchMapIndexes.tsx
+++ b/airflow-core/src/airflow/ui/src/layouts/Details/SearchMapIndexes.tsx
@@ -88,6 +88,7 @@ export const SearchMapIndexes = ({
       const params = new URLSearchParams(searchParams);
 
       params.delete(SearchParamsKeys.REGION_INDEX);
+      params.delete(SearchParamsKeys.CURSOR);
       const query = params.toString();
 
       onClose();
diff --git a/airflow-core/src/airflow/ui/src/pages/Events/Events.test.tsx 
b/airflow-core/src/airflow/ui/src/pages/Events/Events.test.tsx
index af879bd2513..620f1a8a25e 100644
--- a/airflow-core/src/airflow/ui/src/pages/Events/Events.test.tsx
+++ b/airflow-core/src/airflow/ui/src/pages/Events/Events.test.tsx
@@ -16,7 +16,8 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import { render, waitFor } from "@testing-library/react";
+import "@testing-library/jest-dom/vitest";
+import { fireEvent, render, screen, waitFor } from "@testing-library/react";
 import { MemoryRouter, Route, Routes } from "react-router-dom";
 import { afterEach, expect, it, vi } from "vitest";
 
@@ -59,3 +60,54 @@ it("filters a regional audit tab by the pass coordinates, 
keeping every try and
     tryNumber: 2,
   });
 });
+
+it("pages the audit log by cursor and shows a capped total as a minimum", 
async () => {
+  const events = vi.spyOn(EventLogService, "getEventLogs").mockResolvedValue({
+    event_logs: [],
+    next_cursor: "page-2",
+    previous_cursor: null,
+    total_entries: 50_000,
+    total_entries_limit: 50_000,
+  });
+
+  render(
+    <BaseWrapper>
+      <MemoryRouter initialEntries={["/events"]}>
+        <Routes>
+          <Route element={<Events />} path="/events" />
+        </Routes>
+      </MemoryRouter>
+    </BaseWrapper>,
+  );
+
+  await waitFor(() => expect(events).toHaveBeenCalled());
+  expect(events.mock.lastCall?.[0]).toMatchObject({ cursor: "" });
+  expect(events.mock.lastCall?.[0]?.offset).toBeUndefined();
+
+  const next = await screen.findByTestId("next");
+
+  expect(await screen.findByRole("heading", { name: /^50,000\+/u 
})).toBeInTheDocument();
+  expect(screen.getByTestId("prev")).toBeDisabled();
+  fireEvent.click(next);
+  await waitFor(() => expect(events.mock.lastCall?.[0]).toMatchObject({ 
cursor: "page-2" }));
+});
+
+it("names the audit log date filter after the When column it filters", async 
() => {
+  vi.spyOn(EventLogService, "getEventLogs").mockResolvedValue({ event_logs: 
[], total_entries: 0 });
+
+  render(
+    <BaseWrapper>
+      <MemoryRouter initialEntries={["/events"]}>
+        <Routes>
+          <Route element={<Events />} path="/events" />
+        </Routes>
+      </MemoryRouter>
+    </BaseWrapper>,
+  );
+
+  fireEvent.click(await screen.findByTestId("add-filter-button"));
+
+  expect(await 
screen.findByTestId("add-filter-event_date_range")).toHaveTextContent(
+    "browse:auditLog.columns.when",
+  );
+});
diff --git a/airflow-core/src/airflow/ui/src/pages/Events/Events.tsx 
b/airflow-core/src/airflow/ui/src/pages/Events/Events.tsx
index d39995cec8e..82c254faff6 100644
--- a/airflow-core/src/airflow/ui/src/pages/Events/Events.tsx
+++ b/airflow-core/src/airflow/ui/src/pages/Events/Events.tsx
@@ -195,7 +195,7 @@ export const Events = () => {
 
   const [searchParams] = useSearchParams();
   const { setTableURLState, tableURLState } = useTableURLState();
-  const { pagination, sorting } = tableURLState;
+  const { cursor, pagination, sorting } = tableURLState;
   const [sort] = sorting;
   const { onClose, onOpen, open } = useDisclosure();
 
@@ -253,6 +253,7 @@ export const Events = () => {
     {
       after: afterDate,
       before: beforeDate,
+      cursor: cursor ?? "",
       // Use exact match for URL params (dag/run/task context)
       dagId: dagId ?? undefined,
       // Use pattern search for filter inputs (partial matching)
@@ -261,7 +262,6 @@ export const Events = () => {
       limit: pagination.pageSize,
       // A loop pass shares its public map index with every other pass, so its 
coordinates select it.
       mapIndex: regional ? undefined : mapIndexNumber,
-      offset: pagination.pageIndex * pagination.pageSize,
       orderBy,
       ...ownerArg,
       regionId: regional ? coordinates.regionId : undefined,
@@ -274,6 +274,7 @@ export const Events = () => {
       tryNumber: tryNumberNumber,
     },
     undefined,
+    { placeholderData: (prev) => prev },
   );
 
   const eventLogs = data?.event_logs ?? [];
@@ -290,6 +291,7 @@ export const Events = () => {
         initialState={tableURLState}
         isLoading={isLoading}
         modelName="common:event"
+        nextCursor={data?.next_cursor}
         onStateChange={setTableURLState}
         presentationActions={
           eventLogs.length > 0 ? (
@@ -302,8 +304,10 @@ export const Events = () => {
             />
           ) : undefined
         }
+        previousCursor={data?.previous_cursor}
         skeletonCount={undefined}
-        total={data?.total_entries ?? 0}
+        total={data?.total_entries}
+        totalEntriesLimit={data?.total_entries_limit ?? undefined}
       />
     </>
   );
diff --git a/airflow-core/src/airflow/ui/src/utils/executionParams.test.ts 
b/airflow-core/src/airflow/ui/src/utils/executionParams.test.ts
index 164d1a412d7..97857ebd27e 100644
--- a/airflow-core/src/airflow/ui/src/utils/executionParams.test.ts
+++ b/airflow-core/src/airflow/ui/src/utils/executionParams.test.ts
@@ -30,6 +30,12 @@ describe("stripExecutionParams", () => {
     expect(source.has("try_number")).toBe(true);
   });
 
+  it("drops the table page, whose cursor only fits the list it came from", () 
=> {
+    const stripped = stripExecutionParams(new 
URLSearchParams("cursor=page-2&dag_run_state=failed"));
+
+    expect(stripped.toString()).toBe("dag_run_state=failed");
+  });
+
   it("keeps the loop scope, which follows you between a loop's tasks", () => {
     const stripped = stripExecutionParams(new 
URLSearchParams("region_id=r&loop_id=batch&iteration=3"));
 
diff --git a/airflow-core/src/airflow/ui/src/utils/executionParams.ts 
b/airflow-core/src/airflow/ui/src/utils/executionParams.ts
index aa1f160d94c..1638ff11185 100644
--- a/airflow-core/src/airflow/ui/src/utils/executionParams.ts
+++ b/airflow-core/src/airflow/ui/src/utils/executionParams.ts
@@ -22,10 +22,12 @@ const EXECUTION_PARAMS = [
   SearchParamsKeys.TRY_NUMBER,
   SearchParamsKeys.REGION_ID,
   SearchParamsKeys.REGION_INDEX,
+  SearchParamsKeys.CURSOR,
 ];
 
 /**
- * A copy of `searchParams` without the params that pin one execution or try.
+ * A copy of `searchParams` without the params that pin one execution or try, 
or a position in a
+ * table, since a page cursor only means something in the list it came from.
  *
  * The loop filter is deliberately not among them: a pass is where you are in 
a loop, not a row,
  * so it survives moving between the loop's tasks. Pages drop a loop that is 
out of their scope.
diff --git 
a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_event_logs.py 
b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_event_logs.py
index 4a9865b0df5..5103eff9a82 100644
--- 
a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_event_logs.py
+++ 
b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_event_logs.py
@@ -829,3 +829,81 @@ class TestGetEventLogs(TestEventLogsEndpoint):
         mock_is_authorized_view.assert_called_once_with(
             access_view=AccessView.AUDIT_LOGS_ALL, user=mock.ANY, 
team_name=None
         )
+
+    @pytest.mark.parametrize("order_by", ["-when", "event", "owner", 
"-event_log_id"])
+    def test_cursor_pagination_forward_then_previous_page(self, test_client, 
order_by):
+        """Every row is reached once going forward, and previous_cursor 
retraces each page back to the first."""
+        params = {"limit": 1, "order_by": order_by}
+        forward_pages = []
+        cursor = ""
+        while cursor is not None:
+            response = test_client.get("/eventLogs", params={**params, 
"cursor": cursor})
+            assert response.status_code == 200, response.json()
+            body = response.json()
+            forward_pages.append(body)
+            cursor = body["next_cursor"]
+
+        forward_ids = [[log["event_log_id"] for log in page["event_logs"]] for 
page in forward_pages]
+        assert len(forward_pages) == 4
+        assert len({event_log_id for (event_log_id,) in forward_ids}) == 4
+        assert forward_pages[0]["previous_cursor"] is None
+
+        cursor = forward_pages[-1]["previous_cursor"]
+        for expected_index in (2, 1, 0):
+            response = test_client.get("/eventLogs", params={**params, 
"cursor": cursor})
+            assert response.status_code == 200, response.json()
+            body = response.json()
+            assert [log["event_log_id"] for log in body["event_logs"]] == 
forward_ids[expected_index]
+            assert body["next_cursor"] is not None
+            assert (body["previous_cursor"] is not None) == (expected_index > 
0)
+            cursor = body["previous_cursor"]
+
+    @pytest.mark.parametrize("order_by", ["extra", "-extra"])
+    def test_cursor_pagination_rejects_sorting_by_extra(self, test_client, 
order_by):
+        response = test_client.get("/eventLogs", params={"order_by": order_by, 
"cursor": ""})
+        assert response.status_code == 400
+        assert response.json()["detail"] == "Sorting by `extra` is not 
supported with cursor pagination"
+
+    @pytest.mark.parametrize(("count_limit", "expected_total_entries"), [(2, 
2), (10, 4)])
+    def test_cursor_pagination_caps_total_entries(self, test_client, 
count_limit, expected_total_entries):
+        """The count stops at the cap, so a total equal to total_entries_limit 
means at least that many."""
+        with 
mock.patch("airflow.api_fastapi.common.db.common.EXACT_COUNT_LIMIT", 
count_limit):
+            response = test_client.get("/eventLogs", params={"limit": 1, 
"cursor": ""})
+        assert response.status_code == 200, response.json()
+        body = response.json()
+        assert body["total_entries"] == expected_total_entries
+        assert body["total_entries_limit"] == count_limit
+
+    def test_cursor_pagination_keeps_filters_on_every_page(self, test_client):
+        events = []
+        cursor = ""
+        while cursor is not None:
+            response = test_client.get(
+                "/eventLogs", params={"limit": 1, "dag_id": DAG_ID, 
"order_by": "event", "cursor": cursor}
+            )
+            assert response.status_code == 200, response.json()
+            body = response.json()
+            events.extend(log["event"] for log in body["event_logs"])
+            cursor = body["next_cursor"]
+
+        assert events == [EVENT_WITH_OWNER_AND_TASK_INSTANCE, 
TASK_INSTANCE_EVENT]
+
+    @pytest.mark.parametrize("order_by", ["owner_display_name", 
"-owner_display_name"])
+    def test_cursor_pagination_matches_offset_order(self, test_client, 
order_by):
+        expected_ids = [
+            log["event_log_id"]
+            for log in test_client.get("/eventLogs", params={"order_by": 
order_by}).json()["event_logs"]
+        ]
+        event_log_ids = []
+        cursor = ""
+        for _ in expected_ids:
+            response = test_client.get(
+                "/eventLogs", params={"limit": 1, "order_by": order_by, 
"cursor": cursor}
+            )
+            assert response.status_code == 200, response.json()
+            body = response.json()
+            event_log_ids.extend(log["event_log_id"] for log in 
body["event_logs"])
+            cursor = body["next_cursor"]
+
+        assert event_log_ids == expected_ids
+        assert cursor is None
diff --git a/airflow-ctl/src/airflowctl/api/datamodels/generated.py 
b/airflow-ctl/src/airflowctl/api/datamodels/generated.py
index c2cef3cfc95..81aeb4d5aaa 100644
--- a/airflow-ctl/src/airflowctl/api/datamodels/generated.py
+++ b/airflow-ctl/src/airflowctl/api/datamodels/generated.py
@@ -2524,11 +2524,38 @@ class DryRunBackfillCollectionResponse(BaseModel):
 
 class EventLogCollectionResponse(BaseModel):
     """
-    Event Log Collection Response.
+    Event Log collection response supporting both offset and cursor pagination.
     """
 
     event_logs: Annotated[list[EventLogResponse], Field(title="Event Logs")]
-    total_entries: Annotated[int, Field(title="Total Entries")]
+    total_entries: Annotated[
+        int,
+        Field(
+            description="Number of matching items. For offset pagination this 
is the exact total. For cursor pagination it is capped at 
``total_entries_limit``; a value equal to that limit means at least that many 
items match.",
+            title="Total Entries",
+        ),
+    ]
+    total_entries_limit: Annotated[
+        int | None,
+        Field(
+            description="Cap applied to ``total_entries`` under cursor 
pagination. ``null`` for offset pagination, where ``total_entries`` is exact.",
+            title="Total Entries Limit",
+        ),
+    ] = None
+    next_cursor: Annotated[
+        str | None,
+        Field(
+            description="Token pointing to the next page. Populated for cursor 
pagination, ``null`` when using offset pagination or when there is no next 
page.",
+            title="Next Cursor",
+        ),
+    ] = None
+    previous_cursor: Annotated[
+        str | None,
+        Field(
+            description="Token pointing to the previous page. Populated for 
cursor pagination, ``null`` when using offset pagination or when on the first 
page.",
+            title="Previous Cursor",
+        ),
+    ] = None
 
 
 class ExternalViewResponse(BaseModel):

Reply via email to