Skip to content

feat(projects): cancel an in-flight project chat or analysis (#101) - #318

Open
Hustler490 wants to merge 1 commit into
AyinkxLab:mainfrom
Hustler490:feat/101-cancel-in-flight
Open

Hustler490 wants to merge 1 commit into
AyinkxLab:mainfrom
Hustler490:feat/101-cancel-in-flight

Conversation

@Hustler490

Copy link
Copy Markdown

Closes #101.

What

Lets users cancel a running project chat stream or analysis.

Backend (app/workspaces/routes.py)

api_project_chat_stream now accumulates the streamed tokens and:

  • on client disconnect/cancel (GeneratorExit) closes the upstream provider generator and stops without persisting a partial assistant message;
  • on a dropped socket (BrokenPipeError/ConnectionResetError) stops cleanly with no partial write;
  • on success persists the accumulated reply (dropping the previous redundant second chat_with_project LLM call) and emits the done event.

The user message is still persisted up front.

Frontend (project.html + project.js)

  • A Stop button appears while a chat stream or an analysis is running.
  • Chat uses an AbortController on the stream fetch; analysis passes the same signal through the API helper. Aborts are treated as intentional (no error toast) and reset the UI.

Tests (tests/test_project_chat_cancel.py)

  • Cancelling mid-stream (iterator.close()) persists no assistant message, keeps the user message.
  • A completed stream persists the full streamed reply and emits done.

Acceptance criteria

  • A cancel action aborts the stream and does not persist a partial assistant message.
  • The SSE route stops yielding when the client disconnects.
  • Non-streaming analyze has a cancellation path (client abort via AbortController).

@drips-wave

drips-wave Bot commented Sep 29, 2026

Copy link
Copy Markdown

@Hustler490 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Hustler490
Hustler490 force-pushed the feat/101-cancel-in-flight branch from 5b8132b to 9be7a2b Compare October 4, 2026 15:58
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.

Stop an in-flight project chat or analysis

2 participants