fix(bichat): don't discard a sent turn on abort; keep prompt on error#26
Merged
Conversation
Two independent stream-error bugs in the chat UI:
- MessageTransport flattened a user/unmount AbortError into a generic
{type:'error'} chunk, which ChatMachine re-threw as a plain Error,
defeating the AbortError soft-path guard. Stop/unmount thus hit the
destructive error branch and deleted the turn. Re-throw the AbortError
so the soft-cancel path runs; keep a connection timeout as a genuine
error chunk.
- On a genuine stream error, the user's typed prompt was silently lost.
Restore it to the input (mirroring the abort path); the error banner
and Retry remain available.
Refs iota-uz/eai#2998
diyor28
added a commit
that referenced
this pull request
Jun 9, 2026
Includes the BiChat deep-mode abort/error UX fix (#26): re-throw AbortError on user/unmount cancel, restore the typed prompt on a genuine stream error.
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.
Problem
Two independent stream-error bugs in the BiChat React UI, surfaced while tracing iota-uz/eai#2998:
MessageTransportflattened a user-stop / provider-unmountAbortErrorinto a generic{type:'error', error:'Stream cancelled'}chunk, whichChatMachinere-threw as a plainError. That defeated theerr.name === "AbortError"soft-path guard, so Stop/unmount hit the destructive error branch and deleted the turn.Changes
data/MessageTransport.ts: for a user/unmount abort (AbortError && !connectionTimedOut), re-throw the original error so it stays anAbortErrorand the machine takes its soft-cancel path. A connection timeout still yields a genuine error chunk.machine/ChatMachine.ts: on a genuine stream error, restore the user's prompt to the input (mirroring the abort path). The error banner and Retry remain.No data-model / wire-contract change (deliberately minimal; the backend fix in iota-uz/iota-sdk#800 is what makes the answer durable).
Tests
data/MessageTransport.test.ts: abort re-throws anAbortError(no error chunk); connection timeout still yields a timeout error chunk.machine/ChatMachine.sendError.test.ts: genuine error → prompt restored + banner; abort → prompt restored, no banner.pnpm run typecheck+ eslint clean; new tests pass.Refs iota-uz/eai#2998