✨ studio note page as a Mistral Studio tool page, stable player
Browse files at this commit658141415a4f0f06f066de83d0414e3329430447Parent: 1113822- feat
- ✨ studio note page as a Mistral Studio tool page, stable player
6 changed files +75 -29
- src/components/ai/note-studio-panel.tsx +24 -15
- src/components/notes/podcast-history.tsx +11 -8
- src/components/notes/podcast-panel.tsx +9 -2
- src/components/notes/rag-outputs-panel.tsx +3 -1
- src/components/rag/rag-study-panel.tsx +1 -1
- src/components/ui/audio-player.tsx +27 -2
src/components/ai/note-studio-panel.tsxmodified+24 -15
| @@ -131,8 +131,11 @@ export function NoteStudioDetail(props: { noteId: string; episode?: string }) { | ||
| 131 | 131 | <Show when={!notes.error && notes()}> |
| 132 | 132 | <Show when={note()} fallback={<RecordNotFound backTo="/ai/studio" />}> |
| 133 | 133 | {(current) => ( |
| 134 | - <div class="w-full space-y-6"> | |
| 135 | - <div class="space-y-3"> | |
| 134 | + // Laid out like a Mistral Studio tool page (Text to Speech): a thin | |
| 135 | + // top bar with the way back and the note's name, the work on a | |
| 136 | + // wide canvas, and the audio controls on a rail at the right. | |
| 137 | + <div class="flex w-full flex-col lg:-mx-10 lg:-my-6 lg:h-[calc(100dvh-49px-env(safe-area-inset-top))] lg:w-auto"> | |
| 138 | + <div class="flex min-h-12 shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b border-border-hairline pb-3 lg:px-6 lg:pb-0"> | |
| 136 | 139 | <Link |
| 137 | 140 | to="/ai/studio" |
| 138 | 141 | class={cn(buttonVariants({ variant: "ghost", size: "sm" }), "-ml-2 h-8 gap-1 rounded-lg text-muted-foreground")} |
| @@ -140,20 +143,26 @@ export function NoteStudioDetail(props: { noteId: string; episode?: string }) { | ||
| 140 | 143 | <IconChevronLeft class="h-4 w-4" /> |
| 141 | 144 | {t("aiStudio.backToLibrary")} |
| 142 | 145 | </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> | |
| 146 | + <span class="hidden h-4 w-px bg-border-line sm:block" aria-hidden="true" /> | |
| 147 | + <h1 class="min-w-0 truncate text-sm font-semibold text-text-strong">{current().title}</h1> | |
| 148 | + <span class="rounded-md bg-primary/10 px-1.5 py-0.5 text-xs font-medium text-primary-text">{current().courseTitle}</span> | |
| 147 | 149 | </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 /> | |
| 150 | + <div class="grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-[minmax(0,1fr)_22rem]"> | |
| 151 | + <div class="min-w-0 py-6 lg:overflow-y-auto lg:px-8"> | |
| 152 | + <div class="mx-auto w-full max-w-3xl"> | |
| 153 | + <RagOutputsPanel | |
| 154 | + noteId={current().id} | |
| 155 | + source={courseNoteFiles} | |
| 156 | + canManage={canManage()} | |
| 157 | + active | |
| 158 | + flat | |
| 159 | + noteTitle={current().title} | |
| 160 | + /> | |
| 161 | + </div> | |
| 162 | + </div> | |
| 163 | + <aside class="min-w-0 border-t border-border-hairline py-6 lg:overflow-y-auto lg:border-l lg:border-t-0 lg:bg-surface-overlay/30 lg:px-5"> | |
| 164 | + <PodcastPanel noteId={current().id} noteTitle={current().title} episode={props.episode} active flat /> | |
| 165 | + </aside> | |
| 157 | 166 | </div> |
| 158 | 167 | </div> |
| 159 | 168 | )} |
src/components/notes/podcast-history.tsxmodified+11 -8
| @@ -147,15 +147,18 @@ export function PodcastHistory(props: { | ||
| 147 | 147 | /> |
| 148 | 148 | } |
| 149 | 149 | > |
| 150 | - <Show when={current()} keyed> | |
| 151 | - {(row) => ( | |
| 150 | + {/* Keyed on the episode id, not the row object: a list refresh | |
| 151 | + hands back new objects, and remounting the player on each one | |
| 152 | + cut the audio mid-load and stopped playback. */} | |
| 153 | + <Show when={current()?.job_id} keyed> | |
| 154 | + {(jobId) => ( | |
| 152 | 155 | <PodcastPlayer |
| 153 | - jobId={row.job_id} | |
| 154 | - title={rowTitle(row)} | |
| 155 | - subtitle={formatDateTime(row.created_at, locale())} | |
| 156 | - downloadName={noteName(row)} | |
| 157 | - durationSecs={row.duration_secs} | |
| 158 | - transcript={props.transcript?.jobId === row.job_id ? props.transcript.segments : null} | |
| 156 | + jobId={jobId} | |
| 157 | + title={current() ? rowTitle(current()!) : ""} | |
| 158 | + subtitle={formatDateTime(current()?.created_at, locale())} | |
| 159 | + downloadName={current() ? noteName(current()!) : undefined} | |
| 160 | + durationSecs={current()?.duration_secs} | |
| 161 | + transcript={props.transcript?.jobId === jobId ? props.transcript.segments : null} | |
| 159 | 162 | autoplay={autoplay()} |
| 160 | 163 | /> |
| 161 | 164 | )} |
src/components/notes/podcast-panel.tsxmodified+9 -2
| @@ -15,7 +15,14 @@ import { useT } from "@/stores/preferences-context"; | ||
| 15 | 15 | |
| 16 | 16 | const POLL_MS = 2_000; |
| 17 | 17 | |
| 18 | -export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitle?: string; episode?: string }) { | |
| 18 | +export function PodcastPanel(props: { | |
| 19 | + noteId: string; | |
| 20 | + active?: boolean; | |
| 21 | + noteTitle?: string; | |
| 22 | + episode?: string; | |
| 23 | + /** Drop the card frame where the page itself is the frame (studio rail). */ | |
| 24 | + flat?: boolean; | |
| 25 | +}) { | |
| 19 | 26 | const t = useT(); |
| 20 | 27 | const [format, setFormat] = createSignal<PodcastFormat>("duz_okuma"); |
| 21 | 28 | const [jobId, setJobId] = createSignal(""); |
| @@ -167,7 +174,7 @@ export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitl | ||
| 167 | 174 | </section> |
| 168 | 175 | } |
| 169 | 176 | > |
| 170 | - <section class="space-y-4 rounded-xl border border-border-line bg-surface-base p-3 sm:p-4"> | |
| 177 | + <section class={props.flat ? "space-y-4" : "space-y-4 rounded-xl border border-border-line bg-surface-base p-3 sm:p-4"}> | |
| 171 | 178 | <div class="flex items-start gap-3"> |
| 172 | 179 | <div class="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary-text"> |
| 173 | 180 | <IconWaveform class="h-5 w-5" /> |
src/components/notes/rag-outputs-panel.tsxmodified+3 -1
| @@ -39,6 +39,8 @@ export function RagOutputsPanel(props: { | ||
| 39 | 39 | noteTitle?: string; |
| 40 | 40 | /** Delete control is teacher-only; readers see the list. Defaults to true. */ |
| 41 | 41 | canManage?: boolean; |
| 42 | + /** Drop the card frame where the page itself is the frame (studio canvas). */ | |
| 43 | + flat?: boolean; | |
| 42 | 44 | }) { |
| 43 | 45 | const t = useT(); |
| 44 | 46 | const { locale } = usePreferences(); |
| @@ -199,7 +201,7 @@ export function RagOutputsPanel(props: { | ||
| 199 | 201 | }; |
| 200 | 202 | |
| 201 | 203 | return ( |
| 202 | - <section class="min-w-0 space-y-3 rounded-xl border border-border-line bg-surface-base p-3 sm:p-4"> | |
| 204 | + <section class={props.flat ? "min-w-0 space-y-3" : "min-w-0 space-y-3 rounded-xl border border-border-line bg-surface-base p-3 sm:p-4"}> | |
| 203 | 205 | <div class="flex flex-wrap items-start justify-between gap-3"> |
| 204 | 206 | <div> |
| 205 | 207 | <h3 class="text-sm font-semibold">{t("courseNotes.ragTitle")}</h3> |
src/components/rag/rag-study-panel.tsxmodified+1 -1
| @@ -299,7 +299,7 @@ export function RagStudyPanel() { | ||
| 299 | 299 | class={cn( |
| 300 | 300 | "grid h-[calc(var(--app-viewport)-5.5rem-max(env(safe-area-inset-bottom),var(--android-nav-inset,0px)))] gap-4 max-lg:-mt-2", |
| 301 | 301 | "lg:-mx-10 lg:-my-6 lg:h-[calc(100dvh-49px-env(safe-area-inset-top))] lg:gap-0", |
| 302 | - historyCollapsed() ? "lg:grid-cols-[minmax(0,1fr)]" : "lg:grid-cols-[16.5rem_minmax(0,1fr)]", | |
| 302 | + historyCollapsed() ? "lg:grid-cols-[minmax(0,1fr)]" : "lg:grid-cols-[260px_minmax(0,1fr)]", | |
| 303 | 303 | )} |
| 304 | 304 | > |
| 305 | 305 | <button |
src/components/ui/audio-player.tsxmodified+27 -2
| @@ -85,7 +85,13 @@ export function AudioPlayer(props: AudioPlayerProps) { | ||
| 85 | 85 | const [failed, setFailed] = createSignal(false); |
| 86 | 86 | // Seeking waits on the local copy; the seek bar already shows the target. |
| 87 | 87 | const [seeking, setSeeking] = createSignal(false); |
| 88 | - const [source, setSource] = createSignal(props.src); | |
| 88 | + // No src until the element is in the live document. A <Suspense> boundary | |
| 89 | + // renders its children detached first, and Chromium refuses a media load | |
| 90 | + // that starts off-document ("Media load rejected by URL safety check"). | |
| 91 | + const [source, setSource] = createSignal<string | undefined>(); | |
| 92 | + let connected = false; | |
| 93 | + let retriedLoad = false; | |
| 94 | + let disposed = false; | |
| 89 | 95 | |
| 90 | 96 | // The local copy of the file, loaded once per `src` on first play or on the |
| 91 | 97 | // first seek the stream cannot serve. |
| @@ -212,10 +218,21 @@ export function AudioPlayer(props: AudioPlayerProps) { | ||
| 212 | 218 | }; |
| 213 | 219 | |
| 214 | 220 | onMount(() => { |
| 221 | + const attach = () => { | |
| 222 | + if (disposed) return; | |
| 223 | + if (!audio.isConnected) { | |
| 224 | + requestAnimationFrame(attach); | |
| 225 | + return; | |
| 226 | + } | |
| 227 | + connected = true; | |
| 228 | + setSource(objectUrl ?? props.src); | |
| 229 | + }; | |
| 230 | + attach(); | |
| 215 | 231 | players.add(audio); |
| 216 | 232 | props.controller?.({ seek, play }); |
| 217 | 233 | }); |
| 218 | 234 | onCleanup(() => { |
| 235 | + disposed = true; | |
| 219 | 236 | players.delete(audio); |
| 220 | 237 | audio?.pause(); |
| 221 | 238 | dropLocal(); |
| @@ -239,7 +256,8 @@ export function AudioPlayer(props: AudioPlayerProps) { | ||
| 239 | 256 | resumeAfterSeek = false; |
| 240 | 257 | afterLoad = null; |
| 241 | 258 | setSeeking(false); |
| 242 | - setSource(src); | |
| 259 | + retriedLoad = false; | |
| 260 | + if (connected) setSource(src); | |
| 243 | 261 | setCurrent(0); |
| 244 | 262 | setMediaDuration(null); |
| 245 | 263 | setBuffered(0); |
| @@ -318,6 +336,13 @@ export function AudioPlayer(props: AudioPlayerProps) { | ||
| 318 | 336 | props.onTimeUpdate?.(audio.currentTime); |
| 319 | 337 | }} |
| 320 | 338 | onError={() => { |
| 339 | + // One quiet retry for a load that raced the element's attachment; | |
| 340 | + // a real failure (bad file, gone episode) fails again and shows. | |
| 341 | + if (!retriedLoad && audio.isConnected && source()) { | |
| 342 | + retriedLoad = true; | |
| 343 | + audio.load(); | |
| 344 | + return; | |
| 345 | + } | |
| 321 | 346 | setFailed(true); |
| 322 | 347 | setPlaying(false); |
| 323 | 348 | setBuffering(false); |