fix(webui): explain HTTPS requirement for voice input (#5304)

This commit is contained in:
chengyongru
2026-08-09 21:17:57 +08:00
committed by GitHub
parent af52fbcbc4
commit 411d6061ae
14 changed files with 70 additions and 1 deletions
+43
View File
@@ -651,6 +651,49 @@ describe("ThreadComposer", () => {
expect(onSend).not.toHaveBeenCalled();
});
it("explains the HTTPS requirement for voice input on an insecure origin", async () => {
const { getUserMedia } = mockVoiceRecorder();
vi.stubGlobal("isSecureContext", false);
render(
<ThreadComposer
onSend={vi.fn()}
onTranscribeAudio={vi.fn(async () => "unused")}
placeholder="Type your message..."
/>,
);
fireEvent.click(screen.getByRole("button", { name: "Voice input" }));
expect(
await screen.findByText(
"Chrome and other browsers block microphone access on remote HTTP pages for security. "
+ "Open this WebUI over HTTPS to use voice input.",
),
).toBeInTheDocument();
expect(screen.getByRole("alert")).toHaveClass("max-h-24");
expect(getUserMedia).not.toHaveBeenCalled();
});
it("keeps the unsupported-browser error for secure origins without recording support", async () => {
const { getUserMedia } = mockVoiceRecorder();
vi.stubGlobal("isSecureContext", true);
vi.stubGlobal("MediaRecorder", undefined);
render(
<ThreadComposer
onSend={vi.fn()}
onTranscribeAudio={vi.fn(async () => "unused")}
placeholder="Type your message..."
/>,
);
fireEvent.click(screen.getByRole("button", { name: "Voice input" }));
expect(
await screen.findByText("Voice input is not supported in this browser."),
).toBeInTheDocument();
expect(getUserMedia).not.toHaveBeenCalled();
});
it("converts voice recordings to wav for Xiaomi MiMo transcription", async () => {
mockVoiceRecorder(new Blob([new Uint8Array([1, 2, 3, 4])], { type: "audio/webm" }));
const { decodeAudioData } = mockVoiceAudioInput(