forge
Explore
Log in

Don't you dare go Hollow

✨ studio note page as a Mistral Studio tool page, stable player

Browse files at this commit

658141415a4f0f06f066de83d0414e3329430447Burak BoduroğluParent: 1113822
  • feat
    • ✨ studio note page as a Mistral Studio tool page, stable player
Show full message
feat: ✨ studio note page as a Mistral Studio tool page, stable player
- /ai/studio/$noteId: a thin top bar (back to the library, note title,
  course badge), the summary on a wide canvas and the audio workshop on a
  right rail, like Studio's Text to Speech page; both panels get a flat
  variant without the card frame
- study sidebar is 260px, Vibe's own width
- the audio player sets its src only once the element is in the live
  document; a <Suspense> boundary renders detached first and Chromium
  rejected that load ("Media load rejected by URL safety check"), with one
  quiet retry for any load that still races attachment
- the episode player is keyed on the episode id, so a list refresh no
  longer remounts it mid-load or stops playback
src/components/ai/note-studio-panel.tsxmodified+24 -15
@@ -131,8 +131,11 @@ export function NoteStudioDetail(props: { noteId: string; episode?: string }) {
131131 <Show when={!notes.error && notes()}>
132132 <Show when={note()} fallback={<RecordNotFound backTo="/ai/studio" />}>
133133 {(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">
136139 <Link
137140 to="/ai/studio"
138141 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 }) {
140143 <IconChevronLeft class="h-4 w-4" />
141144 {t("aiStudio.backToLibrary")}
142145 </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>
147149 </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>
157166 </div>
158167 </div>
159168 )}
src/components/notes/podcast-history.tsxmodified+11 -8
@@ -147,15 +147,18 @@ export function PodcastHistory(props: {
147147 />
148148 }
149149 >
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) => (
152155 <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}
159162 autoplay={autoplay()}
160163 />
161164 )}
src/components/notes/podcast-panel.tsxmodified+9 -2
@@ -15,7 +15,14 @@ import { useT } from "@/stores/preferences-context";
1515
1616 const POLL_MS = 2_000;
1717
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+}) {
1926 const t = useT();
2027 const [format, setFormat] = createSignal<PodcastFormat>("duz_okuma");
2128 const [jobId, setJobId] = createSignal("");
@@ -167,7 +174,7 @@ export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitl
167174 </section>
168175 }
169176 >
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"}>
171178 <div class="flex items-start gap-3">
172179 <div class="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary-text">
173180 <IconWaveform class="h-5 w-5" />
src/components/notes/rag-outputs-panel.tsxmodified+3 -1
@@ -39,6 +39,8 @@ export function RagOutputsPanel(props: {
3939 noteTitle?: string;
4040 /** Delete control is teacher-only; readers see the list. Defaults to true. */
4141 canManage?: boolean;
42+ /** Drop the card frame where the page itself is the frame (studio canvas). */
43+ flat?: boolean;
4244 }) {
4345 const t = useT();
4446 const { locale } = usePreferences();
@@ -199,7 +201,7 @@ export function RagOutputsPanel(props: {
199201 };
200202
201203 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"}>
203205 <div class="flex flex-wrap items-start justify-between gap-3">
204206 <div>
205207 <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() {
299299 class={cn(
300300 "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",
301301 "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)]",
303303 )}
304304 >
305305 <button
src/components/ui/audio-player.tsxmodified+27 -2
@@ -85,7 +85,13 @@ export function AudioPlayer(props: AudioPlayerProps) {
8585 const [failed, setFailed] = createSignal(false);
8686 // Seeking waits on the local copy; the seek bar already shows the target.
8787 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;
8995
9096 // The local copy of the file, loaded once per `src` on first play or on the
9197 // first seek the stream cannot serve.
@@ -212,10 +218,21 @@ export function AudioPlayer(props: AudioPlayerProps) {
212218 };
213219
214220 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();
215231 players.add(audio);
216232 props.controller?.({ seek, play });
217233 });
218234 onCleanup(() => {
235+ disposed = true;
219236 players.delete(audio);
220237 audio?.pause();
221238 dropLocal();
@@ -239,7 +256,8 @@ export function AudioPlayer(props: AudioPlayerProps) {
239256 resumeAfterSeek = false;
240257 afterLoad = null;
241258 setSeeking(false);
242- setSource(src);
259+ retriedLoad = false;
260+ if (connected) setSource(src);
243261 setCurrent(0);
244262 setMediaDuration(null);
245263 setBuffered(0);
@@ -318,6 +336,13 @@ export function AudioPlayer(props: AudioPlayerProps) {
318336 props.onTimeUpdate?.(audio.currentTime);
319337 }}
320338 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+ }
321346 setFailed(true);
322347 setPlaying(false);
323348 setBuffering(false);