Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

@waleedlatif1 waleedlatif1 commented Jul 26, 2025

Description

Added the ability to cancel a run once its been launched. This prevents users with longer workflows from having to wait until the entire run is complete. Speeds up iteration.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Tested manually

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • All tests pass locally and in CI (bun run test)
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • I have updated version numbers as needed (if needed)
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Security Considerations:

  • My changes do not introduce any new security vulnerabilities
  • I have considered the security implications of my changes
Screen.Recording.2025-07-26.at.12.00.50.PM.mov

@vercel
Copy link

vercel bot commented Jul 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sim ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 26, 2025 7:57pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Skipped (Inspect) Jul 26, 2025 7:57pm

Copy link
Contributor

@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.

Greptile Summary

This PR implements workflow execution cancellation functionality across the entire execution stack. The changes add the ability for users to cancel running workflows through a UI button, which integrates with a new cancellation mechanism in the core executor.

The implementation follows a clean architecture pattern:

  1. Core Executor Changes: The Executor class now includes a private isCancelled boolean flag and a public cancel() method. The execution loop checks this flag at key points (while loop condition and continueExecution method) to halt processing when cancellation is requested. When cancelled, the executor returns a structured error response with telemetry tracking.

  2. Hook Integration: The useWorkflowExecution hook adds a handleCancelExecution callback that calls the executor's cancel method and properly resets all execution state (including debug state cleanup). It also detects cancellation in streaming executions by checking for the specific error message.

  3. UI Enhancement: The control bar component conditionally renders a red cancel button with an X icon when isExecuting is true, replacing the normal run button. This provides immediate visual feedback and user control.

  4. Test Coverage: Comprehensive test suite covers all cancellation scenarios including basic flag setting, debug mode cancellation, multiple cancel calls, prevention of new execution on cancelled executors, and cancellation during execution loops.

The feature integrates seamlessly with existing execution patterns, supporting both normal and debug mode workflows while maintaining proper state management and telemetry tracking.

Confidence score: 4/5

• This PR is generally safe to merge with well-structured cancellation implementation and comprehensive test coverage
• Score reflects solid implementation but minor concerns about potential race conditions in streaming execution and state cleanup timing
• Files needing attention: use-workflow-execution.ts for streaming cancellation logic and potential executor cleanup timing

4 files reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

@vercel vercel bot temporarily deployed to Preview – docs July 26, 2025 19:45 Inactive
@vercel vercel bot temporarily deployed to Preview – docs July 26, 2025 19:49 Inactive
@waleedlatif1 waleedlatif1 merged commit 727e5e8 into staging Jul 26, 2025
4 of 5 checks passed
@waleedlatif1 waleedlatif1 deleted the feat/cancel branch July 26, 2025 19:54
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
…imstudioai#796)

* feat(worfklow): added cancellation after launching manual execution

* fix build error

* ack PR comments

---------

Co-authored-by: waleedlatif <waleedlatif@waleedlatifs-MacBook-Pro.local>
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