Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • use tanstack query to fetch schedule data
  • cleanup ui on schedule info component
  • cleanup ui on trigger save component
  • increase consecutive failure -> auto-disable flow from 10 to 100

Type of Change

  • Performance
  • UI

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Dec 25, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
docs Ready Ready Preview, Comment Dec 25, 2025 8:08pm

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 25, 2025

Greptile Summary

This PR modernizes schedule data fetching by migrating from manual fetch calls and local state management to TanStack Query, improves UI consistency with cleaner styling patterns, and increases the auto-disable threshold from 10 to 100 consecutive failures for better resilience.

Key Changes:

  • Introduced centralized query hooks (useScheduleQuery, useScheduleInfo, useReactivateSchedule, useRedeployWorkflowSchedule) with proper cache invalidation
  • Refactored schedule-info.tsx to remove 170+ lines of manual state management in favor of declarative query hooks
  • Cleaned up UI components with consistent design tokens (var(--warning), var(--text-tertiary)) instead of Tailwind utilities
  • Consolidated MAX_CONSECUTIVE_FAILURES constant to triggers/constants.ts for single source of truth
  • Updated all polling services (Gmail, Outlook, RSS) and background execution to use the centralized constant
  • Updated all documentation files (6 languages) to reflect the new 100 failure threshold

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes follow established patterns (TanStack Query is already used in the codebase), improve maintainability by centralizing constants and eliminating manual state management, and the failure threshold increase is well-documented across all affected files and languages. The refactor removes complexity rather than adding it.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/hooks/queries/schedules.ts New TanStack Query hooks for schedule data fetching with proper query invalidation
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/schedule-info/schedule-info.tsx Simplified UI with TanStack Query, cleaned up badge styling and layout
apps/sim/triggers/constants.ts Increased MAX_CONSECUTIVE_FAILURES from 10 to 100
apps/sim/background/schedule-execution.ts Now imports MAX_CONSECUTIVE_FAILURES constant instead of defining locally

Sequence Diagram

sequenceDiagram
    participant UI as ScheduleInfo Component
    participant Hook as useScheduleQuery
    participant TQ as TanStack Query
    participant API as /api/schedules
    participant DB as Database
    participant Mut as Redeploy Mutation

    Note over UI,DB: Initial Schedule Load
    UI->>Hook: useScheduleQuery(workflowId, blockId)
    Hook->>TQ: useQuery with scheduleKeys
    TQ->>API: GET /api/schedules?workflowId&blockId
    API->>DB: Query workflow schedules
    DB-->>API: Schedule data (status, failedCount, etc)
    API-->>TQ: Schedule response
    TQ-->>Hook: Cached data (staleTime: 30s)
    Hook-->>UI: { data: schedule, isLoading }

    Note over UI,Mut: User Clicks Redeploy (when disabled)
    UI->>Mut: redeployMutation.mutate({workflowId, blockId})
    Mut->>API: POST /api/workflows/{id}/deploy
    API->>DB: Redeploy workflow, reset schedule
    DB-->>API: Success
    API-->>Mut: Deployment complete
    Mut->>TQ: invalidateQueries(scheduleKeys)
    TQ->>API: Refetch schedule data
    API->>DB: Query updated schedule
    DB-->>API: Updated schedule (failedCount=0)
    API-->>TQ: Fresh data
    TQ-->>UI: Updated schedule state
Loading

@waleedlatif1 waleedlatif1 merged commit 3201aba into staging Dec 25, 2025
11 checks passed
@waleedlatif1 waleedlatif1 deleted the improvement/schedules branch December 25, 2025 20:10
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.

2 participants