Skip to content

Bug: composer eats typed text on 4xx/5xx send failure #776

@heavygee

Description

@heavygee

Problem

When the message composer submits and the hub responds with a 4xx or 5xx (or the fetch fails outright), the composer clears the input -- the operator's typed text is destroyed. This is destructive at exactly the moment the operator most needs their text retained so they can retry without losing what they wrote.

Example: composer fires POST /api/sessions/:id/messages, hub returns 503 during a restart -> text discarded.

This is reproducible during any hub restart blip. @assistant-ui/react's composer clears composer.text synchronously the moment send is invoked, so by the time useSendMessage's mutation rejects the input is already gone.

Proposal

Don't clear the composer on error. Only clear on 2xx.

  1. On 2xx - clear input, finalise the optimistic render (today's behaviour).
  2. On 4xx / 5xx / network error - restore the input (don't destroy it), surface the error inline, allow retry.
  3. The operator can edit the retained text and retry without retyping.

Acceptance

  • Submit -> 500/502/503/network error -> composer text not cleared
  • Submit -> 400/401/403 -> composer text not cleared, error surfaces inline
  • Submit -> 2xx -> composer clears as today
  • Operator can edit retained text and retry without re-typing
  • Test covering all three branches

Notes

  • Composer wiring lives in web/src/components/AssistantChat/HappyComposer.tsx and web/src/hooks/mutations/useSendMessage.ts.
  • A small visual on the composer (red ring + inline error message) is welcome alongside text retention so the failure is obvious.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions