fix(collab): preserved editor ask responses verbatim

Dropped trim and empty gating in the collab web composer so custom ask editor responses ship exactly what the user typed, matching HookEditor's local submit.
This commit is contained in:
roboomp
2026-07-01 05:22:47 +00:00
parent 9d3918bdac
commit 6efdd000f0
2 changed files with 12 additions and 4 deletions
@@ -32,7 +32,7 @@ export function Composer({ client, snapshot }: ComposerProps): ReactNode {
const busy = snapshot.working || (snapshot.state?.isStreaming ?? false);
const queued = snapshot.state?.queuedMessageCount ?? 0;
const canSend = canPrompt && text.trim().length > 0;
const canSubmitUiDraft = canPrompt && uiRequest?.kind === "editor" && uiDraft.trim().length > 0;
const canSubmitUiDraft = canPrompt && uiRequest?.kind === "editor";
useEffect(() => {
setUiDraft(uiRequest?.kind === "editor" ? (uiRequestPrefill ?? "") : "");
@@ -55,9 +55,8 @@ export function Composer({ client, snapshot }: ComposerProps): ReactNode {
}, [client, live, readOnly, text]);
const submitUiDraft = useCallback((): void => {
const trimmed = uiDraft.trim();
if (!trimmed || !canPrompt || uiRequest?.kind !== "editor") return;
client.sendUiResponse(uiRequest.reqId, trimmed);
if (!canPrompt || uiRequest?.kind !== "editor") return;
client.sendUiResponse(uiRequest.reqId, uiDraft);
setUiDraft("");
}, [canPrompt, client, uiDraft, uiRequest]);
@@ -57,4 +57,13 @@ describe("Composer host UI requests", () => {
expect(html).toContain("draft");
expect(html).toContain("Submit");
});
it("keeps the editor submit enabled for whitespace-only drafts", () => {
const html = renderToStaticMarkup(
<Composer client={client} snapshot={snapshot({ reqId: 3, kind: "editor", title: "Other", prefill: " " })} />,
);
expect(html).toContain('title="submit response"');
expect(html).not.toMatch(/title="submit response"[^>]*disabled/);
});
});