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

   ### Summary
   
   Closes #67884
   
   This fixes a UI freeze regression introduced after #67212 where Task 
Instance mutation actions (Mark success/failed, etc.) triggered multiple 
overlapping TI summary stream refreshes and excessive React state updates.
   
   Previously:
   - multiple query invalidations could trigger multiple stream restarts
   - overlapping NDJSON streams emitted duplicate updates
   - each streamed line caused an individual React state update
   - expensive grid/task-instance rendering amplified the render pressure
   - the UI became temporarily unresponsive for several seconds after mutation 
actions
   
   This update introduces deterministic refresh coalescing, active stream 
deduplication, and NDJSON state batching to significantly reduce render churn 
while preserving query freshness and the stale badge fix introduced in #67212.
   
   ---
   
   ### Root Cause
   
   The cache subscriber added in #67212 relied on a fragile timing-based 
debounce using setTimeout(..., 0).
   
   Under mutation-heavy invalidation flows:
   - multiple query invalidations emitted separate cache notifications
   - refresh scheduling could execute multiple times
   - multiple TI summary streams became active simultaneously
   - every NDJSON line triggered a separate setSummariesByRunId update
   
   This resulted in dozens of rapid re-renders on already expensive UI surfaces.
   
   ---
   
   ### Changes
   
   #### Deterministic Refresh Coalescing
   - replaced the fragile timeout-based refresh scheduling
   - introduced frame-based refresh coalescing using requestAnimationFrame
   - collapses multiple invalidation notifications into a single refresh cycle
   
   #### Active Stream Deduplication
   - stale streams are now aborted correctly
   - aborted streams immediately stop processing NDJSON updates
   - prevents obsolete stream instances from updating React state
   
   #### NDJSON State Batching
   - buffered streamed summaries per read chunk
   - applied updates in a single batched state update instead of once-per-line
   - significantly reduced render frequency and Map cloning overhead
   
   ---
   
   ### Tests Added
   
   Added comprehensive tests covering:
   - multiple invalidations collapsing into one refresh
   - stale stream abort handling
   - NDJSON batching behavior
   - stable mount behavior
   - prevention of duplicate refresh scheduling
   
   ---
   
   ### Verification
   
   Validated with:
   bash npx vitest run src/queries/useGridTISummaries.test.tsx pnpm lint 
   
   No lint or type errors remain.


-- 
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