{epics.map((e) => (
diff --git a/apps/web/app/(app)/t/[key]/tabs.tsx b/apps/web/app/(app)/t/[key]/tabs.tsx
index c95ed127..2f9d2e4f 100644
--- a/apps/web/app/(app)/t/[key]/tabs.tsx
+++ b/apps/web/app/(app)/t/[key]/tabs.tsx
@@ -5,6 +5,7 @@ import { CircleCheck, CircleX, ExternalLink, GitMerge, GitPullRequest, Hourglass
import type { ChangeArtifacts, CiSummary, CodeReview, DeltaOp, GiteaPull, Question, StoryComment, TasksProgress } from "@peppa/core";
import { reviewLabel } from "@peppa/core";
import { Hidden, QuestionCard } from "@/components/cards";
+import { Dictate } from "@/components/Dictate";
import { ago, Disclosure, Empty } from "@/components/common";
import { Markdown } from "@/components/Markdown";
import { eventLine } from "@/components/RunnerConsole";
@@ -171,6 +172,7 @@ export function CommentsTab({ taskKey, taskStatus, questions, comments, back, ha
+
diff --git a/apps/web/app/api/transcribe/route.ts b/apps/web/app/api/transcribe/route.ts
new file mode 100644
index 00000000..f6f311b6
--- /dev/null
+++ b/apps/web/app/api/transcribe/route.ts
@@ -0,0 +1,51 @@
+// PEP-108: dictation in the web — the browser records (MediaRecorder: webm/opus, Safari mp4) and
+// posts the audio here; Peppa forwards it to the same speech-to-text service as the Telegram bot
+// (PEPPA_TRANSCRIBE_URL, core/transcribe.ts) and returns the text. The page puts it into the
+// field, the user edits and sends. Logged-in users only; size cap and a per-user rate limit.
+import { transcribe, transcribeConfig, TranscribeError } from "@peppa/core";
+import { currentUser } from "@/lib/auth";
+
+export const dynamic = "force-dynamic";
+
+/** ~10 minutes of opus; the service itself takes up to 25 MB. */
+const MAX_BYTES = 10 * 1024 * 1024;
+const PER_USER_PER_5MIN = 30;
+const g = globalThis as { __peppaTranscribeHits?: Map };
+const hits = (g.__peppaTranscribeHits ??= new Map());
+
+function limited(userId: number, now = Date.now()): boolean {
+ const h = hits.get(userId);
+ if (!h || now - h.at >= 5 * 60_000) {
+ hits.set(userId, { at: now, n: 1 });
+ return false;
+ }
+ return ++h.n > PER_USER_PER_5MIN;
+}
+
+const json = (status: number, body: { text?: string; error?: string }) => Response.json(body, { status, headers: { "Cache-Control": "private, no-store" } });
+
+export async function POST(req: Request) {
+ const user = await currentUser();
+ if (!user) return json(401, { error: "Нужно войти" });
+ const cfg = transcribeConfig();
+ if (!cfg) return json(503, { error: "Распознавание речи не настроено — напишите текстом" });
+ if (Number(req.headers.get("content-length") ?? 0) > MAX_BYTES) return json(413, { error: "Слишком длинная запись — запишите короче" });
+ if (limited(user.id)) return json(429, { error: "Слишком много записей подряд — подождите пару минут" });
+ let file: FormDataEntryValue | null;
+ try {
+ file = (await req.formData()).get("file");
+ } catch {
+ return json(400, { error: "Запись не пришла" });
+ }
+ if (!(file instanceof Blob) || !file.size) return json(400, { error: "Запись пустая" });
+ if (file.size > MAX_BYTES) return json(413, { error: "Слишком длинная запись — запишите короче" });
+ const type = file.type || "audio/webm";
+ const ext = type.includes("mp4") ? "m4a" : type.includes("ogg") ? "ogg" : type.includes("wav") ? "wav" : "webm";
+ try {
+ const text = await transcribe(cfg, Buffer.from(await file.arrayBuffer()), `dictation.${ext}`, type);
+ return json(200, { text });
+ } catch (e) {
+ if (e instanceof TranscribeError) return json(502, { error: e.message });
+ throw e;
+ }
+}
diff --git a/apps/web/components/Dictate.tsx b/apps/web/components/Dictate.tsx
new file mode 100644
index 00000000..0987de16
--- /dev/null
+++ b/apps/web/components/Dictate.tsx
@@ -0,0 +1,7 @@
+// PEP-108: the microphone for a text field, only where the server has speech to text.
+import { voiceStoriesEnabled } from "@peppa/shared";
+import { DictateButton } from "@/components/DictateButton";
+
+export function Dictate(props: { target: string; className?: string; compact?: boolean }) {
+ return voiceStoriesEnabled() ? : null;
+}
diff --git a/apps/web/components/DictateButton.tsx b/apps/web/components/DictateButton.tsx
new file mode 100644
index 00000000..ccb9fcdc
--- /dev/null
+++ b/apps/web/components/DictateButton.tsx
@@ -0,0 +1,112 @@
+"use client";
+
+// PEP-108: a microphone next to a text field — records in the browser (MediaRecorder), sends the
+// audio to Peppa (POST /api/transcribe → the speech-to-text service, the same as the Telegram
+// bot's) and appends the text to the field; the user edits it and sends as usual. Rendered only
+// when the server has speech to text (see Dictate) and the browser can record.
+import { useEffect, useRef, useState } from "react";
+import { Loader2, Mic, Square } from "lucide-react";
+import { Button } from "@/components/ui/button";
+import { cn } from "@/lib/utils";
+
+/** Longest recording; the bot's voice limit is the same 3 minutes. */
+const MAX_MS = 3 * 60_000;
+
+type State = "idle" | "recording" | "sending";
+
+/** Appends text to an input/textarea so that React-controlled fields notice it too. */
+function appendTo(target: string, text: string) {
+ const el = document.getElementById(target) as HTMLInputElement | HTMLTextAreaElement | null;
+ if (!el) return;
+ const value = `${el.value}${el.value && !/\s$/.test(el.value) ? " " : ""}${text}`;
+ const proto = el instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
+ Object.getOwnPropertyDescriptor(proto, "value")?.set?.call(el, value);
+ el.dispatchEvent(new Event("input", { bubbles: true }));
+ el.focus();
+}
+
+function pickMime(): string | undefined {
+ for (const t of ["audio/webm;codecs=opus", "audio/webm", "audio/mp4", "audio/ogg;codecs=opus"]) {
+ if (MediaRecorder.isTypeSupported?.(t)) return t;
+ }
+ return undefined;
+}
+
+export function DictateButton({ target, className, compact = false }: { target: string; className?: string; compact?: boolean }) {
+ const [supported, setSupported] = useState(false);
+ const [state, setState] = useState("idle");
+ const [error, setError] = useState(null);
+ const rec = useRef(null);
+ const timer = useRef | null>(null);
+
+ useEffect(() => {
+ setSupported(typeof window !== "undefined" && !!navigator.mediaDevices?.getUserMedia && typeof MediaRecorder !== "undefined");
+ return () => {
+ if (timer.current) clearTimeout(timer.current);
+ rec.current?.stream.getTracks().forEach((t) => t.stop());
+ };
+ }, []);
+ if (!supported) return null;
+
+ async function send(blob: Blob) {
+ setState("sending");
+ try {
+ const form = new FormData();
+ form.set("file", blob, "dictation");
+ const res = await fetch("/api/transcribe", { method: "POST", body: form });
+ const body = (await res.json().catch(() => ({}))) as { text?: string; error?: string };
+ if (!res.ok) throw new Error(body.error || `Не получилось распознать (${res.status})`);
+ if (!body.text) throw new Error("Не разобрал ни слова — попробуйте ещё раз");
+ appendTo(target, body.text);
+ } catch (e) {
+ setError((e as Error).message);
+ } finally {
+ setState("idle");
+ }
+ }
+
+ async function start() {
+ setError(null);
+ let stream: MediaStream;
+ try {
+ stream = await navigator.mediaDevices.getUserMedia({ audio: true });
+ } catch {
+ setError("Нет доступа к микрофону — разрешите его в браузере");
+ return;
+ }
+ const mimeType = pickMime();
+ const r = new MediaRecorder(stream, mimeType ? { mimeType } : undefined);
+ const chunks: Blob[] = [];
+ r.ondataavailable = (e) => e.data.size && chunks.push(e.data);
+ r.onstop = () => {
+ stream.getTracks().forEach((t) => t.stop());
+ if (timer.current) clearTimeout(timer.current);
+ void send(new Blob(chunks, { type: r.mimeType || mimeType || "audio/webm" }));
+ };
+ rec.current = r;
+ r.start();
+ setState("recording");
+ timer.current = setTimeout(() => r.state === "recording" && r.stop(), MAX_MS);
+ }
+
+ const label = state === "recording" ? "Стоп" : state === "sending" ? "Распознаю…" : "Голосом";
+ return (
+
+
+ {error && {error}}
+
+ );
+}
diff --git a/apps/web/components/cards.tsx b/apps/web/components/cards.tsx
index 554e4ed0..a5a20bd1 100644
--- a/apps/web/components/cards.tsx
+++ b/apps/web/components/cards.tsx
@@ -9,6 +9,7 @@ import { AgentBadge } from "@/components/AgentBadge";
import { Input } from "@/components/ui/input";
import { ago, Disclosure, Empty, Key, StatusBadge } from "@/components/common";
import { AgentSteps } from "@/components/AgentSteps";
+import { Dictate } from "@/components/Dictate";
import { RunnerTerminal } from "@/components/RunnerTerminal";
import { SessionUsageLine } from "@/components/Accounting";
import { cn } from "@/lib/utils";
@@ -70,7 +71,8 @@ export function QuestionCard({ q, taskKey, taskStatus, back, compact = false }:
{q.kind !== "permission" && (
-
+
+
)}
@@ -88,7 +90,8 @@ export function SessionActions({ s, back }: { s: SessionView; back: string }) {
{alive && (