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

   ## Problem
   The "Triggered DAG" button only appeared **after** the parent task completed 
execution. During RUNNING/QUEUED states, the button was completely hidden.
   
   ### User Experience Impact
   - Task RUNNING: Button missing 
   - Task SUCCESS: Button appears after page refresh
   
   ## Solution
   Implemented a fix to show the button immediately with a loading state:
   
   ### 1. Backend Enhancement (trigger_dagrun.py)
   - Added database fallback query (`_get_recent_dag_run()`) to find child DAG 
runs
   
   ### 2. Frontend Polling (ExtraLinks.tsx)
   - Added 2-second polling interval to watch for link availability
   - Stops polling once link is resolved (optimization)
   
   ### 3. Rendering Logic Fix (ExtraLinks.tsx)
   - **OLD:** Filtered out null values, skipping button render entirely
   - **NEW:** Renders disabled placeholder button when link is null
   - Shows spinner with "(loading...)" text
   - Auto-transitions to active button when link becomes available
   
   ### 4. Query Cache Optimization (useTrigger.ts)
   - Invalidates multiple query caches on trigger
   - Immediate navigation to newly triggered DAG run
   - Ensures fresh data displayed without manual refresh
   
   ## Changes
   - **backend**: 
`/providers/standard/src/airflow/providers/standard/operators/trigger_dagrun.py`
     - Enhanced `TriggerDagRunLink.get_link()` method
     - Added `_get_recent_dag_run()` nested function with database query
   
   - **frontend**: 
`/airflow-core/src/airflow/ui/src/pages/TaskInstance/ExtraLinks.tsx`
     - Modified rendering logic to show disabled button when value is null
     - Maintains refetch during background operation
   
   - **hooks**: `/airflow-core/src/airflow/ui/src/hooks/useTrigger.ts`
     - Enhanced query invalidation on trigger success
     - Added navigation to newly triggered run
   
   - **tests**: 
`/providers/standard/tests/unit/standard/operators/test_trigger_dagrun.py`
     - Added `TestTriggerDagRunLink` test class
     - Test for link availability during execution
     - Test for graceful null handling
   
   <img width="1910" height="853" alt="Screenshot from 2026-01-27 16-18-16" 
src="https://github.com/user-attachments/assets/8eded73c-3161-4f26-a014-5a5db8fac431";
 />
   <img width="1910" height="853" alt="Screenshot from 2026-01-27 16-19-10" 
src="https://github.com/user-attachments/assets/13304a40-7769-422e-9ba1-249672eee4e0";
 />


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