fix(mobile-chat): restore composer draft on genuine send error (mc#2908 F7) #3034
Reference in New Issue
Block a user
Delete Branch "fix/mobile-chat-f7-composer-state-on-error"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes F7 from mobile-chat audit #2908.
MobileChatcleareddraftandpendingFilesbefore awaitingsendMessage, so a genuine send error left the composer empty with no way to retry. This PR snapshots the composer state before clearing and restores it whensendErrorsurfaces.Validation
npm run buildincanvas/passes.npx vitest run src/components/mobile/__tests__/MobileChat.test.tsxpasses (41/41), including a new regression test that verifies the textarea is repopulated after the "agent may be unreachable" banner appears.Relates-to: #2908
APPROVED after independent 5-axis review.
Correctness: mobile now snapshots draft text and attachments before clearing the composer, then restores them only when a genuine
sendErrorsurfaces. The snapshot is cleared after restore and overwritten on each send, so retry behavior is scoped to the failed send. Robustness: test covers the rejected-send path. Security/performance: no meaningful risk; files are already local pending attachments. Readability: minimal hook-level state with clear intent.APPROVED. 5-axis review on head
8991b5d0.Correctness: MobileChat snapshots the composer state before clearing it and restores draft/files when useChatSend surfaces a genuine sendError, so the user can retry after the unreachable/send-failure path. The snapshot is cleared after restore, avoiding repeated restores on unrelated later error state changes.
Robustness/security/performance: local React state only; no new network or auth behavior. File references are preserved in memory for retry and cleared on success/normal reachable flows as before.
Readability/tests: the regression test exercises the visible error banner and verifies the textarea is repopulated. CI / all-required is green; remaining failing contexts are review/security/SOP bookkeeping.