Skip to content

fix(bichat): don't discard a sent turn on abort; keep prompt on error#26

Merged
diyor28 merged 1 commit into
mainfrom
fix/bichat-deepmode-persist
Jun 9, 2026
Merged

fix(bichat): don't discard a sent turn on abort; keep prompt on error#26
diyor28 merged 1 commit into
mainfrom
fix/bichat-deepmode-persist

Conversation

@diyor28

@diyor28 diyor28 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Problem

Two independent stream-error bugs in the BiChat React UI, surfaced while tracing iota-uz/eai#2998:

  1. AbortError misclassificationMessageTransport flattened a user-stop / provider-unmount AbortError into a generic {type:'error', error:'Stream cancelled'} chunk, which ChatMachine re-threw as a plain Error. That defeated the err.name === "AbortError" soft-path guard, so Stop/unmount hit the destructive error branch and deleted the turn.
  2. Typed prompt lost on genuine error — the generic error branch removed the optimistic turn and showed a banner but, unlike the abort path, never restored the user's message to the input, silently losing what they typed.

Changes

  • data/MessageTransport.ts: for a user/unmount abort (AbortError && !connectionTimedOut), re-throw the original error so it stays an AbortError and 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 an AbortError (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

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 diyor28 merged commit f22f4f7 into main Jun 9, 2026
1 check passed
@diyor28 diyor28 deleted the fix/bichat-deepmode-persist branch June 9, 2026 06:29
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.
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.

1 participant