Skip to content

Commit a3a8dd3

Browse files
committed
fix(web): keep /side on its thread and off a pending question's attachments
1 parent c672780 commit a3a8dd3

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,13 @@ export function useComposerSend(input: ComposerSendInput) {
568568
);
569569
return;
570570
}
571-
const attachments = [...sendCtx.images, ...sendCtx.files];
571+
// A pending question's attachments belong to its answer, so the side chat gets none.
572+
const attachments = answeringQuestion ? [] : [...sendCtx.images, ...sendCtx.files];
572573
const startWithAttachments = async () => {
573574
const turnAttachments = await uploadSideChatAttachments(activeThread.id, attachments);
574-
if (turnAttachments === null) return false;
575+
if (turnAttachments === null || currentRouteThreadKeyRef.current !== routeThreadKey) {
576+
return false;
577+
}
575578
return onSideChat(
576579
sideChatFirstMessage({ prompt: sideChatCommand.prompt, attachments, turnAttachments }),
577580
);
@@ -588,11 +591,13 @@ export function useComposerSend(input: ComposerSendInput) {
588591
started &&
589592
currentRouteThreadKeyRef.current === routeThreadKey &&
590593
promptRef.current === promptAtSend &&
591-
composerRef.current?.hasPendingAttachments() !== true &&
592-
sameAttachmentIds(current ? [...current.images, ...current.files] : [], attachments)
594+
(answeringQuestion ||
595+
(composerRef.current?.hasPendingAttachments() !== true &&
596+
sameAttachmentIds(current ? [...current.images, ...current.files] : [], attachments)))
593597
) {
594598
promptRef.current = "";
595-
clearComposerPromptAndImages(composerDraftTarget);
599+
if (answeringQuestion) setComposerDraftPrompt(composerDraftTarget, "");
600+
else clearComposerPromptAndImages(composerDraftTarget);
596601
composerRef.current?.resetCursorState();
597602
releaseDraftAttachments(attachments);
598603
}

0 commit comments

Comments
 (0)