Skip to content

Customer chat: composer is cleared before the SDK has accepted the send #1377

Description

@marassteiner

Follow-up from #1297 (not a merge blocker). Pre-existing pattern (the merge-base already called submitMessage and then cleared the input). This PR added a .catch(reportClientError) that does not match the published SDK’s promise.

Evidence

src/screens/chat.screen.tsx:411 clears inputValue and selectedFiles immediately after submitMessage(...).

Published @dfx.swiss/react 1.7.x starts file conversion in an un-awaited forEach(async ...). Conversion happens before the optimistic bubble is inserted; API failures are swallowed inside the SDK (createMessage(...).catch(() => settleMessage(messageId))). The new screen-level .catch therefore does not run on a network failure. If FileReader fails, the composer is already empty and no failed bubble appears — text and attachments are gone.

The unit test that mocks submitMessage as a rejecting promise does not model this SDK behaviour.

Suggested fix

Fix belongs in the SDK: await the send jobs, turn conversion errors into a visible failed message, and return a promise that actually rejects. In this repo, clear the composer only after the SDK has taken the optimistic message. Consume that SDK release here (same sequence as DFXswiss/packages#210).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions