Skip to content

Add job stop/cancel functionality for running executions #17

@nehmetohmedb

Description

@nehmetohmedb

Summary

Currently, users cannot stop or cancel jobs that are running. Once a job execution starts, it must complete or fail naturally. This limits user control and can be problematic for long-running jobs or jobs that get stuck.

Current State

  • Job execution is managed through the ExecutionHistory component
  • Jobs have states: pending, running, completed, failed
  • Users can view results, logs, traces, schedule, and delete completed jobs
  • No mechanism exists to interrupt running jobs

Proposed Solution

Frontend Changes

  1. Add Stop Button in ExecutionActions.tsx

    • Only visible for jobs with running status
    • Use Material-UI StopIcon with error color
    • Include confirmation dialog for critical jobs
  2. Update Job Status System

    • Add new statuses: stopping, cancelled
    • Update status chips and colors in ExecutionHistory
    • Add translations for new statuses
  3. API Integration

    • Add stopJob(jobId) method to JobExecutionService.ts
    • Integrate with runStatusStore for state management
    • Handle stop errors gracefully

Backend Changes

  1. New API Endpoint

    • POST /executions/{job_id}/stop
    • Gracefully terminate CrewAI execution
    • Update job status to cancelled
    • Return success/failure response
  2. CrewAI Integration

    • Implement job termination in CrewAI engine
    • Handle cleanup of running tasks
    • Ensure database consistency

Technical Details

Frontend Files to Modify:

  • src/frontend/src/components/Jobs/ExecutionActions.tsx - Add stop button
  • src/frontend/src/services/JobExecutionService.ts - Add stop API call
  • src/frontend/src/store/runStatus.ts - Add stop action
  • src/frontend/src/locales/ - Add translations

Backend Files to Modify:

  • src/backend/src/api/executions/routes.py - Add stop endpoint
  • src/backend/src/services/execution_service.py - Add stop logic
  • src/backend/src/engines/crewai/ - Implement job termination

Acceptance Criteria

  • Running jobs display a stop button in ExecutionActions
  • Stop button shows confirmation dialog before proceeding
  • Backend endpoint gracefully terminates CrewAI processes
  • Job status updates to "cancelled" when stopped
  • Real-time UI updates reflect stopped status
  • Error handling for already completed jobs
  • Unit tests for stop functionality
  • Integration tests for stop endpoint

Priority

Medium - This is a quality-of-life improvement that enhances user control over job execution.

Labels

enhancement, frontend, backend, user-experience

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions