Skip to content

Commit 489260d

Browse files
t3dotggclaude
andcommitted
fix(web): question answers submit while normal sends are blocked
An enabled Submit on a pending question did nothing while the composer could not send a provider turn (no provider, messages loading, send in flight, reconnecting). Answers now skip those provider-turn guards and go straight to the answer handler. Their own attachment checks and the connection check still apply. Closes #9318 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 066c8fc commit 489260d

3 files changed

Lines changed: 58 additions & 4 deletions

File tree

‎apps/web/src/components/chat/ChatComposer.tsx‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ import { cn, isMacPlatform, randomUUID } from "~/lib/utils";
310310
import {
311311
getComposerPromptLengthValidationMessage,
312312
getComposerSubmissionValidationMessage,
313+
isComposerSubmissionBlocked,
313314
submitComposerDraft,
314315
} from "./composerSubmission";
315316
import { ComposerPromptLengthValidation } from "./ComposerPromptLengthValidation";
@@ -3446,9 +3447,15 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
34463447
dispatchMode?: ComposerDispatchMode,
34473448
submissionIntent?: ComposerSubmissionIntent,
34483449
) => {
3450+
const submissionTarget = activePendingProgress ? "pending-user-input" : "provider-turn";
34493451
if (
3450-
noProviderAvailable ||
3451-
isSendDisabled ||
3452+
isComposerSubmissionBlocked({
3453+
submissionTarget,
3454+
noProviderAvailable,
3455+
sendDisabledReason,
3456+
attachmentBlockReason,
3457+
environmentUnavailable: environmentUnavailable !== null,
3458+
}) ||
34523459
!readEnvironmentScope(environmentId, AuthOrchestrationOperateScope)
34533460
) {
34543461
event?.preventDefault();
@@ -3477,9 +3484,15 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
34773484
}
34783485
const submission = submitComposerDraft({
34793486
prompt: promptRef.current,
3480-
submissionTarget: activePendingProgress ? "pending-user-input" : "provider-turn",
3487+
submissionTarget,
34813488
event,
34823489
onSend: (sendEvent) => {
3490+
// The thread's send guards are for provider turns, so an answer skips them.
3491+
if (submissionTarget === "pending-user-input") {
3492+
sendEvent?.preventDefault();
3493+
onAdvanceActivePendingUserInput();
3494+
return;
3495+
}
34833496
providerInputRejectedRef.current = false;
34843497
onSend(
34853498
sendEvent,

‎apps/web/src/components/chat/composerSubmission.test.ts‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from "@t3tools/shared/assistantCitations";
1212
import { describe, expect, it, vi } from "vite-plus/test";
1313

14-
import { submitComposerDraft } from "./composerSubmission";
14+
import { isComposerSubmissionBlocked, submitComposerDraft } from "./composerSubmission";
1515

1616
const assistantCitation = {
1717
version: 1 as const,
@@ -208,3 +208,30 @@ describe("submitComposerDraft", () => {
208208
expect(onSend).toHaveBeenCalledOnce();
209209
});
210210
});
211+
212+
describe("isComposerSubmissionBlocked", () => {
213+
const sendBlocked = {
214+
noProviderAvailable: true,
215+
sendDisabledReason: "Messages loading",
216+
attachmentBlockReason: null,
217+
environmentUnavailable: false,
218+
};
219+
220+
// regression: #9318
221+
it("lets a pending answer through while provider-turn sends are blocked", () => {
222+
expect(
223+
isComposerSubmissionBlocked({ ...sendBlocked, submissionTarget: "pending-user-input" }),
224+
).toBe(false);
225+
expect(isComposerSubmissionBlocked({ ...sendBlocked, submissionTarget: "provider-turn" })).toBe(
226+
true,
227+
);
228+
});
229+
230+
it("still blocks a pending answer on its attachments or a lost connection", () => {
231+
const answer = { ...sendBlocked, submissionTarget: "pending-user-input" as const };
232+
expect(
233+
isComposerSubmissionBlocked({ ...answer, attachmentBlockReason: "Attach the file again" }),
234+
).toBe(true);
235+
expect(isComposerSubmissionBlocked({ ...answer, environmentUnavailable: true })).toBe(true);
236+
});
237+
});

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ export function getComposerSubmissionValidationMessage(
3030
: null;
3131
}
3232

33+
// Answering a question responds to the open request instead of starting a provider turn, so
34+
// provider and turn-send state must not block it. Its own attachments and connection still do.
35+
export function isComposerSubmissionBlocked(input: {
36+
submissionTarget: ComposerSubmissionInput["submissionTarget"];
37+
noProviderAvailable: boolean;
38+
sendDisabledReason: string | null;
39+
attachmentBlockReason: string | null;
40+
environmentUnavailable: boolean;
41+
}): boolean {
42+
return input.submissionTarget === "pending-user-input"
43+
? input.attachmentBlockReason !== null || input.environmentUnavailable
44+
: input.noProviderAvailable || input.sendDisabledReason !== null;
45+
}
46+
3347
export function submitComposerDraft(
3448
options: ComposerSubmissionInput & {
3549
event: ComposerSubmitEvent | undefined;

0 commit comments

Comments
 (0)