Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(webui): disarm queued prompt for voice shortcut
chengyongru47d498bab07b
diff --git a/webui/src/components/thread/ThreadComposer.tsx b/webui/src/components/thread/ThreadComposer.tsxindex 7571e5176..973cbdf25 100644--- a/webui/src/components/thread/ThreadComposer.tsx+++ b/webui/src/components/thread/ThreadComposer.tsx@@ -1304,6 +1304,7 @@ export function ThreadComposer({function onKeyDown(event: KeyboardEvent): void {if (!isVoiceShortcutDown(event) || event.repeat || voiceShortcutDownRef.current) return;event.preventDefault();+ secondEnterPromptIdRef.current = null;voiceShortcutDownRef.current = true;voiceRecorder.beginShortcutHold();}diff --git a/webui/src/tests/thread-composer.test.tsx b/webui/src/tests/thread-composer.test.tsxindex 239ccdbb5..5baf30632 100644--- a/webui/src/tests/thread-composer.test.tsx+++ b/webui/src/tests/thread-composer.test.tsx@@ -1581,9 +1581,41 @@ describe("ThreadComposer", () => {fireEvent.keyDown(input, { key: "Enter" });expect(onSend).toHaveBeenCalledWith("send this guidance now");+ expect(onSend).toHaveBeenCalledTimes(1);expect(screen.queryByText("send this guidance now")).not.toBeInTheDocument();});+ it("disarms the second Enter shortcut when keyboard voice recording starts", async () => {+ mockVoiceRecorder();+ const onSend = vi.fn();+ const onTranscribeAudio = vi.fn(async () => "voice guidance");+ render(+ <ThreadComposer+ onSend={onSend}+ onStop={vi.fn()}+ onTranscribeAudio={onTranscribeAudio}+ isStreaming+ placeholder="Type your message..."+ />,+ );++ const input = screen.getByLabelText("Message input");+ fireEvent.change(input, { target: { value: "keep this queued" } });+ fireEvent.keyDown(input, { key: "Enter" });+ fireEvent.keyDown(window, { code: "KeyD", ctrlKey: true, key: "D", shiftKey: true });++ expect(await screen.findByLabelText("Recording 0:00")).toBeInTheDocument();+ expect(input).toHaveFocus();+ fireEvent.keyDown(input, { key: "Enter" });++ expect(onSend).not.toHaveBeenCalled();+ expect(screen.getByText("keep this queued")).toBeInTheDocument();++ await waitForVoiceCapture();+ fireEvent.keyUp(window, { code: "KeyD", ctrlKey: true, key: "D", shiftKey: true });+ await waitFor(() => expect(onTranscribeAudio).toHaveBeenCalled());+ });+it("disarms the second Enter shortcut after stopping the active response", () => {const onSend = vi.fn();const onStop = vi.fn();@@ -1669,6 +1701,7 @@ describe("ThreadComposer", () => {fireEvent.keyDown(input, { key: "Enter" });expect(onSend).toHaveBeenCalledWith("guide this one now");+ expect(onSend).toHaveBeenCalledTimes(1);expect(screen.getByText("older guidance")).toBeInTheDocument();expect(screen.queryByText("guide this one now")).not.toBeInTheDocument();});@@ -2021,6 +2054,19 @@ describe("ThreadComposer", () => {expect(screen.queryByText("remember this edited follow-up")).not.toBeInTheDocument();});+ rerender(+ <ThreadComposer+ onSend={onSend}+ onStop={vi.fn()}+ isStreaming+ pendingQueueKey="chat-a"+ placeholder="Type your message..."+ />,+ );+ expect(await screen.findByText("remember this edited follow-up")).toBeInTheDocument();+ fireEvent.keyDown(screen.getByLabelText("Message input"), { key: "Enter" });+ expect(onSend).not.toHaveBeenCalled();+unmount();const remount = render(<ThreadComposer