forked from evanp/inference-coop-copilot
Cancellation was only checked at POST time; once the SSE stream was open the reader loop never looked at the token again, so a stopped chat kept generating server-side (and billing) until the response ended. Wire an AbortController to token.onCancellationRequested, pass its signal to fetch, and check token.isCancellationRequested at the top of the reader loop so the connection closes as soon as the user stops the request. AbortError is swallowed (a stop is not a failure); real HTTP errors still surface, and the cancellation listener is disposed in a finally.