forge
Explore
Log in

Don't you dare go Hollow

✨ podcast stage trail and studio run inspector

Browse files at this commit

c274ff3fc406ace41539f7c685ebc860cf1ade59Burak BoduroğluParent: dcf123a
  • feat
    • ✨ podcast stage trail and studio run inspector
Show full message
feat: ✨ podcast stage trail and studio run inspector
- podcast progress drops the percentage bar for a trail of the stages the job
  has passed through, each with the time it took; the percentage and the
  receipt's ETA stay as compact text beside the state
- the trail is what this client observed: a row is appended when the reported
  stage changes, so a job picked back up after a reload starts where it was
  found rather than inventing the steps before that
- the studio library is a run history now: one row per produced artifact,
  newest first, with a status dot, the narration, and when it ran
- failed and cancelled runs are listed too — hiding them lost the only place
  that says a job did not work out
- clicking an episode opens a run inspector with its state, source note,
  start/end, running time, failure code and the player; a summary row has no
  artifact of its own, so it opens the note's producer panel as before
src/components/ai/studio-output-library.test.tsxmodified+43 -14
@@ -4,7 +4,10 @@ import type { PodcastJobSummary, RagOutput } from "@/api/client";
44 import { StudioOutputLibrary } from "@/components/ai/studio-output-library";
55 import { PreferencesProvider } from "@/stores/preferences-context";
66
7-const podcastApi = vi.hoisted(() => ({ listPodcastJobs: vi.fn() }));
7+const podcastApi = vi.hoisted(() => ({
8+ listPodcastJobs: vi.fn(),
9+ podcastAudioUrl: vi.fn((jobId: string) => `/api/podcast/jobs/${encodeURIComponent(jobId)}/audio`),
10+}));
811 const courseNotesApi = vi.hoisted(() => ({ getCourseNoteRag: vi.fn() }));
912
1013 vi.mock("@/api/podcast", () => podcastApi);
@@ -52,7 +55,7 @@ describe("StudioOutputLibrary", () => {
5255 podcastApi.listPodcastJobs.mockResolvedValue(page([
5356 podcast({ job_id: "job-1" }),
5457 podcast({ job_id: "job-2" }),
55- podcast({ job_id: "job-failed", source_id: "note-3", state: "failed" }),
58+ podcast({ job_id: "job-failed", source_id: "note-3", source_title: "Polinomlar", state: "failed", error_code: "tts_failed" }),
5659 ]));
5760 courseNotesApi.getCourseNoteRag.mockImplementation(async (noteId: string) =>
5861 page(noteId === "note-2" ? [summary(noteId)] : []),
@@ -65,28 +68,54 @@ describe("StudioOutputLibrary", () => {
6568 vi.clearAllMocks();
6669 });
6770
68- it("shows only notes with finished outputs and selects one directly", async () => {
69- const onSelect = vi.fn();
70-
71+ const renderLibrary = (onSelect = vi.fn()) => {
7172 render(() => (
7273 <PreferencesProvider>
7374 <StudioOutputLibrary notes={notes} selectedId="note-1" onSelect={onSelect} />
7475 </PreferencesProvider>
7576 ));
77+ return onSelect;
78+ };
79+
80+ it("lists one row per produced artifact, newest first, failures included", async () => {
81+ renderLibrary();
7682
77- await waitFor(() => expect(screen.getByText("Hücre")).toBeTruthy());
83+ await waitFor(() => expect(screen.getAllByText("Hücre").length).toBe(2));
84+ // The failed run is part of the history and says so rather than vanishing.
85+ expect(screen.getByText("Polinomlar")).toBeTruthy();
86+ expect(screen.getByText("Başarısız")).toBeTruthy();
7887 expect(screen.getByText("Kuvvet")).toBeTruthy();
79- expect(screen.queryByText("Polinomlar")).toBeNull();
80- expect(screen.getByText("2 podcast")).toBeTruthy();
81- expect(screen.getByText("Yapay zekâ özeti")).toBeTruthy();
82- expect(screen.getByText("2 not")).toBeTruthy();
88+ expect(screen.getByText("4 çıktı")).toBeTruthy();
8389
84- const selected = screen.getByRole("button", { name: /Hücre/ });
85- expect(selected.getAttribute("aria-current")).toBe("true");
90+ expect(podcastApi.listPodcastJobs).toHaveBeenCalledWith({ limit: 100 });
91+ expect(courseNotesApi.getCourseNoteRag).toHaveBeenCalledTimes(3);
92+ });
93+
94+ it("marks every row of the selected note as current", async () => {
95+ renderLibrary();
96+
97+ await waitFor(() => expect(screen.getAllByText("Hücre").length).toBe(2));
98+ const current = screen.getAllByRole("button").filter((el) => el.getAttribute("aria-current") === "true");
99+ expect(current.length).toBe(2);
100+ });
86101
102+ it("opens the run inspector for an episode instead of selecting its note", async () => {
103+ const onSelect = renderLibrary();
104+
105+ await waitFor(() => expect(screen.getAllByText("Hücre").length).toBe(2));
106+ fireEvent.click(screen.getAllByRole("button", { name: /Hücre/ })[0]!);
107+
108+ await waitFor(() => expect(screen.getByText("Üretim ayrıntısı")).toBeTruthy());
109+ expect(onSelect).not.toHaveBeenCalled();
110+ });
111+
112+ it("opens the note for a summary row, which has no artifact of its own", async () => {
113+ const onSelect = renderLibrary();
114+
115+ await waitFor(() => expect(screen.getByText("Kuvvet")).toBeTruthy());
87116 fireEvent.click(screen.getByRole("button", { name: /Kuvvet/ }));
117+
88118 expect(onSelect).toHaveBeenCalledWith("note-2");
89- expect(podcastApi.listPodcastJobs).toHaveBeenCalledWith({ limit: 100 });
90- expect(courseNotesApi.getCourseNoteRag).toHaveBeenCalledTimes(3);
119+ expect(screen.queryByText("Üretim ayrıntısı")).toBeNull();
91120 });
92121 });
src/components/ai/studio-output-library.tsxmodified+129 -59
@@ -1,13 +1,15 @@
1-import { For, Show, Suspense, createMemo } from "solid-js";
1+import { For, Show, Suspense, createMemo, createSignal } from "solid-js";
22 import { createResource } from "@/lib/create-resource";
33 import { getCourseNoteRag } from "@/api/course-notes";
44 import { listPodcastJobs } from "@/api/podcast";
5+import type { PodcastJobSummary } from "@/api/client";
6+import { StudioRunInspector } from "@/components/ai/studio-run-inspector";
57 import { Badge } from "@/components/ui/badge";
68 import { EmptyInline } from "@/components/ui/empty-inline";
7-import { IconNote, IconSparkles, IconWaveform } from "@/components/ui/icons";
9+import { IconSparkles, IconWaveform } from "@/components/ui/icons";
810 import { PageSpinner } from "@/components/ui/page-spinner";
911 import { cn } from "@/lib/cn";
10-import { formatDate } from "@/lib/format";
12+import { formatDateTime } from "@/lib/format";
1113 import { usePreferences, useT } from "@/stores/preferences-context";
1214
1315 export type StudioLibraryNote = {
@@ -16,10 +18,19 @@ export type StudioLibraryNote = {
1618 courseTitle: string;
1719 };
1820
19-type StudioLibraryItem = StudioLibraryNote & {
20- podcastCount: number;
21- hasSummary: boolean;
22- latestAt: number;
21+/**
22+ * One thing the studio produced. A podcast row is a real job row — it keeps the
23+ * whole summary so the inspector can read it without a second request — while a
24+ * summary row is the single stored output a note carries.
25+ */
26+type StudioArtifact = {
27+ key: string;
28+ noteId: string;
29+ title: string;
30+ courseTitle: string;
31+ /** Sorts the list: when the run finished, else when it started. */
32+ at: number;
33+ job: PodcastJobSummary | null;
2334 };
2435
2536 const LIBRARY_LIMIT = 100;
@@ -31,41 +42,83 @@ export function StudioOutputLibrary(props: {
3142 }) {
3243 const t = useT();
3344 const { locale } = usePreferences();
45+ const [inspecting, setInspecting] = createSignal<PodcastJobSummary | null>(null);
3446 const source = createMemo(() => props.notes.map((note) => note.id).join(","));
35- const [items] = createResource(source, async (): Promise<StudioLibraryItem[]> => {
47+
48+ const stateVariant = (state: string) => {
49+ if (state === "done") return "success" as const;
50+ if (state === "failed") return "destructive" as const;
51+ if (state === "cancelled") return "secondary" as const;
52+ return "warning" as const;
53+ };
54+ const stateLabel = (state: string) => {
55+ if (state === "done") return t("podcast.history.state.done");
56+ if (state === "failed") return t("podcast.history.state.failed");
57+ if (state === "cancelled") return t("podcast.history.state.cancelled");
58+ return t("podcast.history.state.pending");
59+ };
60+ const formatLabel = (format: string | null) => {
61+ if (!format) return "";
62+ if (format === "duz_okuma") return t("podcast.format.duz_okuma");
63+ if (format === "tek_ogretici") return t("podcast.format.tek_ogretici");
64+ if (format === "ogrenci_hoca") return t("podcast.format.ogrenci_hoca");
65+ return format;
66+ };
67+ const dotClass = (state: string) => {
68+ if (state === "done") return "bg-success";
69+ if (state === "failed") return "bg-destructive";
70+ if (state === "cancelled") return "bg-muted-foreground/50";
71+ return "bg-warning";
72+ };
73+
74+ const [items] = createResource(source, async (): Promise<StudioArtifact[]> => {
3675 const [podcastResult, ...summaryResults] = await Promise.allSettled([
3776 listPodcastJobs({ limit: LIBRARY_LIMIT }),
3877 ...props.notes.map((note) => getCourseNoteRag(note.id, { limit: 1 })),
3978 ]);
40- const podcasts = podcastResult.status === "fulfilled" ? podcastResult.value.items : [];
41- const podcastsByNote = new Map<string, { count: number; latestAt: number }>();
79+ const byId = new Map(props.notes.map((note) => [note.id, note]));
80+ const rows: StudioArtifact[] = [];
4281
43- for (const podcast of podcasts) {
44- if (podcast.state !== "done") continue;
45- const current = podcastsByNote.get(podcast.source_id) ?? { count: 0, latestAt: 0 };
46- podcastsByNote.set(podcast.source_id, {
47- count: current.count + 1,
48- latestAt: Math.max(current.latestAt, podcast.finished_at ?? podcast.created_at),
49- });
82+ // Every job, not only the finished ones: a failed or cancelled run is part
83+ // of the history and saying so is more useful than hiding it.
84+ if (podcastResult.status === "fulfilled") {
85+ for (const job of podcastResult.value.items) {
86+ const note = byId.get(job.source_id);
87+ rows.push({
88+ key: `podcast:${job.job_id}`,
89+ noteId: job.source_id,
90+ title: note?.title ?? job.source_title ?? job.source_id,
91+ courseTitle: note?.courseTitle ?? "",
92+ at: job.finished_at ?? job.created_at,
93+ job,
94+ });
95+ }
5096 }
5197
52- return props.notes
53- .map((note, index): StudioLibraryItem | null => {
54- const summaryResult = summaryResults[index];
55- const summary = summaryResult?.status === "fulfilled" ? summaryResult.value.items[0] : undefined;
56- const podcast = podcastsByNote.get(note.id);
57- if (!summary && !podcast) return null;
58- return {
59- ...note,
60- podcastCount: podcast?.count ?? 0,
61- hasSummary: !!summary,
62- latestAt: Math.max(summary?.generated_at ?? 0, podcast?.latestAt ?? 0),
63- };
64- })
65- .filter((item): item is StudioLibraryItem => item != null)
66- .sort((a, b) => b.latestAt - a.latestAt);
98+ props.notes.forEach((note, index) => {
99+ const result = summaryResults[index];
100+ const summary = result?.status === "fulfilled" ? result.value.items[0] : undefined;
101+ if (!summary) return;
102+ rows.push({
103+ key: `summary:${summary.id}`,
104+ noteId: note.id,
105+ title: note.title,
106+ courseTitle: note.courseTitle,
107+ at: summary.generated_at,
108+ job: null,
109+ });
110+ });
111+
112+ return rows.sort((a, b) => b.at - a.at);
67113 });
68114
115+ const open = (item: StudioArtifact) => {
116+ // A produced episode has an artifact of its own to inspect; a summary is
117+ // rendered by the note's own producer panel, so that row opens the note.
118+ if (item.job) setInspecting(item.job);
119+ else props.onSelect(item.noteId);
120+ };
121+
69122 return (
70123 <section class="overflow-hidden rounded-xl border border-border-line bg-surface-base">
71124 <header class="flex flex-wrap items-baseline justify-between gap-3 border-b border-border-hairline px-4 py-3">
@@ -84,54 +137,62 @@ export function StudioOutputLibrary(props: {
84137 <Show
85138 when={(items()?.length ?? 0) > 0}
86139 fallback={
87- <div class="px-4 py-5 sm:px-5">
140+ <div class="px-4 py-5">
88141 <EmptyInline title={t("aiStudio.library.empty")} hint={t("aiStudio.library.emptyHint")} />
89142 </div>
90143 }
91144 >
92- {/* Studio's own working screens are flat, dense lists rather than
93- card grids: hairline dividers, one row per thing, and the active
94- row marked by an accent edge instead of a box of its own. */}
145+ {/* A run history, the way a studio lists one: hairline dividers, a
146+ status dot, what was produced and when — no cards. */}
95147 <ul class="divide-y divide-border-hairline">
96148 <For each={items()}>
97149 {(item) => (
98150 <li>
99151 <button
100152 type="button"
101- aria-current={props.selectedId === item.id ? "true" : undefined}
153+ aria-current={props.selectedId === item.noteId ? "true" : undefined}
102154 class={cn(
103155 "flex w-full items-center gap-3 border-l-2 px-4 py-2.5 text-left outline-hidden transition-colors hover:bg-surface-tint focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",
104- props.selectedId === item.id
105- ? "border-l-primary bg-primary/[0.04]"
106- : "border-l-transparent",
156+ props.selectedId === item.noteId ? "border-l-primary bg-primary/[0.04]" : "border-l-transparent",
107157 )}
108- onClick={() => props.onSelect(item.id)}
158+ onClick={() => open(item)}
109159 >
110- <span class="shrink-0 text-muted-foreground">
111- <Show when={item.podcastCount > 0} fallback={<IconNote class="h-4 w-4" />}>
112- <IconWaveform class="h-4 w-4" />
113- </Show>
114- </span>
160+ <span
161+ class={cn("h-1.5 w-1.5 shrink-0 rounded-full", item.job ? dotClass(item.job.state) : "bg-success")}
162+ />
115163 <span class="min-w-0 flex-1">
116164 <span class="block truncate text-sm font-medium text-text-strong">{item.title}</span>
117- <span class="mt-0.5 block truncate text-xs text-muted-foreground">{item.courseTitle}</span>
165+ <span class="mt-0.5 block truncate text-xs text-muted-foreground">
166+ {item.courseTitle}
167+ </span>
118168 </span>
119169 <span class="hidden shrink-0 items-center gap-1.5 sm:flex">
120- <Show when={item.hasSummary}>
121- <Badge variant="outline" class="gap-1 rounded-md font-normal">
122- <IconSparkles class="h-3 w-3" />
123- {t("aiStudio.library.summary")}
124- </Badge>
125- </Show>
126- <Show when={item.podcastCount > 0}>
127- <Badge variant="outline" class="gap-1 rounded-md font-normal">
128- <IconWaveform class="h-3 w-3" />
129- {t("aiStudio.library.podcastCount", { count: item.podcastCount })}
130- </Badge>
170+ <Show
171+ when={item.job}
172+ fallback={
173+ <Badge variant="outline" class="gap-1 rounded-md font-normal">
174+ <IconSparkles class="h-3 w-3" />
175+ {t("aiStudio.library.summary")}
176+ </Badge>
177+ }
178+ >
179+ {(job) => (
180+ <>
181+ <Badge variant="outline" class="gap-1 rounded-md font-normal">
182+ <IconWaveform class="h-3 w-3" />
183+ {formatLabel(job().format) || t("podcast.title")}
184+ </Badge>
185+ <Show when={job().state !== "done"}>
186+ <Badge variant={stateVariant(job().state)} class="rounded-md font-normal">
187+ {stateLabel(job().state)}
188+ </Badge>
189+ </Show>
190+ </>
191+ )}
131192 </Show>
132193 </span>
133194 <span class="shrink-0 text-xs tabular-nums text-muted-foreground">
134- {formatDate(item.latestAt, locale())}
195+ {formatDateTime(item.at, locale())}
135196 </span>
136197 </button>
137198 </li>
@@ -140,6 +201,15 @@ export function StudioOutputLibrary(props: {
140201 </ul>
141202 </Show>
142203 </Suspense>
204+
205+ <StudioRunInspector
206+ job={inspecting()}
207+ onOpenChange={(next) => { if (!next) setInspecting(null); }}
208+ formatLabel={formatLabel}
209+ stateLabel={stateLabel}
210+ stateVariant={stateVariant}
211+ title={t("aiStudio.run.title")}
212+ />
143213 </section>
144214 );
145215 }
src/components/ai/studio-run-inspector.tsxadded+107 -0
@@ -0,0 +1,107 @@
1+import { Show } from "solid-js";
2+import type { PodcastJobSummary } from "@/api/client";
3+import { podcastAudioUrl } from "@/api/podcast";
4+import { podcastDownloadFilename, usePodcastDownloadT } from "@/components/notes/podcast-download";
5+import { Alert } from "@/components/ui/alert";
6+import { Badge } from "@/components/ui/badge";
7+import { buttonVariants } from "@/components/ui/button";
8+import { IconDownload } from "@/components/ui/icons";
9+import { SidePanel } from "@/components/ui/side-panel";
10+import { cn } from "@/lib/cn";
11+import { formatDateTime, formatDurationClock } from "@/lib/format";
12+import { usePreferences, useT } from "@/stores/preferences-context";
13+
14+/** One label/value line of run metadata. */
15+function MetaRow(props: { label: string; value: string }) {
16+ return (
17+ <div class="flex items-baseline justify-between gap-3 py-1.5 text-sm">
18+ <dt class="shrink-0 text-muted-foreground">{props.label}</dt>
19+ <dd class="min-w-0 truncate text-right font-medium tabular-nums text-text-strong">{props.value}</dd>
20+ </div>
21+ );
22+}
23+
24+/**
25+ * One produced episode, opened from the studio library.
26+ *
27+ * Everything here comes off the job row the list already holds — state, the
28+ * narration the service settled on, when it started and finished, how long the
29+ * audio runs — plus the audio door, which is addressed by job id. A job that
30+ * never finished has no player, and says why instead.
31+ */
32+export function StudioRunInspector(props: {
33+ job: PodcastJobSummary | null;
34+ onOpenChange: (open: boolean) => void;
35+ /** Resolves the narration's label; unknown formats come back verbatim. */
36+ formatLabel: (format: string | null) => string;
37+ stateLabel: (state: string) => string;
38+ stateVariant: (state: string) => "success" | "destructive" | "secondary" | "warning";
39+ title: string;
40+}) {
41+ const t = useT();
42+ const { locale } = usePreferences();
43+ const downloadT = usePodcastDownloadT();
44+ const job = () => props.job;
45+ const sourceName = () => job()?.source_title ?? job()?.source_id ?? "";
46+
47+ return (
48+ <SidePanel
49+ size="wide"
50+ open={job() != null}
51+ onOpenChange={props.onOpenChange}
52+ title={props.title}
53+ description={sourceName()}
54+ >
55+ <Show when={job()}>
56+ {(row) => (
57+ <div class="space-y-4">
58+ <div class="flex flex-wrap items-center gap-2">
59+ <Badge variant={props.stateVariant(row().state)}>{props.stateLabel(row().state)}</Badge>
60+ <Show when={props.formatLabel(row().format)}>
61+ {(label) => <Badge variant="outline">{label()}</Badge>}
62+ </Show>
63+ </div>
64+
65+ <dl class="divide-y divide-border-hairline border-y border-border-hairline">
66+ <MetaRow label={t("aiStudio.run.source")} value={sourceName()} />
67+ <MetaRow label={t("aiStudio.run.started")} value={formatDateTime(row().created_at, locale())} />
68+ <Show when={row().finished_at != null}>
69+ <MetaRow label={t("aiStudio.run.ended")} value={formatDateTime(row().finished_at!, locale())} />
70+ </Show>
71+ <Show when={row().duration_secs != null}>
72+ <MetaRow
73+ label={t("aiStudio.run.length")}
74+ value={formatDurationClock(row().duration_secs! * 1_000)}
75+ />
76+ </Show>
77+ </dl>
78+
79+ <Show when={row().state === "failed" && row().error_code}>
80+ {(code) => <Alert variant="destructive">{code()}</Alert>}
81+ </Show>
82+
83+ <Show
84+ when={row().state === "done"}
85+ fallback={<p class="text-sm text-muted-foreground">{t("podcast.history.emptyHint")}</p>}
86+ >
87+ <div class="space-y-3">
88+ <audio class="w-full" controls preload="metadata" src={podcastAudioUrl(row().job_id)}>
89+ {t("podcast.audioUnsupported")}
90+ </audio>
91+ <a
92+ href={podcastAudioUrl(row().job_id)}
93+ download={podcastDownloadFilename(sourceName(), downloadT("podcast.download.fallback"))}
94+ aria-label={downloadT("podcast.download.aria")}
95+ class={cn(buttonVariants({ variant: "outline", size: "sm" }), "rounded-lg")}
96+ >
97+ <IconDownload class="h-4 w-4" />
98+ {downloadT("podcast.download.label")}
99+ </a>
100+ </div>
101+ </Show>
102+ </div>
103+ )}
104+ </Show>
105+ </SidePanel>
106+ );
107+}
src/components/notes/podcast-panel.tsxmodified+34 -21
@@ -15,6 +15,7 @@ import { IconDownload, IconWaveform, IconX } from "@/components/ui/icons";
1515 import { Label } from "@/components/ui/label";
1616 import { Select } from "@/components/ui/select";
1717 import { PodcastHistory } from "@/components/notes/podcast-history";
18+import { PodcastStageTrail, type PodcastStageEntry } from "@/components/notes/podcast-stage-trail";
1819 import { podcastDownloadFilename, usePodcastDownloadT } from "@/components/notes/podcast-download";
1920 import { cn } from "@/lib/cn";
2021 import { createLivePoll } from "@/lib/create-live-poll";
@@ -36,8 +37,16 @@ export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitl
3637 // restated by the status door, so it is shown as the one estimate it is and
3738 // never recomputed into a countdown the backend did not promise.
3839 const [etaSecs, setEtaSecs] = createSignal<number | null>(null);
40+ const [stages, setStages] = createSignal<PodcastStageEntry[]>([]);
3941 let generation = 0;
4042
43+ // One row per stage the service reports, appended only when it actually
44+ // changes; the trail is this client's observation, not a backend timeline.
45+ const recordStage = (stage: string) => {
46+ if (!stage) return;
47+ setStages((list) => (list[list.length - 1]?.stage === stage ? list : [...list, { stage, at: Date.now() }]));
48+ };
49+
4150 // Declared before the resource below: its source runs during setup, so a
4251 // later `const active` would be read in its temporal dead zone.
4352 const active = () => props.active !== false;
@@ -54,6 +63,7 @@ export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitl
5463 const next = await getPodcastJobById(id);
5564 if (token !== generation || !active()) return;
5665 setStatus(next);
66+ recordStage(next.stage);
5767 if (next.state === "done") {
5868 const result = await getPodcastJobResultById(id);
5969 if (token === generation) setArtifacts(result);
@@ -76,6 +86,7 @@ export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitl
7686 setStatus(null);
7787 setArtifacts(null);
7888 setEtaSecs(null);
89+ setStages([]);
7990 setError("");
8091 if (!enabled || !noteId || typeof sessionStorage === "undefined") return;
8192 const stored = sessionStorage.getItem(storageKey());
@@ -101,6 +112,8 @@ export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitl
101112 if (token !== generation) return;
102113 setJobId(receipt.job_id);
103114 setStatus({ job_id: receipt.job_id, state: receipt.state, stage: "queued", progress: 0 });
115+ setStages([]);
116+ recordStage("queued");
104117 setEtaSecs(receipt.eta_secs);
105118 if (typeof sessionStorage !== "undefined") sessionStorage.setItem(storageKey(), receipt.job_id);
106119 } catch (err) {
@@ -202,29 +215,29 @@ export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitl
202215
203216 <Show when={status()}>
204217 {(current) => (
205- <div class="space-y-3 rounded-lg border border-border/70 bg-muted/20 p-3">
206- <div class="flex items-center justify-between gap-3 text-sm">
207- <span class="font-medium">{stateLabel(current().state)}</span>
208- <span class="font-mono text-xs tabular-nums text-muted-foreground">{progress()}%</span>
209- </div>
210- <div class="h-2 overflow-hidden rounded-full bg-muted" role="progressbar" aria-valuenow={progress()} aria-valuemin="0" aria-valuemax="100">
211- <div class="h-full rounded-full bg-primary transition-[width]" style={{ width: `${progress()}%` }} />
218+ <div class="space-y-3 rounded-lg border border-border-hairline bg-surface-overlay/40 p-3">
219+ {/* Compact textual metadata over a progress bar: the state, how far
220+ the service says it is, and its one estimate. */}
221+ <div class="flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1">
222+ <span class="text-sm font-medium">{stateLabel(current().state)}</span>
223+ <span
224+ class="text-xs tabular-nums text-muted-foreground"
225+ role="progressbar"
226+ aria-valuenow={progress()}
227+ aria-valuemin="0"
228+ aria-valuemax="100"
229+ >
230+ {progress()}%
231+ <Show when={working() && etaSecs() != null}>
232+ <span class="ml-2">{t("podcast.etaHint", { secs: etaSecs()! })}</span>
233+ </Show>
234+ </span>
212235 </div>
213236 {/* The stage names itself in the service's own vocabulary and is not
214- an enumerated set, so only the prefix is translated — the value
215- is shown as it came rather than guessed at. */}
216- <div class="flex flex-wrap items-baseline gap-x-3 gap-y-1 text-xs text-muted-foreground">
217- <Show when={current().stage}>
218- {(stage) => (
219- <span>
220- {t("podcast.stageLabel")} <span class="font-medium text-foreground">{stage()}</span>
221- </span>
222- )}
223- </Show>
224- <Show when={working() && etaSecs() != null}>
225- <span class="tabular-nums">{t("podcast.etaHint", { secs: etaSecs()! })}</span>
226- </Show>
227- </div>
237+ an enumerated set, so the values are shown as they came. */}
238+ <Show when={stages().length > 0}>
239+ <PodcastStageTrail entries={stages()} live={working()} label={t("podcast.stageLabel")} />
240+ </Show>
228241 <Show when={working()}>
229242 <Button type="button" size="sm" variant="outline" class="rounded-lg" disabled={cancelling()} onClick={() => void cancel()}>
230243 <IconX class="h-4 w-4" />{t("podcast.cancel")}
src/components/notes/podcast-stage-trail.test.tsxadded+57 -0
@@ -0,0 +1,57 @@
1+import { cleanup, render, screen } from "@solidjs/testing-library";
2+import { afterEach, describe, expect, it, vi } from "vitest";
3+import { PodcastStageTrail } from "@/components/notes/podcast-stage-trail";
4+
5+const T = Date.UTC(2026, 0, 2, 10, 0, 0);
6+
7+describe("PodcastStageTrail", () => {
8+ afterEach(() => {
9+ cleanup();
10+ vi.useRealTimers();
11+ vi.restoreAllMocks();
12+ });
13+
14+ it("times each stage by the one that replaced it", () => {
15+ render(() => (
16+ <PodcastStageTrail
17+ entries={[
18+ { stage: "queued", at: T },
19+ { stage: "synthesizing", at: T + 12_000 },
20+ ]}
21+ live={false}
22+ label="Aşamalar"
23+ />
24+ ));
25+
26+ expect(screen.getByText("queued")).toBeTruthy();
27+ expect(screen.getByText("synthesizing")).toBeTruthy();
28+ expect(screen.getByText("00:12")).toBeTruthy();
29+ });
30+
31+ it("leaves the last stage of a settled job without a span to guess at", () => {
32+ render(() => (
33+ <PodcastStageTrail entries={[{ stage: "queued", at: T }]} live={false} label="Aşamalar" />
34+ ));
35+
36+ expect(screen.getByText("—")).toBeTruthy();
37+ });
38+
39+ it("measures the running stage against the clock", () => {
40+ vi.useFakeTimers();
41+ vi.setSystemTime(T + 7_000);
42+
43+ render(() => (
44+ <PodcastStageTrail entries={[{ stage: "queued", at: T }]} live label="Aşamalar" />
45+ ));
46+
47+ expect(screen.getByText("00:07")).toBeTruthy();
48+ });
49+
50+ it("shows the service's own stage names verbatim", () => {
51+ render(() => (
52+ <PodcastStageTrail entries={[{ stage: "some_unknown_stage", at: T }]} live label="Aşamalar" />
53+ ));
54+
55+ expect(screen.getByText("some_unknown_stage")).toBeTruthy();
56+ });
57+});
src/components/notes/podcast-stage-trail.tsxadded+66 -0
@@ -0,0 +1,66 @@
1+import { For, createSignal, onCleanup } from "solid-js";
2+import { cn } from "@/lib/cn";
3+import { formatDurationClock } from "@/lib/format";
4+
5+export type PodcastStageEntry = {
6+ /** The service's own stage name, stored as it came. */
7+ stage: string;
8+ /** When this client first saw the job in that stage, epoch ms. */
9+ at: number;
10+};
11+
12+const TICK_MS = 1_000;
13+
14+/**
15+ * The stages a job has passed through, newest last, each with the time it took.
16+ *
17+ * The backend reports one current stage per poll, never a list with durations,
18+ * so the trail is what *this client observed*: a row is added when the reported
19+ * stage changes, and a stage's time is the gap to the next observation. A job
20+ * picked back up after a reload therefore starts its trail where it was found —
21+ * inventing the steps before that would be making up a history we never saw.
22+ */
23+export function PodcastStageTrail(props: { entries: PodcastStageEntry[]; live: boolean; label: string }) {
24+ const [now, setNow] = createSignal(Date.now());
25+ const timer = window.setInterval(() => setNow(Date.now()), TICK_MS);
26+ onCleanup(() => window.clearInterval(timer));
27+
28+ // The last row is still running while the job is live, so it measures against
29+ // the clock; every earlier row is closed by the row that replaced it.
30+ const spanOf = (index: number) => {
31+ const entries = props.entries;
32+ const start = entries[index]!.at;
33+ const next = entries[index + 1];
34+ if (next) return next.at - start;
35+ return props.live ? Math.max(0, now() - start) : null;
36+ };
37+
38+ return (
39+ <div class="space-y-1.5">
40+ <p class="text-[11px] font-medium uppercase tracking-wide text-muted-foreground">{props.label}</p>
41+ <ol class="divide-y divide-border-hairline border-y border-border-hairline">
42+ <For each={props.entries}>
43+ {(entry, index) => {
44+ const running = () => props.live && index() === props.entries.length - 1;
45+ return (
46+ <li class="flex items-center gap-2.5 py-1.5 text-xs">
47+ <span
48+ class={cn(
49+ "h-1.5 w-1.5 shrink-0 rounded-full",
50+ running() ? "animate-pulse bg-primary" : "bg-muted-foreground/50",
51+ )}
52+ />
53+ <span class={cn("min-w-0 flex-1 truncate", running() ? "font-medium text-foreground" : "text-muted-foreground")}>
54+ {entry.stage}
55+ </span>
56+ <span class="shrink-0 tabular-nums text-muted-foreground">
57+ {spanOf(index()) == null ? "—" : formatDurationClock(spanOf(index())!)}
58+ </span>
59+ </li>
60+ );
61+ }}
62+ </For>
63+ </ol>
64+ </div>
65+ );
66+}
src/i18n/locales/en.tsmodified+8 -3
@@ -701,9 +701,14 @@ export const en: Dict = {
701701 "aiStudio.tab.summary": "AI summary",
702702 "aiStudio.outputs.title": "Studio outputs",
703703 "aiStudio.outputs.description": "Select a lesson note and keep its summary and podcast together for quick access.",
704+ "aiStudio.run.title": "Run detail",
705+ "aiStudio.run.source": "Source note",
706+ "aiStudio.run.started": "Started",
707+ "aiStudio.run.ended": "Ended",
708+ "aiStudio.run.length": "Length",
704709 "aiStudio.library.title": "Your generated library",
705- "aiStudio.library.description": "Return to notes that already have a summary or podcast, just like a NotebookLM studio.",
706- "aiStudio.library.count": "{count} notes",
710+ "aiStudio.library.description": "Every summary and podcast you produced, newest first.",
711+ "aiStudio.library.count": "{count} outputs",
707712 "aiStudio.library.empty": "Your generated content will appear here",
708713 "aiStudio.library.emptyHint": "Create a summary or podcast for a lesson note to add it to this area.",
709714 "aiStudio.library.summary": "AI summary",
@@ -1016,7 +1021,7 @@ export const en: Dict = {
10161021 "podcast.noNotes": "No lesson notes are available.",
10171022 "podcast.noNotesHint": "Add a note to one of your courses before creating audio.",
10181023 "podcast.format": "Narration style",
1019- "podcast.stageLabel": "Stage:",
1024+ "podcast.stageLabel": "Stages",
10201025 "podcast.etaHint": "Estimated time: about {secs}s",
10211026 "podcast.format.duz_okuma": "Straight reading",
10221027 "podcast.format.tek_ogretici": "Single instructor",
src/i18n/locales/tr.tsmodified+8 -3
@@ -697,9 +697,14 @@ export const tr: Dict = {
697697 "aiStudio.tab.summary": "Yapay zekâ özeti",
698698 "aiStudio.outputs.title": "Hazır çıktılar",
699699 "aiStudio.outputs.description": "Bir ders notu seçin; özetini ve podcast'ini hızlı erişim için aynı alanda üretin.",
700+ "aiStudio.run.title": "Üretim ayrıntısı",
701+ "aiStudio.run.source": "Kaynak not",
702+ "aiStudio.run.started": "Başladı",
703+ "aiStudio.run.ended": "Bitti",
704+ "aiStudio.run.length": "Uzunluk",
700705 "aiStudio.library.title": "Üretim kitaplığın",
701- "aiStudio.library.description": "NotebookLM'deki gibi, özeti veya podcast'i hazır olan notlarına doğrudan dön.",
702- "aiStudio.library.count": "{count} not",
706+ "aiStudio.library.description": "Ürettiğin her özet ve podcast, en yenisi üstte.",
707+ "aiStudio.library.count": "{count} çıktı",
703708 "aiStudio.library.empty": "Ürettiğin içerikler burada görünecek",
704709 "aiStudio.library.emptyHint": "Bu alana eklemek için bir ders notundan özet veya podcast oluştur.",
705710 "aiStudio.library.summary": "Yapay zekâ özeti",
@@ -1012,7 +1017,7 @@ export const tr: Dict = {
10121017 "podcast.noNotes": "Kullanılabilir ders notu yok.",
10131018 "podcast.noNotesHint": "Ses oluşturmadan önce derslerinizden birine not ekleyin.",
10141019 "podcast.format": "Anlatım biçimi",
1015- "podcast.stageLabel": "Aşama:",
1020+ "podcast.stageLabel": "Aşamalar",
10161021 "podcast.etaHint": "Tahmini süre: yaklaşık {secs} sn",
10171022 "podcast.format.duz_okuma": "Düz okuma",
10181023 "podcast.format.tek_ogretici": "Tek öğretici",
src/i18n/messages.tsmodified+5 -0
@@ -685,6 +685,11 @@ export type MessageKey =
685685 | "aiStudio.tab.summary"
686686 | "aiStudio.outputs.title"
687687 | "aiStudio.outputs.description"
688+ | "aiStudio.run.title"
689+ | "aiStudio.run.source"
690+ | "aiStudio.run.started"
691+ | "aiStudio.run.ended"
692+ | "aiStudio.run.length"
688693 | "aiStudio.library.title"
689694 | "aiStudio.library.description"
690695 | "aiStudio.library.count"