2026-10-24 02:50:47 +08:00
|
|
|
import { useState } from "react";
|
|
|
|
|
import { ThreadComposer } from "@/components/thread/ThreadComposer";
|
2026-11-18 16:10:02 +08:00
|
|
|
import { ToastProvider } from "@/components/ui/toast";
|
|
|
|
|
|
|
|
|
|
export function installMissingMicrophonePreview() {
|
|
|
|
|
Object.defineProperty(navigator.mediaDevices, "getUserMedia", {
|
|
|
|
|
value: async () => { throw new DOMException("No microphone", "NotFoundError"); },
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-10-24 02:50:47 +08:00
|
|
|
|
|
|
|
|
export function ComposerActionFixture({ parameters }: { parameters: URLSearchParams }) {
|
|
|
|
|
const [running, setRunning] = useState(false);
|
|
|
|
|
const [stopRequested, setStopRequested] = useState(false);
|
2026-11-18 16:10:02 +08:00
|
|
|
return <ToastProvider><main className="mx-auto w-full max-w-5xl px-4" style={{ paddingTop: "6rem" }}>
|
2026-10-24 02:50:47 +08:00
|
|
|
<ThreadComposer
|
|
|
|
|
variant={parameters.get("composerVariant") === "thread" ? "thread" : "hero"}
|
2026-11-06 11:57:27 +08:00
|
|
|
placeholder={parameters.has("opening") ? "Opening a new topic…" : undefined}
|
2026-10-24 02:50:47 +08:00
|
|
|
modelLabel="Preview"
|
|
|
|
|
isStreaming={running}
|
|
|
|
|
onTranscribeAudio={async () => "Voice draft"}
|
|
|
|
|
onSend={() => { setStopRequested(false); setRunning(true); }}
|
|
|
|
|
onStop={() => setStopRequested(true)}
|
|
|
|
|
/>
|
|
|
|
|
<div className="mt-6 flex gap-4 text-sm">
|
|
|
|
|
<output aria-label="Execution status">{stopRequested ? "Stop requested" : running ? "Working" : "Idle"}</output>
|
|
|
|
|
<button onClick={() => { setRunning(false); setStopRequested(false); }}>Finish response</button>
|
|
|
|
|
<button onClick={() => document.documentElement.classList.toggle("dark")}>Toggle theme</button>
|
|
|
|
|
</div>
|
2026-11-18 16:10:02 +08:00
|
|
|
</main></ToastProvider>;
|
2026-10-24 02:50:47 +08:00
|
|
|
}
|