Skip to content

Commit bbc031c

Browse files
sergiiopmclaude
andcommitted
fix(web): keep the /side send path compilable by React Compiler
React Compiler skips hooks that use try/finally without catch, which failed the compiler coverage test for useComposerSend. Reset the in-flight flag with Promise.finally instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 4873ab6 commit bbc031c

1 file changed

Lines changed: 20 additions & 19 deletions

File tree

‎apps/web/src/components/chat/useComposerSend.ts‎

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -567,29 +567,30 @@ export function useComposerSend(input: ComposerSendInput) {
567567
return;
568568
}
569569
const attachments = [...sendCtx.images, ...sendCtx.files];
570-
sendInFlightRef.current = true;
571-
try {
570+
const startWithAttachments = async () => {
572571
const turnAttachments = await uploadSideChatAttachments(activeThread.id, attachments);
573-
if (turnAttachments === null) return;
574-
const started = await onSideChat(
572+
if (turnAttachments === null) return false;
573+
return onSideChat(
575574
sideChatFirstMessage({ prompt: sideChatCommand.prompt, attachments, turnAttachments }),
576575
);
577-
const current = composerRef.current?.getSendContext();
578-
// Clear only what was sent; the user may have edited the draft or left meanwhile.
579-
if (
580-
started &&
581-
currentRouteThreadKeyRef.current === routeThreadKey &&
582-
promptRef.current === promptAtSend &&
583-
composerRef.current?.hasPendingAttachments() !== true &&
584-
sameAttachmentIds(current ? [...current.images, ...current.files] : [], attachments)
585-
) {
586-
promptRef.current = "";
587-
clearComposerPromptAndImages(composerDraftTarget);
588-
composerRef.current?.resetCursorState();
589-
releaseDraftAttachments(attachments);
590-
}
591-
} finally {
576+
};
577+
sendInFlightRef.current = true;
578+
const started = await startWithAttachments().finally(() => {
592579
sendInFlightRef.current = false;
580+
});
581+
const current = composerRef.current?.getSendContext();
582+
// Clear only what was sent; the user may have edited the draft or left meanwhile.
583+
if (
584+
started &&
585+
currentRouteThreadKeyRef.current === routeThreadKey &&
586+
promptRef.current === promptAtSend &&
587+
composerRef.current?.hasPendingAttachments() !== true &&
588+
sameAttachmentIds(current ? [...current.images, ...current.files] : [], attachments)
589+
) {
590+
promptRef.current = "";
591+
clearComposerPromptAndImages(composerDraftTarget);
592+
composerRef.current?.resetCursorState();
593+
releaseDraftAttachments(attachments);
593594
}
594595
return;
595596
}

0 commit comments

Comments
 (0)