Skip to content

feat: add prompt aborting in agent chat#4112

Open
abtonc wants to merge 1 commit intosuperplanehq:mainfrom
abtonc:feat/add-prompt-aborting
Open

feat: add prompt aborting in agent chat#4112
abtonc wants to merge 1 commit intosuperplanehq:mainfrom
abtonc:feat/add-prompt-aborting

Conversation

@abtonc
Copy link
Copy Markdown
Contributor

@abtonc abtonc commented Apr 14, 2026

What Changed

This PR adds prompt cancellation support to the Agent chat UI in the workflow sidebar.

  • Added a "Stop" action while a response is generating (square icon replaces send button while running, also kind of works like a "Steer" feature.).
  • Introduced request cancellation via AbortController for the agent stream request and added explicit abort handling so canceled runs do not show an error and instead show Stopped..
  • Prevented new chat session selection updates when a run is aborted.
  • Added cleanup to cancel in-flight agent streams on canvas and component unmount.

How

  • Added an onStopPrompt callback next to onSendPrompt.
  • Added chatAbortControllerRef state in sidebar scope and passed it into sendChatPrompt.
  • Added abort-aware error detection (AbortError) and a dedicated cancellation UI path.
  • Added stopRunningChatPrompt(...) helper:
    • explicit stop button click
    • canvas change reset
    • component unmount cleanup

Related Issues

Closes #4076

Let me know if anything needs to be changed. Much love.

Signed-off-by: Arda Barış Tonç <tonc29719@yazilimlisesi.k12.tr>
@superplanehq-integration
Copy link
Copy Markdown

👋 Commands for maintainers:

  • /sp start - Start an ephemeral machine (takes ~30s)
  • /sp stop - Stop a running machine (auto-executed on pr close)

Copy link
Copy Markdown
Contributor

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

❌ 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;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f01a707. Configure here.

}

return previous;
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f01a707. Configure here.

title="Stop prompt"
>
<Square size={14} />
</button>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Fix in Cursor Fix in Web

Triggered by project rule: SuperPlane frontend — Bugbot rules

Reviewed by Cursor Bugbot for commit f01a707. Configure here.

@darkofabijan
Copy link
Copy Markdown
Contributor

/sp start

@superplanehq-integration
Copy link
Copy Markdown

✅ Ready.

Web: https://pr-4112-ephemeral.superplane.com
SSH: ssh -o StrictHostKeyChecking=no app@178.104.28.255
Logs: ssh -o StrictHostKeyChecking=no app@178.104.28.255 'cd superplane && make dev.logs.app'

@darkofabijan
Copy link
Copy Markdown
Contributor

/sp stop

@superplanehq-integration
Copy link
Copy Markdown

✅ Ephemeral machine has been terminated.

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.

Agent: Allow me to stop a running prompt

2 participants