Skip to content

fix: stop dashboard and cockpit dag run refetch loop#1954

Merged
yottahmd merged 1 commit intomainfrom
fix/dashboard-cockpit-dag-runs-loop
Apr 2, 2026
Merged

fix: stop dashboard and cockpit dag run refetch loop#1954
yottahmd merged 1 commit intomainfrom
fix/dashboard-cockpit-dag-runs-loop

Conversation

@yottahmd
Copy link
Copy Markdown
Collaborator

@yottahmd yottahmd commented Apr 2, 2026

Summary

  • stabilize exact DAG run fetching against semantically identical query rerenders
  • memoize dashboard and cockpit DAG run queries so callers stay explicit and easy to reason about
  • add regression coverage for rerender stability, stale request handling, and fallback polling cadence

Testing

  • make fmt
  • cd ui && pnpm exec vitest run src/features/dag-runs/hooks/__tests__/useExactDAGRuns.test.tsx
  • cd ui && pnpm typecheck

Summary by CodeRabbit

  • Refactor

    • Improved query handling efficiency to reduce unnecessary re-renders and API calls.
  • Tests

    • Added comprehensive test coverage for query request behavior, including caching, polling, and cancellation logic.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 2, 2026

📝 Walkthrough

Walkthrough

Refactored DAG run query handling to use memoized query objects and stable query keys instead of inline construction. Added helper functions to normalize and sort query parameters, enabling semantic equivalence checking. Updated useExactDAGRuns to store queries in refs and depend on computed query keys. Added comprehensive test suite validating memoization, refetch behavior, request aborting, and polling intervals.

Changes

Cohort / File(s) Summary
Query Memoization
ui/src/features/cockpit/hooks/useDateKanbanData.ts, ui/src/pages/index.tsx
Refactored to construct query objects via useMemo instead of inline literals, passing memoized queries to useExactDAGRuns to prevent unnecessary refetches on rerenders.
Query Dependency Tracking
ui/src/features/dag-runs/hooks/dagRunPagination.ts
Added normalizeDAGRunListQuery and getDAGRunListQueryKey for stable, order-independent query hashing. Refactored useExactDAGRuns to use queryRef for latest query value and depend on semantic query keys instead of object identity. Updated usePaginatedDAGRuns to reset pagination on semantic query changes.
Test Suite
ui/src/features/dag-runs/hooks/__tests__/useExactDAGRuns.test.tsx
New comprehensive Vitest suite validating memoized query behavior: no refetch on equivalent inline objects, refetch on semantic changes, stale request aborting, and polling behavior with controlled timers.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: stop dashboard and cockpit dag run refetch loop' directly and accurately describes the main objective of this PR—preventing refetch loops by memoizing DAG run queries.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dashboard-cockpit-dag-runs-loop

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
ui/src/features/dag-runs/hooks/__tests__/useExactDAGRuns.test.tsx (1)

1-4: Missing GPL v3 license header.

Per coding guidelines, source files should include GPL v3 license headers. Run make addlicense to add the required header.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/src/features/dag-runs/hooks/__tests__/useExactDAGRuns.test.tsx` around
lines 1 - 4, The file is missing the required GPL v3 license header; add the
standard GPL v3 header comment to the top of the test file (the file containing
useExactDAGRuns.test.tsx which tests useExactDAGRuns and imports
DAGRunListQuery) — run the repository helper (make addlicense) or insert the
canonical GPL v3 header block as used across the project so the file matches
other sources and CI/license checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@ui/src/features/dag-runs/hooks/__tests__/useExactDAGRuns.test.tsx`:
- Around line 1-4: The file is missing the required GPL v3 license header; add
the standard GPL v3 header comment to the top of the test file (the file
containing useExactDAGRuns.test.tsx which tests useExactDAGRuns and imports
DAGRunListQuery) — run the repository helper (make addlicense) or insert the
canonical GPL v3 header block as used across the project so the file matches
other sources and CI/license checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c6b5ed06-0e25-48b0-af84-cfb5bb52a8e2

📥 Commits

Reviewing files that changed from the base of the PR and between 01495ae and 1f42fb7.

📒 Files selected for processing (4)
  • ui/src/features/cockpit/hooks/useDateKanbanData.ts
  • ui/src/features/dag-runs/hooks/__tests__/useExactDAGRuns.test.tsx
  • ui/src/features/dag-runs/hooks/dagRunPagination.ts
  • ui/src/pages/index.tsx

@yottahmd yottahmd merged commit 795b337 into main Apr 2, 2026
2 checks passed
@yottahmd yottahmd deleted the fix/dashboard-cockpit-dag-runs-loop branch April 2, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant