feat: add a Stop button to cancel in-flight AI chat responses#549
Merged
Conversation
While an AI chat response is running, the send button becomes a Stop (■) button; pressing it aborts the run instead of waiting for the answer. - chat-run-manager: hold an AbortController per run, add abort() / abortRunsForChat(), and settle cancelled runs as a new "aborted" status - thread the AbortSignal from the client fetch (runAgent) through the server route (c.req.raw.signal) into generateText, so the LLM call is stopped too — not just the client fetch — to avoid wasted tokens - treat AbortError as a cancellation, not an error: the question stays in the conversation, loading clears, input re-enables, no error message - i18n: aiChat.stop (en / ja) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Migration fixturesClick to expand migration results |
Contributor
Adversarial probesClick to expand probe results |
Contributor
Performance regressionClick to expand performance results |
Contributor
ELIFECYCLE Command failed with exit code 1. |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Stop button to the AI chat panel to cancel an in-flight response. While a response is running, the send button becomes a Stop (■) button; clicking it aborts the run — the client fetch is aborted and the
AbortSignalis threaded through the server route (c.req.raw.signal) intogenerateText, so the LLM call stops too (no wasted tokens), not just the client fetch.AbortErroris treated as a cancellation (not an error): the question stays in the conversation, loading clears, input re-enables.Because chat responses are single-shot (not streamed), Stop discards the pending generation and returns to the input.
What changed
chat-run-manager.ts: AbortController per run,abort()/abortRunsForChat(), new"aborted"statusnote-app.tsx: thread AbortSignal intorunAgent;applyAbortedkeeps the question and clears loading;handleAiChatStoppanel.tsx: render Stop (■) in place of Send while loading (onStop)agent-loop.ts/agent-loop-text-tools.ts/agent.ts): passabortSignaltogenerateTextaiChat.stop(en/ja)No data-model / index-schema changes.
Test Plan
tsc --noEmit/vitest(1306 pass) /build— all green🤖 Generated with Claude Code