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:
@@ -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/);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user