🐛 seek waits for unloaded audio, resizable rail, clearer errors
Browse files at this commite78105f294e6ed242904be736ecf36a838258197Parent: 6581414- fix
- 🐛 seek waits for unloaded audio, resizable rail, clearer errors
11 changed files +215 -52
- src/api/__tests__/client/client.test.ts +23 -5
- src/api/client/client.ts +63 -8
- src/components/ai/note-studio-panel.tsx +64 -3
- src/components/events/event-roll-call.test.tsx +1 -1
- src/components/notes/podcast-player.test.tsx +2 -2
- src/components/rag/rag-study-panel.tsx +27 -23
- src/components/ui/audio-player.tsx +20 -6
- src/components/ui/table-pagination.tsx +9 -4
- src/i18n/locales/en.ts +2 -0
- src/i18n/locales/tr.ts +2 -0
- src/i18n/messages.ts +2 -0
src/api/__tests__/client/client.test.tsmodified+23 -5
| @@ -278,13 +278,31 @@ describe("client", () => { | ||
| 278 | 278 | ).toBe("Bu sınava yalnızca dersin öğretmenleri veya bir müdür soru ekleyebilir."); |
| 279 | 279 | }); |
| 280 | 280 | |
| 281 | - it("falls back to a clean localized message for unmapped errors (no raw leak)", () => { | |
| 281 | + it("names the failure and quotes the server's reason for unmapped errors", () => { | |
| 282 | 282 | expect(formatApiErrorMessage("custom error occurred", "en")).toBe( |
| 283 | - "Something went wrong. Please check your input and try again.", | |
| 283 | + "The action could not be completed. Server said: “custom error occurred”.", | |
| 284 | 284 | ); |
| 285 | 285 | expect(formatApiErrorMessage("custom error occurred", "tr")).toBe( |
| 286 | - "İşlem tamamlanamadı. Lütfen bilgileri kontrol edip tekrar dene.", | |
| 286 | + "İşlem tamamlanamadı. Sunucu yanıtı: “custom error occurred”.", | |
| 287 | 287 | ); |
| 288 | + expect(formatApiError(new ApiError(409, "slot taken by a later edit"), "tr")).toBe( | |
| 289 | + "İşlem kaydın şu anki durumuyla çakışıyor. Sunucu yanıtı: “slot taken by a later edit”.", | |
| 290 | + ); | |
| 291 | + expect(formatApiError(new ApiError(400, ""), "tr")).toBe( | |
| 292 | + "Sunucu isteği geçersiz buldu. Bilgileri kontrol edip tekrar dene.", | |
| 293 | + ); | |
| 294 | + }); | |
| 295 | + | |
| 296 | + it("translates request bodies the backend could not decode", () => { | |
| 297 | + expect( | |
| 298 | + formatApiError(new ApiError(422, "Failed to deserialize the JSON body into the target type: missing field `title` at line 1 column 2"), "tr"), | |
| 299 | + ).toBe("“Başlık” alanı eksik. Doldurup tekrar dene."); | |
| 300 | + expect( | |
| 301 | + formatApiError(new ApiError(422, "Failed to deserialize the JSON body into the target type: format: unknown variant `kisa`, expected `duz_okuma` or `tek_ogretici` at line 1 column 20"), "tr"), | |
| 302 | + ).toBe("“kisa” geçerli bir seçenek değil. Geçerli değerler: duz_okuma or tek_ogretici."); | |
| 303 | + expect( | |
| 304 | + formatApiError(new ApiError(422, "Failed to deserialize the JSON body into the target type: ders_saati: invalid type: string \"3\", expected u32 at line 1 column 18"), "tr"), | |
| 305 | + ).toBe("“Ders saati” alanının biçimi hatalı: u32 bekleniyordu, string \"3\" geldi."); | |
| 288 | 306 | }); |
| 289 | 307 | |
| 290 | 308 | it("localizes backend max-length validation messages", () => { |
| @@ -370,8 +388,8 @@ describe("client", () => { | ||
| 370 | 388 | }); |
| 371 | 389 | |
| 372 | 390 | it("formats generic Error", () => { |
| 373 | - expect(formatApiError(new Error("generic"), "en")).toBe("Something went wrong. Please check your input and try again."); | |
| 374 | - expect(formatApiError(new Error("generic"), "tr")).toBe("İşlem tamamlanamadı. Lütfen bilgileri kontrol edip tekrar dene."); | |
| 391 | + expect(formatApiError(new Error("generic"), "en")).toBe("The action could not be completed. Server said: “generic”."); | |
| 392 | + expect(formatApiError(new Error("generic"), "tr")).toBe("İşlem tamamlanamadı. Sunucu yanıtı: “generic”."); | |
| 375 | 393 | }); |
| 376 | 394 | |
| 377 | 395 | it("does not expose network, runtime, or provider errors to users", () => { |
src/api/client/client.tsmodified+63 -8
| @@ -539,7 +539,62 @@ export async function blobClient(path: string, signal?: AbortSignal): Promise<Bl | ||
| 539 | 539 | return res.blob(); |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | -export function formatApiErrorMessage(message: string, locale: Locale = currentLocale()): string { | |
| 542 | +/** | |
| 543 | + * A request body the backend could not read (its JSON extractor, serde). The | |
| 544 | + * text names the field and what was wrong with it, which is exactly what a | |
| 545 | + * reader needs to fix the form — so it is translated instead of hidden. | |
| 546 | + */ | |
| 547 | +function formatDecodeMessage(message: string, locale: Locale): string | null { | |
| 548 | + const tr = locale === "tr"; | |
| 549 | + const missing = message.match(/missing field `([^`]+)`/i); | |
| 550 | + if (missing) { | |
| 551 | + const label = fieldLabel(missing[1], locale); | |
| 552 | + return tr ? `“${label}” alanı eksik. Doldurup tekrar dene.` : `The “${label}” field is missing. Fill it in and try again.`; | |
| 553 | + } | |
| 554 | + const variant = message.match(/unknown variant `([^`]*)`, expected (.+?)(?: at line \d+.*)?$/i); | |
| 555 | + if (variant) { | |
| 556 | + return tr | |
| 557 | + ? `“${variant[1]}” geçerli bir seçenek değil. Geçerli değerler: ${variant[2].replace(/`/g, "")}.` | |
| 558 | + : `“${variant[1]}” is not a valid option. Valid values: ${variant[2].replace(/`/g, "")}.`; | |
| 559 | + } | |
| 560 | + const field = message.match(/([\w.[\]]+): invalid (?:type|value|length)/i)?.[1]; | |
| 561 | + const typed = message.match(/invalid (?:type|value): (.+?), expected (.+?)(?: at line \d+.*)?$/i); | |
| 562 | + if (typed) { | |
| 563 | + const where = field ? (tr ? `“${fieldLabel(field, locale)}” alanının` : `The “${fieldLabel(field, locale)}” field has the`) : tr ? "Bir alanın" : "A field has the"; | |
| 564 | + return tr | |
| 565 | + ? `${where} biçimi hatalı: ${typed[2]} bekleniyordu, ${typed[1]} geldi.` | |
| 566 | + : `${where} wrong format: expected ${typed[2]}, got ${typed[1]}.`; | |
| 567 | + } | |
| 568 | + if (/failed to (parse|deserialize) the (request )?(json )?body|expected value at line|eof while parsing/i.test(message)) { | |
| 569 | + return tr ? "Gönderilen veri okunamadı (biçim hatası). Alanları kontrol edip tekrar dene." : "The data sent could not be read (format error). Check the fields and try again."; | |
| 570 | + } | |
| 571 | + return null; | |
| 572 | +} | |
| 573 | + | |
| 574 | +/** What kind of failure a status is, for when the backend's words are not mapped. */ | |
| 575 | +function statusLead(status: number | null, locale: Locale): string { | |
| 576 | + const tr = locale === "tr"; | |
| 577 | + if (status === 400) return tr ? "Sunucu isteği geçersiz buldu." : "The server rejected the request as invalid."; | |
| 578 | + if (status === 408) return tr ? "Sunucu zamanında yanıt vermedi." : "The server did not answer in time."; | |
| 579 | + if (status === 409) return tr ? "İşlem kaydın şu anki durumuyla çakışıyor." : "The action conflicts with the record's current state."; | |
| 580 | + if (status === 422) return tr ? "Gönderilen bilgilerde eksik ya da hatalı bir alan var." : "A field is missing or has the wrong format."; | |
| 581 | + return tr ? "İşlem tamamlanamadı." : "The action could not be completed."; | |
| 582 | +} | |
| 583 | + | |
| 584 | +/** | |
| 585 | + * The last resort: say what kind of failure it was and quote the backend's | |
| 586 | + * own reason, so the reader (and whoever they ask) can tell a format problem | |
| 587 | + * from a conflict. Raw text is labelled as the server's, not passed off as ours. | |
| 588 | + */ | |
| 589 | +function formatFallbackMessage(message: string, status: number | null, locale: Locale): string { | |
| 590 | + const lead = statusLead(status, locale); | |
| 591 | + const detail = message.trim().replace(/[.\s]+$/, ""); | |
| 592 | + const generic = !detail || /^(request failed|bad request|unprocessable entity|conflict|error)$/i.test(detail); | |
| 593 | + if (generic) return `${lead} ${locale === "tr" ? "Bilgileri kontrol edip tekrar dene." : "Check your input and try again."}`; | |
| 594 | + return `${lead} ${locale === "tr" ? "Sunucu yanıtı" : "Server said"}: “${detail}”.`; | |
| 595 | +} | |
| 596 | + | |
| 597 | +export function formatApiErrorMessage(message: string, locale: Locale = currentLocale(), status: number | null = null): string { | |
| 543 | 598 | const normalized = normalizeApiMessage(message); |
| 544 | 599 | const known = API_ERROR_MESSAGES[normalized]?.[locale]; |
| 545 | 600 | if (known) return known; |
| @@ -547,12 +602,12 @@ export function formatApiErrorMessage(message: string, locale: Locale = currentL | ||
| 547 | 602 | if (runtime) return runtime; |
| 548 | 603 | const validation = formatValidationMessage(message, locale); |
| 549 | 604 | if (validation) return validation; |
| 550 | - // Unmapped backend text is raw English/technical — never surface it to the | |
| 551 | - // user. Fall back to a clean localized line; add a mapping in | |
| 552 | - // API_ERROR_MESSAGES when a specific message deserves its own wording. | |
| 553 | - return locale === "tr" | |
| 554 | - ? "İşlem tamamlanamadı. Lütfen bilgileri kontrol edip tekrar dene." | |
| 555 | - : "Something went wrong. Please check your input and try again."; | |
| 605 | + const decode = formatDecodeMessage(message, locale); | |
| 606 | + if (decode) return decode; | |
| 607 | + // Unmapped backend text: name the kind of failure and quote the server's | |
| 608 | + // reason instead of a bare "something went wrong" that hides it. Add a | |
| 609 | + // mapping in API_ERROR_MESSAGES when a message deserves its own wording. | |
| 610 | + return formatFallbackMessage(message, status, locale); | |
| 556 | 611 | } |
| 557 | 612 | |
| 558 | 613 | export function formatApiError(err: unknown, locale: Locale = currentLocale()): string { |
| @@ -574,7 +629,7 @@ export function formatApiError(err: unknown, locale: Locale = currentLocale()): | ||
| 574 | 629 | if (err.status === 404) return API_ERROR_MESSAGES["not found"][locale]; |
| 575 | 630 | if (err.status === 413) return API_ERROR_MESSAGES["payload too large"][locale]; |
| 576 | 631 | if (err.status >= 500) return locale === "tr" ? "Sunucuda bir sorun oluştu. Lütfen tekrar dene." : "Server error. Please try again."; |
| 577 | - return formatApiErrorMessage(err.message, locale); | |
| 632 | + return formatApiErrorMessage(err.message, locale, err.status); | |
| 578 | 633 | } |
| 579 | 634 | if (err instanceof TypeError) { |
| 580 | 635 | return formatRuntimeErrorMessage(err.message, locale) ?? |
src/components/ai/note-studio-panel.tsxmodified+64 -3
| @@ -1,4 +1,4 @@ | ||
| 1 | -import { Show, Suspense, createMemo } from "solid-js"; | |
| 1 | +import { Show, Suspense, createEffect, createMemo, createSignal } from "solid-js"; | |
| 2 | 2 | import { Link, useNavigate } from "@tanstack/solid-router"; |
| 3 | 3 | import { createResource } from "@/lib/create-resource"; |
| 4 | 4 | import { getCourseNotes } from "@/api/course-notes"; |
| @@ -22,6 +22,17 @@ import { cn } from "@/lib/cn"; | ||
| 22 | 22 | import { courseNoteFiles } from "@/lib/note-source"; |
| 23 | 23 | import { hasMinRole } from "@/lib/roles"; |
| 24 | 24 | |
| 25 | +const RAIL_KEY = "hezarfen.studio.railWidth"; | |
| 26 | +const RAIL_MIN = 280; | |
| 27 | +const RAIL_MAX = 720; | |
| 28 | +const RAIL_DEFAULT = 352; | |
| 29 | + | |
| 30 | +function readRailWidth(): number { | |
| 31 | + if (typeof localStorage === "undefined") return RAIL_DEFAULT; | |
| 32 | + const value = Number(localStorage.getItem(RAIL_KEY)); | |
| 33 | + return Number.isFinite(value) && value >= RAIL_MIN && value <= RAIL_MAX ? value : RAIL_DEFAULT; | |
| 34 | +} | |
| 35 | + | |
| 25 | 36 | type StudioNote = CourseNote & { courseTitle: string; courseCreatorId: string }; |
| 26 | 37 | |
| 27 | 38 | /** Every lesson note the account can produce from, with its course. */ |
| @@ -117,6 +128,32 @@ export function NoteStudioDetail(props: { noteId: string; episode?: string }) { | ||
| 117 | 128 | const auth = useAuth(); |
| 118 | 129 | const [notes, { refetch }] = useStudioNotes(); |
| 119 | 130 | const note = createMemo(() => (notes() ?? []).find((row) => row.id === props.noteId) ?? null); |
| 131 | + // The audio rail is resizable from its left edge, remembered on this device. | |
| 132 | + const [railWidth, setRailWidth] = createSignal(readRailWidth()); | |
| 133 | + const clampRail = (value: number) => Math.round(Math.min(RAIL_MAX, Math.max(RAIL_MIN, value))); | |
| 134 | + createEffect(() => { | |
| 135 | + if (typeof localStorage !== "undefined") localStorage.setItem(RAIL_KEY, String(railWidth())); | |
| 136 | + }); | |
| 137 | + const startResize = (event: PointerEvent) => { | |
| 138 | + event.preventDefault(); | |
| 139 | + const handle = event.currentTarget as HTMLElement; | |
| 140 | + handle.setPointerCapture(event.pointerId); | |
| 141 | + const startX = event.clientX; | |
| 142 | + const startWidth = railWidth(); | |
| 143 | + const move = (next: PointerEvent) => setRailWidth(clampRail(startWidth + (startX - next.clientX))); | |
| 144 | + const stop = () => { | |
| 145 | + handle.removeEventListener("pointermove", move); | |
| 146 | + handle.removeEventListener("pointerup", stop); | |
| 147 | + handle.removeEventListener("pointercancel", stop); | |
| 148 | + document.body.style.removeProperty("cursor"); | |
| 149 | + document.body.style.removeProperty("user-select"); | |
| 150 | + }; | |
| 151 | + document.body.style.cursor = "col-resize"; | |
| 152 | + document.body.style.userSelect = "none"; | |
| 153 | + handle.addEventListener("pointermove", move); | |
| 154 | + handle.addEventListener("pointerup", stop); | |
| 155 | + handle.addEventListener("pointercancel", stop); | |
| 156 | + }; | |
| 120 | 157 | const canManage = () => { |
| 121 | 158 | const current = note(); |
| 122 | 159 | const user = auth.user(); |
| @@ -147,7 +184,10 @@ export function NoteStudioDetail(props: { noteId: string; episode?: string }) { | ||
| 147 | 184 | <h1 class="min-w-0 truncate text-sm font-semibold text-text-strong">{current().title}</h1> |
| 148 | 185 | <span class="rounded-md bg-primary/10 px-1.5 py-0.5 text-xs font-medium text-primary-text">{current().courseTitle}</span> |
| 149 | 186 | </div> |
| 150 | - <div class="grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-[minmax(0,1fr)_22rem]"> | |
| 187 | + <div | |
| 188 | + class="grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-[minmax(0,1fr)_var(--studio-rail)]" | |
| 189 | + style={{ "--studio-rail": `${railWidth()}px` }} | |
| 190 | + > | |
| 151 | 191 | <div class="min-w-0 py-6 lg:overflow-y-auto lg:px-8"> |
| 152 | 192 | <div class="mx-auto w-full max-w-3xl"> |
| 153 | 193 | <RagOutputsPanel |
| @@ -160,7 +200,28 @@ export function NoteStudioDetail(props: { noteId: string; episode?: string }) { | ||
| 160 | 200 | /> |
| 161 | 201 | </div> |
| 162 | 202 | </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"> | |
| 203 | + <aside class="relative 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"> | |
| 204 | + {/* Drag (or arrow keys) to widen the rail; double-click resets it. */} | |
| 205 | + <div | |
| 206 | + role="separator" | |
| 207 | + aria-orientation="vertical" | |
| 208 | + aria-label={t("aiStudio.resizeRail")} | |
| 209 | + aria-valuemin={RAIL_MIN} | |
| 210 | + aria-valuemax={RAIL_MAX} | |
| 211 | + aria-valuenow={railWidth()} | |
| 212 | + tabIndex={0} | |
| 213 | + class="group absolute inset-y-0 left-0 z-10 hidden w-2 cursor-col-resize touch-none outline-hidden lg:block" | |
| 214 | + onPointerDown={startResize} | |
| 215 | + onDblClick={() => setRailWidth(RAIL_DEFAULT)} | |
| 216 | + onKeyDown={(event) => { | |
| 217 | + if (event.key === "ArrowLeft") setRailWidth((w) => clampRail(w + 24)); | |
| 218 | + else if (event.key === "ArrowRight") setRailWidth((w) => clampRail(w - 24)); | |
| 219 | + else return; | |
| 220 | + event.preventDefault(); | |
| 221 | + }} | |
| 222 | + > | |
| 223 | + <span class="block h-full w-px bg-transparent transition-colors group-hover:bg-primary/60 group-focus-visible:bg-primary group-active:bg-primary" /> | |
| 224 | + </div> | |
| 164 | 225 | <PodcastPanel noteId={current().id} noteTitle={current().title} episode={props.episode} active flat /> |
| 165 | 226 | </aside> |
| 166 | 227 | </div> |
src/components/events/event-roll-call.test.tsxmodified+1 -1
| @@ -55,7 +55,7 @@ test("saves only changed rows and reports a failed row on that row", async () => | ||
| 55 | 55 | expect(postEventAttendance).toHaveBeenNthCalledWith(1, "event-1", { user_id: "s-2", status: "absent" }); |
| 56 | 56 | expect(postEventAttendance).toHaveBeenNthCalledWith(2, "event-1", { user_id: "s-3", status: "late" }); |
| 57 | 57 | // The failed row keeps its pick and carries its own error line. |
| 58 | - expect(await screen.findByText(/İşlem tamamlanamadı|Something went wrong/)).toBeTruthy(); | |
| 58 | + expect(await screen.findByText(/İşlem tamamlanamadı|could not be completed/)).toBeTruthy(); | |
| 59 | 59 | expect(screen.getByText(/1 of 2 rows|2 satırdan 1/)).toBeTruthy(); |
| 60 | 60 | expect(onSaved).toHaveBeenCalledTimes(1); |
| 61 | 61 | }); |
src/components/notes/podcast-player.test.tsxmodified+2 -2
| @@ -33,8 +33,8 @@ describe("PodcastPlayer", () => { | ||
| 33 | 33 | vi.spyOn(HTMLMediaElement.prototype, "pause").mockImplementation(() => {}); |
| 34 | 34 | // Nor element scrolling, which the transcript's follow uses. |
| 35 | 35 | Element.prototype.scrollTo ??= () => {}; |
| 36 | - // A stream the server lets the browser seek in, so no local copy is loaded. | |
| 37 | - vi.spyOn(HTMLMediaElement.prototype, "seekable", "get").mockReturnValue({ | |
| 36 | + // Audio already buffered this far, so the seek needs no local copy. | |
| 37 | + vi.spyOn(HTMLMediaElement.prototype, "buffered", "get").mockReturnValue({ | |
| 38 | 38 | length: 1, |
| 39 | 39 | start: () => 0, |
| 40 | 40 | end: () => 754, |
src/components/rag/rag-study-panel.tsxmodified+27 -23
| @@ -299,7 +299,9 @@ 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-[260px_minmax(0,1fr)]", | |
| 302 | + // The history docks on the RIGHT on desktop: on the left it sat flush | |
| 303 | + // against the app's own sidebar and the two read as one tangled nav. | |
| 304 | + historyCollapsed() ? "lg:grid-cols-[minmax(0,1fr)]" : "lg:grid-cols-[minmax(0,1fr)_260px]", | |
| 303 | 305 | )} |
| 304 | 306 | > |
| 305 | 307 | <button |
| @@ -320,7 +322,7 @@ export function RagStudyPanel() { | ||
| 320 | 322 | // slides out before it leaves the tab order. |
| 321 | 323 | "fixed inset-y-0 left-0 z-[60] w-[min(20rem,85vw)] border-r border-border-line px-3 pb-[calc(max(env(safe-area-inset-bottom),var(--android-nav-inset,0px))+0.75rem)] pt-[calc(env(safe-area-inset-top)+0.75rem)] shadow-xl transition-[transform,visibility] duration-300 ease-out", |
| 322 | 324 | historyOpen() ? "visible translate-x-0" : "invisible -translate-x-full", |
| 323 | - "lg:visible lg:static lg:z-auto lg:h-full lg:w-auto lg:translate-x-0 lg:gap-2 lg:border-r lg:border-border-hairline lg:bg-surface-overlay/40 lg:px-2 lg:py-3 lg:shadow-none lg:transition-none", | |
| 325 | + "lg:visible lg:static lg:z-auto lg:h-full lg:w-auto lg:translate-x-0 lg:order-last lg:gap-2 lg:border-l lg:border-r-0 lg:border-border-hairline lg:bg-surface-overlay/40 lg:px-2 lg:py-3 lg:shadow-none lg:transition-none", | |
| 324 | 326 | historyCollapsed() && "lg:hidden", |
| 325 | 327 | )} |
| 326 | 328 | > |
| @@ -334,7 +336,7 @@ export function RagStudyPanel() { | ||
| 334 | 336 | title={copy().collapseHistory} |
| 335 | 337 | onClick={() => setHistoryCollapsed(true)} |
| 336 | 338 | > |
| 337 | - <IconPanelLeft class="h-4 w-4" /> | |
| 339 | + <IconPanelLeft class="h-4 w-4 -scale-x-100" /> | |
| 338 | 340 | </button> |
| 339 | 341 | <button |
| 340 | 342 | type="button" |
| @@ -408,26 +410,6 @@ export function RagStudyPanel() { | ||
| 408 | 410 | {/* Desktop top bar: the open chat's title and its menu; with the |
| 409 | 411 | sidebar folded away, the way back to it and a fresh chat. */} |
| 410 | 412 | <div class="hidden h-12 shrink-0 items-center gap-1 px-3 lg:flex"> |
| 411 | - <Show when={historyCollapsed()}> | |
| 412 | - <button | |
| 413 | - type="button" | |
| 414 | - class="inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground outline-hidden transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring" | |
| 415 | - aria-label={copy().expandHistory} | |
| 416 | - title={copy().expandHistory} | |
| 417 | - onClick={() => setHistoryCollapsed(false)} | |
| 418 | - > | |
| 419 | - <IconPanelLeft class="h-4 w-4" /> | |
| 420 | - </button> | |
| 421 | - <button | |
| 422 | - type="button" | |
| 423 | - class="inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground outline-hidden transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring" | |
| 424 | - aria-label={copy().newThread} | |
| 425 | - title={copy().newThread} | |
| 426 | - onClick={newThread} | |
| 427 | - > | |
| 428 | - <IconPlus class="h-4 w-4" /> | |
| 429 | - </button> | |
| 430 | - </Show> | |
| 431 | 413 | <Show when={activeThread()}> |
| 432 | 414 | {(thread) => ( |
| 433 | 415 | <div class="flex min-w-0 items-center gap-1 pl-1"> |
| @@ -451,6 +433,28 @@ export function RagStudyPanel() { | ||
| 451 | 433 | </div> |
| 452 | 434 | )} |
| 453 | 435 | </Show> |
| 436 | + <Show when={historyCollapsed()}> | |
| 437 | + <div class="ml-auto flex items-center gap-1"> | |
| 438 | + <button | |
| 439 | + type="button" | |
| 440 | + class="inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground outline-hidden transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring" | |
| 441 | + aria-label={copy().expandHistory} | |
| 442 | + title={copy().expandHistory} | |
| 443 | + onClick={() => setHistoryCollapsed(false)} | |
| 444 | + > | |
| 445 | + <IconPanelLeft class="h-4 w-4 -scale-x-100" /> | |
| 446 | + </button> | |
| 447 | + <button | |
| 448 | + type="button" | |
| 449 | + class="inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground outline-hidden transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring" | |
| 450 | + aria-label={copy().newThread} | |
| 451 | + title={copy().newThread} | |
| 452 | + onClick={newThread} | |
| 453 | + > | |
| 454 | + <IconPlus class="h-4 w-4" /> | |
| 455 | + </button> | |
| 456 | + </div> | |
| 457 | + </Show> | |
| 454 | 458 | </div> |
| 455 | 459 | <Show when={error()}> |
| 456 | 460 | <div class="mx-auto w-full max-w-3xl px-4 pt-1 sm:px-6"> |
src/components/ui/audio-player.tsxmodified+20 -6
| @@ -130,10 +130,15 @@ export function AudioPlayer(props: AudioPlayerProps) { | ||
| 130 | 130 | } |
| 131 | 131 | return localLoad; |
| 132 | 132 | }; |
| 133 | + // A seek is instant only where the audio is actually here: the local copy, | |
| 134 | + // or a range the stream has already buffered. `seekable` is not trusted — | |
| 135 | + // Safari reports the whole file as seekable on a stream that ignores Range, | |
| 136 | + // then keeps playing from the old spot. | |
| 133 | 137 | const canSeekTo = (secs: number) => { |
| 134 | - const ranges = audio.seekable; | |
| 138 | + if (objectUrl && source() === objectUrl) return true; | |
| 139 | + const ranges = audio.buffered; | |
| 135 | 140 | for (let i = 0; i < ranges.length; i += 1) { |
| 136 | - if (ranges.end(i) > 0 && secs >= ranges.start(i) && secs <= ranges.end(i)) return true; | |
| 141 | + if (secs >= ranges.start(i) && secs <= ranges.end(i) - 0.5) return true; | |
| 137 | 142 | } |
| 138 | 143 | return false; |
| 139 | 144 | }; |
| @@ -203,7 +208,8 @@ export function AudioPlayer(props: AudioPlayerProps) { | ||
| 203 | 208 | else if (audio.paused) play(); |
| 204 | 209 | else audio.pause(); |
| 205 | 210 | }; |
| 206 | - const skip = (delta: number) => seek(audio.currentTime + delta); | |
| 211 | + // Skips stack on a pending seek's target, not on the stalled stream. | |
| 212 | + const skip = (delta: number) => seek((pendingSeek ?? audio.currentTime) + delta); | |
| 207 | 213 | const cycleRate = () => { |
| 208 | 214 | const index = RATES.indexOf(rate() as (typeof RATES)[number]); |
| 209 | 215 | setRate(RATES[(index + 1) % RATES.length]); |
| @@ -400,14 +406,22 @@ export function AudioPlayer(props: AudioPlayerProps) { | ||
| 400 | 406 | <div |
| 401 | 407 | aria-hidden="true" |
| 402 | 408 | class={cn( |
| 403 | - "pointer-events-none absolute top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-background transition-transform peer-focus-visible:ring-2 peer-focus-visible:ring-ring", | |
| 404 | - playing() || current() > 0 ? "scale-100" : "scale-0 group-hover:scale-100 peer-focus-visible:scale-100", | |
| 409 | + "pointer-events-none absolute top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 transition-transform peer-focus-visible:ring-2 peer-focus-visible:ring-ring", | |
| 410 | + // While the target loads the thumb turns into a spinner right | |
| 411 | + // where playback will resume. | |
| 412 | + seeking() ? "scale-125 animate-spin border-primary border-t-transparent bg-background" : "border-primary bg-background", | |
| 413 | + seeking() || playing() || current() > 0 ? "" : "scale-0 group-hover:scale-100 peer-focus-visible:scale-100", | |
| 405 | 414 | )} |
| 406 | 415 | style={{ left: `${fraction(current()) * 100}%` }} |
| 407 | 416 | /> |
| 408 | 417 | </div> |
| 409 | 418 | <div class="mt-1 flex justify-between text-[11px] tabular-nums text-muted-foreground"> |
| 410 | - <span>{formatDurationClock(current() * 1000)}</span> | |
| 419 | + <span class="flex items-center gap-1.5"> | |
| 420 | + {formatDurationClock(current() * 1000)} | |
| 421 | + <Show when={seeking()}> | |
| 422 | + <span class="text-primary-text" role="status">{t("audio.loadingPosition")}</span> | |
| 423 | + </Show> | |
| 424 | + </span> | |
| 411 | 425 | <span>{formatDurationClock(duration() == null ? null : duration()! * 1000)}</span> |
| 412 | 426 | </div> |
| 413 | 427 | </div> |
src/components/ui/table-pagination.tsxmodified+9 -4
| @@ -34,13 +34,18 @@ export function TablePagination(props: TablePaginationProps) { | ||
| 34 | 34 | <Show when={hasRange() || props.pageCount > 1}> |
| 35 | 35 | <div |
| 36 | 36 | class={cn( |
| 37 | - "flex w-full items-center justify-between gap-2 rounded-lg border border-border-line bg-surface-overlay px-2.5 py-1.5", | |
| 37 | + "flex w-full items-center gap-2 rounded-lg border border-border-line bg-surface-overlay px-2.5 py-1.5", | |
| 38 | + // With no row count to show, the empty left slot pushed the buttons | |
| 39 | + // to the right edge; alone, they sit in the middle. | |
| 40 | + hasRange() ? "justify-between" : "justify-center", | |
| 38 | 41 | props.class, |
| 39 | 42 | )} |
| 40 | 43 | > |
| 41 | - <span class="text-xs font-medium tabular-nums text-muted-foreground sm:text-[11px]"> | |
| 42 | - <Show when={hasRange()}>{t("common.pageRange", { start: start(), end: end(), total: props.total ?? 0 })}</Show> | |
| 43 | - </span> | |
| 44 | + <Show when={hasRange()}> | |
| 45 | + <span class="text-xs font-medium tabular-nums text-muted-foreground sm:text-[11px]"> | |
| 46 | + {t("common.pageRange", { start: start(), end: end(), total: props.total ?? 0 })} | |
| 47 | + </span> | |
| 48 | + </Show> | |
| 44 | 49 | <Show when={props.pageCount > 1}> |
| 45 | 50 | <nav class="flex items-center gap-1" aria-label={t("common.pagination")}> |
| 46 | 51 | <Button |
src/i18n/locales/en.tsmodified+2 -0
| @@ -710,6 +710,7 @@ export const en: Dict = { | ||
| 710 | 710 | "aiStudio.outputs.title": "Studio outputs", |
| 711 | 711 | "aiStudio.outputs.description": "Select a lesson note and keep its summary and podcast together for quick access.", |
| 712 | 712 | "aiStudio.library.title": "Your generated library", |
| 713 | + "aiStudio.resizeRail": "Audio workshop panel width", | |
| 713 | 714 | "aiStudio.backToLibrary": "Back to library", |
| 714 | 715 | "aiStudio.library.description": "Every summary and podcast you produced, newest first.", |
| 715 | 716 | "aiStudio.library.count": "{count} outputs", |
| @@ -1092,6 +1093,7 @@ export const en: Dict = { | ||
| 1092 | 1093 | "audio.mute": "Mute", |
| 1093 | 1094 | "audio.unmute": "Unmute", |
| 1094 | 1095 | "audio.volume": "Volume", |
| 1096 | + "audio.loadingPosition": "Loading this part…", | |
| 1095 | 1097 | "audio.loadFailed": "The audio could not be loaded.", |
| 1096 | 1098 | "podcast.transcript.title": "Transcript", |
| 1097 | 1099 | "podcast.transcript.show": "Show transcript", |
src/i18n/locales/tr.tsmodified+2 -0
| @@ -706,6 +706,7 @@ export const tr: Dict = { | ||
| 706 | 706 | "aiStudio.outputs.title": "Hazır çıktılar", |
| 707 | 707 | "aiStudio.outputs.description": "Bir ders notu seçin; özetini ve podcast'ini hızlı erişim için aynı alanda üretin.", |
| 708 | 708 | "aiStudio.library.title": "Üretim kitaplığın", |
| 709 | + "aiStudio.resizeRail": "Ses Atölyesi panelinin genişliği", | |
| 709 | 710 | "aiStudio.backToLibrary": "Kitaplığa dön", |
| 710 | 711 | "aiStudio.library.description": "Ürettiğin her özet ve podcast, en yenisi üstte.", |
| 711 | 712 | "aiStudio.library.count": "{count} çıktı", |
| @@ -1088,6 +1089,7 @@ export const tr: Dict = { | ||
| 1088 | 1089 | "audio.mute": "Sesi kapat", |
| 1089 | 1090 | "audio.unmute": "Sesi aç", |
| 1090 | 1091 | "audio.volume": "Ses düzeyi", |
| 1092 | + "audio.loadingPosition": "Bu kısım yükleniyor…", | |
| 1091 | 1093 | "audio.loadFailed": "Ses yüklenemedi.", |
| 1092 | 1094 | "podcast.transcript.title": "Transkript", |
| 1093 | 1095 | "podcast.transcript.show": "Transkripti göster", |
src/i18n/messages.tsmodified+2 -0
| @@ -694,6 +694,7 @@ export type MessageKey = | ||
| 694 | 694 | | "aiStudio.outputs.title" |
| 695 | 695 | | "aiStudio.outputs.description" |
| 696 | 696 | | "aiStudio.library.title" |
| 697 | + | "aiStudio.resizeRail" | |
| 697 | 698 | | "aiStudio.backToLibrary" |
| 698 | 699 | | "aiStudio.library.description" |
| 699 | 700 | | "aiStudio.library.count" |
| @@ -1079,6 +1080,7 @@ export type MessageKey = | ||
| 1079 | 1080 | | "audio.mute" |
| 1080 | 1081 | | "audio.unmute" |
| 1081 | 1082 | | "audio.volume" |
| 1083 | + | "audio.loadingPosition" | |
| 1082 | 1084 | | "audio.loadFailed" |
| 1083 | 1085 | | "podcast.transcript.title" |
| 1084 | 1086 | | "podcast.transcript.show" |