Skip to content

fix(platform): ensure cache invalidation before automation list refresh#1116

Merged
yannickmonney merged 1 commit into
mainfrom
fix/1112-automation-creation-race
Apr 8, 2026
Merged

fix(platform): ensure cache invalidation before automation list refresh#1116
yannickmonney merged 1 commit into
mainfrom
fix/1112-automation-creation-race

Conversation

@yannickmonney
Copy link
Copy Markdown
Contributor

@yannickmonney yannickmonney commented Apr 8, 2026

Summary

  • Fixes Failed to create blank automation, data is not added. #1112
  • Fixes a race condition where window.dispatchEvent('workflow-updated') fired before TanStack Query cache invalidation completed, causing the automations table to refetch stale data
  • Exports useInvalidateWorkflows and explicitly awaits cache invalidation in both the blank automation creation dialog and the template installation grid before dispatching the refresh event

Test plan

  • Lint and typecheck pass
  • Create a blank automation and verify it appears in the list immediately
  • Install a template automation and verify it appears in the list

Summary by CodeRabbit

  • Bug Fixes
    • Workflows now properly refresh after creation and template installation, ensuring users see up-to-date workflow data immediately without manual refresh.

Await queryClient.invalidateQueries() before dispatching the
workflow-updated window event. This prevents the automations table
from refetching stale data before TanStack Query's cache is properly
invalidated, fixing the race condition where newly created automations
would not appear in the list.

Closes #1112
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@yannickmonney yannickmonney merged commit 559d47e into main Apr 8, 2026
21 of 23 checks passed
@yannickmonney yannickmonney deleted the fix/1112-automation-creation-race branch April 8, 2026 08:09
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 8, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b1c79f0b-e644-4c10-9146-95df768be7b1

📥 Commits

Reviewing files that changed from the base of the PR and between daa845d and 838c378.

📒 Files selected for processing (3)
  • services/platform/app/features/automations/components/automation-create-dialog.tsx
  • services/platform/app/features/automations/components/workflow-template-grid.tsx
  • services/platform/app/features/automations/hooks/file-mutations.ts

📝 Walkthrough

Walkthrough

The PR exports the useInvalidateWorkflows hook from the file-mutations module and integrates it into two automation creation workflows. In both automation-create-dialog.tsx and workflow-template-grid.tsx, after successfully creating or installing a workflow, the code now invalidates the React Query cache for the workflows query before dispatching events and navigating. This ensures that the client-side cache is refreshed to reflect newly created workflows.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

✨ 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/1112-automation-creation-race

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.

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.

Failed to create blank automation, data is not added.

1 participant