feat: add prompt aborting in agent chat#4112
feat: add prompt aborting in agent chat#4112abtonc wants to merge 1 commit intosuperplanehq:mainfrom
Conversation
Signed-off-by: Arda Barış Tonç <tonc29719@yazilimlisesi.k12.tr>
|
👋 Commands for maintainers:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f01a707. Configure here.
| streamAbortController = new AbortController(); | ||
| if (chatAbortControllerRef) { | ||
| chatAbortControllerRef.current = streamAbortController; | ||
| } |
There was a problem hiding this comment.
Stop button non-functional during session creation phase
Medium Severity
The AbortController is created only after createChatSession() resolves, but isGeneratingResponse is set to true (making the stop button visible) inside addLocalPromptMessages which runs before createChatSession. During the session-creation API call, chatAbortControllerRef.current remains null, so clicking the stop button silently does nothing. This also means the canvas-change cleanup via stopRunningChatPrompt is ineffective during this window, allowing the old prompt to continue running against a stale canvas.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit f01a707. Configure here.
| } | ||
|
|
||
| return previous; | ||
| }); |
There was a problem hiding this comment.
Stale "Stopped." message appears after canvas change
Medium Severity
When canvasId changes, the effect synchronously calls stopRunningChatPrompt then setAiMessages([]). The abort causes sendChatPrompt's async catch block to run applyChatPromptCancellation, whose setAiMessages updater receives the already-cleared [] array. Since existingIndex < 0, it pushes a new "Stopped." message onto the empty array, leaving a stale cancellation message visible on the new canvas.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit f01a707. Configure here.
| title="Stop prompt" | ||
| > | ||
| <Square size={14} /> | ||
| </button> |
There was a problem hiding this comment.
Prefer shadcn/ui primitives
Low Severity
The newly added stop <button> is a raw HTML element. The project provides a shadcn/ui Button via @/components/ui (used elsewhere in the sidebar). Using @/components/ui (Input, Label, Select, Textarea, Checkbox, Switch, Button, Dialog, etc.) instead of raw HTML is preferred when an equivalent exists. (The pre-existing submit button follows the same raw pattern, so this could be addressed together.)
Triggered by project rule: SuperPlane frontend — Bugbot rules
Reviewed by Cursor Bugbot for commit f01a707. Configure here.
|
/sp start |
|
✅ Ready. Web: https://pr-4112-ephemeral.superplane.com |
|
/sp stop |
|
✅ Ephemeral machine has been terminated. |


What Changed
This PR adds prompt cancellation support to the Agent chat UI in the workflow sidebar.
AbortControllerfor the agent stream request and added explicit abort handling so canceled runs do not show an error and instead showStopped..How
onStopPromptcallback next toonSendPrompt.chatAbortControllerRefstate in sidebar scope and passed it intosendChatPrompt.AbortError) and a dedicated cancellation UI path.stopRunningChatPrompt(...)helper:Related Issues
Closes #4076
Let me know if anything needs to be changed. Much love.