Skip to content

Add terminate button for running workflows on tasks page #306

@tbrandenburg

Description

@tbrandenburg

Summary

Add a terminate button next to each running workflow entry on the tasks page to allow users to manually stop long-running or stuck jobs.

Background

The recent cron service improvements (#297, #305) added robust timeout monitoring and admin functions like force_terminate_job() for manually terminating workflows. However, there's currently no UI for users to access this functionality.

Requirements

Frontend Changes

  • Add a "Terminate" button next to each workflow entry in the tasks page that is currently running
  • Button should only be visible when workflow status is "running"
  • Button should be styled consistently with existing UI (likely a small red/orange button)
  • Show confirmation dialog before termination: "Are you sure you want to terminate this job?"
  • Disable button and show loading state during termination request
  • Show success/error feedback after termination attempt

Backend Changes

  • Add new API endpoint: POST /api/cron/jobs/{workflow_id}/terminate
  • Endpoint should call existing force_terminate_job(workflow_id) function
  • Return appropriate HTTP status codes:
    • 200: Successfully terminated
    • 404: Workflow not found or not running
    • 500: Internal error during termination
  • Include response body with termination result

UX Considerations

  • Button should have clear labeling and appropriate icon (stop/X symbol)
  • Consider placement - likely in the actions column or as part of status indicator
  • Ensure button doesn't accidentally get clicked (confirmation dialog)
  • Provide clear feedback about what happened

Acceptance Criteria

  • Terminate button appears only for running workflows
  • Clicking button shows confirmation dialog
  • Confirmed termination calls backend API
  • Backend API successfully terminates running jobs
  • UI updates to reflect job termination
  • Error handling for failed termination attempts
  • Consistent styling with existing task page design

Technical Notes

  • Backend function force_terminate_job() already exists in cron_service.py
  • Frontend likely needs to call existing cron diagnostics API to get current job states
  • Consider real-time updates or polling to refresh job status after termination

Priority

Medium - This is a quality-of-life improvement that makes the existing admin functionality accessible to users through the UI.

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