Skip to content

feat(logs): add cancel execution to log row context menu#4130

Merged
waleedlatif1 merged 3 commits intostagingfrom
waleedlatif1/cancel-running-log
Apr 13, 2026
Merged

feat(logs): add cancel execution to log row context menu#4130
waleedlatif1 merged 3 commits intostagingfrom
waleedlatif1/cancel-running-log

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Add "Cancel Execution" option to the log row right-click context menu for running logs
  • Wire existing cancel API endpoint (/api/workflows/{id}/executions/{executionId}/cancel) to the logs UI
  • Add useCancelExecution mutation hook with full log cache invalidation

Type of Change

  • New feature

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
Copy Markdown

vercel bot commented Apr 13, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 13, 2026 7:00pm

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 13, 2026

PR Summary

Medium Risk
Adds a new user-triggered cancellation action that calls a workflow execution cancel endpoint and refreshes log queries; incorrect gating or cache invalidation could lead to unintended cancels or stale UI state.

Overview
Adds a Cancel Execution action to the log row right-click menu, shown only for running logs with a valid workflowId and executionId.

Wires the logs page to a new useCancelExecution React Query mutation that POSTs to /api/workflows/:workflowId/executions/:executionId/cancel and invalidates logKeys.all so the logs list/detail refresh after a cancel request.

Reviewed by Cursor Bugbot for commit 1dce08a. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 13, 2026

Greptile Summary

This PR adds a "Cancel Execution" option to the log row context menu, visible only for running logs that have both an execution ID and a workflow. It wires a new useCancelExecution mutation hook (in hooks/queries/logs.ts) to the existing cancel API endpoint, with targeted cache invalidation covering lists, details, and stats. Prior review concerns about silent failure on { success: false } responses and overly broad cache invalidation have both been addressed in the latest commit.

Confidence Score: 5/5

Safe to merge — all P0/P1 concerns from prior reviews are resolved; only a P2 UX suggestion remains.

Both prior review issues (silent success-false passthrough and overly broad cache invalidation) have been addressed. The single remaining finding is a P2 style suggestion about adding an onError toast — it does not affect correctness or data integrity.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/hooks/queries/logs.ts Adds useCancelExecution mutation with targeted invalidation (lists, details, stats); correctly throws on both !res.ok and !data.success; uses onSettled for cache reconciliation per project conventions.
apps/sim/app/workspace/[workspaceId]/logs/logs.tsx Wires handleCancelExecution callback with correct eslint-disable pattern for stable mutate reference; passes onCancelExecution to LogRowContextMenu.
apps/sim/app/workspace/[workspaceId]/logs/components/log-row-context-menu/log-row-context-menu.tsx Adds Cancel Execution menu item behind an isRunning guard, styled with text-destructive and separated from other items; clean and correct.

Sequence Diagram

sequenceDiagram
    actor User
    participant Menu as LogRowContextMenu
    participant Logs as logs.tsx
    participant Hook as useCancelExecution
    participant API as /api/workflows/{id}/executions/{id}/cancel
    participant QC as QueryClient

    User->>Menu: Right-click running log
    Menu->>Menu: isRunning check (status=running + executionId + workflowId)
    Menu-->>User: Show Cancel Execution item

    User->>Menu: Click Cancel Execution
    Menu->>Logs: onCancelExecution()
    Logs->>Hook: cancelExecution.mutate({ workflowId, executionId })
    Menu-->>User: Menu closes (Radix default)

    Hook->>API: POST /cancel
    alt res.ok && data.success
        API-->>Hook: { success: true }
        Hook->>QC: onSettled - invalidate lists, details, stats
        QC-->>Logs: Refetch - log status updated
    else failure
        API-->>Hook: !res.ok or { success: false }
        Hook->>QC: onSettled - invalidate lists, details, stats (still fires)
        Note over Logs,User: No error feedback shown to user
    end
Loading

Reviews (2): Last reviewed commit: "fix(logs): check success response and us..." | Re-trigger Greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 64424a0. Configure here.

@waleedlatif1 waleedlatif1 merged commit eba48e8 into staging Apr 13, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/cancel-running-log branch April 13, 2026 19:05
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.

1 participant