anzinmhd opened a new pull request, #75905:
URL: https://github.com/apache/airflow/pull/75905

   Selecting task instances across multiple pages shows the combined selection 
count, but bulk actions receive only selected tasks on the current page. This 
PR retains selected task data across pages so the count and bulk actions use 
the same selections.
   
   ### Problem
   
   On the Task Instances page, selecting one task on the first page and another 
on the second page shows **2 Selected** in the toolbar. However, opening 
**Clear Task Instances** shows **Affected Tasks: 1**, containing only the 
selected task from the current page.
   
   This happens during normal UI navigation with the default page size. It does 
not require manually modifying pagination parameters and occurs with or without 
a Dag filter.
   
   ### Cause
   
   The selection count and bulk-action task list are derived differently:
   
   - `useRowSelection` retains selected row identifiers across page changes.
   - The toolbar displays `selectedRows.size`, counting selections from all 
visited pages.
   - `TaskInstances` constructs `selectedTaskInstances` by filtering only the 
current page’s `data.task_instances`.
   
   Consequently, selected tasks from previous pages remain in the toolbar count 
but are omitted from the list passed to bulk actions.
   
   Clear, Mark, and Delete all receive this same incomplete list. The 
clear-preview mismatch was manually reproduced; regression tests verify the 
selected task list passed to all three action components.
   
   ### Fix
   
   Store selected row data in `useRowSelection`, keyed by the existing row 
identifiers, and expose the retained rows as `selectedItems`.
   
   The Task Instances page now passes these retained items to its bulk actions 
instead of reconstructing selections from the current page’s results.
   
   This keeps selection behavior consistent:
   
   - Selecting tasks on different pages retains each selected task’s data.
   - The toolbar count and bulk-action inputs derive from the same retained 
selections.
   - Individual deselection and page-level deselection remove the corresponding 
items.
   - Clearing selections removes all retained items.
   - Deselection by action-result identifiers also removes the corresponding 
retained items.
   - Selected items visible on the current page use the latest loaded row data.
   
   The existing `selectedRows` interface remains available to other consumers 
of the shared hook. Only the Task Instances page is switched to using the 
retained items for bulk actions.
   
   No backend or API changes are required.
   
   ### Steps to reproduce
   
   1. Create a manually triggered Dag containing enough independent tasks to 
exceed the default Task Instances page size. The manual reproduction used **60 
independent tasks**, named `task_001` through `task_060`.
   2. Trigger the Dag and wait for all tasks to succeed.
   3. Open **Browse → Task Instances**.
   4. Optionally filter by the reproduction Dag.
   5. Select one task on the first page.
   6. Scroll to the pagination controls and click **Next page**.
   7. Select another task on the second page.
   8. Confirm that the toolbar shows **2 Selected**.
   9. Click **Clear Task Instances** in the bottom toolbar.
   10. Compare the selected count with the affected-task preview.
   
   Independent tasks avoid upstream or downstream relationships adding tasks to 
the preview. Cancel the dialog after checking; confirming the clear operation 
is unnecessary to demonstrate the mismatch.
   
   **Before:** The toolbar shows **2 Selected**, but the preview shows 
**Affected Tasks: 1**, omitting the selected task from the previous page.
   
   **After:** The toolbar shows **2 Selected**, and the preview shows 
**Affected Tasks: 2**, including both selected tasks.
   
   ### Version verification
   
   - Reproduced on the local `main` checkout.
   - Manually verified the fix in Chrome using normal pagination.
   - The affected release range has not been established. This report does not 
claim verification on a beta or released version.
   
   ### Tests and validation
   
   Added nine regression cases covering:
   
   - Passing selections from both pages to the Clear, Mark, and Delete action 
components.
   - Retaining selected row data across page changes for individual and 
page-level selection.
   - Removing retained items through individual and page-level deselection.
   - Removing retained items through clearing selections and deselection by key.
   - Using refreshed data for selected items on the current page.
   - Ignoring selection requests for items absent from the current data.
   
   Validation completed:
   
   - All nine new regression cases fail without the production fix.
   - **157 tests across 13 test files pass**, covering DataTable, Task 
Instances, Dag Runs, and Dag-list behavior.
   - Targeted ESLint checks report no errors; the existing Fast Refresh warning 
remains.
   - Targeted Prettier checks pass.
   - TypeScript checking passes.
   - The UI production build passes.
   - Manual Chrome verification confirms that tasks selected across two pages 
appear together in the clear preview.
   
   The broader test run emitted a socket teardown warning after the passing 
summary and exited successfully. The production build completed with a 
chunk-size warning.
   
   ### Before
   
   Selecting tasks across two pages shows **2 Selected**, but the clear preview 
includes only the selected task from the current page.
   
   
https://github.com/user-attachments/assets/0f2e7ac4-28b7-4c0e-979f-ff1cb3b33ce6
   
   ### After
   
   The clear preview includes both tasks selected across pages, matching the 
toolbar’s **2 Selected** count.
   
   
https://github.com/user-attachments/assets/fa92510a-139d-40e2-9dae-415006bf51d3
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Codex (GPT-6)


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to