✨ studio library rows open their own note page
Browse files at this commitc923286e3fdee822637a7f30569cc28d43e72024Parent: f1158ba- feat
- ✨ studio library rows open their own note page
11 changed files +145 -227
- src/components/ai/note-studio-panel.tsx +107 -101
- src/components/ai/studio-output-library.test.tsx +3 -5
- src/components/ai/studio-output-library.tsx +5 -15
- src/components/ai/studio-run-inspector.tsx +0 -89
- src/components/notes/podcast-history.tsx +3 -1
- src/components/notes/podcast-panel.tsx +2 -1
- src/i18n/locales/en.ts +0 -5
- src/i18n/locales/tr.ts +0 -5
- src/i18n/messages.ts +0 -5
- src/pages/ai-studio-note-page.tsx +13 -0
- src/routes/router.tsx +12 -0
src/components/ai/note-studio-panel.tsxmodified+107 -101
| @@ -1,13 +1,15 @@ | |||
| 1 | -import { Show, Suspense, createMemo, createSignal } from "solid-js"; | 1 | +import { Show, Suspense, createMemo } from "solid-js"; |
| 2 | +import { Link, useNavigate } from "@tanstack/solid-router"; | ||
| 2 | import { createResource } from "@/lib/create-resource"; | 3 | import { createResource } from "@/lib/create-resource"; |
| 3 | import { getCourseNotes } from "@/api/course-notes"; | 4 | import { getCourseNotes } from "@/api/course-notes"; |
| 4 | import { getCourses } from "@/api/courses"; | 5 | import { getCourses } from "@/api/courses"; |
| 5 | import { getMyCourses } from "@/api/reports"; | 6 | import { getMyCourses } from "@/api/reports"; |
| 6 | -import { formatApiError, type CourseNote } from "@/api/client"; | 7 | +import { formatApiError, type CourseNote, type Role } from "@/api/client"; |
| 7 | import { PodcastPanel } from "@/components/notes/podcast-panel"; | 8 | import { PodcastPanel } from "@/components/notes/podcast-panel"; |
| 8 | import { RagOutputsPanel } from "@/components/notes/rag-outputs-panel"; | 9 | import { RagOutputsPanel } from "@/components/notes/rag-outputs-panel"; |
| 9 | import { StudioOutputLibrary } from "@/components/ai/studio-output-library"; | 10 | import { StudioOutputLibrary } from "@/components/ai/studio-output-library"; |
| 10 | -import { Button } from "@/components/ui/button"; | 11 | +import { RecordNotFound } from "@/components/layout/record-not-found"; |
| 12 | +import { buttonVariants } from "@/components/ui/button"; | ||
| 11 | import { EmptyState } from "@/components/ui/empty-state"; | 13 | import { EmptyState } from "@/components/ui/empty-state"; |
| 12 | import { ErrorAlert } from "@/components/ui/error-alert"; | 14 | import { ErrorAlert } from "@/components/ui/error-alert"; |
| 13 | import { IconChevronLeft } from "@/components/ui/icons"; | 15 | import { IconChevronLeft } from "@/components/ui/icons"; |
| @@ -22,44 +24,44 @@ import { hasMinRole } from "@/lib/roles"; | |||
| 22 | 24 | ||
| 23 | type StudioNote = CourseNote & { courseTitle: string; courseCreatorId: string }; | 25 | type StudioNote = CourseNote & { courseTitle: string; courseCreatorId: string }; |
| 24 | 26 | ||
| 25 | -/** Pick a lesson note, then read its AI outputs and produce its podcast — | 27 | +/** Every lesson note the account can produce from, with its course. */ |
| 26 | - * the same two panels the note reader shows, gathered on the AI hub. */ | 28 | +async function loadStudioNotes(role: Role): Promise<StudioNote[]> { |
| 29 | + const courses = role === "student" ? await getMyCourses({ limit: 100 }) : await getCourses({ limit: 100 }); | ||
| 30 | + const rows = await Promise.all( | ||
| 31 | + courses.items.map(async (course) => { | ||
| 32 | + try { | ||
| 33 | + const page = await getCourseNotes(course.id, { limit: 100 }); | ||
| 34 | + return page.items.map<StudioNote>((note) => ({ | ||
| 35 | + ...note, | ||
| 36 | + courseTitle: course.title, | ||
| 37 | + courseCreatorId: course.creator.id, | ||
| 38 | + })); | ||
| 39 | + } catch { | ||
| 40 | + return []; | ||
| 41 | + } | ||
| 42 | + }), | ||
| 43 | + ); | ||
| 44 | + return rows.flat(); | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +function useStudioNotes() { | ||
| 48 | + const auth = useAuth(); | ||
| 49 | + return createResource(() => auth.user()?.role ?? null, loadStudioNotes); | ||
| 50 | +} | ||
| 51 | + | ||
| 52 | +/** | ||
| 53 | + * The studio's landing page: what it makes, a picker to start on any note, | ||
| 54 | + * and the library of everything produced so far. Picking a note or a row | ||
| 55 | + * opens that note's own page (`/ai/studio/$noteId`); nothing opens in place. | ||
| 56 | + */ | ||
| 27 | export function NoteStudioPanel() { | 57 | export function NoteStudioPanel() { |
| 28 | const t = useT(); | 58 | const t = useT(); |
| 29 | - const auth = useAuth(); | 59 | + const navigate = useNavigate(); |
| 30 | - const [selectedId, setSelectedId] = createSignal(""); | 60 | + const [notes, { refetch }] = useStudioNotes(); |
| 31 | - let outputsSection: HTMLElement | undefined; | ||
| 32 | - const [notes, { refetch }] = createResource( | ||
| 33 | - () => auth.user()?.role ?? null, | ||
| 34 | - async (role) => { | ||
| 35 | - const courses = role === "student" ? await getMyCourses({ limit: 100 }) : await getCourses({ limit: 100 }); | ||
| 36 | - const rows = await Promise.all( | ||
| 37 | - courses.items.map(async (course) => { | ||
| 38 | - try { | ||
| 39 | - const page = await getCourseNotes(course.id, { limit: 100 }); | ||
| 40 | - return page.items.map<StudioNote>((note) => ({ | ||
| 41 | - ...note, | ||
| 42 | - courseTitle: course.title, | ||
| 43 | - courseCreatorId: course.creator.id, | ||
| 44 | - })); | ||
| 45 | - } catch { | ||
| 46 | - return []; | ||
| 47 | - } | ||
| 48 | - }), | ||
| 49 | - ); | ||
| 50 | - return rows.flat(); | ||
| 51 | - }, | ||
| 52 | - ); | ||
| 53 | const options = createMemo(() => (notes() ?? []).map((note) => ({ value: note.id, label: `${note.courseTitle} · ${note.title}` }))); | 61 | const options = createMemo(() => (notes() ?? []).map((note) => ({ value: note.id, label: `${note.courseTitle} · ${note.title}` }))); |
| 54 | - const selected = createMemo(() => (notes() ?? []).find((note) => note.id === selectedId()) ?? null); | 62 | + const open = (noteId: string, episode?: string) => { |
| 55 | - const canManageSelected = () => { | 63 | + if (!noteId) return; |
| 56 | - const note = selected(); | 64 | + void navigate({ to: "/ai/studio/$noteId", params: { noteId }, search: { episode } }); |
| 57 | - const user = auth.user(); | ||
| 58 | - return !!note && !!user && (hasMinRole(user.role, "manager") || note.courseCreatorId === user.id); | ||
| 59 | - }; | ||
| 60 | - const selectLibraryNote = (noteId: string) => { | ||
| 61 | - setSelectedId(noteId); | ||
| 62 | - requestAnimationFrame(() => outputsSection?.scrollIntoView({ behavior: "smooth", block: "start" })); | ||
| 63 | }; | 65 | }; |
| 64 | 66 | ||
| 65 | return ( | 67 | return ( |
| @@ -72,14 +74,11 @@ export function NoteStudioPanel() { | |||
| 72 | when={(notes()?.length ?? 0) > 0} | 74 | when={(notes()?.length ?? 0) > 0} |
| 73 | fallback={<EmptyState kind="notes" title={t("podcast.noNotes")} description={t("podcast.noNotesHint")} />} | 75 | fallback={<EmptyState kind="notes" title={t("podcast.noNotes")} description={t("podcast.noNotesHint")} />} |
| 74 | > | 76 | > |
| 75 | - {/* Laid out the way a studio home reads: a plain title and one line | 77 | + {/* A studio home: a plain title and one line saying what it makes, |
| 76 | - saying what it makes, the source picker, the producers, then | 78 | + the way to start on a note, then everything produced so far. |
| 77 | - everything produced so far. Flat hairline cards, no banner and no | 79 | + Flat hairline cards, no banner and no shadow stack. */} |
| 78 | - shadow stack — the work is the content, not the chrome. */} | ||
| 79 | <div class="w-full space-y-8"> | 80 | <div class="w-full space-y-8"> |
| 80 | - {/* On a phone an open note needs the screen more than the page | 81 | + <header class="space-y-1.5"> |
| 81 | - title does; the picker below still says where you are. */} | ||
| 82 | - <header class={cn("space-y-1.5", selected() && "max-sm:hidden")}> | ||
| 83 | <h1 class="text-2xl font-semibold tracking-tight text-text-strong">{t("aiHub.tab.studio")}</h1> | 82 | <h1 class="text-2xl font-semibold tracking-tight text-text-strong">{t("aiHub.tab.studio")}</h1> |
| 84 | <p class="text-sm text-muted-foreground">{t("aiStudio.heading")}</p> | 83 | <p class="text-sm text-muted-foreground">{t("aiStudio.heading")}</p> |
| 85 | </header> | 84 | </header> |
| @@ -89,70 +88,77 @@ export function NoteStudioPanel() { | |||
| 89 | <SearchableSelect | 88 | <SearchableSelect |
| 90 | id="sound-studio-note" | 89 | id="sound-studio-note" |
| 91 | class="w-full" | 90 | class="w-full" |
| 92 | - value={selectedId()} | 91 | + value="" |
| 93 | - onChange={setSelectedId} | 92 | + onChange={(noteId) => open(noteId)} |
| 94 | options={options()} | 93 | options={options()} |
| 95 | placeholder={t("podcast.selectNote")} | 94 | placeholder={t("podcast.selectNote")} |
| 96 | /> | 95 | /> |
| 97 | </div> | 96 | </div> |
| 98 | 97 | ||
| 99 | - <Show | 98 | + <StudioOutputLibrary |
| 100 | - when={selected()} | 99 | + notes={(notes() ?? []).map((note) => ({ id: note.id, title: note.title, courseTitle: note.courseTitle }))} |
| 101 | - fallback={ | 100 | + selectedId="" |
| 102 | - <div class="rounded-xl border border-dashed border-border-line px-6 py-12 text-center"> | 101 | + onSelect={open} |
| 103 | - <p class="text-sm font-medium text-text-strong">{t("aiStudio.pickPrompt")}</p> | 102 | + /> |
| 104 | - <p class="mx-auto mt-1 max-w-md text-sm text-muted-foreground">{t("aiStudio.pickPromptHint")}</p> | ||
| 105 | - </div> | ||
| 106 | - } | ||
| 107 | - > | ||
| 108 | - {(note) => ( | ||
| 109 | - <section ref={outputsSection} class="scroll-mt-20 space-y-4"> | ||
| 110 | - {/* The library steps aside while a note is open; this is the | ||
| 111 | - way back to it without emptying the picker by hand. */} | ||
| 112 | - <div class="flex items-center gap-3"> | ||
| 113 | - <Button | ||
| 114 | - type="button" | ||
| 115 | - variant="outline" | ||
| 116 | - size="sm" | ||
| 117 | - class="h-8 shrink-0 gap-1 rounded-lg max-sm:h-10 max-sm:w-10 max-sm:px-0" | ||
| 118 | - aria-label={t("aiStudio.backToLibrary")} | ||
| 119 | - onClick={() => setSelectedId("")} | ||
| 120 | - > | ||
| 121 | - <IconChevronLeft class="h-4 w-4" /> | ||
| 122 | - <span class="hidden sm:inline">{t("aiStudio.backToLibrary")}</span> | ||
| 123 | - </Button> | ||
| 124 | - <div class="min-w-0 flex-1"> | ||
| 125 | - <h2 class="truncate text-base font-semibold text-text-strong">{note().title}</h2> | ||
| 126 | - <p class="truncate text-xs text-muted-foreground">{note().courseTitle}</p> | ||
| 127 | - </div> | ||
| 128 | - </div> | ||
| 129 | - <div class="grid grid-cols-1 gap-4 xl:grid-cols-2"> | ||
| 130 | - <RagOutputsPanel | ||
| 131 | - noteId={note().id} | ||
| 132 | - source={courseNoteFiles} | ||
| 133 | - canManage={canManageSelected()} | ||
| 134 | - active | ||
| 135 | - noteTitle={note().title} | ||
| 136 | - /> | ||
| 137 | - <PodcastPanel noteId={note().id} noteTitle={note().title} active /> | ||
| 138 | - </div> | ||
| 139 | - </section> | ||
| 140 | - )} | ||
| 141 | - </Show> | ||
| 142 | - | ||
| 143 | - {/* The library is the landing view. Once a note is open the page is | ||
| 144 | - about producing for that note, so the list of everything else | ||
| 145 | - steps out of the way. */} | ||
| 146 | - <Show when={!selected()}> | ||
| 147 | - <StudioOutputLibrary | ||
| 148 | - notes={(notes() ?? []).map((note) => ({ id: note.id, title: note.title, courseTitle: note.courseTitle }))} | ||
| 149 | - selectedId={selectedId()} | ||
| 150 | - onSelect={selectLibraryNote} | ||
| 151 | - /> | ||
| 152 | - </Show> | ||
| 153 | </div> | 103 | </div> |
| 154 | </Show> | 104 | </Show> |
| 155 | </Show> | 105 | </Show> |
| 156 | </Suspense> | 106 | </Suspense> |
| 157 | ); | 107 | ); |
| 158 | } | 108 | } |
| 109 | + | ||
| 110 | +/** | ||
| 111 | + * One note's studio page: its summary and its episodes, nothing else — no | ||
| 112 | + * picker, no library. "Kitaplığa dön" is the way back. `episode` preselects | ||
| 113 | + * an episode opened from the library. | ||
| 114 | + */ | ||
| 115 | +export function NoteStudioDetail(props: { noteId: string; episode?: string }) { | ||
| 116 | + const t = useT(); | ||
| 117 | + const auth = useAuth(); | ||
| 118 | + const [notes, { refetch }] = useStudioNotes(); | ||
| 119 | + const note = createMemo(() => (notes() ?? []).find((row) => row.id === props.noteId) ?? null); | ||
| 120 | + const canManage = () => { | ||
| 121 | + const current = note(); | ||
| 122 | + const user = auth.user(); | ||
| 123 | + return !!current && !!user && (hasMinRole(user.role, "manager") || current.courseCreatorId === user.id); | ||
| 124 | + }; | ||
| 125 | + | ||
| 126 | + return ( | ||
| 127 | + <Suspense fallback={<PageSpinner />}> | ||
| 128 | + <Show when={notes.error}> | ||
| 129 | + <ErrorAlert message={formatApiError(notes.error)} onRetry={() => void refetch()} /> | ||
| 130 | + </Show> | ||
| 131 | + <Show when={!notes.error && notes()}> | ||
| 132 | + <Show when={note()} fallback={<RecordNotFound backTo="/ai/studio" />}> | ||
| 133 | + {(current) => ( | ||
| 134 | + <div class="w-full space-y-6"> | ||
| 135 | + <div class="space-y-3"> | ||
| 136 | + <Link | ||
| 137 | + to="/ai/studio" | ||
| 138 | + class={cn(buttonVariants({ variant: "ghost", size: "sm" }), "-ml-2 h-8 gap-1 rounded-lg text-muted-foreground")} | ||
| 139 | + > | ||
| 140 | + <IconChevronLeft class="h-4 w-4" /> | ||
| 141 | + {t("aiStudio.backToLibrary")} | ||
| 142 | + </Link> | ||
| 143 | + <header class="space-y-1"> | ||
| 144 | + <h1 class="text-2xl font-semibold tracking-tight text-text-strong">{current().title}</h1> | ||
| 145 | + <p class="text-sm text-muted-foreground">{current().courseTitle}</p> | ||
| 146 | + </header> | ||
| 147 | + </div> | ||
| 148 | + <div class="grid grid-cols-1 gap-4 xl:grid-cols-2"> | ||
| 149 | + <RagOutputsPanel | ||
| 150 | + noteId={current().id} | ||
| 151 | + source={courseNoteFiles} | ||
| 152 | + canManage={canManage()} | ||
| 153 | + active | ||
| 154 | + noteTitle={current().title} | ||
| 155 | + /> | ||
| 156 | + <PodcastPanel noteId={current().id} noteTitle={current().title} episode={props.episode} active /> | ||
| 157 | + </div> | ||
| 158 | + </div> | ||
| 159 | + )} | ||
| 160 | + </Show> | ||
| 161 | + </Show> | ||
| 162 | + </Suspense> | ||
| 163 | + ); | ||
| 164 | +} | ||
src/components/ai/studio-output-library.test.tsxmodified+3 -5
| @@ -120,14 +120,13 @@ describe("StudioOutputLibrary", () => { | |||
| 120 | expect(screen.queryByText("Bölüm 12")).toBeNull(); | 120 | expect(screen.queryByText("Bölüm 12")).toBeNull(); |
| 121 | }); | 121 | }); |
| 122 | 122 | ||
| 123 | - it("opens the run inspector for an episode instead of selecting its note", async () => { | 123 | + it("opens an episode's note page with that episode picked", async () => { |
| 124 | const onSelect = renderLibrary(); | 124 | const onSelect = renderLibrary(); |
| 125 | 125 | ||
| 126 | await waitFor(() => expect(screen.getAllByText("Hücre").length).toBe(2)); | 126 | await waitFor(() => expect(screen.getAllByText("Hücre").length).toBe(2)); |
| 127 | fireEvent.click(screen.getAllByRole("button", { name: /Hücre/ })[0]!); | 127 | fireEvent.click(screen.getAllByRole("button", { name: /Hücre/ })[0]!); |
| 128 | 128 | ||
| 129 | - await waitFor(() => expect(screen.getByText("Üretim ayrıntısı")).toBeTruthy()); | 129 | + expect(onSelect).toHaveBeenCalledWith("note-1", expect.any(String)); |
| 130 | - expect(onSelect).not.toHaveBeenCalled(); | ||
| 131 | }); | 130 | }); |
| 132 | 131 | ||
| 133 | it("opens the note for a summary row, which has no artifact of its own", async () => { | 132 | it("opens the note for a summary row, which has no artifact of its own", async () => { |
| @@ -136,7 +135,6 @@ describe("StudioOutputLibrary", () => { | |||
| 136 | await waitFor(() => expect(screen.getByText("Kuvvet")).toBeTruthy()); | 135 | await waitFor(() => expect(screen.getByText("Kuvvet")).toBeTruthy()); |
| 137 | fireEvent.click(screen.getByRole("button", { name: /Kuvvet/ })); | 136 | fireEvent.click(screen.getByRole("button", { name: /Kuvvet/ })); |
| 138 | 137 | ||
| 139 | - expect(onSelect).toHaveBeenCalledWith("note-2"); | 138 | + expect(onSelect).toHaveBeenCalledWith("note-2", undefined); |
| 140 | - expect(screen.queryByText("Üretim ayrıntısı")).toBeNull(); | ||
| 141 | }); | 139 | }); |
| 142 | }); | 140 | }); |
src/components/ai/studio-output-library.tsxmodified+5 -15
| @@ -3,7 +3,6 @@ import { createResource } from "@/lib/create-resource"; | |||
| 3 | import { getCourseNoteRag } from "@/api/course-notes"; | 3 | import { getCourseNoteRag } from "@/api/course-notes"; |
| 4 | import { listPodcastJobs } from "@/api/podcast"; | 4 | import { listPodcastJobs } from "@/api/podcast"; |
| 5 | import type { PodcastJobSummary } from "@/api/client"; | 5 | import type { PodcastJobSummary } from "@/api/client"; |
| 6 | -import { StudioRunInspector } from "@/components/ai/studio-run-inspector"; | ||
| 7 | import { Badge } from "@/components/ui/badge"; | 6 | import { Badge } from "@/components/ui/badge"; |
| 8 | import { EmptyInline } from "@/components/ui/empty-inline"; | 7 | import { EmptyInline } from "@/components/ui/empty-inline"; |
| 9 | import { IconSparkles, IconWaveform } from "@/components/ui/icons"; | 8 | import { IconSparkles, IconWaveform } from "@/components/ui/icons"; |
| @@ -41,11 +40,11 @@ const LIBRARY_PAGE_SIZE = 10; | |||
| 41 | export function StudioOutputLibrary(props: { | 40 | export function StudioOutputLibrary(props: { |
| 42 | notes: StudioLibraryNote[]; | 41 | notes: StudioLibraryNote[]; |
| 43 | selectedId: string; | 42 | selectedId: string; |
| 44 | - onSelect: (noteId: string) => void; | 43 | + /** Opens the row's own page: the note, with the episode picked for a podcast row. */ |
| 44 | + onSelect: (noteId: string, episodeId?: string) => void; | ||
| 45 | }) { | 45 | }) { |
| 46 | const t = useT(); | 46 | const t = useT(); |
| 47 | const { locale } = usePreferences(); | 47 | const { locale } = usePreferences(); |
| 48 | - const [inspecting, setInspecting] = createSignal<PodcastJobSummary | null>(null); | ||
| 49 | const source = createMemo(() => props.notes.map((note) => note.id).join(",")); | 48 | const source = createMemo(() => props.notes.map((note) => note.id).join(",")); |
| 50 | 49 | ||
| 51 | const stateVariant = (state: string) => { | 50 | const stateVariant = (state: string) => { |
| @@ -131,10 +130,9 @@ export function StudioOutputLibrary(props: { | |||
| 131 | }); | 130 | }); |
| 132 | 131 | ||
| 133 | const open = (item: StudioArtifact) => { | 132 | const open = (item: StudioArtifact) => { |
| 134 | - // A produced episode has an artifact of its own to inspect; a summary is | 133 | + // Every row opens a page of its own; an episode opens its note's page |
| 135 | - // rendered by the note's own producer panel, so that row opens the note. | 134 | + // with that episode loaded in the player. |
| 136 | - if (item.job) setInspecting(item.job); | 135 | + props.onSelect(item.noteId, item.job?.job_id); |
| 137 | - else props.onSelect(item.noteId); | ||
| 138 | }; | 136 | }; |
| 139 | 137 | ||
| 140 | return ( | 138 | return ( |
| @@ -232,14 +230,6 @@ export function StudioOutputLibrary(props: { | |||
| 232 | </Show> | 230 | </Show> |
| 233 | </Suspense> | 231 | </Suspense> |
| 234 | 232 | ||
| 235 | - <StudioRunInspector | ||
| 236 | - job={inspecting()} | ||
| 237 | - onOpenChange={(next) => { if (!next) setInspecting(null); }} | ||
| 238 | - formatLabel={formatLabel} | ||
| 239 | - stateLabel={stateLabel} | ||
| 240 | - stateVariant={stateVariant} | ||
| 241 | - title={t("aiStudio.run.title")} | ||
| 242 | - /> | ||
| 243 | </section> | 233 | </section> |
| 244 | ); | 234 | ); |
| 245 | } | 235 | } |
src/components/ai/studio-run-inspector.tsxdeleted+0 -89
| @@ -1,89 +0,0 @@ | |||
| 1 | -import { Show } from "solid-js"; | ||
| 2 | -import type { PodcastJobSummary } from "@/api/client"; | ||
| 3 | -import { PodcastPlayer } from "@/components/notes/podcast-player"; | ||
| 4 | -import { Alert } from "@/components/ui/alert"; | ||
| 5 | -import { Badge } from "@/components/ui/badge"; | ||
| 6 | -import { SidePanel } from "@/components/ui/side-panel"; | ||
| 7 | -import { formatDateTime, formatDurationClock } from "@/lib/format"; | ||
| 8 | -import { usePreferences, useT } from "@/stores/preferences-context"; | ||
| 9 | - | ||
| 10 | -/** One label/value line of run metadata. */ | ||
| 11 | -function MetaRow(props: { label: string; value: string }) { | ||
| 12 | - return ( | ||
| 13 | - <div class="flex items-baseline justify-between gap-3 py-1.5 text-sm"> | ||
| 14 | - <dt class="shrink-0 text-muted-foreground">{props.label}</dt> | ||
| 15 | - <dd class="min-w-0 truncate text-right font-medium tabular-nums text-text-strong">{props.value}</dd> | ||
| 16 | - </div> | ||
| 17 | - ); | ||
| 18 | -} | ||
| 19 | - | ||
| 20 | -/** | ||
| 21 | - * One produced episode, opened from the studio library. | ||
| 22 | - * | ||
| 23 | - * Everything here comes off the job row the list already holds — state, the | ||
| 24 | - * narration the service settled on, when it started and finished, how long the | ||
| 25 | - * audio runs — plus the audio door, which is addressed by job id. A job that | ||
| 26 | - * never finished has no player, and says why instead. | ||
| 27 | - */ | ||
| 28 | -export function StudioRunInspector(props: { | ||
| 29 | - job: PodcastJobSummary | null; | ||
| 30 | - onOpenChange: (open: boolean) => void; | ||
| 31 | - /** Resolves the narration's label; unknown formats come back verbatim. */ | ||
| 32 | - formatLabel: (format: string | null) => string; | ||
| 33 | - stateLabel: (state: string) => string; | ||
| 34 | - stateVariant: (state: string) => "success" | "destructive" | "secondary" | "warning"; | ||
| 35 | - title: string; | ||
| 36 | -}) { | ||
| 37 | - const t = useT(); | ||
| 38 | - const { locale } = usePreferences(); | ||
| 39 | - const job = () => props.job; | ||
| 40 | - const sourceName = () => job()?.source_title ?? job()?.source_id ?? ""; | ||
| 41 | - | ||
| 42 | - return ( | ||
| 43 | - <SidePanel | ||
| 44 | - size="wide" | ||
| 45 | - open={job() != null} | ||
| 46 | - onOpenChange={props.onOpenChange} | ||
| 47 | - title={props.title} | ||
| 48 | - description={sourceName()} | ||
| 49 | - > | ||
| 50 | - <Show when={job()}> | ||
| 51 | - {(row) => ( | ||
| 52 | - <div class="space-y-4"> | ||
| 53 | - <div class="flex flex-wrap items-center gap-2"> | ||
| 54 | - <Badge variant={props.stateVariant(row().state)}>{props.stateLabel(row().state)}</Badge> | ||
| 55 | - <Show when={props.formatLabel(row().format)}> | ||
| 56 | - {(label) => <Badge variant="outline">{label()}</Badge>} | ||
| 57 | - </Show> | ||
| 58 | - </div> | ||
| 59 | - | ||
| 60 | - <dl class="divide-y divide-border-hairline border-y border-border-hairline"> | ||
| 61 | - <MetaRow label={t("aiStudio.run.source")} value={sourceName()} /> | ||
| 62 | - <MetaRow label={t("aiStudio.run.started")} value={formatDateTime(row().created_at, locale())} /> | ||
| 63 | - <Show when={row().finished_at != null}> | ||
| 64 | - <MetaRow label={t("aiStudio.run.ended")} value={formatDateTime(row().finished_at!, locale())} /> | ||
| 65 | - </Show> | ||
| 66 | - <Show when={row().duration_secs != null}> | ||
| 67 | - <MetaRow | ||
| 68 | - label={t("aiStudio.run.length")} | ||
| 69 | - value={formatDurationClock(row().duration_secs! * 1_000)} | ||
| 70 | - /> | ||
| 71 | - </Show> | ||
| 72 | - </dl> | ||
| 73 | - | ||
| 74 | - <Show when={row().state === "failed" && row().error_code}> | ||
| 75 | - {(code) => <Alert variant="destructive">{code()}</Alert>} | ||
| 76 | - </Show> | ||
| 77 | - | ||
| 78 | - <Show | ||
| 79 | - when={row().state === "done"} | ||
| 80 | - fallback={<p class="text-sm text-muted-foreground">{t("podcast.history.emptyHint")}</p>} | ||
| 81 | - > | ||
| 82 | - <PodcastPlayer jobId={row().job_id} title={sourceName()} durationSecs={row().duration_secs} /> | ||
| 83 | - </Show> | ||
| 84 | - </div> | ||
| 85 | - )} | ||
| 86 | - </Show> | ||
| 87 | - </SidePanel> | ||
| 88 | - ); | ||
| 89 | -} | ||
src/components/notes/podcast-history.tsxmodified+3 -1
| @@ -40,6 +40,8 @@ export function PodcastHistory(props: { | |||
| 40 | noteId?: string; | 40 | noteId?: string; |
| 41 | active?: boolean; | 41 | active?: boolean; |
| 42 | refetchKey?: string | number; | 42 | refetchKey?: string | number; |
| 43 | + /** An episode to open with, e.g. one picked in the studio library. */ | ||
| 44 | + episode?: string; | ||
| 43 | /** The transcript of the episode the panel just produced, if the service sent one. */ | 45 | /** The transcript of the episode the panel just produced, if the service sent one. */ |
| 44 | transcript?: { jobId: string; segments: PodcastTranscriptSegment[] } | null; | 46 | transcript?: { jobId: string; segments: PodcastTranscriptSegment[] } | null; |
| 45 | }) { | 47 | }) { |
| @@ -56,7 +58,7 @@ export function PodcastHistory(props: { | |||
| 56 | props.noteId; | 58 | props.noteId; |
| 57 | pageSize(); | 59 | pageSize(); |
| 58 | setPage(0); | 60 | setPage(0); |
| 59 | - setSelected(""); | 61 | + setSelected(props.episode ?? ""); |
| 60 | setAutoplay(false); | 62 | setAutoplay(false); |
| 61 | }); | 63 | }); |
| 62 | 64 | ||
src/components/notes/podcast-panel.tsxmodified+2 -1
| @@ -15,7 +15,7 @@ import { useT } from "@/stores/preferences-context"; | |||
| 15 | 15 | ||
| 16 | const POLL_MS = 2_000; | 16 | const POLL_MS = 2_000; |
| 17 | 17 | ||
| 18 | -export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitle?: string }) { | 18 | +export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitle?: string; episode?: string }) { |
| 19 | const t = useT(); | 19 | const t = useT(); |
| 20 | const [format, setFormat] = createSignal<PodcastFormat>("duz_okuma"); | 20 | const [format, setFormat] = createSignal<PodcastFormat>("duz_okuma"); |
| 21 | const [jobId, setJobId] = createSignal(""); | 21 | const [jobId, setJobId] = createSignal(""); |
| @@ -241,6 +241,7 @@ export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitl | |||
| 241 | <PodcastHistory | 241 | <PodcastHistory |
| 242 | noteId={props.noteId} | 242 | noteId={props.noteId} |
| 243 | active={active()} | 243 | active={active()} |
| 244 | + episode={props.episode} | ||
| 244 | refetchKey={status()?.state === "done" ? jobId() : ""} | 245 | refetchKey={status()?.state === "done" ? jobId() : ""} |
| 245 | transcript={ | 246 | transcript={ |
| 246 | artifacts()?.transcript?.length ? { jobId: artifacts()!.job_id, segments: artifacts()!.transcript! } : null | 247 | artifacts()?.transcript?.length ? { jobId: artifacts()!.job_id, segments: artifacts()!.transcript! } : null |
src/i18n/locales/en.tsmodified+0 -5
| @@ -709,11 +709,6 @@ export const en: Dict = { | |||
| 709 | "aiStudio.tab.summary": "AI summary", | 709 | "aiStudio.tab.summary": "AI summary", |
| 710 | "aiStudio.outputs.title": "Studio outputs", | 710 | "aiStudio.outputs.title": "Studio outputs", |
| 711 | "aiStudio.outputs.description": "Select a lesson note and keep its summary and podcast together for quick access.", | 711 | "aiStudio.outputs.description": "Select a lesson note and keep its summary and podcast together for quick access.", |
| 712 | - "aiStudio.run.title": "Run detail", | ||
| 713 | - "aiStudio.run.source": "Source note", | ||
| 714 | - "aiStudio.run.started": "Started", | ||
| 715 | - "aiStudio.run.ended": "Ended", | ||
| 716 | - "aiStudio.run.length": "Length", | ||
| 717 | "aiStudio.library.title": "Your generated library", | 712 | "aiStudio.library.title": "Your generated library", |
| 718 | "aiStudio.backToLibrary": "Back to library", | 713 | "aiStudio.backToLibrary": "Back to library", |
| 719 | "aiStudio.library.description": "Every summary and podcast you produced, newest first.", | 714 | "aiStudio.library.description": "Every summary and podcast you produced, newest first.", |
src/i18n/locales/tr.tsmodified+0 -5
| @@ -705,11 +705,6 @@ export const tr: Dict = { | |||
| 705 | "aiStudio.tab.summary": "Yapay zekâ özeti", | 705 | "aiStudio.tab.summary": "Yapay zekâ özeti", |
| 706 | "aiStudio.outputs.title": "Hazır çıktılar", | 706 | "aiStudio.outputs.title": "Hazır çıktılar", |
| 707 | "aiStudio.outputs.description": "Bir ders notu seçin; özetini ve podcast'ini hızlı erişim için aynı alanda üretin.", | 707 | "aiStudio.outputs.description": "Bir ders notu seçin; özetini ve podcast'ini hızlı erişim için aynı alanda üretin.", |
| 708 | - "aiStudio.run.title": "Üretim ayrıntısı", | ||
| 709 | - "aiStudio.run.source": "Kaynak not", | ||
| 710 | - "aiStudio.run.started": "Başladı", | ||
| 711 | - "aiStudio.run.ended": "Bitti", | ||
| 712 | - "aiStudio.run.length": "Uzunluk", | ||
| 713 | "aiStudio.library.title": "Üretim kitaplığın", | 708 | "aiStudio.library.title": "Üretim kitaplığın", |
| 714 | "aiStudio.backToLibrary": "Kitaplığa dön", | 709 | "aiStudio.backToLibrary": "Kitaplığa dön", |
| 715 | "aiStudio.library.description": "Ürettiğin her özet ve podcast, en yenisi üstte.", | 710 | "aiStudio.library.description": "Ürettiğin her özet ve podcast, en yenisi üstte.", |
src/i18n/messages.tsmodified+0 -5
| @@ -693,11 +693,6 @@ export type MessageKey = | |||
| 693 | | "aiStudio.tab.summary" | 693 | | "aiStudio.tab.summary" |
| 694 | | "aiStudio.outputs.title" | 694 | | "aiStudio.outputs.title" |
| 695 | | "aiStudio.outputs.description" | 695 | | "aiStudio.outputs.description" |
| 696 | - | "aiStudio.run.title" | ||
| 697 | - | "aiStudio.run.source" | ||
| 698 | - | "aiStudio.run.started" | ||
| 699 | - | "aiStudio.run.ended" | ||
| 700 | - | "aiStudio.run.length" | ||
| 701 | | "aiStudio.library.title" | 696 | | "aiStudio.library.title" |
| 702 | | "aiStudio.backToLibrary" | 697 | | "aiStudio.backToLibrary" |
| 703 | | "aiStudio.library.description" | 698 | | "aiStudio.library.description" |
src/pages/ai-studio-note-page.tsxadded+13 -0
| @@ -0,0 +1,13 @@ | |||
| 1 | +import { useParams, useSearch } from "@tanstack/solid-router"; | ||
| 2 | +import { NoteStudioDetail } from "@/components/ai/note-studio-panel"; | ||
| 3 | +import { RouteGuard } from "@/components/layout/route-guard"; | ||
| 4 | + | ||
| 5 | +export default function AiStudioNotePage() { | ||
| 6 | + const params = useParams({ from: "/ai/studio/$noteId" }); | ||
| 7 | + const search = useSearch({ from: "/ai/studio/$noteId" }); | ||
| 8 | + return ( | ||
| 9 | + <RouteGuard minRole="student"> | ||
| 10 | + <NoteStudioDetail noteId={params().noteId} episode={search().episode} /> | ||
| 11 | + </RouteGuard> | ||
| 12 | + ); | ||
| 13 | +} | ||
src/routes/router.tsxmodified+12 -0
| @@ -74,6 +74,7 @@ const PaymentStatementPage = lazyRoute(() => import("@/pages/payment-statement-p | |||
| 74 | const WhiteboardsPage = lazyRoute(() => import("@/pages/whiteboards-page")); | 74 | const WhiteboardsPage = lazyRoute(() => import("@/pages/whiteboards-page")); |
| 75 | const WhiteboardPage = lazyRoute(() => import("@/pages/whiteboard-page")); | 75 | const WhiteboardPage = lazyRoute(() => import("@/pages/whiteboard-page")); |
| 76 | const AiStudioPage = lazyRoute(() => import("@/pages/ai-studio-page")); | 76 | const AiStudioPage = lazyRoute(() => import("@/pages/ai-studio-page")); |
| 77 | +const AiStudioNotePage = lazyRoute(() => import("@/pages/ai-studio-note-page")); | ||
| 77 | const AiStudyPage = lazyRoute(() => import("@/pages/ai-study-page")); | 78 | const AiStudyPage = lazyRoute(() => import("@/pages/ai-study-page")); |
| 78 | const AiInsightsPage = lazyRoute(() => import("@/pages/ai-insights-page")); | 79 | const AiInsightsPage = lazyRoute(() => import("@/pages/ai-insights-page")); |
| 79 | const AiInsightStudentPage = lazyRoute(() => import("@/pages/ai-insight-student-page")); | 80 | const AiInsightStudentPage = lazyRoute(() => import("@/pages/ai-insight-student-page")); |
| @@ -477,6 +478,16 @@ const aiStudioRoute = createRoute({ | |||
| 477 | component: AiStudioPage, | 478 | component: AiStudioPage, |
| 478 | }); | 479 | }); |
| 479 | 480 | ||
| 481 | +// One note's studio page; `episode` preselects an episode from the library. | ||
| 482 | +const aiStudioNoteRoute = createRoute({ | ||
| 483 | + getParentRoute: () => rootRoute, | ||
| 484 | + path: "/ai/studio/$noteId", | ||
| 485 | + validateSearch: (search: Record<string, unknown>) => ({ | ||
| 486 | + episode: typeof search.episode === "string" && search.episode ? search.episode : undefined, | ||
| 487 | + }), | ||
| 488 | + component: AiStudioNotePage, | ||
| 489 | +}); | ||
| 490 | + | ||
| 480 | const aiStudyRoute = createRoute({ | 491 | const aiStudyRoute = createRoute({ |
| 481 | getParentRoute: () => rootRoute, | 492 | getParentRoute: () => rootRoute, |
| 482 | path: "/ai/study", | 493 | path: "/ai/study", |
| @@ -624,6 +635,7 @@ const routeTree = rootRoute.addChildren([ | |||
| 624 | whiteboardRoute, | 635 | whiteboardRoute, |
| 625 | aiRoute, | 636 | aiRoute, |
| 626 | aiStudioRoute, | 637 | aiStudioRoute, |
| 638 | + aiStudioNoteRoute, | ||
| 627 | aiStudyRoute, | 639 | aiStudyRoute, |
| 628 | aiInsightsRoute, | 640 | aiInsightsRoute, |
| 629 | aiInsightStudentRoute, | 641 | aiInsightStudentRoute, |