fix: thread allowEmptySubmit through composer submit path
The Create button on the new workspace screen was visible but clicking it did nothing — submitAgentInput() still rejected empty payloads as "noop". Thread allowEmptySubmit through Composer into submitAgentInput so the callback fires and workspace creation + redirect completes. Adds regression test for the empty-submit path.
This commit is contained in:
@@ -137,4 +137,37 @@ describe("submitAgentInput", () => {
|
||||
expect(setIsProcessing).toHaveBeenNthCalledWith(2, false);
|
||||
expect(clearDraft).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("submits when empty submit is explicitly allowed", async () => {
|
||||
const queueMessage = vi.fn();
|
||||
const submitMessage = vi.fn(async () => {});
|
||||
const clearDraft = vi.fn();
|
||||
const setUserInput = vi.fn();
|
||||
const setSelectedImages = vi.fn();
|
||||
const setSendError = vi.fn();
|
||||
const setIsProcessing = vi.fn();
|
||||
|
||||
await expect(
|
||||
submitAgentInput({
|
||||
message: " ",
|
||||
allowEmptySubmit: true,
|
||||
isAgentRunning: false,
|
||||
canSubmit: true,
|
||||
queueMessage,
|
||||
submitMessage,
|
||||
clearDraft,
|
||||
setUserInput,
|
||||
setSelectedImages,
|
||||
setSendError,
|
||||
setIsProcessing,
|
||||
}),
|
||||
).resolves.toBe("submitted");
|
||||
|
||||
expect(queueMessage).not.toHaveBeenCalled();
|
||||
expect(submitMessage).toHaveBeenCalledWith({
|
||||
message: "",
|
||||
imageAttachments: undefined,
|
||||
});
|
||||
expect(clearDraft).toHaveBeenCalledWith("sent");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ export interface AgentInputSubmitActionInput<TImage> {
|
||||
message: string;
|
||||
imageAttachments?: TImage[];
|
||||
hasExternalContent?: boolean;
|
||||
allowEmptySubmit?: boolean;
|
||||
forceSend?: boolean;
|
||||
isAgentRunning: boolean;
|
||||
canSubmit: boolean;
|
||||
@@ -23,7 +24,12 @@ export async function submitAgentInput<TImage>(
|
||||
const trimmedMessage = input.message.trim();
|
||||
const imageAttachments = input.imageAttachments;
|
||||
|
||||
if (!trimmedMessage && !imageAttachments?.length && !input.hasExternalContent) {
|
||||
if (
|
||||
!trimmedMessage &&
|
||||
!imageAttachments?.length &&
|
||||
!input.hasExternalContent &&
|
||||
!input.allowEmptySubmit
|
||||
) {
|
||||
return "noop";
|
||||
}
|
||||
|
||||
|
||||
@@ -359,6 +359,7 @@ export function Composer({
|
||||
message,
|
||||
imageAttachments,
|
||||
hasExternalContent,
|
||||
allowEmptySubmit,
|
||||
forceSend,
|
||||
isAgentRunning: agentState.status === "running",
|
||||
// Parent-managed submits are still valid submit paths even when the
|
||||
|
||||
Reference in New Issue
Block a user