feat(webui): interject via the send button while streaming
While a turn is streaming, the primary action button stays Stop only while the composer is empty. Once the user types, the send affordance takes over (ChatGPT-style): tapping Send stops the running turn for the agent and immediately delivers the new message with continueActiveTurn semantics — the same backend contract the queued-guidance flush uses. This restores 插嘴 (interjection) on touch devices, where Enter now inserts a newline instead of queueing guidance (the queue-guidance flow stays available on precision-pointer devices via Enter, and the queued prompt stack still sends already-queued prompts anywhere). submit() now carries continueActiveTurn while streaming; the button icon switches to the send arrow in that state.
This commit is contained in:
1 parent
2750a19601
commit
42b85efa98
2 files changed
+70
-6
No files matched your search
@@ -2966,6 +2966,61 @@ describe("ThreadComposer", () => {
|
||||
expect(screen.queryByRole("button", { name: "Send message" })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("switches the primary action from Stop to Send while streaming once the user types", () => {
|
||||
const onSend = vi.fn();
|
||||
const onStop = vi.fn();
|
||||
render(
|
||||
<ThreadComposer
|
||||
onSend={onSend}
|
||||
onStop={onStop}
|
||||
isStreaming
|
||||
placeholder="Type your message..."
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(screen.getByRole("button", { name: "Stop response" })).toBeInTheDocument();
|
||||
|
||||
const input = screen.getByLabelText("Message input");
|
||||
fireEvent.change(input, { target: { value: "one more thing: " } });
|
||||
|
||||
expect(screen.queryByRole("button", { name: "Stop response" })).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Send message" }));
|
||||
|
||||
expect(onStop).not.toHaveBeenCalled();
|
||||
expect(onSend).toHaveBeenCalledWith("one more thing:", undefined, {
|
||||
continueActiveTurn: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("interjects with the send button on coarse-pointer devices while streaming", () => {
|
||||
stubCoarsePointer();
|
||||
const onSend = vi.fn();
|
||||
render(
|
||||
<ThreadComposer
|
||||
onSend={onSend}
|
||||
onStop={vi.fn()}
|
||||
isStreaming
|
||||
placeholder="Type your message..."
|
||||
/>,
|
||||
);
|
||||
|
||||
const input = screen.getByLabelText("Message input");
|
||||
fireEvent.change(input, { target: { value: "hold on, actually…" } });
|
||||
const keyEvent = createEvent.keyDown(input, { key: "Enter" });
|
||||
fireEvent(input, keyEvent);
|
||||
|
||||
// Enter inserts a newline on touch; the send button is the interject path.
|
||||
expect(keyEvent.defaultPrevented).toBe(false);
|
||||
expect(onSend).not.toHaveBeenCalled();
|
||||
expect(screen.getByRole("button", { name: "Send message" })).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "Send message" }));
|
||||
|
||||
expect(onSend).toHaveBeenCalledWith("hold on, actually…", undefined, {
|
||||
continueActiveTurn: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("queues plain guidance while a task is running", () => {
|
||||
const onSend = vi.fn();
|
||||
render(
|
||||
|
||||
Reference in new issue
Block a user