Skip to content

Commit 751a51c

Browse files
sergiiopmclaude
andcommitted
fix(web): show the composer busy while /side starts
After uploads finished, the side chat could still be opening while the send button stayed enabled, and a second send returned silently. Keep the composer busy until the side-chat start settles, scoped to the thread that started it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent bbc031c commit 751a51c

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2918,7 +2918,7 @@ export default function ChatView(props: ChatViewProps) {
29182918
activeEnvironmentUnavailable,
29192919
defaultRuntimeMode,
29202920
});
2921-
const { onSend } = useComposerSend({
2921+
const { onSend, sideChatStarting } = useComposerSend({
29222922
environmentId,
29232923
routeThreadKey,
29242924
currentRouteThreadKeyRef,
@@ -3646,6 +3646,7 @@ export default function ChatView(props: ChatViewProps) {
36463646
canInterrupt={canInterruptRunningThread}
36473647
isSendBusy={
36483648
(isSendBusy && !sendQueuesBehindSetup) ||
3649+
sideChatStarting ||
36493650
(setupQueueSendThreadKey !== null &&
36503651
setupQueueSendThreadKey === activeThreadKey) ||
36513652
queuedRunEdit.isSaving ||

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import {
4646
scopeThreadRef,
4747
} from "@t3tools/client-runtime/environment";
4848
import { createModelSelection } from "@t3tools/shared/model";
49-
import { type SetStateAction, useLayoutEffect, useRef } from "react";
49+
import { type SetStateAction, useLayoutEffect, useRef, useState } from "react";
5050
import { flushSync } from "react-dom";
5151
import { useNavigate } from "@tanstack/react-router";
5252
import {
@@ -400,6 +400,8 @@ export function useComposerSend(input: ComposerSendInput) {
400400
persistThreadSettingsForNextTurn,
401401
});
402402
const { sendInFlight: sendInFlightRef } = draftSendState(routeThreadKey);
403+
// Keeps the composer busy until a `/side` start settles, uploads included.
404+
const [sideChatStartingThreadKey, setSideChatStartingThreadKey] = useState<string | null>(null);
403405
const composerSendGenerationRef = useRef(0);
404406
const environmentUnavailableSendToastSlotRef = useRef(0);
405407
// A send awaits uploads before it declines, so it reads the approvals pending by then.
@@ -575,8 +577,10 @@ export function useComposerSend(input: ComposerSendInput) {
575577
);
576578
};
577579
sendInFlightRef.current = true;
580+
setSideChatStartingThreadKey(routeThreadKey);
578581
const started = await startWithAttachments().finally(() => {
579582
sendInFlightRef.current = false;
583+
setSideChatStartingThreadKey((current) => (current === routeThreadKey ? null : current));
580584
});
581585
const current = composerRef.current?.getSendContext();
582586
// Clear only what was sent; the user may have edited the draft or left meanwhile.
@@ -1588,7 +1592,7 @@ export function useComposerSend(input: ComposerSendInput) {
15881592
}
15891593
};
15901594

1591-
return { onSend };
1595+
return { onSend, sideChatStarting: sideChatStartingThreadKey === routeThreadKey };
15921596
}
15931597

15941598
function sameAttachmentIds(

0 commit comments

Comments
 (0)