✨ student numbers, Mistral-shaped study and studio, evidence redesign
Browse files at this commitdcf123a8823bd55f0a656ce94de6b865f41dc08aParent: 7d6f928- feat
- ✨ student numbers, Mistral-shaped study and studio, evidence redesign
31 changed files +843 -277
- --full-page +0 -0
- src/api/__tests__/users/users.test.ts +24 -0
- src/api/client/types.ts +19 -0
- src/components/ai/note-studio-panel.tsx +38 -35
- src/components/ai/studio-output-library.tsx +31 -31
- src/components/insights/insight-module-views.tsx +33 -18
- src/components/insights/insight-student-analysis-tabs.tsx +13 -19
- src/components/layout/nav-items.ts +2 -2
- src/components/notes/podcast-history.test.tsx +25 -0
- src/components/notes/podcast-history.tsx +29 -6
- src/components/notes/podcast-panel.tsx +34 -13
- src/components/notes/rag-outputs-panel.tsx +1 -1
- src/components/rag/rag-composer.tsx +15 -6
- src/components/rag/rag-copy.ts +22 -2
- src/components/rag/rag-message-row.test.tsx +63 -0
- src/components/rag/rag-message-row.tsx +60 -11
- src/components/rag/rag-study-panel.tsx +103 -40
- src/components/rag/rag-study-welcome.tsx +10 -5
- src/components/rag/rag-thinking-label.tsx +20 -0
- src/components/rag/rag-thread-list.tsx +79 -31
- src/components/ui/chart-comparator-bar.tsx +82 -0
- src/components/users/create-user-panel.tsx +27 -1
- src/components/users/profile-form.tsx +27 -0
- src/components/users/student-directory-columns.tsx +35 -0
- src/i18n/locales/en.ts +11 -5
- src/i18n/locales/tr.ts +12 -6
- src/i18n/messages.ts +9 -3
- src/pages/admin-user-detail-page.tsx +7 -0
- src/pages/student-attendance-page.tsx +4 -14
- src/pages/student-marks-page.tsx +4 -14
- src/pages/student-pomodoro-page.tsx +4 -14
--full-pageadded+0 -0
Binary file changed
src/api/__tests__/users/users.test.tsmodified+24 -0
| @@ -228,4 +228,28 @@ describe("users API", () => { | |||
| 228 | expect(init?.method).toBe("POST"); | 228 | expect(init?.method).toBe("POST"); |
| 229 | expect(JSON.parse(init?.body as string)).toEqual(body); | 229 | expect(JSON.parse(init?.body as string)).toEqual(body); |
| 230 | }); | 230 | }); |
| 231 | + | ||
| 232 | + it("postUser carries the school-issued student number", async () => { | ||
| 233 | + mockFetchSuccess({ id: "u9", username: "ayse", role: "student", student_number: "1234" }); | ||
| 234 | + | ||
| 235 | + const body = { username: "ayse", password: "secret123", role: "student" as const, student_number: "1234" }; | ||
| 236 | + await postUser(body); | ||
| 237 | + | ||
| 238 | + const [url, init] = lastFetchCall(); | ||
| 239 | + expect(url).toBe("/api/users"); | ||
| 240 | + expect(init?.method).toBe("POST"); | ||
| 241 | + expect(JSON.parse(init?.body as string)).toEqual(body); | ||
| 242 | + }); | ||
| 243 | + | ||
| 244 | + it("patchUserProfile sends an empty student number to clear it", async () => { | ||
| 245 | + mockFetchSuccess({ id: "u1", student_number: null }); | ||
| 246 | + | ||
| 247 | + const updates = { student_number: "" }; | ||
| 248 | + await patchUserProfile("u1", updates); | ||
| 249 | + | ||
| 250 | + const [url, init] = lastFetchCall(); | ||
| 251 | + expect(url).toBe("/api/users/u1/profile"); | ||
| 252 | + expect(init?.method).toBe("PATCH"); | ||
| 253 | + expect(JSON.parse(init?.body as string)).toEqual(updates); | ||
| 254 | + }); | ||
| 231 | }); | 255 | }); |
src/api/client/types.tsmodified+19 -0
| @@ -26,6 +26,9 @@ export type User = { | |||
| 26 | theme: UserTheme | null; | 26 | theme: UserTheme | null; |
| 27 | language: UserLanguage | null; | 27 | language: UserLanguage | null; |
| 28 | palette_color: string | null; | 28 | palette_color: string | null; |
| 29 | + // The school-issued student number, unique inside the school. Only ever a | ||
| 30 | + // value on a `student` row — a role change away from `student` clears it. | ||
| 31 | + student_number?: string | null; | ||
| 29 | }; | 32 | }; |
| 30 | 33 | ||
| 31 | // PATCH /users/me and PATCH /users/{id}/profile take the same body: an omitted | 34 | // PATCH /users/me and PATCH /users/{id}/profile take the same body: an omitted |
| @@ -40,6 +43,11 @@ export type ProfileUpdate = { | |||
| 40 | bio?: string | null; | 43 | bio?: string | null; |
| 41 | // The teacher's branş, by name from settings.branches. | 44 | // The teacher's branş, by name from settings.branches. |
| 42 | branch?: string | null; | 45 | branch?: string | null; |
| 46 | + // The school-issued student number, unique inside the school and only ever | ||
| 47 | + // held by a `student` account. Omit to keep it; send "" (or whitespace) to | ||
| 48 | + // clear it. Naming one for another role, or one another student holds, is | ||
| 49 | + // refused. | ||
| 50 | + student_number?: string | null; | ||
| 43 | }; | 51 | }; |
| 44 | 52 | ||
| 45 | // POST /users (admin): the school office opens an account directly. `role` | 53 | // POST /users (admin): the school office opens an account directly. `role` |
| @@ -49,12 +57,20 @@ export type CreateUserInput = { | |||
| 49 | username: string; | 57 | username: string; |
| 50 | password: string; | 58 | password: string; |
| 51 | role?: Role; | 59 | role?: Role; |
| 60 | + // Only a `student` account may hold one: naming it for any other role is a | ||
| 61 | + // 400, and a number another student already holds is a 409. Omit (or leave | ||
| 62 | + // blank) to open the account unnumbered. | ||
| 63 | + student_number?: string | null; | ||
| 52 | }; | 64 | }; |
| 53 | 65 | ||
| 54 | export type PersonRef = { | 66 | export type PersonRef = { |
| 55 | id: string; | 67 | id: string; |
| 56 | username: string; | 68 | username: string; |
| 57 | display_name: string | null; | 69 | display_name: string | null; |
| 70 | + // The school-issued student number; `null` for every account that holds none, | ||
| 71 | + // every staff account included. It rides this ref the way a username does, so | ||
| 72 | + // a roster that names a student can name their number without a second read. | ||
| 73 | + student_number?: string | null; | ||
| 58 | }; | 74 | }; |
| 59 | 75 | ||
| 60 | // The lifetime counter a badge reads. Badges sharing a stat form a ladder. | 76 | // The lifetime counter a badge reads. Badges sharing a stat form a ladder. |
| @@ -824,6 +840,9 @@ export type Limits = { | |||
| 824 | max_name_len: number; | 840 | max_name_len: number; |
| 825 | max_display_name_len: number; | 841 | max_display_name_len: number; |
| 826 | max_bio_len: number; | 842 | max_bio_len: number; |
| 843 | + // A student number's length bound; the value is free text, unique inside the | ||
| 844 | + // school and only ever held by a `student` account. | ||
| 845 | + max_student_number_len: number; | ||
| 827 | // Caps on what a profile read embeds, not on membership: the full lists | 846 | // Caps on what a profile read embeds, not on membership: the full lists |
| 828 | // stay at /courses/me and /classes/me. | 847 | // stay at /courses/me and /classes/me. |
| 829 | max_profile_courses: number; | 848 | max_profile_courses: number; |
src/components/ai/note-studio-panel.tsxmodified+38 -35
| @@ -9,7 +9,6 @@ import { RagOutputsPanel } from "@/components/notes/rag-outputs-panel"; | |||
| 9 | import { StudioOutputLibrary } from "@/components/ai/studio-output-library"; | 9 | import { StudioOutputLibrary } from "@/components/ai/studio-output-library"; |
| 10 | import { EmptyState } from "@/components/ui/empty-state"; | 10 | import { EmptyState } from "@/components/ui/empty-state"; |
| 11 | import { ErrorAlert } from "@/components/ui/error-alert"; | 11 | import { ErrorAlert } from "@/components/ui/error-alert"; |
| 12 | -import { IconSparkles } from "@/components/ui/icons"; | ||
| 13 | import { Label } from "@/components/ui/label"; | 12 | import { Label } from "@/components/ui/label"; |
| 14 | import { PageSpinner } from "@/components/ui/page-spinner"; | 13 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 15 | import { SearchableSelect } from "@/components/ui/searchable-select"; | 14 | import { SearchableSelect } from "@/components/ui/searchable-select"; |
| @@ -70,42 +69,42 @@ export function NoteStudioPanel() { | |||
| 70 | when={(notes()?.length ?? 0) > 0} | 69 | when={(notes()?.length ?? 0) > 0} |
| 71 | fallback={<EmptyState kind="notes" title={t("podcast.noNotes")} description={t("podcast.noNotesHint")} />} | 70 | fallback={<EmptyState kind="notes" title={t("podcast.noNotes")} description={t("podcast.noNotesHint")} />} |
| 72 | > | 71 | > |
| 73 | - <div class="w-full space-y-5"> | 72 | + {/* Laid out the way a studio home reads: a plain title and one line |
| 74 | - <section class="overflow-hidden rounded-2xl border border-border-line bg-surface-base shadow-xs"> | 73 | + saying what it makes, the source picker, the producers, then |
| 75 | - <div class="flex items-start gap-3 border-b border-border-line bg-primary/[0.035] px-4 py-4 sm:px-5"> | 74 | + everything produced so far. Flat hairline cards, no banner and no |
| 76 | - <div class="flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary-text"> | 75 | + shadow stack — the work is the content, not the chrome. */} |
| 77 | - <IconSparkles class="h-5 w-5" /> | 76 | + <div class="w-full space-y-8"> |
| 78 | - </div> | 77 | + <header class="space-y-1.5"> |
| 79 | - <div class="min-w-0"> | 78 | + <h1 class="text-2xl font-semibold tracking-tight text-text-strong">{t("aiHub.tab.studio")}</h1> |
| 80 | - <p class="text-xs font-medium uppercase tracking-[0.12em] text-primary-text">{t("aiHub.tab.studio")}</p> | 79 | + <p class="text-sm text-muted-foreground">{t("aiStudio.heading")}</p> |
| 81 | - <h1 class="mt-1 text-lg font-semibold tracking-tight text-text-strong">{t("aiHub.tab.studio")}</h1> | 80 | + </header> |
| 82 | - <p class="mt-1 max-w-2xl text-sm text-muted-foreground">{t("aiHub.description")}</p> | 81 | + |
| 82 | + <div class="max-w-xl space-y-2"> | ||
| 83 | + <Label for="sound-studio-note">{t("podcast.source")}</Label> | ||
| 84 | + <SearchableSelect | ||
| 85 | + id="sound-studio-note" | ||
| 86 | + class="w-full" | ||
| 87 | + value={selectedId()} | ||
| 88 | + onChange={setSelectedId} | ||
| 89 | + options={options()} | ||
| 90 | + placeholder={t("podcast.selectNote")} | ||
| 91 | + /> | ||
| 92 | + </div> | ||
| 93 | + | ||
| 94 | + <Show | ||
| 95 | + when={selected()} | ||
| 96 | + fallback={ | ||
| 97 | + <div class="rounded-xl border border-dashed border-border-line px-6 py-12 text-center"> | ||
| 98 | + <p class="text-sm font-medium text-text-strong">{t("aiStudio.pickPrompt")}</p> | ||
| 99 | + <p class="mx-auto mt-1 max-w-md text-sm text-muted-foreground">{t("aiStudio.pickPromptHint")}</p> | ||
| 83 | </div> | 100 | </div> |
| 84 | - </div> | 101 | + } |
| 85 | - <div class="space-y-2 px-4 py-4 sm:px-5"> | 102 | + > |
| 86 | - <Label for="sound-studio-note">{t("podcast.source")}</Label> | ||
| 87 | - <SearchableSelect | ||
| 88 | - id="sound-studio-note" | ||
| 89 | - class="w-full" | ||
| 90 | - value={selectedId()} | ||
| 91 | - onChange={setSelectedId} | ||
| 92 | - options={options()} | ||
| 93 | - placeholder={t("podcast.selectNote")} | ||
| 94 | - /> | ||
| 95 | - </div> | ||
| 96 | - </section> | ||
| 97 | - <Show when={selected()}> | ||
| 98 | {(note) => ( | 103 | {(note) => ( |
| 99 | - <section ref={outputsSection} class="scroll-mt-20 space-y-3 rounded-2xl border border-border-line bg-surface-base p-3 shadow-xs sm:p-4"> | 104 | + <section ref={outputsSection} class="scroll-mt-20 space-y-4"> |
| 100 | - <div class="flex flex-wrap items-center justify-between gap-2 px-1"> | 105 | + <div class="flex flex-wrap items-baseline justify-between gap-2"> |
| 101 | - <div class="min-w-0"> | 106 | + <h2 class="min-w-0 truncate text-base font-semibold text-text-strong">{note().title}</h2> |
| 102 | - <p class="text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground">{t("aiStudio.outputs.title")}</p> | 107 | + <span class="shrink-0 text-xs text-muted-foreground">{note().courseTitle}</span> |
| 103 | - <h2 class="mt-1 truncate text-base font-semibold text-text-strong">{note().title}</h2> | ||
| 104 | - <p class="mt-1 text-xs text-muted-foreground">{t("aiStudio.outputs.description")}</p> | ||
| 105 | - </div> | ||
| 106 | - <span class="rounded-full border border-border-line bg-background px-2.5 py-1 text-xs text-muted-foreground"> | ||
| 107 | - {note().courseTitle} | ||
| 108 | - </span> | ||
| 109 | </div> | 108 | </div> |
| 110 | <div class="grid gap-4 xl:grid-cols-2"> | 109 | <div class="grid gap-4 xl:grid-cols-2"> |
| 111 | <RagOutputsPanel | 110 | <RagOutputsPanel |
| @@ -120,6 +119,10 @@ export function NoteStudioPanel() { | |||
| 120 | </section> | 119 | </section> |
| 121 | )} | 120 | )} |
| 122 | </Show> | 121 | </Show> |
| 122 | + | ||
| 123 | + {/* The library is the landing view. Once a note is open the page is | ||
| 124 | + about producing for that note, so the list of everything else | ||
| 125 | + steps out of the way. */} | ||
| 123 | <Show when={!selected()}> | 126 | <Show when={!selected()}> |
| 124 | <StudioOutputLibrary | 127 | <StudioOutputLibrary |
| 125 | notes={(notes() ?? []).map((note) => ({ id: note.id, title: note.title, courseTitle: note.courseTitle }))} | 128 | notes={(notes() ?? []).map((note) => ({ id: note.id, title: note.title, courseTitle: note.courseTitle }))} |
src/components/ai/studio-output-library.tsxmodified+31 -31
| @@ -4,10 +4,11 @@ import { getCourseNoteRag } from "@/api/course-notes"; | |||
| 4 | import { listPodcastJobs } from "@/api/podcast"; | 4 | import { listPodcastJobs } from "@/api/podcast"; |
| 5 | import { Badge } from "@/components/ui/badge"; | 5 | import { Badge } from "@/components/ui/badge"; |
| 6 | import { EmptyInline } from "@/components/ui/empty-inline"; | 6 | import { EmptyInline } from "@/components/ui/empty-inline"; |
| 7 | -import { IconChevronRight, IconNote, IconSparkles, IconWaveform } from "@/components/ui/icons"; | 7 | +import { IconNote, IconSparkles, IconWaveform } from "@/components/ui/icons"; |
| 8 | import { PageSpinner } from "@/components/ui/page-spinner"; | 8 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 9 | import { cn } from "@/lib/cn"; | 9 | import { cn } from "@/lib/cn"; |
| 10 | -import { useT } from "@/stores/preferences-context"; | 10 | +import { formatDate } from "@/lib/format"; |
| 11 | +import { usePreferences, useT } from "@/stores/preferences-context"; | ||
| 11 | 12 | ||
| 12 | export type StudioLibraryNote = { | 13 | export type StudioLibraryNote = { |
| 13 | id: string; | 14 | id: string; |
| @@ -29,6 +30,7 @@ export function StudioOutputLibrary(props: { | |||
| 29 | onSelect: (noteId: string) => void; | 30 | onSelect: (noteId: string) => void; |
| 30 | }) { | 31 | }) { |
| 31 | const t = useT(); | 32 | const t = useT(); |
| 33 | + const { locale } = usePreferences(); | ||
| 32 | const source = createMemo(() => props.notes.map((note) => note.id).join(",")); | 34 | const source = createMemo(() => props.notes.map((note) => note.id).join(",")); |
| 33 | const [items] = createResource(source, async (): Promise<StudioLibraryItem[]> => { | 35 | const [items] = createResource(source, async (): Promise<StudioLibraryItem[]> => { |
| 34 | const [podcastResult, ...summaryResults] = await Promise.allSettled([ | 36 | const [podcastResult, ...summaryResults] = await Promise.allSettled([ |
| @@ -66,17 +68,15 @@ export function StudioOutputLibrary(props: { | |||
| 66 | 68 | ||
| 67 | return ( | 69 | return ( |
| 68 | <section class="overflow-hidden rounded-xl border border-border-line bg-surface-base"> | 70 | <section class="overflow-hidden rounded-xl border border-border-line bg-surface-base"> |
| 69 | - <header class="flex flex-wrap items-start justify-between gap-3 border-b border-border-hairline px-4 py-4 sm:px-5"> | 71 | + <header class="flex flex-wrap items-baseline justify-between gap-3 border-b border-border-hairline px-4 py-3"> |
| 70 | - <div class="flex min-w-0 items-start gap-3"> | 72 | + <div class="min-w-0"> |
| 71 | - <div class="min-w-0"> | 73 | + <h2 class="text-sm font-semibold text-text-strong">{t("aiStudio.library.title")}</h2> |
| 72 | - <h2 class="text-sm font-semibold text-text-strong">{t("aiStudio.library.title")}</h2> | 74 | + <p class="mt-0.5 text-xs text-muted-foreground">{t("aiStudio.library.description")}</p> |
| 73 | - <p class="mt-0.5 text-xs text-muted-foreground">{t("aiStudio.library.description")}</p> | ||
| 74 | - </div> | ||
| 75 | </div> | 75 | </div> |
| 76 | <Show when={(items()?.length ?? 0) > 0}> | 76 | <Show when={(items()?.length ?? 0) > 0}> |
| 77 | - <Badge variant="secondary" class="rounded-md"> | 77 | + <span class="shrink-0 text-xs tabular-nums text-muted-foreground"> |
| 78 | {t("aiStudio.library.count", { count: items()?.length ?? 0 })} | 78 | {t("aiStudio.library.count", { count: items()?.length ?? 0 })} |
| 79 | - </Badge> | 79 | + </span> |
| 80 | </Show> | 80 | </Show> |
| 81 | </header> | 81 | </header> |
| 82 | 82 | ||
| @@ -89,7 +89,10 @@ export function StudioOutputLibrary(props: { | |||
| 89 | </div> | 89 | </div> |
| 90 | } | 90 | } |
| 91 | > | 91 | > |
| 92 | - <ul class="grid gap-3 p-3 sm:grid-cols-2 sm:p-4 xl:grid-cols-3"> | 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. */} | ||
| 95 | + <ul class="divide-y divide-border-hairline"> | ||
| 93 | <For each={items()}> | 96 | <For each={items()}> |
| 94 | {(item) => ( | 97 | {(item) => ( |
| 95 | <li> | 98 | <li> |
| @@ -97,24 +100,23 @@ export function StudioOutputLibrary(props: { | |||
| 97 | type="button" | 100 | type="button" |
| 98 | aria-current={props.selectedId === item.id ? "true" : undefined} | 101 | aria-current={props.selectedId === item.id ? "true" : undefined} |
| 99 | class={cn( | 102 | class={cn( |
| 100 | - "group flex h-full w-full flex-col rounded-xl border bg-background p-4 text-left outline-hidden transition-colors hover:border-primary/35 hover:bg-surface-tint focus-visible:ring-2 focus-visible:ring-ring", | 103 | + "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", |
| 101 | - props.selectedId === item.id ? "border-primary/40 bg-primary/[0.035]" : "border-border-hairline", | 104 | + props.selectedId === item.id |
| 105 | + ? "border-l-primary bg-primary/[0.04]" | ||
| 106 | + : "border-l-transparent", | ||
| 102 | )} | 107 | )} |
| 103 | onClick={() => props.onSelect(item.id)} | 108 | onClick={() => props.onSelect(item.id)} |
| 104 | > | 109 | > |
| 105 | - <div class="flex w-full items-start gap-3"> | 110 | + <span class="shrink-0 text-muted-foreground"> |
| 106 | - <span class="flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary-text"> | 111 | + <Show when={item.podcastCount > 0} fallback={<IconNote class="h-4 w-4" />}> |
| 107 | - <Show when={item.podcastCount > 0} fallback={<IconNote class="h-4 w-4" />}> | 112 | + <IconWaveform class="h-4 w-4" /> |
| 108 | - <IconWaveform class="h-4 w-4" /> | 113 | + </Show> |
| 109 | - </Show> | 114 | + </span> |
| 110 | - </span> | 115 | + <span class="min-w-0 flex-1"> |
| 111 | - <div class="min-w-0 flex-1"> | 116 | + <span class="block truncate text-sm font-medium text-text-strong">{item.title}</span> |
| 112 | - <p class="truncate text-sm font-semibold text-text-strong">{item.title}</p> | 117 | + <span class="mt-0.5 block truncate text-xs text-muted-foreground">{item.courseTitle}</span> |
| 113 | - <p class="mt-0.5 truncate text-xs text-muted-foreground">{item.courseTitle}</p> | 118 | + </span> |
| 114 | - </div> | 119 | + <span class="hidden shrink-0 items-center gap-1.5 sm:flex"> |
| 115 | - </div> | ||
| 116 | - | ||
| 117 | - <div class="mt-4 flex flex-wrap gap-1.5"> | ||
| 118 | <Show when={item.hasSummary}> | 120 | <Show when={item.hasSummary}> |
| 119 | <Badge variant="outline" class="gap-1 rounded-md font-normal"> | 121 | <Badge variant="outline" class="gap-1 rounded-md font-normal"> |
| 120 | <IconSparkles class="h-3 w-3" /> | 122 | <IconSparkles class="h-3 w-3" /> |
| @@ -127,11 +129,9 @@ export function StudioOutputLibrary(props: { | |||
| 127 | {t("aiStudio.library.podcastCount", { count: item.podcastCount })} | 129 | {t("aiStudio.library.podcastCount", { count: item.podcastCount })} |
| 128 | </Badge> | 130 | </Badge> |
| 129 | </Show> | 131 | </Show> |
| 130 | - </div> | 132 | + </span> |
| 131 | - | 133 | + <span class="shrink-0 text-xs tabular-nums text-muted-foreground"> |
| 132 | - <span class="mt-4 inline-flex items-center gap-1 text-xs font-medium text-primary-text"> | 134 | + {formatDate(item.latestAt, locale())} |
| 133 | - {t("aiStudio.library.open")} | ||
| 134 | - <IconChevronRight class="h-3.5 w-3.5 transition-transform group-hover:translate-x-0.5" /> | ||
| 135 | </span> | 135 | </span> |
| 136 | </button> | 136 | </button> |
| 137 | </li> | 137 | </li> |
src/components/insights/insight-module-views.tsxmodified+33 -18
| @@ -1,5 +1,6 @@ | |||
| 1 | import { For, Show, createSignal, type JSX } from "solid-js"; | 1 | import { For, Show, createSignal, type JSX } from "solid-js"; |
| 2 | import { Badge } from "@/components/ui/badge"; | 2 | import { Badge } from "@/components/ui/badge"; |
| 3 | +import { ChartComparatorBar } from "@/components/ui/chart-comparator-bar"; | ||
| 3 | import { detailText, dimensionLabel, type InsightDetailKey } from "@/i18n/insights-detail"; | 4 | import { detailText, dimensionLabel, type InsightDetailKey } from "@/i18n/insights-detail"; |
| 4 | import type { Locale } from "@/i18n/messages"; | 5 | import type { Locale } from "@/i18n/messages"; |
| 5 | import { cn } from "@/lib/cn"; | 6 | import { cn } from "@/lib/cn"; |
| @@ -168,11 +169,24 @@ function AttendanceView(props: { value: Rec; courseTitle: CourseTitle }) { | |||
| 168 | <p class="text-xs font-semibold text-text-strong"> | 169 | <p class="text-xs font-semibold text-text-strong"> |
| 169 | {courseLabel(id, props.courseTitle, index())} | 170 | {courseLabel(id, props.courseTitle, index())} |
| 170 | </p> | 171 | </p> |
| 172 | + {/* The rate, its cohort baseline and the gap between them are | ||
| 173 | + one claim, so they read as one device instead of three rows | ||
| 174 | + the reader has to hold in their head at once. */} | ||
| 175 | + <Show | ||
| 176 | + when={num(stat().rate) !== null} | ||
| 177 | + fallback={<NoteLine>{detailText("attendance.rateSuppressed")}</NoteLine>} | ||
| 178 | + > | ||
| 179 | + <ChartComparatorBar | ||
| 180 | + label={detailText("attendance.rate")} | ||
| 181 | + fraction={num(stat().rate)!} | ||
| 182 | + valueText={pct(stat().rate)!} | ||
| 183 | + comparatorFraction={num(stat().cohort_median)} | ||
| 184 | + comparatorLabel={detailText("attendance.cohortMedian")} | ||
| 185 | + comparatorText={pct(stat().cohort_median)} | ||
| 186 | + gapText={ratePoints(stat().relative_gap)} | ||
| 187 | + /> | ||
| 188 | + </Show> | ||
| 171 | <dl class="space-y-1"> | 189 | <dl class="space-y-1"> |
| 172 | - <LabeledRow label={detailText("attendance.rate")} value={pct(stat().rate)} mono /> | ||
| 173 | - <Show when={num(stat().rate) === null}> | ||
| 174 | - <NoteLine>{detailText("attendance.rateSuppressed")}</NoteLine> | ||
| 175 | - </Show> | ||
| 176 | <LabeledRow | 190 | <LabeledRow |
| 177 | label={detailText("attendance.present")} | 191 | label={detailText("attendance.present")} |
| 178 | value={String(num(stat().present) ?? 0)} | 192 | value={String(num(stat().present) ?? 0)} |
| @@ -189,21 +203,11 @@ function AttendanceView(props: { value: Rec; courseTitle: CourseTitle }) { | |||
| 189 | mono | 203 | mono |
| 190 | /> | 204 | /> |
| 191 | <LabeledRow label={detailText("attendance.excused")} value={String(num(stat().excused) ?? 0)} mono /> | 205 | <LabeledRow label={detailText("attendance.excused")} value={String(num(stat().excused) ?? 0)} mono /> |
| 192 | - <LabeledRow | ||
| 193 | - label={detailText("attendance.cohortMedian")} | ||
| 194 | - value={pct(stat().cohort_median)} | ||
| 195 | - mono | ||
| 196 | - /> | ||
| 197 | <LabeledRow | 206 | <LabeledRow |
| 198 | label={detailText("attendance.cohortN")} | 207 | label={detailText("attendance.cohortN")} |
| 199 | value={String(num(stat().cohort_n) ?? 0)} | 208 | value={String(num(stat().cohort_n) ?? 0)} |
| 200 | mono | 209 | mono |
| 201 | /> | 210 | /> |
| 202 | - <LabeledRow | ||
| 203 | - label={detailText("attendance.relativeGap")} | ||
| 204 | - value={ratePoints(stat().relative_gap)} | ||
| 205 | - mono | ||
| 206 | - /> | ||
| 207 | </dl> | 211 | </dl> |
| 208 | </div> | 212 | </div> |
| 209 | ); | 213 | ); |
| @@ -296,13 +300,24 @@ function MarksCourseDetail(props: { id: string; statRaw: unknown; courseTitle: C | |||
| 296 | </div> | 300 | </div> |
| 297 | </Show> | 301 | </Show> |
| 298 | <Show when={placed()}> | 302 | <Show when={placed()}> |
| 299 | - <LabeledRow label={detailText("marks.classAverage")} value={nText(placement().class_average)} mono /> | 303 | + {/* The service's own sentence is the claim; the numbers below are what |
| 300 | - <LabeledRow label={detailText("marks.classSd")} value={nText(placement().class_sd)} mono /> | 304 | + backs it, so the sentence leads rather than trailing the dump. */} |
| 301 | - <LabeledRow label={detailText("marks.cohortN")} value={String(num(placement().cohort_n) ?? 0)} mono /> | ||
| 302 | - <LabeledRow label={detailText("marks.z")} value={zText(placement().z)} mono /> | ||
| 303 | <Show when={str(placement().reason)}> | 305 | <Show when={str(placement().reason)}> |
| 304 | {(reason) => <NoteLine>{reason()}</NoteLine>} | 306 | {(reason) => <NoteLine>{reason()}</NoteLine>} |
| 305 | </Show> | 307 | </Show> |
| 308 | + <Show when={num(stat().average) !== null}> | ||
| 309 | + <ChartComparatorBar | ||
| 310 | + label={detailText("marks.average")} | ||
| 311 | + fraction={num(stat().average)! / 100} | ||
| 312 | + valueText={nText(stat().average)!} | ||
| 313 | + comparatorFraction={num(placement().class_average) == null ? null : num(placement().class_average)! / 100} | ||
| 314 | + comparatorLabel={detailText("marks.classAverage")} | ||
| 315 | + comparatorText={nText(placement().class_average)} | ||
| 316 | + /> | ||
| 317 | + </Show> | ||
| 318 | + <LabeledRow label={detailText("marks.classSd")} value={nText(placement().class_sd)} mono /> | ||
| 319 | + <LabeledRow label={detailText("marks.cohortN")} value={String(num(placement().cohort_n) ?? 0)} mono /> | ||
| 320 | + <LabeledRow label={detailText("marks.z")} value={zText(placement().z)} mono /> | ||
| 306 | </Show> | 321 | </Show> |
| 307 | </dl> | 322 | </dl> |
| 308 | 323 | ||
src/components/insights/insight-student-analysis-tabs.tsxmodified+13 -19
| @@ -5,7 +5,7 @@ import { InsightModuleView } from "@/components/insights/insight-module-views"; | |||
| 5 | import { ChartBar, type ChartBarItem } from "@/components/ui/chart-bar"; | 5 | import { ChartBar, type ChartBarItem } from "@/components/ui/chart-bar"; |
| 6 | import { ChartProgressRing, type ProgressRingSegment } from "@/components/ui/chart-progress-ring"; | 6 | import { ChartProgressRing, type ProgressRingSegment } from "@/components/ui/chart-progress-ring"; |
| 7 | import { EmptyInline } from "@/components/ui/empty-inline"; | 7 | import { EmptyInline } from "@/components/ui/empty-inline"; |
| 8 | -import { IconAlert, IconChart, IconChevronDown } from "@/components/ui/icons"; | 8 | +import { IconAlert, IconChevronDown } from "@/components/ui/icons"; |
| 9 | import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; | 9 | import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; |
| 10 | import { isRecord, type UnknownRecord } from "@/lib/is-record"; | 10 | import { isRecord, type UnknownRecord } from "@/lib/is-record"; |
| 11 | import { usePreferences } from "@/stores/preferences-context"; | 11 | import { usePreferences } from "@/stores/preferences-context"; |
| @@ -153,26 +153,20 @@ function ModuleTab(props: { | |||
| 153 | <Show when={props.value != null} fallback={<EmptyInline title={props.t("insights.sectionNotComputed")} illustration="charts" />}> | 153 | <Show when={props.value != null} fallback={<EmptyInline title={props.t("insights.sectionNotComputed")} illustration="charts" />}> |
| 154 | <div class="space-y-3"> | 154 | <div class="space-y-3"> |
| 155 | {chart()} | 155 | {chart()} |
| 156 | - <details class="group overflow-hidden rounded-xl border border-primary/20 bg-gradient-to-br from-primary/10 via-surface-base to-info/5 shadow-xs"> | 156 | + {/* The evidence behind the chart above. A native disclosure — keyboard |
| 157 | - <summary class="flex cursor-pointer list-none items-center justify-between gap-4 p-4 sm:p-5 [&::-webkit-details-marker]:hidden"> | 157 | + operable and state-exposing for free — kept deliberately quiet: the |
| 158 | - <span class="flex min-w-0 items-center gap-3"> | 158 | + numbers inside are the subject, so the frame does not compete with |
| 159 | - <span class="flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border border-primary/20 bg-primary/10 text-primary-text shadow-xs"> | 159 | + them. The chevron leads, which is where a reader looks for one. */} |
| 160 | - <IconChart class="h-5 w-5" /> | 160 | + <details class="group rounded-xl border border-border-line bg-surface-base"> |
| 161 | - </span> | 161 | + <summary class="flex cursor-pointer list-none items-center gap-3 rounded-xl px-4 py-3 transition-colors hover:bg-surface-overlay/50 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-details-marker]:hidden"> |
| 162 | - <span class="min-w-0"> | 162 | + <IconChevronDown class="h-4 w-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180" /> |
| 163 | - <span class="block text-sm font-semibold text-text-strong">{props.t("insights.analysis.details")}</span> | 163 | + <span class="min-w-0 flex-1"> |
| 164 | - <span class="mt-0.5 block text-xs leading-5 text-muted-foreground">{props.t("insights.analysis.detailsHint")}</span> | 164 | + <span class="block text-sm font-medium text-text-strong">{props.t("insights.analysis.details")}</span> |
| 165 | - </span> | 165 | + <span class="mt-0.5 block text-xs leading-5 text-muted-foreground">{props.t("insights.analysis.detailsHint")}</span> |
| 166 | - </span> | ||
| 167 | - <span class="flex shrink-0 items-center gap-2 rounded-lg border border-border-line bg-surface-base px-3 py-2 text-xs font-medium text-text-strong shadow-xs transition-colors group-hover:border-primary/30 group-hover:text-primary-text"> | ||
| 168 | - <span class="hidden sm:inline">{props.t("insights.analysis.detailsAction")}</span> | ||
| 169 | - <IconChevronDown class="h-4 w-4 text-muted-foreground transition-transform group-open:rotate-180" /> | ||
| 170 | </span> | 166 | </span> |
| 171 | </summary> | 167 | </summary> |
| 172 | - <div class="border-t border-primary/15 bg-surface-base/90 p-4 sm:p-5"> | 168 | + <div class="border-t border-border-hairline px-4 py-4"> |
| 173 | - <div class="rounded-xl border border-border-hairline bg-surface-overlay/40 p-3 sm:p-4"> | 169 | + <InsightModuleView module={props.module} value={props.value} courseTitle={props.courseTitle} /> |
| 174 | - <InsightModuleView module={props.module} value={props.value} courseTitle={props.courseTitle} /> | ||
| 175 | - </div> | ||
| 176 | </div> | 170 | </div> |
| 177 | </details> | 171 | </details> |
| 178 | </div> | 172 | </div> |
src/components/layout/nav-items.tsmodified+2 -2
| @@ -182,7 +182,7 @@ const ADMIN_GROUPS: NavGroup[] = [ | |||
| 182 | labelKey: "nav.group.tracking", | 182 | labelKey: "nav.group.tracking", |
| 183 | Icon: IconClipboardCheck, | 183 | Icon: IconClipboardCheck, |
| 184 | items: [ | 184 | items: [ |
| 185 | - { id: "student-attendance", to: "/management/student-attendance", labelKey: "nav.attendance", Icon: IconClipboardCheck, minRole: "teacher", module: "attendance" }, | 185 | + { id: "student-attendance", to: "/management/student-attendance", labelKey: "nav.studentAttendance", Icon: IconClipboardCheck, minRole: "teacher", module: "attendance" }, |
| 186 | { id: "student-marks", to: "/management/student-marks", labelKey: "nav.studentMarks", Icon: IconChart, minRole: "teacher", module: "marks" }, | 186 | { id: "student-marks", to: "/management/student-marks", labelKey: "nav.studentMarks", Icon: IconChart, minRole: "teacher", module: "marks" }, |
| 187 | { id: "student-pomodoros", to: "/management/pomodoros", labelKey: "nav.studentPomodoro", Icon: IconTimer, minRole: "teacher", module: "pomodoro" }, | 187 | { id: "student-pomodoros", to: "/management/pomodoros", labelKey: "nav.studentPomodoro", Icon: IconTimer, minRole: "teacher", module: "pomodoro" }, |
| 188 | ], | 188 | ], |
| @@ -235,7 +235,7 @@ const TEACHER_GROUPS: NavGroup[] = [ | |||
| 235 | labelKey: "nav.group.tracking", | 235 | labelKey: "nav.group.tracking", |
| 236 | Icon: IconClipboardCheck, | 236 | Icon: IconClipboardCheck, |
| 237 | items: [ | 237 | items: [ |
| 238 | - { id: "student-attendance", to: "/management/student-attendance", labelKey: "nav.attendance", Icon: IconClipboardCheck, module: "attendance" }, | 238 | + { id: "student-attendance", to: "/management/student-attendance", labelKey: "nav.studentAttendance", Icon: IconClipboardCheck, module: "attendance" }, |
| 239 | { id: "student-marks", to: "/management/student-marks", labelKey: "nav.studentMarks", Icon: IconChart, module: "marks" }, | 239 | { id: "student-marks", to: "/management/student-marks", labelKey: "nav.studentMarks", Icon: IconChart, module: "marks" }, |
| 240 | { id: "student-pomodoros", to: "/management/pomodoros", labelKey: "nav.studentPomodoro", Icon: IconTimer, module: "pomodoro" }, | 240 | { id: "student-pomodoros", to: "/management/pomodoros", labelKey: "nav.studentPomodoro", Icon: IconTimer, module: "pomodoro" }, |
| 241 | { id: "student-analysis", to: "/ai/insights", labelKey: "nav.studentAnalysis", Icon: IconChart }, | 241 | { id: "student-analysis", to: "/ai/insights", labelKey: "nav.studentAnalysis", Icon: IconChart }, |
src/components/notes/podcast-history.test.tsxmodified+25 -0
| @@ -181,4 +181,29 @@ describe("PodcastHistory", () => { | |||
| 181 | expect(podcastApi.listPodcastJobs).toHaveBeenLastCalledWith({ limit: 10, offset: 10, sourceId: "note-1" }); | 181 | expect(podcastApi.listPodcastJobs).toHaveBeenLastCalledWith({ limit: 10, offset: 10, sourceId: "note-1" }); |
| 182 | expect(screen.getByText("2 / 2")).toBeTruthy(); | 182 | expect(screen.getByText("2 / 2")).toBeTruthy(); |
| 183 | }); | 183 | }); |
| 184 | + | ||
| 185 | + it("marks each episode with the narration the service settled on", async () => { | ||
| 186 | + podcastApi.listPodcastJobs.mockResolvedValue( | ||
| 187 | + page([ | ||
| 188 | + job({ job_id: "job-1", source_title: "Düz", format: "duz_okuma" }), | ||
| 189 | + job({ job_id: "job-2", source_title: "İkili", format: "ogrenci_hoca" }), | ||
| 190 | + ]), | ||
| 191 | + ); | ||
| 192 | + | ||
| 193 | + renderHistory("note-1"); | ||
| 194 | + | ||
| 195 | + await waitFor(() => expect(screen.getByText("Düz okuma")).toBeTruthy()); | ||
| 196 | + expect(screen.getByText("Öğrenci ve öğretmen")).toBeTruthy(); | ||
| 197 | + }); | ||
| 198 | + | ||
| 199 | + it("leaves a job the service has not settled a format for unmarked", async () => { | ||
| 200 | + podcastApi.listPodcastJobs.mockResolvedValue( | ||
| 201 | + page([job({ state: "queued", format: null, duration_secs: null, finished_at: null })]), | ||
| 202 | + ); | ||
| 203 | + | ||
| 204 | + renderHistory("note-1"); | ||
| 205 | + | ||
| 206 | + await waitFor(() => expect(screen.getByText("Hücre")).toBeTruthy()); | ||
| 207 | + expect(screen.queryByText("Düz okuma")).toBeNull(); | ||
| 208 | + }); | ||
| 184 | }); | 209 | }); |
src/components/notes/podcast-history.tsxmodified+29 -6
| @@ -1,6 +1,7 @@ | |||
| 1 | import { For, Show, Suspense, createEffect, createMemo, createSignal } from "solid-js"; | 1 | import { For, Show, Suspense, createEffect, createMemo, createSignal } from "solid-js"; |
| 2 | import { createResource } from "@/lib/create-resource"; | 2 | import { createResource } from "@/lib/create-resource"; |
| 3 | import { formatApiError } from "@/api/client"; | 3 | import { formatApiError } from "@/api/client"; |
| 4 | +import type { MessageKey } from "@/i18n/messages"; | ||
| 4 | import { listPodcastJobs, podcastAudioUrl } from "@/api/podcast"; | 5 | import { listPodcastJobs, podcastAudioUrl } from "@/api/podcast"; |
| 5 | import { Alert } from "@/components/ui/alert"; | 6 | import { Alert } from "@/components/ui/alert"; |
| 6 | import { Badge } from "@/components/ui/badge"; | 7 | import { Badge } from "@/components/ui/badge"; |
| @@ -16,6 +17,15 @@ import { usePreferences, useT } from "@/stores/preferences-context"; | |||
| 16 | 17 | ||
| 17 | const HISTORY_PAGE_SIZE = 10; | 18 | const HISTORY_PAGE_SIZE = 10; |
| 18 | 19 | ||
| 20 | +// The three narrations the service produces. It settles the format on its first | ||
| 21 | +// report, so a live job often carries none yet, and a format this build has no | ||
| 22 | +// label for is shown verbatim rather than dropped. | ||
| 23 | +const FORMAT_KEYS: Record<string, MessageKey> = { | ||
| 24 | + duz_okuma: "podcast.format.duz_okuma", | ||
| 25 | + tek_ogretici: "podcast.format.tek_ogretici", | ||
| 26 | + ogrenci_hoca: "podcast.format.ogrenci_hoca", | ||
| 27 | +}; | ||
| 28 | + | ||
| 19 | /** | 29 | /** |
| 20 | * The caller's own episodes, under the Ses Atölyesi panel. One-directional: | 30 | * The caller's own episodes, under the Ses Atölyesi panel. One-directional: |
| 21 | * the studio produces, this only reads. A finished episode plays through the | 31 | * the studio produces, this only reads. A finished episode plays through the |
| @@ -66,6 +76,11 @@ export function PodcastHistory(props: { noteId?: string; active?: boolean; refet | |||
| 66 | if (state === "cancelled") return "secondary" as const; | 76 | if (state === "cancelled") return "secondary" as const; |
| 67 | return "warning" as const; | 77 | return "warning" as const; |
| 68 | }; | 78 | }; |
| 79 | + const formatLabel = (format: string | null) => { | ||
| 80 | + if (!format) return ""; | ||
| 81 | + const key = FORMAT_KEYS[format]; | ||
| 82 | + return key ? t(key) : format; | ||
| 83 | + }; | ||
| 69 | const stateLabel = (state: string) => { | 84 | const stateLabel = (state: string) => { |
| 70 | if (state === "done") return t("podcast.history.state.done"); | 85 | if (state === "done") return t("podcast.history.state.done"); |
| 71 | if (state === "failed") return t("podcast.history.state.failed"); | 86 | if (state === "failed") return t("podcast.history.state.failed"); |
| @@ -101,11 +116,15 @@ export function PodcastHistory(props: { noteId?: string; active?: boolean; refet | |||
| 101 | <ul class="space-y-2"> | 116 | <ul class="space-y-2"> |
| 102 | <For each={jobs()}> | 117 | <For each={jobs()}> |
| 103 | {(row) => ( | 118 | {(row) => ( |
| 104 | - <li class="flex items-center gap-3 rounded-lg border border-border/60 p-3"> | 119 | + <li class="rounded-lg border border-border/60 p-3"> |
| 120 | + <div class="flex items-center gap-3"> | ||
| 105 | <div class="min-w-0 flex-1"> | 121 | <div class="min-w-0 flex-1"> |
| 106 | <p class="truncate text-sm font-medium">{row.source_title ?? row.source_id}</p> | 122 | <p class="truncate text-sm font-medium">{row.source_title ?? row.source_id}</p> |
| 107 | <div class="mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground"> | 123 | <div class="mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground"> |
| 108 | <Badge variant={stateVariant(row.state)}>{stateLabel(row.state)}</Badge> | 124 | <Badge variant={stateVariant(row.state)}>{stateLabel(row.state)}</Badge> |
| 125 | + <Show when={formatLabel(row.format)}> | ||
| 126 | + {(label) => <Badge variant="outline">{label()}</Badge>} | ||
| 127 | + </Show> | ||
| 109 | <Show when={row.state === "failed" && row.error_code}> | 128 | <Show when={row.state === "failed" && row.error_code}> |
| 110 | <span class="mono">{row.error_code}</span> | 129 | <span class="mono">{row.error_code}</span> |
| 111 | </Show> | 130 | </Show> |
| @@ -141,6 +160,15 @@ export function PodcastHistory(props: { noteId?: string; active?: boolean; refet | |||
| 141 | </a> | 160 | </a> |
| 142 | </div> | 161 | </div> |
| 143 | </Show> | 162 | </Show> |
| 163 | + </div> | ||
| 164 | + {/* The player opens in the row the reader clicked. A single | ||
| 165 | + one under the whole list put it a screen away from the | ||
| 166 | + episode it belonged to. */} | ||
| 167 | + <Show when={playing() === row.job_id}> | ||
| 168 | + <audio class="mt-3 w-full" controls autoplay preload="metadata" src={podcastAudioUrl(row.job_id)}> | ||
| 169 | + {t("podcast.audioUnsupported")} | ||
| 170 | + </audio> | ||
| 171 | + </Show> | ||
| 144 | </li> | 172 | </li> |
| 145 | )} | 173 | )} |
| 146 | </For> | 174 | </For> |
| @@ -152,11 +180,6 @@ export function PodcastHistory(props: { noteId?: string; active?: boolean; refet | |||
| 152 | </Suspense> | 180 | </Suspense> |
| 153 | </Show> | 181 | </Show> |
| 154 | 182 | ||
| 155 | - <Show when={playing()}> | ||
| 156 | - <audio class="w-full" controls autoplay preload="metadata" src={podcastAudioUrl(playing())}> | ||
| 157 | - {t("podcast.audioUnsupported")} | ||
| 158 | - </audio> | ||
| 159 | - </Show> | ||
| 160 | </div> | 183 | </div> |
| 161 | ); | 184 | ); |
| 162 | } | 185 | } |
src/components/notes/podcast-panel.tsxmodified+34 -13
| @@ -17,6 +17,7 @@ import { Select } from "@/components/ui/select"; | |||
| 17 | import { PodcastHistory } from "@/components/notes/podcast-history"; | 17 | import { PodcastHistory } from "@/components/notes/podcast-history"; |
| 18 | import { podcastDownloadFilename, usePodcastDownloadT } from "@/components/notes/podcast-download"; | 18 | import { podcastDownloadFilename, usePodcastDownloadT } from "@/components/notes/podcast-download"; |
| 19 | import { cn } from "@/lib/cn"; | 19 | import { cn } from "@/lib/cn"; |
| 20 | +import { createLivePoll } from "@/lib/create-live-poll"; | ||
| 20 | import { useT } from "@/stores/preferences-context"; | 21 | import { useT } from "@/stores/preferences-context"; |
| 21 | 22 | ||
| 22 | const POLL_MS = 2_000; | 23 | const POLL_MS = 2_000; |
| @@ -31,7 +32,10 @@ export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitl | |||
| 31 | const [error, setError] = createSignal(""); | 32 | const [error, setError] = createSignal(""); |
| 32 | const [submitting, setSubmitting] = createSignal(false); | 33 | const [submitting, setSubmitting] = createSignal(false); |
| 33 | const [cancelling, setCancelling] = createSignal(false); | 34 | const [cancelling, setCancelling] = createSignal(false); |
| 34 | - let timer: ReturnType<typeof setTimeout> | undefined; | 35 | + // The service's own estimate, taken from the submit receipt. It is never |
| 36 | + // restated by the status door, so it is shown as the one estimate it is and | ||
| 37 | + // never recomputed into a countdown the backend did not promise. | ||
| 38 | + const [etaSecs, setEtaSecs] = createSignal<number | null>(null); | ||
| 35 | let generation = 0; | 39 | let generation = 0; |
| 36 | 40 | ||
| 37 | // Declared before the resource below: its source runs during setup, so a | 41 | // Declared before the resource below: its source runs during setup, so a |
| @@ -39,9 +43,10 @@ export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitl | |||
| 39 | const active = () => props.active !== false; | 43 | const active = () => props.active !== false; |
| 40 | const [capabilities] = createResource(() => (active() ? getAiCapabilities() : null)); | 44 | const [capabilities] = createResource(() => (active() ? getAiCapabilities() : null)); |
| 41 | const storageKey = () => `hezarfen.podcast.${props.noteId}`; | 45 | const storageKey = () => `hezarfen.podcast.${props.noteId}`; |
| 46 | + // A cancelled or finished job is simply not polled again; the ticker below | ||
| 47 | + // asks whether there is live work rather than being torn down. | ||
| 42 | const stopPolling = () => { | 48 | const stopPolling = () => { |
| 43 | - if (timer) clearTimeout(timer); | 49 | + generation += 1; |
| 44 | - timer = undefined; | ||
| 45 | }; | 50 | }; |
| 46 | 51 | ||
| 47 | const poll = async (id: string, token: number) => { | 52 | const poll = async (id: string, token: number) => { |
| @@ -56,10 +61,7 @@ export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitl | |||
| 56 | } | 61 | } |
| 57 | if (next.state === "failed") { | 62 | if (next.state === "failed") { |
| 58 | setError(t("podcast.failed")); | 63 | setError(t("podcast.failed")); |
| 59 | - return; | ||
| 60 | } | 64 | } |
| 61 | - if (next.state === "cancelled") return; | ||
| 62 | - timer = setTimeout(() => void poll(id, token), POLL_MS); | ||
| 63 | } catch (err) { | 65 | } catch (err) { |
| 64 | if (token === generation) setError(formatApiError(err)); | 66 | if (token === generation) setError(formatApiError(err)); |
| 65 | } | 67 | } |
| @@ -70,10 +72,10 @@ export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitl | |||
| 70 | const enabled = active(); | 72 | const enabled = active(); |
| 71 | generation += 1; | 73 | generation += 1; |
| 72 | const token = generation; | 74 | const token = generation; |
| 73 | - stopPolling(); | ||
| 74 | setJobId(""); | 75 | setJobId(""); |
| 75 | setStatus(null); | 76 | setStatus(null); |
| 76 | setArtifacts(null); | 77 | setArtifacts(null); |
| 78 | + setEtaSecs(null); | ||
| 77 | setError(""); | 79 | setError(""); |
| 78 | if (!enabled || !noteId || typeof sessionStorage === "undefined") return; | 80 | if (!enabled || !noteId || typeof sessionStorage === "undefined") return; |
| 79 | const stored = sessionStorage.getItem(storageKey()); | 81 | const stored = sessionStorage.getItem(storageKey()); |
| @@ -85,14 +87,12 @@ export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitl | |||
| 85 | 87 | ||
| 86 | onCleanup(() => { | 88 | onCleanup(() => { |
| 87 | generation += 1; | 89 | generation += 1; |
| 88 | - stopPolling(); | ||
| 89 | }); | 90 | }); |
| 90 | 91 | ||
| 91 | const submit = async () => { | 92 | const submit = async () => { |
| 92 | if (submitting()) return; | 93 | if (submitting()) return; |
| 93 | generation += 1; | 94 | generation += 1; |
| 94 | const token = generation; | 95 | const token = generation; |
| 95 | - stopPolling(); | ||
| 96 | setSubmitting(true); | 96 | setSubmitting(true); |
| 97 | setError(""); | 97 | setError(""); |
| 98 | setArtifacts(null); | 98 | setArtifacts(null); |
| @@ -101,8 +101,8 @@ export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitl | |||
| 101 | if (token !== generation) return; | 101 | if (token !== generation) return; |
| 102 | setJobId(receipt.job_id); | 102 | setJobId(receipt.job_id); |
| 103 | setStatus({ job_id: receipt.job_id, state: receipt.state, stage: "queued", progress: 0 }); | 103 | setStatus({ job_id: receipt.job_id, state: receipt.state, stage: "queued", progress: 0 }); |
| 104 | + setEtaSecs(receipt.eta_secs); | ||
| 104 | if (typeof sessionStorage !== "undefined") sessionStorage.setItem(storageKey(), receipt.job_id); | 105 | if (typeof sessionStorage !== "undefined") sessionStorage.setItem(storageKey(), receipt.job_id); |
| 105 | - timer = setTimeout(() => void poll(receipt.job_id, token), POLL_MS); | ||
| 106 | } catch (err) { | 106 | } catch (err) { |
| 107 | setError(formatApiError(err)); | 107 | setError(formatApiError(err)); |
| 108 | } finally { | 108 | } finally { |
| @@ -117,7 +117,6 @@ export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitl | |||
| 117 | setError(""); | 117 | setError(""); |
| 118 | try { | 118 | try { |
| 119 | await postPodcastJobCancel(id); | 119 | await postPodcastJobCancel(id); |
| 120 | - generation += 1; | ||
| 121 | stopPolling(); | 120 | stopPolling(); |
| 122 | setStatus((current) => current ? { ...current, state: "cancelled" } : current); | 121 | setStatus((current) => current ? { ...current, state: "cancelled" } : current); |
| 123 | if (typeof sessionStorage !== "undefined") sessionStorage.removeItem(storageKey()); | 122 | if (typeof sessionStorage !== "undefined") sessionStorage.removeItem(storageKey()); |
| @@ -130,6 +129,13 @@ export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitl | |||
| 130 | 129 | ||
| 131 | const progress = () => Math.round(Math.min(1, Math.max(0, status()?.progress ?? 0)) * 100); | 130 | const progress = () => Math.round(Math.min(1, Math.max(0, status()?.progress ?? 0)) * 100); |
| 132 | const working = () => ["queued", "running"].includes(status()?.state ?? ""); | 131 | const working = () => ["queued", "running"].includes(status()?.state ?? ""); |
| 132 | + | ||
| 133 | + // Poll through the shared primitive so a parked tab stops asking and a | ||
| 134 | + // tab-back is fresh at once — the hand-rolled timeout chain did neither. | ||
| 135 | + createLivePoll(() => { | ||
| 136 | + const id = jobId(); | ||
| 137 | + if (id && working() && active()) void poll(id, generation); | ||
| 138 | + }, POLL_MS); | ||
| 133 | const available = () => { | 139 | const available = () => { |
| 134 | const current = capabilities(); | 140 | const current = capabilities(); |
| 135 | if (!current || capabilities.error) return true; | 141 | if (!current || capabilities.error) return true; |
| @@ -152,12 +158,12 @@ export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitl | |||
| 152 | return ( | 158 | return ( |
| 153 | <Suspense | 159 | <Suspense |
| 154 | fallback={ | 160 | fallback={ |
| 155 | - <section class="flex min-h-44 items-center justify-center rounded-xl border border-border-line bg-surface-base p-4 shadow-xs"> | 161 | + <section class="flex min-h-44 items-center justify-center rounded-xl border border-border-line bg-surface-base p-4"> |
| 156 | <p class="text-sm text-muted-foreground">{t("common.loading")}</p> | 162 | <p class="text-sm text-muted-foreground">{t("common.loading")}</p> |
| 157 | </section> | 163 | </section> |
| 158 | } | 164 | } |
| 159 | > | 165 | > |
| 160 | - <section class="space-y-4 rounded-xl border border-border-line bg-surface-base p-4 shadow-xs"> | 166 | + <section class="space-y-4 rounded-xl border border-border-line bg-surface-base p-4"> |
| 161 | <div class="flex items-start gap-3"> | 167 | <div class="flex items-start gap-3"> |
| 162 | <div class="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary-text"> | 168 | <div class="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary-text"> |
| 163 | <IconWaveform class="h-5 w-5" /> | 169 | <IconWaveform class="h-5 w-5" /> |
| @@ -204,6 +210,21 @@ export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitl | |||
| 204 | <div class="h-2 overflow-hidden rounded-full bg-muted" role="progressbar" aria-valuenow={progress()} aria-valuemin="0" aria-valuemax="100"> | 210 | <div class="h-2 overflow-hidden rounded-full bg-muted" role="progressbar" aria-valuenow={progress()} aria-valuemin="0" aria-valuemax="100"> |
| 205 | <div class="h-full rounded-full bg-primary transition-[width]" style={{ width: `${progress()}%` }} /> | 211 | <div class="h-full rounded-full bg-primary transition-[width]" style={{ width: `${progress()}%` }} /> |
| 206 | </div> | 212 | </div> |
| 213 | + {/* 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> | ||
| 207 | <Show when={working()}> | 228 | <Show when={working()}> |
| 208 | <Button type="button" size="sm" variant="outline" class="rounded-lg" disabled={cancelling()} onClick={() => void cancel()}> | 229 | <Button type="button" size="sm" variant="outline" class="rounded-lg" disabled={cancelling()} onClick={() => void cancel()}> |
| 209 | <IconX class="h-4 w-4" />{t("podcast.cancel")} | 230 | <IconX class="h-4 w-4" />{t("podcast.cancel")} |
src/components/notes/rag-outputs-panel.tsxmodified+1 -1
| @@ -199,7 +199,7 @@ export function RagOutputsPanel(props: { | |||
| 199 | }; | 199 | }; |
| 200 | 200 | ||
| 201 | return ( | 201 | return ( |
| 202 | - <section class="space-y-3 rounded-lg border border-border/80 bg-card p-4 shadow-xs dark:border-white/8"> | 202 | + <section class="space-y-3 rounded-xl border border-border-line bg-surface-base p-4"> |
| 203 | <div class="flex flex-wrap items-start justify-between gap-3"> | 203 | <div class="flex flex-wrap items-start justify-between gap-3"> |
| 204 | <div> | 204 | <div> |
| 205 | <h3 class="text-sm font-semibold">{t("courseNotes.ragTitle")}</h3> | 205 | <h3 class="text-sm font-semibold">{t("courseNotes.ragTitle")}</h3> |
src/components/rag/rag-composer.tsxmodified+15 -6
| @@ -1,7 +1,8 @@ | |||
| 1 | -import { createEffect } from "solid-js"; | 1 | +import { createEffect, onMount } from "solid-js"; |
| 2 | import { Button } from "@/components/ui/button"; | 2 | import { Button } from "@/components/ui/button"; |
| 3 | import { IconSend } from "@/components/ui/icons"; | 3 | import { IconSend } from "@/components/ui/icons"; |
| 4 | import { Textarea } from "@/components/ui/textarea"; | 4 | import { Textarea } from "@/components/ui/textarea"; |
| 5 | +import { cn } from "@/lib/cn"; | ||
| 5 | 6 | ||
| 6 | const MAX_HEIGHT_PX = 176; | 7 | const MAX_HEIGHT_PX = 176; |
| 7 | 8 | ||
| @@ -11,6 +12,10 @@ export function RagComposer(props: { | |||
| 11 | sendLabel: string; | 12 | sendLabel: string; |
| 12 | hint: string; | 13 | hint: string; |
| 13 | disabled: boolean; | 14 | disabled: boolean; |
| 15 | + /** Take the caret on mount — the landing screen is the composer, so it should | ||
| 16 | + * be ready to type into, and a send that re-places it returns focus. */ | ||
| 17 | + autofocus?: boolean; | ||
| 18 | + class?: string; | ||
| 14 | onInput: (value: string) => void; | 19 | onInput: (value: string) => void; |
| 15 | onSubmit: () => void; | 20 | onSubmit: () => void; |
| 16 | }) { | 21 | }) { |
| @@ -27,15 +32,19 @@ export function RagComposer(props: { | |||
| 27 | resize(); | 32 | resize(); |
| 28 | }); | 33 | }); |
| 29 | 34 | ||
| 35 | + onMount(() => { | ||
| 36 | + if (props.autofocus) field?.focus(); | ||
| 37 | + }); | ||
| 38 | + | ||
| 30 | return ( | 39 | return ( |
| 31 | <form | 40 | <form |
| 32 | - class="border-t border-border/70 bg-surface-base px-4 py-3 sm:px-6" | 41 | + class={cn("px-4 sm:px-6", props.class)} |
| 33 | onSubmit={(event) => { | 42 | onSubmit={(event) => { |
| 34 | event.preventDefault(); | 43 | event.preventDefault(); |
| 35 | if (!props.disabled) props.onSubmit(); | 44 | if (!props.disabled) props.onSubmit(); |
| 36 | }} | 45 | }} |
| 37 | > | 46 | > |
| 38 | - <div class="mx-auto flex w-full max-w-3xl items-end gap-2 rounded-xl border border-border bg-background px-3 py-2 transition-colors focus-within:border-primary/50 focus-within:ring-2 focus-within:ring-ring"> | 47 | + <div class="mx-auto flex w-full max-w-3xl items-end gap-2 rounded-2xl border border-border bg-surface-overlay px-3.5 py-2.5 transition-colors focus-within:border-primary/50 focus-within:ring-2 focus-within:ring-ring"> |
| 39 | <Textarea | 48 | <Textarea |
| 40 | ref={field} | 49 | ref={field} |
| 41 | rows={1} | 50 | rows={1} |
| @@ -43,7 +52,7 @@ export function RagComposer(props: { | |||
| 43 | value={props.value} | 52 | value={props.value} |
| 44 | disabled={props.disabled} | 53 | disabled={props.disabled} |
| 45 | placeholder={props.placeholder} | 54 | placeholder={props.placeholder} |
| 46 | - class="max-h-44 min-h-0 flex-1 resize-none overflow-y-auto border-0 bg-transparent px-0 py-1.5 shadow-none hover:border-0 hover:bg-transparent focus:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0" | 55 | + class="max-h-44 min-h-0 flex-1 resize-none overflow-y-auto border-0 bg-transparent px-0 py-1.5 text-base shadow-none hover:border-0 hover:bg-transparent focus:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0" |
| 47 | onInput={(event) => props.onInput(event.currentTarget.value)} | 56 | onInput={(event) => props.onInput(event.currentTarget.value)} |
| 48 | onKeyDown={(event) => { | 57 | onKeyDown={(event) => { |
| 49 | if (event.key === "Enter" && !event.shiftKey) { | 58 | if (event.key === "Enter" && !event.shiftKey) { |
| @@ -55,7 +64,7 @@ export function RagComposer(props: { | |||
| 55 | <Button | 64 | <Button |
| 56 | type="submit" | 65 | type="submit" |
| 57 | size="sm" | 66 | size="sm" |
| 58 | - class="h-8 w-8 shrink-0 rounded-full p-0" | 67 | + class="h-9 w-9 shrink-0 rounded-full p-0" |
| 59 | aria-label={props.sendLabel} | 68 | aria-label={props.sendLabel} |
| 60 | title={props.sendLabel} | 69 | title={props.sendLabel} |
| 61 | disabled={props.disabled || !props.value.trim()} | 70 | disabled={props.disabled || !props.value.trim()} |
| @@ -63,7 +72,7 @@ export function RagComposer(props: { | |||
| 63 | <IconSend class="h-4 w-4" /> | 72 | <IconSend class="h-4 w-4" /> |
| 64 | </Button> | 73 | </Button> |
| 65 | </div> | 74 | </div> |
| 66 | - <p class="mx-auto mt-1.5 w-full max-w-3xl px-1 text-[11px] leading-4 text-muted-foreground">{props.hint}</p> | 75 | + <p class="mx-auto mt-2 w-full max-w-3xl px-1 text-center text-[11px] leading-4 text-muted-foreground">{props.hint}</p> |
| 67 | </form> | 76 | </form> |
| 68 | ); | 77 | ); |
| 69 | } | 78 | } |
src/components/rag/rag-copy.tsmodified+22 -2
| @@ -17,7 +17,6 @@ function reasonText(locale: Locale, reason: string): string { | |||
| 17 | const copy = { | 17 | const copy = { |
| 18 | en: { | 18 | en: { |
| 19 | title: "Ask your notes", | 19 | title: "Ask your notes", |
| 20 | - description: "Ask questions across the course material available to you and review the sources behind each answer.", | ||
| 21 | newThread: "New chat", | 20 | newThread: "New chat", |
| 22 | history: "Chat history", | 21 | history: "Chat history", |
| 23 | untitled: "Untitled chat", | 22 | untitled: "Untitled chat", |
| @@ -29,6 +28,17 @@ const copy = { | |||
| 29 | send: "Send", | 28 | send: "Send", |
| 30 | composerHint: "Enter to send · Shift+Enter for a new line", | 29 | composerHint: "Enter to send · Shift+Enter for a new line", |
| 31 | thinking: "Searching your course material…", | 30 | thinking: "Searching your course material…", |
| 31 | + thinking2: "Reading the sources…", | ||
| 32 | + thinking3: "Preparing the answer…", | ||
| 33 | + copy: "Copy", | ||
| 34 | + copied: "Copied", | ||
| 35 | + retry: "Ask again", | ||
| 36 | + scrollToLatest: "Latest", | ||
| 37 | + newMessages: "New message", | ||
| 38 | + groupToday: "Today", | ||
| 39 | + groupYesterday: "Yesterday", | ||
| 40 | + groupThisWeek: "This week", | ||
| 41 | + groupEarlier: "Earlier", | ||
| 32 | sources: "Sources", | 42 | sources: "Sources", |
| 33 | source: "Source", | 43 | source: "Source", |
| 34 | subject: "Subject", | 44 | subject: "Subject", |
| @@ -66,7 +76,6 @@ const copy = { | |||
| 66 | }, | 76 | }, |
| 67 | tr: { | 77 | tr: { |
| 68 | title: "Notlarına sor", | 78 | title: "Notlarına sor", |
| 69 | - description: "Erişebildiğin ders içeriklerinde soru sor ve her yanıtın dayandığı kaynakları incele.", | ||
| 70 | newThread: "Yeni sohbet", | 79 | newThread: "Yeni sohbet", |
| 71 | history: "Sohbet geçmişi", | 80 | history: "Sohbet geçmişi", |
| 72 | untitled: "Başlıksız sohbet", | 81 | untitled: "Başlıksız sohbet", |
| @@ -78,6 +87,17 @@ const copy = { | |||
| 78 | send: "Gönder", | 87 | send: "Gönder", |
| 79 | composerHint: "Göndermek için Enter · Yeni satır için Shift+Enter", | 88 | composerHint: "Göndermek için Enter · Yeni satır için Shift+Enter", |
| 80 | thinking: "Ders içeriklerinde aranıyor…", | 89 | thinking: "Ders içeriklerinde aranıyor…", |
| 90 | + thinking2: "Kaynaklar taranıyor…", | ||
| 91 | + thinking3: "Yanıt hazırlanıyor…", | ||
| 92 | + copy: "Kopyala", | ||
| 93 | + copied: "Kopyalandı", | ||
| 94 | + retry: "Tekrar sor", | ||
| 95 | + scrollToLatest: "En son", | ||
| 96 | + newMessages: "Yeni mesaj", | ||
| 97 | + groupToday: "Bugün", | ||
| 98 | + groupYesterday: "Dün", | ||
| 99 | + groupThisWeek: "Bu hafta", | ||
| 100 | + groupEarlier: "Daha önce", | ||
| 81 | sources: "Kaynaklar", | 101 | sources: "Kaynaklar", |
| 82 | source: "Kaynak", | 102 | source: "Kaynak", |
| 83 | subject: "Ders", | 103 | subject: "Ders", |
src/components/rag/rag-message-row.test.tsxadded+63 -0
| @@ -0,0 +1,63 @@ | |||
| 1 | +import { cleanup, fireEvent, render, screen, waitFor } from "@solidjs/testing-library"; | ||
| 2 | +import { afterEach, describe, expect, it, vi } from "vitest"; | ||
| 3 | +import type { RagMessage } from "@/api/client"; | ||
| 4 | +import { RagMessageRow } from "@/components/rag/rag-message-row"; | ||
| 5 | +import { ragCopy } from "@/components/rag/rag-copy"; | ||
| 6 | + | ||
| 7 | +const labels = ragCopy("tr"); | ||
| 8 | + | ||
| 9 | +function message(over: Partial<RagMessage>): RagMessage { | ||
| 10 | + return { | ||
| 11 | + id: "m1", | ||
| 12 | + thread_id: "t1", | ||
| 13 | + role: "assistant", | ||
| 14 | + status: "complete", | ||
| 15 | + content: "Hücre zarı seçici geçirgendir.", | ||
| 16 | + abstained: false, | ||
| 17 | + reason: "", | ||
| 18 | + citations: [], | ||
| 19 | + created_at: Date.UTC(2026, 0, 2), | ||
| 20 | + ...over, | ||
| 21 | + }; | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +describe("RagMessageRow", () => { | ||
| 25 | + afterEach(() => { | ||
| 26 | + cleanup(); | ||
| 27 | + vi.restoreAllMocks(); | ||
| 28 | + }); | ||
| 29 | + | ||
| 30 | + it("copies a finished answer and says so", async () => { | ||
| 31 | + const writeText = vi.fn().mockResolvedValue(undefined); | ||
| 32 | + Object.assign(navigator, { clipboard: { writeText } }); | ||
| 33 | + | ||
| 34 | + render(() => <RagMessageRow message={message({})} labels={labels} />); | ||
| 35 | + | ||
| 36 | + fireEvent.click(screen.getByRole("button", { name: labels.copy })); | ||
| 37 | + | ||
| 38 | + await waitFor(() => expect(writeText).toHaveBeenCalledWith("Hücre zarı seçici geçirgendir.")); | ||
| 39 | + await waitFor(() => expect(screen.getByText(labels.copied)).toBeTruthy()); | ||
| 40 | + }); | ||
| 41 | + | ||
| 42 | + it("offers no copy on the user's own turn", () => { | ||
| 43 | + render(() => <RagMessageRow message={message({ role: "user" })} labels={labels} />); | ||
| 44 | + | ||
| 45 | + expect(screen.queryByRole("button", { name: labels.copy })).toBeNull(); | ||
| 46 | + }); | ||
| 47 | + | ||
| 48 | + it("re-asks through the handler the panel supplies", () => { | ||
| 49 | + const onRetry = vi.fn(); | ||
| 50 | + render(() => <RagMessageRow message={message({ status: "failed" })} labels={labels} onRetry={onRetry} />); | ||
| 51 | + | ||
| 52 | + fireEvent.click(screen.getByRole("button", { name: labels.retry })); | ||
| 53 | + | ||
| 54 | + expect(onRetry).toHaveBeenCalledTimes(1); | ||
| 55 | + }); | ||
| 56 | + | ||
| 57 | + it("shows no action row while the answer is still pending", () => { | ||
| 58 | + render(() => <RagMessageRow message={message({ status: "pending", content: "" })} labels={labels} onRetry={vi.fn()} />); | ||
| 59 | + | ||
| 60 | + expect(screen.queryByRole("button", { name: labels.retry })).toBeNull(); | ||
| 61 | + expect(screen.queryByRole("button", { name: labels.copy })).toBeNull(); | ||
| 62 | + }); | ||
| 63 | +}); | ||
src/components/rag/rag-message-row.tsxmodified+60 -11
| @@ -1,16 +1,28 @@ | |||
| 1 | -import { Match, Show, Switch, type JSX } from "solid-js"; | 1 | +import { Match, Show, Switch, createSignal, type JSX } from "solid-js"; |
| 2 | import type { RagMessage } from "@/api/client"; | 2 | import type { RagMessage } from "@/api/client"; |
| 3 | import { CelebiMarkdown } from "@/components/layout/celebi-markdown"; | 3 | import { CelebiMarkdown } from "@/components/layout/celebi-markdown"; |
| 4 | -import { IconAlert, IconBotSquare } from "@/components/ui/icons"; | 4 | +import { IconAlert, IconCopy, IconRefresh } from "@/components/ui/icons"; |
| 5 | import { RagCitations } from "@/components/rag/rag-citations"; | 5 | import { RagCitations } from "@/components/rag/rag-citations"; |
| 6 | +import { RagThinkingLabel } from "@/components/rag/rag-thinking-label"; | ||
| 6 | import { cn } from "@/lib/cn"; | 7 | import { cn } from "@/lib/cn"; |
| 7 | 8 | ||
| 8 | export function RagMessageRow(props: { | 9 | export function RagMessageRow(props: { |
| 9 | message: RagMessage; | 10 | message: RagMessage; |
| 10 | /** Rendered under the citations of an answer (e.g. study actions). */ | 11 | /** Rendered under the citations of an answer (e.g. study actions). */ |
| 11 | footer?: JSX.Element; | 12 | footer?: JSX.Element; |
| 13 | + /** | ||
| 14 | + * Re-asks the question this answer replies to. Passed only for the newest | ||
| 15 | + * answer — re-asking an older one would append it at the end of the | ||
| 16 | + * transcript, far from the turn the reader was looking at. | ||
| 17 | + */ | ||
| 18 | + onRetry?: () => void; | ||
| 12 | labels: { | 19 | labels: { |
| 13 | thinking: string; | 20 | thinking: string; |
| 21 | + thinking2: string; | ||
| 22 | + thinking3: string; | ||
| 23 | + copy: string; | ||
| 24 | + copied: string; | ||
| 25 | + retry: string; | ||
| 14 | sources: string; | 26 | sources: string; |
| 15 | source: string; | 27 | source: string; |
| 16 | subject: string; | 28 | subject: string; |
| @@ -22,27 +34,38 @@ export function RagMessageRow(props: { | |||
| 22 | abstainedReason: (reason: string) => string; | 34 | abstainedReason: (reason: string) => string; |
| 23 | }; | 35 | }; |
| 24 | }) { | 36 | }) { |
| 37 | + const [copied, setCopied] = createSignal(false); | ||
| 25 | const assistant = () => props.message.role === "assistant"; | 38 | const assistant = () => props.message.role === "assistant"; |
| 26 | const failure = () => props.message.error_code | 39 | const failure = () => props.message.error_code |
| 27 | ? props.labels.failedWithCode(props.message.error_code) | 40 | ? props.labels.failedWithCode(props.message.error_code) |
| 28 | : props.labels.failed; | 41 | : props.labels.failed; |
| 42 | + const settled = () => props.message.status === "complete" || props.message.status === "failed"; | ||
| 43 | + const copyable = () => assistant() && props.message.status === "complete" && !!props.message.content; | ||
| 44 | + | ||
| 45 | + const copy = async () => { | ||
| 46 | + await navigator.clipboard.writeText(props.message.content); | ||
| 47 | + setCopied(true); | ||
| 48 | + window.setTimeout(() => setCopied(false), 1_500); | ||
| 49 | + }; | ||
| 29 | 50 | ||
| 30 | return ( | 51 | return ( |
| 31 | - <article class={cn("flex gap-3", assistant() ? "justify-start" : "justify-end")}> | 52 | + // The user's turn is a bubble; the answer is not. An answer is the page's |
| 32 | - <Show when={assistant()}> | 53 | + // content, not a message in a thread, so it runs the full reading column |
| 33 | - <span class="mt-1 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary-text"> | 54 | + // with no frame and no avatar competing with the first line of text. |
| 34 | - <IconBotSquare class="h-4 w-4" /> | 55 | + <article class={cn("flex", assistant() ? "justify-start" : "justify-end")}> |
| 35 | - </span> | ||
| 36 | - </Show> | ||
| 37 | <div | 56 | <div |
| 38 | class={cn( | 57 | class={cn( |
| 39 | - "max-w-[min(46rem,88%)] rounded-xl px-4 py-3 text-sm", | 58 | + "text-sm", |
| 40 | - assistant() ? "border border-border-line bg-surface-base text-foreground" : "bg-primary text-primary-foreground", | 59 | + assistant() |
| 60 | + ? "w-full min-w-0 text-foreground" | ||
| 61 | + : "max-w-[min(46rem,88%)] rounded-xl bg-primary px-4 py-3 text-primary-foreground", | ||
| 41 | )} | 62 | )} |
| 42 | > | 63 | > |
| 43 | <Switch> | 64 | <Switch> |
| 44 | <Match when={props.message.status === "pending" && !props.message.content}> | 65 | <Match when={props.message.status === "pending" && !props.message.content}> |
| 45 | - <p class="animate-pulse text-muted-foreground" role="status">{props.labels.thinking}</p> | 66 | + <p class="animate-pulse text-muted-foreground" role="status"> |
| 67 | + <RagThinkingLabel phases={[props.labels.thinking, props.labels.thinking2, props.labels.thinking3]} /> | ||
| 68 | + </p> | ||
| 46 | </Match> | 69 | </Match> |
| 47 | <Match when={props.message.status === "failed"}> | 70 | <Match when={props.message.status === "failed"}> |
| 48 | <div class="flex items-start gap-2 text-destructive-text"> | 71 | <div class="flex items-start gap-2 text-destructive-text"> |
| @@ -65,6 +88,32 @@ export function RagMessageRow(props: { | |||
| 65 | <Show when={assistant()}> | 88 | <Show when={assistant()}> |
| 66 | <RagCitations citations={props.message.citations} labels={props.labels} /> | 89 | <RagCitations citations={props.message.citations} labels={props.labels} /> |
| 67 | {props.footer} | 90 | {props.footer} |
| 91 | + <Show when={settled() && (copyable() || props.onRetry)}> | ||
| 92 | + <div class="mt-2 flex flex-wrap items-center gap-3"> | ||
| 93 | + <Show when={copyable()}> | ||
| 94 | + <button | ||
| 95 | + type="button" | ||
| 96 | + class="flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground" | ||
| 97 | + onClick={() => void copy()} | ||
| 98 | + > | ||
| 99 | + <IconCopy class="h-3 w-3" /> | ||
| 100 | + {copied() ? props.labels.copied : props.labels.copy} | ||
| 101 | + </button> | ||
| 102 | + </Show> | ||
| 103 | + <Show when={props.onRetry}> | ||
| 104 | + {(retry) => ( | ||
| 105 | + <button | ||
| 106 | + type="button" | ||
| 107 | + class="flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground" | ||
| 108 | + onClick={() => retry()()} | ||
| 109 | + > | ||
| 110 | + <IconRefresh class="h-3 w-3" /> | ||
| 111 | + {props.labels.retry} | ||
| 112 | + </button> | ||
| 113 | + )} | ||
| 114 | + </Show> | ||
| 115 | + </div> | ||
| 116 | + </Show> | ||
| 68 | </Show> | 117 | </Show> |
| 69 | </div> | 118 | </div> |
| 70 | </article> | 119 | </article> |
src/components/rag/rag-study-panel.tsxmodified+103 -40
| @@ -19,7 +19,8 @@ import { RagThreadList } from "@/components/rag/rag-thread-list"; | |||
| 19 | import { Alert } from "@/components/ui/alert"; | 19 | import { Alert } from "@/components/ui/alert"; |
| 20 | import { Button } from "@/components/ui/button"; | 20 | import { Button } from "@/components/ui/button"; |
| 21 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | 21 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; |
| 22 | -import { IconBook, IconEdit, IconPlus } from "@/components/ui/icons"; | 22 | +import { IconChevronDown, IconPlus } from "@/components/ui/icons"; |
| 23 | +import { cn } from "@/lib/cn"; | ||
| 23 | import { scopeFromCitations } from "@/lib/rag-study-scope"; | 24 | import { scopeFromCitations } from "@/lib/rag-study-scope"; |
| 24 | import { usePreferences } from "@/stores/preferences-context"; | 25 | import { usePreferences } from "@/stores/preferences-context"; |
| 25 | 26 | ||
| @@ -162,9 +163,33 @@ export function RagStudyPanel() { | |||
| 162 | } | 163 | } |
| 163 | }; | 164 | }; |
| 164 | 165 | ||
| 165 | - // Follow the conversation: a new turn (or a streamed chunk) keeps the view | 166 | + // The transcript follows the newest turn only while the reader is pinned to |
| 166 | - // on the latest message, unless the reader has scrolled up to reread. | 167 | + // the bottom. Any upward scroll unpins at once — a distance threshold alone |
| 168 | + // lost to a streamed answer that grows every frame and kept dragging the | ||
| 169 | + // reader back down. Content that lands while unpinned raises the pill below | ||
| 170 | + // instead of yanking the view. | ||
| 167 | let scroller: HTMLDivElement | undefined; | 171 | let scroller: HTMLDivElement | undefined; |
| 172 | + const NEAR_BOTTOM_PX = 64; | ||
| 173 | + const [pinned, setPinned] = createSignal(true); | ||
| 174 | + const [unread, setUnread] = createSignal(false); | ||
| 175 | + let lastScrollTop = 0; | ||
| 176 | + const scrollToLatest = () => { | ||
| 177 | + if (!scroller) return; | ||
| 178 | + setPinned(true); | ||
| 179 | + setUnread(false); | ||
| 180 | + scroller.scrollTo({ top: scroller.scrollHeight, behavior: "smooth" }); | ||
| 181 | + }; | ||
| 182 | + const handleTranscriptScroll = () => { | ||
| 183 | + if (!scroller) return; | ||
| 184 | + const top = scroller.scrollTop; | ||
| 185 | + const distance = scroller.scrollHeight - top - scroller.clientHeight; | ||
| 186 | + if (top < lastScrollTop - 1 && distance > 1) setPinned(false); | ||
| 187 | + else if (distance <= NEAR_BOTTOM_PX) { | ||
| 188 | + setPinned(true); | ||
| 189 | + setUnread(false); | ||
| 190 | + } | ||
| 191 | + lastScrollTop = top; | ||
| 192 | + }; | ||
| 168 | createEffect( | 193 | createEffect( |
| 169 | on( | 194 | on( |
| 170 | () => { | 195 | () => { |
| @@ -174,13 +199,23 @@ export function RagStudyPanel() { | |||
| 174 | () => { | 199 | () => { |
| 175 | const el = scroller; | 200 | const el = scroller; |
| 176 | if (!el) return; | 201 | if (!el) return; |
| 177 | - const nearBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 160; | 202 | + if (!pinned()) { setUnread(true); return; } |
| 178 | - if (nearBottom || sending()) queueMicrotask(() => el.scrollTo({ top: el.scrollHeight })); | 203 | + queueMicrotask(() => { |
| 204 | + el.scrollTop = el.scrollHeight; | ||
| 205 | + lastScrollTop = el.scrollTop; | ||
| 206 | + }); | ||
| 179 | }, | 207 | }, |
| 180 | { defer: true }, | 208 | { defer: true }, |
| 181 | ), | 209 | ), |
| 182 | ); | 210 | ); |
| 183 | 211 | ||
| 212 | + /** Re-ask the question an answer replies to, through the same send pipeline. */ | ||
| 213 | + const retry = (question: string) => { | ||
| 214 | + if (sending()) return; | ||
| 215 | + setDraft(question); | ||
| 216 | + void send(); | ||
| 217 | + }; | ||
| 218 | + | ||
| 184 | /** The user turn an answer replies to, used as the study range's label. */ | 219 | /** The user turn an answer replies to, used as the study range's label. */ |
| 185 | const questionBefore = (index: number) => { | 220 | const questionBefore = (index: number) => { |
| 186 | for (let i = index - 1; i >= 0; i -= 1) if (messages()[i]?.role === "user") return messages()[i]!.content; | 221 | for (let i = index - 1; i >= 0; i -= 1) if (messages()[i]?.role === "user") return messages()[i]!.content; |
| @@ -208,36 +243,37 @@ export function RagStudyPanel() { | |||
| 208 | /> | 243 | /> |
| 209 | </aside> | 244 | </aside> |
| 210 | 245 | ||
| 211 | - <section class="flex h-full min-h-0 flex-col overflow-hidden rounded-xl border border-border-line bg-surface-base shadow-xs" aria-label={copy().title}> | 246 | + {/* No card, no header strip: the transcript sits on the page the way a |
| 212 | - <header class="flex shrink-0 items-center justify-between gap-3 border-b border-border-line px-4 py-3 sm:px-5"> | 247 | + chat does. The conversation's own actions live on its row in the |
| 213 | - <div class="flex min-w-0 items-center gap-3"> | 248 | + sidebar, which is where they were already duplicated. */} |
| 214 | - <span class="flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary-text"> | 249 | + <section class="flex h-full min-h-0 flex-col" aria-label={copy().title}> |
| 215 | - <IconBook class="h-4 w-4" /> | 250 | + <Show when={error()}> |
| 216 | - </span> | 251 | + <div class="mx-auto w-full max-w-3xl px-4 pt-1 sm:px-6"> |
| 217 | - <div class="min-w-0"> | ||
| 218 | - <p class="truncate text-sm font-semibold text-text-strong">{threadId() ? activeThread()?.title || copy().untitled : copy().title}</p> | ||
| 219 | - <p class="truncate text-xs text-muted-foreground">{copy().description}</p> | ||
| 220 | - </div> | ||
| 221 | - </div> | ||
| 222 | - <div class="flex shrink-0 items-center gap-2"> | ||
| 223 | - <Show when={activeThread()}> | ||
| 224 | - {(thread) => ( | ||
| 225 | - <Button type="button" size="sm" variant="outline" class="h-8 rounded-lg" aria-label={copy().rename} title={copy().rename} onClick={() => setRenaming(thread())}> | ||
| 226 | - <IconEdit class="h-3.5 w-3.5" /> | ||
| 227 | - </Button> | ||
| 228 | - )} | ||
| 229 | - </Show> | ||
| 230 | - </div> | ||
| 231 | - </header> | ||
| 232 | - <div ref={scroller} class="min-h-0 flex-1 overflow-y-auto px-4 py-5 sm:px-6" aria-live="polite"> | ||
| 233 | - <div class="mx-auto w-full max-w-3xl space-y-5"> | ||
| 234 | - <Show when={error()}> | ||
| 235 | <Alert variant="destructive">{error()}</Alert> | 252 | <Alert variant="destructive">{error()}</Alert> |
| 236 | - </Show> | 253 | + </div> |
| 254 | + </Show> | ||
| 255 | + <div class="relative min-h-0 flex-1"> | ||
| 256 | + <div ref={scroller} onScroll={handleTranscriptScroll} class="h-full overflow-y-auto px-4 py-5 sm:px-6" aria-live="polite"> | ||
| 257 | + <div class="mx-auto w-full max-w-3xl space-y-6"> | ||
| 237 | <Show | 258 | <Show |
| 238 | when={messages().length > 0} | 259 | when={messages().length > 0} |
| 239 | fallback={ | 260 | fallback={ |
| 240 | - <RagStudyWelcome title={copy().emptyChat} hint={copy().emptyChatHint} /> | 261 | + // The landing screen centres the mark and the composer instead of |
| 262 | + // stranding the composer at the bottom of an empty page. | ||
| 263 | + <div class="flex min-h-[60vh] flex-col justify-center"> | ||
| 264 | + <RagStudyWelcome title={copy().emptyChat} hint={copy().emptyChatHint} /> | ||
| 265 | + <RagComposer | ||
| 266 | + value={draft()} | ||
| 267 | + placeholder={copy().placeholder} | ||
| 268 | + sendLabel={copy().send} | ||
| 269 | + hint={copy().composerHint} | ||
| 270 | + disabled={sending()} | ||
| 271 | + autofocus | ||
| 272 | + class="px-0 sm:px-0" | ||
| 273 | + onInput={setDraft} | ||
| 274 | + onSubmit={() => void send()} | ||
| 275 | + /> | ||
| 276 | + </div> | ||
| 241 | } | 277 | } |
| 242 | > | 278 | > |
| 243 | <For each={messages()}> | 279 | <For each={messages()}> |
| @@ -246,10 +282,17 @@ export function RagStudyPanel() { | |||
| 246 | message.role === "assistant" && message.status === "complete" && !message.abstained | 282 | message.role === "assistant" && message.status === "complete" && !message.abstained |
| 247 | ? scopeFromCitations(message.citations, questionBefore(index())) | 283 | ? scopeFromCitations(message.citations, questionBefore(index())) |
| 248 | : null; | 284 | : null; |
| 285 | + const question = () => questionBefore(index()); | ||
| 286 | + const retryable = () => | ||
| 287 | + message.role === "assistant" && | ||
| 288 | + index() === messages().length - 1 && | ||
| 289 | + (message.status === "complete" || message.status === "failed") && | ||
| 290 | + question() != null; | ||
| 249 | return ( | 291 | return ( |
| 250 | <RagMessageRow | 292 | <RagMessageRow |
| 251 | message={message} | 293 | message={message} |
| 252 | labels={copy()} | 294 | labels={copy()} |
| 295 | + onRetry={retryable() ? () => retry(question()!) : undefined} | ||
| 253 | footer={ | 296 | footer={ |
| 254 | <Show when={scope()}> | 297 | <Show when={scope()}> |
| 255 | {(current) => ( | 298 | {(current) => ( |
| @@ -269,15 +312,35 @@ export function RagStudyPanel() { | |||
| 269 | </Show> | 312 | </Show> |
| 270 | </div> | 313 | </div> |
| 271 | </div> | 314 | </div> |
| 272 | - <RagComposer | 315 | + <Show when={!pinned()}> |
| 273 | - value={draft()} | 316 | + <button |
| 274 | - placeholder={copy().placeholder} | 317 | + type="button" |
| 275 | - sendLabel={copy().send} | 318 | + class={cn( |
| 276 | - hint={copy().composerHint} | 319 | + "absolute bottom-3 left-1/2 inline-flex h-8 -translate-x-1/2 items-center gap-1.5 rounded-full border px-3 text-xs font-medium shadow-md backdrop-blur transition-colors", |
| 277 | - disabled={sending()} | 320 | + unread() |
| 278 | - onInput={setDraft} | 321 | + ? "border-primary bg-primary text-primary-foreground hover:bg-primary/90" |
| 279 | - onSubmit={() => void send()} | 322 | + : "border-border bg-surface-base/95 text-foreground hover:bg-surface-overlay", |
| 280 | - /> | 323 | + )} |
| 324 | + onClick={scrollToLatest} | ||
| 325 | + > | ||
| 326 | + <IconChevronDown class="h-3.5 w-3.5" /> | ||
| 327 | + {unread() ? copy().newMessages : copy().scrollToLatest} | ||
| 328 | + </button> | ||
| 329 | + </Show> | ||
| 330 | + </div> | ||
| 331 | + <Show when={messages().length > 0}> | ||
| 332 | + <RagComposer | ||
| 333 | + value={draft()} | ||
| 334 | + placeholder={copy().placeholder} | ||
| 335 | + sendLabel={copy().send} | ||
| 336 | + hint={copy().composerHint} | ||
| 337 | + disabled={sending()} | ||
| 338 | + autofocus | ||
| 339 | + class="pb-4" | ||
| 340 | + onInput={setDraft} | ||
| 341 | + onSubmit={() => void send()} | ||
| 342 | + /> | ||
| 343 | + </Show> | ||
| 281 | </section> | 344 | </section> |
| 282 | 345 | ||
| 283 | <ConfirmDialog | 346 | <ConfirmDialog |
src/components/rag/rag-study-welcome.tsxmodified+10 -5
| @@ -1,13 +1,18 @@ | |||
| 1 | import { IconSparkles } from "@/components/ui/icons"; | 1 | import { IconSparkles } from "@/components/ui/icons"; |
| 2 | 2 | ||
| 3 | -/** The Study tab before the first question: what it answers from, nothing more. */ | 3 | +/** |
| 4 | + * The landing screen, which is really just the brand mark above the composer. | ||
| 5 | + * The old version was a bordered illustration block that pushed the composer to | ||
| 6 | + * the bottom edge; here the mark introduces the composer and nothing else | ||
| 7 | + * competes with it — the page's whole job is "start typing". | ||
| 8 | + */ | ||
| 4 | export function RagStudyWelcome(props: { title: string; hint: string }) { | 9 | export function RagStudyWelcome(props: { title: string; hint: string }) { |
| 5 | return ( | 10 | return ( |
| 6 | - <div class="flex min-h-[40vh] flex-col items-center justify-center gap-3 py-10 text-center"> | 11 | + <div class="flex flex-col items-center gap-3 pb-6 text-center"> |
| 7 | - <span class="flex h-12 w-12 items-center justify-center rounded-2xl border border-primary/20 bg-primary/10 text-primary-text"> | 12 | + <span class="flex h-11 w-11 items-center justify-center rounded-2xl bg-primary/10 text-primary-text"> |
| 8 | - <IconSparkles class="h-6 w-6" /> | 13 | + <IconSparkles class="h-5 w-5" /> |
| 9 | </span> | 14 | </span> |
| 10 | - <h2 class="text-xl font-semibold tracking-tight text-text-strong">{props.title}</h2> | 15 | + <h2 class="text-2xl font-semibold tracking-tight text-text-strong">{props.title}</h2> |
| 11 | <p class="max-w-md text-sm leading-6 text-muted-foreground">{props.hint}</p> | 16 | <p class="max-w-md text-sm leading-6 text-muted-foreground">{props.hint}</p> |
| 12 | </div> | 17 | </div> |
| 13 | ); | 18 | ); |
src/components/rag/rag-thinking-label.tsxadded+20 -0
| @@ -0,0 +1,20 @@ | |||
| 1 | +import { createSignal, onCleanup } from "solid-js"; | ||
| 2 | + | ||
| 3 | +const ROTATE_MS = 1_800; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * The "working on it" line while an answer is still pending. | ||
| 7 | + * | ||
| 8 | + * Retrieval here runs over the whole course corpus and takes longer than the | ||
| 9 | + * assistant popover's turn, and a single frozen sentence starts to read as a | ||
| 10 | + * stall. Rotating through the phases says the wait is expected — same device as | ||
| 11 | + * `CelebiThinkingLabel`, but the phrases come from this tree's own copy object | ||
| 12 | + * rather than the global message union. | ||
| 13 | + */ | ||
| 14 | +export function RagThinkingLabel(props: { phases: string[] }) { | ||
| 15 | + const [index, setIndex] = createSignal(0); | ||
| 16 | + const count = () => Math.max(1, props.phases.length); | ||
| 17 | + const timer = window.setInterval(() => setIndex((i) => i + 1), ROTATE_MS); | ||
| 18 | + onCleanup(() => window.clearInterval(timer)); | ||
| 19 | + return <>{props.phases[index() % count()]}</>; | ||
| 20 | +} | ||
src/components/rag/rag-thread-list.tsxmodified+79 -31
| @@ -12,12 +12,37 @@ import { formatDateTime } from "@/lib/format"; | |||
| 12 | import type { Locale } from "@/i18n/messages"; | 12 | import type { Locale } from "@/i18n/messages"; |
| 13 | 13 | ||
| 14 | const THREAD_PAGE_SIZE = 12; | 14 | const THREAD_PAGE_SIZE = 12; |
| 15 | +const DAY_MS = 86_400_000; | ||
| 16 | + | ||
| 17 | +type Bucket = "today" | "yesterday" | "week" | "earlier"; | ||
| 18 | +const BUCKET_ORDER: Bucket[] = ["today", "yesterday", "week", "earlier"]; | ||
| 19 | + | ||
| 20 | +/** Which recency bucket a thread falls in, by local calendar day rather than a | ||
| 21 | + * rolling 24 hours — "dün" has to mean yesterday's date, not 25 hours ago. */ | ||
| 22 | +function bucketOf(updatedAt: number, now: Date): Bucket { | ||
| 23 | + const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime(); | ||
| 24 | + if (updatedAt >= startOfToday) return "today"; | ||
| 25 | + if (updatedAt >= startOfToday - DAY_MS) return "yesterday"; | ||
| 26 | + if (updatedAt >= startOfToday - 6 * DAY_MS) return "week"; | ||
| 27 | + return "earlier"; | ||
| 28 | +} | ||
| 15 | 29 | ||
| 16 | export function RagThreadList(props: { | 30 | export function RagThreadList(props: { |
| 17 | activeId?: string; | 31 | activeId?: string; |
| 18 | version: number; | 32 | version: number; |
| 19 | locale: Locale; | 33 | locale: Locale; |
| 20 | - labels: { untitled: string; emptyThreads: string; emptyThreadsHint: string; rename: string; actions: string; delete: string }; | 34 | + labels: { |
| 35 | + untitled: string; | ||
| 36 | + emptyThreads: string; | ||
| 37 | + emptyThreadsHint: string; | ||
| 38 | + rename: string; | ||
| 39 | + actions: string; | ||
| 40 | + delete: string; | ||
| 41 | + groupToday: string; | ||
| 42 | + groupYesterday: string; | ||
| 43 | + groupThisWeek: string; | ||
| 44 | + groupEarlier: string; | ||
| 45 | + }; | ||
| 21 | onOpen: (thread: RagThread) => void; | 46 | onOpen: (thread: RagThread) => void; |
| 22 | onRename: (thread: RagThread) => void; | 47 | onRename: (thread: RagThread) => void; |
| 23 | onRemove: (thread: RagThread) => void; | 48 | onRemove: (thread: RagThread) => void; |
| @@ -28,6 +53,20 @@ export function RagThreadList(props: { | |||
| 28 | ({ page }) => getRagThreads({ limit: THREAD_PAGE_SIZE, offset: page * THREAD_PAGE_SIZE }), | 53 | ({ page }) => getRagThreads({ limit: THREAD_PAGE_SIZE, offset: page * THREAD_PAGE_SIZE }), |
| 29 | ); | 54 | ); |
| 30 | const totalPages = () => Math.max(1, Math.ceil((threads.latest?.total ?? 0) / THREAD_PAGE_SIZE)); | 55 | const totalPages = () => Math.max(1, Math.ceil((threads.latest?.total ?? 0) / THREAD_PAGE_SIZE)); |
| 56 | + const bucketLabel = (bucket: Bucket) => | ||
| 57 | + bucket === "today" ? props.labels.groupToday | ||
| 58 | + : bucket === "yesterday" ? props.labels.groupYesterday | ||
| 59 | + : bucket === "week" ? props.labels.groupThisWeek | ||
| 60 | + : props.labels.groupEarlier; | ||
| 61 | + // Grouping is presentational only — the page still comes from the server in | ||
| 62 | + // its own order, so an empty bucket simply does not get a heading. | ||
| 63 | + const groups = (items: RagThread[]) => { | ||
| 64 | + const now = new Date(); | ||
| 65 | + return BUCKET_ORDER.flatMap((bucket) => { | ||
| 66 | + const rows = items.filter((thread) => bucketOf(thread.updated_at, now) === bucket); | ||
| 67 | + return rows.length > 0 ? [{ bucket, rows }] : []; | ||
| 68 | + }); | ||
| 69 | + }; | ||
| 31 | 70 | ||
| 32 | createEffect(on(() => threads.latest, (result) => { | 71 | createEffect(on(() => threads.latest, (result) => { |
| 33 | if (result && result.items.length === 0 && page() > 0) setPage(Math.min(page() - 1, totalPages() - 1)); | 72 | if (result && result.items.length === 0 && page() > 0) setPage(Math.min(page() - 1, totalPages() - 1)); |
| @@ -42,36 +81,45 @@ export function RagThreadList(props: { | |||
| 42 | when={result().items.length > 0} | 81 | when={result().items.length > 0} |
| 43 | fallback={<EmptyInline class="h-full py-10" size="md" illustration="messages" title={props.labels.emptyThreads} hint={props.labels.emptyThreadsHint} />} | 82 | fallback={<EmptyInline class="h-full py-10" size="md" illustration="messages" title={props.labels.emptyThreads} hint={props.labels.emptyThreadsHint} />} |
| 44 | > | 83 | > |
| 45 | - <ul class="space-y-1.5"> | 84 | + <For each={groups(result().items)}> |
| 46 | - <For each={result().items}> | 85 | + {(group) => ( |
| 47 | - {(thread) => ( | 86 | + <section class="mb-3 last:mb-0"> |
| 48 | - <li | 87 | + <h3 class="px-1 pb-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground"> |
| 49 | - class={cn( | 88 | + {bucketLabel(group.bucket)} |
| 50 | - "flex overflow-hidden rounded-lg border transition-colors", | 89 | + </h3> |
| 51 | - thread.id === props.activeId ? "border-primary/40 bg-primary/5" : "border-border-hairline bg-card hover:border-border-line", | 90 | + <ul class="space-y-1.5"> |
| 52 | - )} | 91 | + <For each={group.rows}> |
| 53 | - aria-current={thread.id === props.activeId ? "true" : undefined} | 92 | + {(thread) => ( |
| 54 | - > | 93 | + <li |
| 55 | - <button | 94 | + class={cn( |
| 56 | - type="button" | 95 | + "flex overflow-hidden rounded-lg border transition-colors", |
| 57 | - class="flex min-w-0 flex-1 flex-col items-start gap-0.5 px-3 py-2 text-left transition-colors hover:bg-muted/60" | 96 | + thread.id === props.activeId ? "border-primary/40 bg-primary/5" : "border-border-hairline bg-card hover:border-border-line", |
| 58 | - onClick={() => props.onOpen(thread)} | 97 | + )} |
| 59 | - > | 98 | + aria-current={thread.id === props.activeId ? "true" : undefined} |
| 60 | - <span class="w-full truncate text-sm font-medium">{thread.title || props.labels.untitled}</span> | 99 | + > |
| 61 | - <span class="text-[11px] tabular-nums text-muted-foreground">{formatDateTime(thread.updated_at, props.locale)}</span> | 100 | + <button |
| 62 | - </button> | 101 | + type="button" |
| 63 | - <TableRowActions | 102 | + class="flex min-w-0 flex-1 flex-col items-start gap-0.5 px-3 py-2 text-left transition-colors hover:bg-muted/60" |
| 64 | - compact | 103 | + onClick={() => props.onOpen(thread)} |
| 65 | - label={props.labels.actions} | 104 | + > |
| 66 | - actions={[ | 105 | + <span class="w-full truncate text-sm font-medium">{thread.title || props.labels.untitled}</span> |
| 67 | - { label: props.labels.rename, icon: <IconEdit class="h-4 w-4" />, onSelect: () => props.onRename(thread) }, | 106 | + <span class="text-[11px] tabular-nums text-muted-foreground">{formatDateTime(thread.updated_at, props.locale)}</span> |
| 68 | - { label: props.labels.delete, icon: <IconTrash class="h-4 w-4" />, destructive: true, onSelect: () => props.onRemove(thread) }, | 107 | + </button> |
| 69 | - ]} | 108 | + <TableRowActions |
| 70 | - /> | 109 | + compact |
| 71 | - </li> | 110 | + label={props.labels.actions} |
| 72 | - )} | 111 | + actions={[ |
| 73 | - </For> | 112 | + { label: props.labels.rename, icon: <IconEdit class="h-4 w-4" />, onSelect: () => props.onRename(thread) }, |
| 74 | - </ul> | 113 | + { label: props.labels.delete, icon: <IconTrash class="h-4 w-4" />, destructive: true, onSelect: () => props.onRemove(thread) }, |
| 114 | + ]} | ||
| 115 | + /> | ||
| 116 | + </li> | ||
| 117 | + )} | ||
| 118 | + </For> | ||
| 119 | + </ul> | ||
| 120 | + </section> | ||
| 121 | + )} | ||
| 122 | + </For> | ||
| 75 | </Show> | 123 | </Show> |
| 76 | )} | 124 | )} |
| 77 | </Show> | 125 | </Show> |
src/components/ui/chart-comparator-bar.tsxadded+82 -0
| @@ -0,0 +1,82 @@ | |||
| 1 | +import { Show, type Component } from "solid-js"; | ||
| 2 | +import { cn } from "@/lib/cn"; | ||
| 3 | + | ||
| 4 | +export type ChartComparatorBarProps = { | ||
| 5 | + label: string; | ||
| 6 | + /** Where the fill ends, as a 0..1 fraction of the track. */ | ||
| 7 | + fraction: number; | ||
| 8 | + /** The value as the caller already formatted it — a percent, a mark, a count. */ | ||
| 9 | + valueText: string; | ||
| 10 | + /** | ||
| 11 | + * The baseline this value is read against (a cohort median, a class average) | ||
| 12 | + * as a fraction of the same track. Null when the service withheld it, and | ||
| 13 | + * then the bar is drawn without a tick rather than against a guessed one. | ||
| 14 | + */ | ||
| 15 | + comparatorFraction?: number | null; | ||
| 16 | + /** What the baseline is, e.g. "sınıf ortalaması". */ | ||
| 17 | + comparatorLabel?: string; | ||
| 18 | + comparatorText?: string | null; | ||
| 19 | + /** The signed distance between value and baseline, formatted by the caller. */ | ||
| 20 | + gapText?: string | null; | ||
| 21 | + class?: string; | ||
| 22 | +}; | ||
| 23 | + | ||
| 24 | +const clamp = (value: number) => Math.max(0, Math.min(1, Number.isFinite(value) ? value : 0)); | ||
| 25 | + | ||
| 26 | +/** | ||
| 27 | + * One value read against one baseline, in the width of a table row: the fill is | ||
| 28 | + * the value, the tick across it is the baseline. | ||
| 29 | + * | ||
| 30 | + * Both numbers stay printed next to the bar rather than being encoded in it — | ||
| 31 | + * the bar is the quick read, the text is the actual claim, so the comparison | ||
| 32 | + * survives for a reader who cannot separate the two colours (WCAG 1.4.1). | ||
| 33 | + */ | ||
| 34 | +export const ChartComparatorBar: Component<ChartComparatorBarProps> = (props) => { | ||
| 35 | + const fill = () => clamp(props.fraction); | ||
| 36 | + const tick = () => (props.comparatorFraction == null ? null : clamp(props.comparatorFraction)); | ||
| 37 | + const ariaLabel = () => | ||
| 38 | + [ | ||
| 39 | + `${props.label}: ${props.valueText}`, | ||
| 40 | + props.comparatorText ? `${props.comparatorLabel ?? ""} ${props.comparatorText}`.trim() : null, | ||
| 41 | + props.gapText, | ||
| 42 | + ] | ||
| 43 | + .filter(Boolean) | ||
| 44 | + .join(", "); | ||
| 45 | + | ||
| 46 | + return ( | ||
| 47 | + <div class={cn("space-y-1", props.class)} role="img" aria-label={ariaLabel()}> | ||
| 48 | + <div class="flex items-baseline justify-between gap-3"> | ||
| 49 | + <span class="min-w-0 truncate text-xs text-muted-foreground">{props.label}</span> | ||
| 50 | + <span class="shrink-0 text-sm font-semibold tabular-nums text-text-strong">{props.valueText}</span> | ||
| 51 | + </div> | ||
| 52 | + <div class="relative h-2 overflow-hidden rounded-full bg-surface-overlay"> | ||
| 53 | + <div class="h-full rounded-full bg-primary" style={{ width: `${fill() * 100}%` }} /> | ||
| 54 | + <Show when={tick() != null}> | ||
| 55 | + {/* Pulled half its own width back so the tick sits on the baseline, | ||
| 56 | + not just past it; the last pixel stays inside the track. */} | ||
| 57 | + <span | ||
| 58 | + class="absolute inset-y-0 w-0.5 -translate-x-1/2 rounded-full bg-text-strong" | ||
| 59 | + style={{ left: `${tick()! * 100}%` }} | ||
| 60 | + /> | ||
| 61 | + </Show> | ||
| 62 | + </div> | ||
| 63 | + <Show when={props.comparatorText || props.gapText}> | ||
| 64 | + <p class="flex flex-wrap items-baseline gap-x-2 text-[11px] leading-5 text-muted-foreground"> | ||
| 65 | + <Show when={props.comparatorText}> | ||
| 66 | + {(text) => ( | ||
| 67 | + <span> | ||
| 68 | + <Show when={props.comparatorLabel}> | ||
| 69 | + <span>{props.comparatorLabel}: </span> | ||
| 70 | + </Show> | ||
| 71 | + <span class="font-medium tabular-nums">{text()}</span> | ||
| 72 | + </span> | ||
| 73 | + )} | ||
| 74 | + </Show> | ||
| 75 | + <Show when={props.gapText}> | ||
| 76 | + {(gap) => <span class="font-medium tabular-nums text-text-strong">{gap()}</span>} | ||
| 77 | + </Show> | ||
| 78 | + </p> | ||
| 79 | + </Show> | ||
| 80 | + </div> | ||
| 81 | + ); | ||
| 82 | +}; | ||
src/components/users/create-user-panel.tsxmodified+27 -1
| @@ -32,15 +32,20 @@ export function CreateUserPanel(props: { | |||
| 32 | const [username, setUsername] = createSignal(""); | 32 | const [username, setUsername] = createSignal(""); |
| 33 | const [password, setPassword] = createSignal(""); | 33 | const [password, setPassword] = createSignal(""); |
| 34 | const [role, setRole] = createSignal<Role>(props.fixedRole ?? "student"); | 34 | const [role, setRole] = createSignal<Role>(props.fixedRole ?? "student"); |
| 35 | + const [studentNumber, setStudentNumber] = createSignal(""); | ||
| 35 | const [error, setError] = createSignal(""); | 36 | const [error, setError] = createSignal(""); |
| 36 | const [pending, setPending] = createSignal(false); | 37 | const [pending, setPending] = createSignal(false); |
| 37 | 38 | ||
| 38 | const userLimits = () => limits.latest?.user; | 39 | const userLimits = () => limits.latest?.user; |
| 40 | + // Only a student account may hold a number; the server 400s on any other | ||
| 41 | + // role, so the field is asked for — and sent — only when the role is student. | ||
| 42 | + const effectiveRole = () => props.fixedRole ?? role(); | ||
| 39 | 43 | ||
| 40 | const reset = () => { | 44 | const reset = () => { |
| 41 | setUsername(""); | 45 | setUsername(""); |
| 42 | setPassword(""); | 46 | setPassword(""); |
| 43 | setRole(props.fixedRole ?? "student"); | 47 | setRole(props.fixedRole ?? "student"); |
| 48 | + setStudentNumber(""); | ||
| 44 | setError(""); | 49 | setError(""); |
| 45 | }; | 50 | }; |
| 46 | 51 | ||
| @@ -63,7 +68,14 @@ export function CreateUserPanel(props: { | |||
| 63 | if (msg) { setError(msg); return; } | 68 | if (msg) { setError(msg); return; } |
| 64 | setPending(true); | 69 | setPending(true); |
| 65 | try { | 70 | try { |
| 66 | - const created = await postUser({ username: username().trim(), password: password(), role: props.fixedRole ?? role() }); | 71 | + const number = studentNumber().trim(); |
| 72 | + const created = await postUser({ | ||
| 73 | + username: username().trim(), | ||
| 74 | + password: password(), | ||
| 75 | + role: effectiveRole(), | ||
| 76 | + // Blank is the same as omitted, so an unnumbered student stays unnumbered. | ||
| 77 | + ...(effectiveRole() === "student" && number ? { student_number: number } : {}), | ||
| 78 | + }); | ||
| 67 | reset(); | 79 | reset(); |
| 68 | props.onCreated(created); | 80 | props.onCreated(created); |
| 69 | } catch (err) { | 81 | } catch (err) { |
| @@ -120,6 +132,20 @@ export function CreateUserPanel(props: { | |||
| 120 | </Select> | 132 | </Select> |
| 121 | </div> | 133 | </div> |
| 122 | </Show> | 134 | </Show> |
| 135 | + <Show when={effectiveRole() === "student"}> | ||
| 136 | + <div class="space-y-1.5"> | ||
| 137 | + <Label for="create-user-student-number">{t("roster.studentNumber")}</Label> | ||
| 138 | + <Input | ||
| 139 | + id="create-user-student-number" | ||
| 140 | + class="h-10 rounded-lg" | ||
| 141 | + maxlength={userLimits()?.max_student_number_len} | ||
| 142 | + autocomplete="off" | ||
| 143 | + value={studentNumber()} | ||
| 144 | + onInput={(e) => setStudentNumber(e.currentTarget.value)} | ||
| 145 | + /> | ||
| 146 | + <p class="text-xs text-muted-foreground">{t("admin.studentNumberHint")}</p> | ||
| 147 | + </div> | ||
| 148 | + </Show> | ||
| 123 | <div class="flex flex-wrap items-center justify-end gap-2"> | 149 | <div class="flex flex-wrap items-center justify-end gap-2"> |
| 124 | <Button type="button" variant="outline" class="h-10 rounded-lg" onClick={close}> | 150 | <Button type="button" variant="outline" class="h-10 rounded-lg" onClick={close}> |
| 125 | {t("common.cancel")} | 151 | {t("common.cancel")} |
src/components/users/profile-form.tsxmodified+27 -0
| @@ -54,6 +54,14 @@ export function ProfileForm(props: { | |||
| 54 | branches?: string[]; | 54 | branches?: string[]; |
| 55 | maxDisplayNameLen?: number; | 55 | maxDisplayNameLen?: number; |
| 56 | maxBioLen?: number; | 56 | maxBioLen?: number; |
| 57 | + /** | ||
| 58 | + * Offer the school-issued student number. It is the office's field, not the | ||
| 59 | + * account holder's, so only the admin surface passes this; it stays hidden | ||
| 60 | + * for anyone editing their own profile. Ignored for a non-student role, | ||
| 61 | + * which the server refuses a number for anyway. | ||
| 62 | + */ | ||
| 63 | + editStudentNumber?: boolean; | ||
| 64 | + maxStudentNumberLen?: number; | ||
| 57 | onSaved: () => void; | 65 | onSaved: () => void; |
| 58 | onSave?: (body: ProfileUpdate) => Promise<User>; | 66 | onSave?: (body: ProfileUpdate) => Promise<User>; |
| 59 | }) { | 67 | }) { |
| @@ -66,6 +74,8 @@ export function ProfileForm(props: { | |||
| 66 | const [displayName, setDisplayName] = createSignal(props.profile?.display_name ?? ""); | 74 | const [displayName, setDisplayName] = createSignal(props.profile?.display_name ?? ""); |
| 67 | const [bio, setBio] = createSignal(props.profile?.bio ?? ""); | 75 | const [bio, setBio] = createSignal(props.profile?.bio ?? ""); |
| 68 | const [branch, setBranch] = createSignal(props.profile?.branch ?? ""); | 76 | const [branch, setBranch] = createSignal(props.profile?.branch ?? ""); |
| 77 | + const [studentNumber, setStudentNumber] = createSignal(props.user.student_number ?? ""); | ||
| 78 | + const showStudentNumber = () => !!props.editStudentNumber && props.user.role === "student"; | ||
| 69 | // Branş is a teacher's field; a stored value outside the list still shows so | 79 | // Branş is a teacher's field; a stored value outside the list still shows so |
| 70 | // saving the form never silently drops it. | 80 | // saving the form never silently drops it. |
| 71 | const branchOptions = () => { | 81 | const branchOptions = () => { |
| @@ -100,6 +110,10 @@ export function ProfileForm(props: { | |||
| 100 | if (e !== (props.user.email ?? "")) b.email = e; | 110 | if (e !== (props.user.email ?? "")) b.email = e; |
| 101 | if (p !== (props.user.phone ?? "")) b.phone = p; | 111 | if (p !== (props.user.phone ?? "")) b.phone = p; |
| 102 | if (d !== (props.user.birth_date ?? "")) b.birth_date = d; | 112 | if (d !== (props.user.birth_date ?? "")) b.birth_date = d; |
| 113 | + // Blank clears it server-side, which is how the office un-numbers a student. | ||
| 114 | + if (showStudentNumber() && studentNumber().trim() !== (props.user.student_number ?? "")) { | ||
| 115 | + b.student_number = studentNumber().trim(); | ||
| 116 | + } | ||
| 103 | if (props.profile) { | 117 | if (props.profile) { |
| 104 | // An empty string clears the field server-side; an omitted key keeps it. | 118 | // An empty string clears the field server-side; an omitted key keeps it. |
| 105 | const dn = displayName().trim(); | 119 | const dn = displayName().trim(); |
| @@ -183,6 +197,19 @@ export function ProfileForm(props: { | |||
| 183 | </Select> | 197 | </Select> |
| 184 | </div> | 198 | </div> |
| 185 | </Show> | 199 | </Show> |
| 200 | + <Show when={showStudentNumber()}> | ||
| 201 | + <div class="space-y-1.5"> | ||
| 202 | + <Label for="pf-student-number">{t("roster.studentNumber")}</Label> | ||
| 203 | + <Input | ||
| 204 | + id="pf-student-number" | ||
| 205 | + class="h-10" | ||
| 206 | + maxlength={props.maxStudentNumberLen} | ||
| 207 | + value={studentNumber()} | ||
| 208 | + onInput={(e) => setStudentNumber(e.currentTarget.value)} | ||
| 209 | + /> | ||
| 210 | + <p class="text-xs text-muted-foreground">{t("admin.studentNumberHint")}</p> | ||
| 211 | + </div> | ||
| 212 | + </Show> | ||
| 186 | <div class="space-y-1.5"> | 213 | <div class="space-y-1.5"> |
| 187 | <Label for="pf-email">{t("profile.email")}</Label> | 214 | <Label for="pf-email">{t("profile.email")}</Label> |
| 188 | <Input id="pf-email" class="h-10" type="email" value={email()} onInput={(e) => setEmail(e.currentTarget.value)} /> | 215 | <Input id="pf-email" class="h-10" type="email" value={email()} onInput={(e) => setEmail(e.currentTarget.value)} /> |
src/components/users/student-directory-columns.tsxadded+35 -0
| @@ -0,0 +1,35 @@ | |||
| 1 | +import type { ColumnDef } from "@tanstack/solid-table"; | ||
| 2 | +import type { StudentDirectoryRow } from "@/lib/student-directory"; | ||
| 3 | +import type { useT } from "@/stores/preferences-context"; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * The three identifying columns every teacher-facing tracking table opens with — | ||
| 7 | + * student number, name, class — so Yoklamalar, Sınav Notları and Pomodorolar | ||
| 8 | + * read the same row the same way. Each page appends its own columns after these. | ||
| 9 | + */ | ||
| 10 | +export function studentDirectoryColumns(t: ReturnType<typeof useT>): ColumnDef<StudentDirectoryRow>[] { | ||
| 11 | + return [ | ||
| 12 | + { | ||
| 13 | + id: "studentNumber", | ||
| 14 | + // Sorts as text: the backend stores a free-text number, not an integer. | ||
| 15 | + accessorFn: (row) => row.person.student_number ?? "", | ||
| 16 | + header: t("roster.studentNumber"), | ||
| 17 | + meta: { headerClass: "w-32 min-w-32 whitespace-nowrap" }, | ||
| 18 | + cell: (cell) => ( | ||
| 19 | + <span class="tabular-nums text-muted-foreground">{cell.row.original.person.student_number || "—"}</span> | ||
| 20 | + ), | ||
| 21 | + }, | ||
| 22 | + { | ||
| 23 | + id: "student", | ||
| 24 | + accessorFn: (row) => row.person.display_name || row.person.username, | ||
| 25 | + header: t("roster.name"), | ||
| 26 | + cell: (cell) => <span class="font-medium">{cell.row.original.person.display_name || t("exams.nameless")}</span>, | ||
| 27 | + }, | ||
| 28 | + { | ||
| 29 | + id: "class", | ||
| 30 | + accessorFn: (row) => row.classes.map((cls) => cls.name).join(", "), | ||
| 31 | + header: t("roster.studentClass"), | ||
| 32 | + cell: (cell) => <span>{cell.row.original.classes.map((cls) => cls.name).join(", ") || "—"}</span>, | ||
| 33 | + }, | ||
| 34 | + ]; | ||
| 35 | +} | ||
src/i18n/locales/en.tsmodified+11 -5
| @@ -37,8 +37,10 @@ export const en: Dict = { | |||
| 37 | "ai.noChats": "No chats yet. Start one and it will appear here.", | 37 | "ai.noChats": "No chats yet. Start one and it will appear here.", |
| 38 | "ai.searchCount": "{current} / {total}", | 38 | "ai.searchCount": "{current} / {total}", |
| 39 | "ai.noSearchResults": "No messages match your search.", | 39 | "ai.noSearchResults": "No messages match your search.", |
| 40 | - "aiHub.description": "Every AI surface in one place: note outputs and podcasts, student analysis, and Çelebi.", | ||
| 41 | "aiHub.tab.studio": "Note studio", | 40 | "aiHub.tab.studio": "Note studio", |
| 41 | + "aiStudio.heading": "Turn one course note into a summary or a podcast", | ||
| 42 | + "aiStudio.pickPrompt": "Pick a course note", | ||
| 43 | + "aiStudio.pickPromptHint": "Pick a course note above; its summary and podcast producers open here.", | ||
| 42 | "aiHub.tab.insights": "Analysis", | 44 | "aiHub.tab.insights": "Analysis", |
| 43 | // Çelebi's intent engine only understands Turkish: the same English wording | 45 | // Çelebi's intent engine only understands Turkish: the same English wording |
| 44 | // comes back as "please rephrase" from the live assistant, so the examples | 46 | // comes back as "please rephrase" from the live assistant, so the examples |
| @@ -385,9 +387,9 @@ export const en: Dict = { | |||
| 385 | "nav.work": "Shift", | 387 | "nav.work": "Shift", |
| 386 | "nav.staffWork": "Staff work logs", | 388 | "nav.staffWork": "Staff work logs", |
| 387 | "nav.users": "Users & roles", | 389 | "nav.users": "Users & roles", |
| 388 | - "nav.studentMarks": "Student marks", | 390 | + "nav.studentMarks": "Exam marks", |
| 389 | "nav.studentAttendance": "Attendance", | 391 | "nav.studentAttendance": "Attendance", |
| 390 | - "nav.studentPomodoro": "Student pomodoros", | 392 | + "nav.studentPomodoro": "Pomodoros", |
| 391 | "nav.settings": "Settings", | 393 | "nav.settings": "Settings", |
| 392 | "nav.terms": "Terms", | 394 | "nav.terms": "Terms", |
| 393 | "nav.guide": "Guide", | 395 | "nav.guide": "Guide", |
| @@ -474,7 +476,10 @@ export const en: Dict = { | |||
| 474 | "comingSoon.emptyTitle": "Not available yet", | 476 | "comingSoon.emptyTitle": "Not available yet", |
| 475 | "comingSoon.emptyDescription": "This part of Hezarfen is still being built. Check back soon.", | 477 | "comingSoon.emptyDescription": "This part of Hezarfen is still being built. Check back soon.", |
| 476 | "roster.student": "Student", | 478 | "roster.student": "Student", |
| 479 | + "roster.studentNumber": "Student no", | ||
| 477 | "roster.studentName": "Student name", | 480 | "roster.studentName": "Student name", |
| 481 | + "roster.name": "Name", | ||
| 482 | + "roster.studentClass": "Class", | ||
| 478 | "roster.teacher": "Teacher", | 483 | "roster.teacher": "Teacher", |
| 479 | "roster.class": "Class", | 484 | "roster.class": "Class", |
| 480 | "roster.classAll": "Class: All", | 485 | "roster.classAll": "Class: All", |
| @@ -703,7 +708,6 @@ export const en: Dict = { | |||
| 703 | "aiStudio.library.emptyHint": "Create a summary or podcast for a lesson note to add it to this area.", | 708 | "aiStudio.library.emptyHint": "Create a summary or podcast for a lesson note to add it to this area.", |
| 704 | "aiStudio.library.summary": "AI summary", | 709 | "aiStudio.library.summary": "AI summary", |
| 705 | "aiStudio.library.podcastCount": "{count} podcasts", | 710 | "aiStudio.library.podcastCount": "{count} podcasts", |
| 706 | - "aiStudio.library.open": "Open note", | ||
| 707 | "today.titleStudent": "Today's lessons", | 711 | "today.titleStudent": "Today's lessons", |
| 708 | "today.inProgress": "On now", | 712 | "today.inProgress": "On now", |
| 709 | "childHomework.title": "Homework", | 713 | "childHomework.title": "Homework", |
| @@ -1012,6 +1016,8 @@ export const en: Dict = { | |||
| 1012 | "podcast.noNotes": "No lesson notes are available.", | 1016 | "podcast.noNotes": "No lesson notes are available.", |
| 1013 | "podcast.noNotesHint": "Add a note to one of your courses before creating audio.", | 1017 | "podcast.noNotesHint": "Add a note to one of your courses before creating audio.", |
| 1014 | "podcast.format": "Narration style", | 1018 | "podcast.format": "Narration style", |
| 1019 | + "podcast.stageLabel": "Stage:", | ||
| 1020 | + "podcast.etaHint": "Estimated time: about {secs}s", | ||
| 1015 | "podcast.format.duz_okuma": "Straight reading", | 1021 | "podcast.format.duz_okuma": "Straight reading", |
| 1016 | "podcast.format.tek_ogretici": "Single instructor", | 1022 | "podcast.format.tek_ogretici": "Single instructor", |
| 1017 | "podcast.format.ogrenci_hoca": "Student and teacher", | 1023 | "podcast.format.ogrenci_hoca": "Student and teacher", |
| @@ -1106,7 +1112,6 @@ export const en: Dict = { | |||
| 1106 | "insights.analysis.onTime": "On time", | 1112 | "insights.analysis.onTime": "On time", |
| 1107 | "insights.analysis.details": "What supports this analysis?", | 1113 | "insights.analysis.details": "What supports this analysis?", |
| 1108 | "insights.analysis.detailsHint": "Explore comparisons, trends and the limits of the available data.", | 1114 | "insights.analysis.detailsHint": "Explore comparisons, trends and the limits of the available data.", |
| 1109 | - "insights.analysis.detailsAction": "Explore", | ||
| 1110 | "insights.runs": "Analysis runs", | 1115 | "insights.runs": "Analysis runs", |
| 1111 | "insights.runsSubtitle": "Nightly and manually queued school analyses.", | 1116 | "insights.runsSubtitle": "Nightly and manually queued school analyses.", |
| 1112 | "insights.runDay": "Run day", | 1117 | "insights.runDay": "Run day", |
| @@ -1547,6 +1552,7 @@ export const en: Dict = { | |||
| 1547 | "admin.createUserHint": "Open an account directly — no invite or self-registration.", | 1552 | "admin.createUserHint": "Open an account directly — no invite or self-registration.", |
| 1548 | "admin.createUserPassword": "Password", | 1553 | "admin.createUserPassword": "Password", |
| 1549 | "admin.createUserPasswordHint": "If this username already exists at another school, enter that account's current password to add it here.", | 1554 | "admin.createUserPasswordHint": "If this username already exists at another school, enter that account's current password to add it here.", |
| 1555 | + "admin.studentNumberHint": "The school-issued student number, unique inside the school. May be left blank.", | ||
| 1550 | "admin.createUserReserved": "This username is reserved. Pick another one.", | 1556 | "admin.createUserReserved": "This username is reserved. Pick another one.", |
| 1551 | "admin.createUserDone": "Account {username} created.", | 1557 | "admin.createUserDone": "Account {username} created.", |
| 1552 | "admin.username": "Username", | 1558 | "admin.username": "Username", |
src/i18n/locales/tr.tsmodified+12 -6
| @@ -37,8 +37,10 @@ export const tr: Dict = { | |||
| 37 | "ai.noChats": "Henüz sohbet yok. Başlattığın sohbetler burada görünür.", | 37 | "ai.noChats": "Henüz sohbet yok. Başlattığın sohbetler burada görünür.", |
| 38 | "ai.searchCount": "{current} / {total}", | 38 | "ai.searchCount": "{current} / {total}", |
| 39 | "ai.noSearchResults": "Aramanla eşleşen mesaj yok.", | 39 | "ai.noSearchResults": "Aramanla eşleşen mesaj yok.", |
| 40 | - "aiHub.description": "Tüm yapay zekâ araçları tek yerde: not çıktıları ve podcast, öğrenci analizi ve Çelebi.", | ||
| 41 | "aiHub.tab.studio": "Not Stüdyosu", | 40 | "aiHub.tab.studio": "Not Stüdyosu", |
| 41 | + "aiStudio.heading": "Bir ders notundan özet ve podcast üret", | ||
| 42 | + "aiStudio.pickPrompt": "Bir ders notu seç", | ||
| 43 | + "aiStudio.pickPromptHint": "Yukarıdaki listeden bir ders notu seç; özet ve podcast üretimi burada açılır.", | ||
| 42 | "aiHub.tab.insights": "Analiz", | 44 | "aiHub.tab.insights": "Analiz", |
| 43 | "aiHub.celebiExample.student1": "Bu hafta hangi ödevlerin teslimi var?", | 45 | "aiHub.celebiExample.student1": "Bu hafta hangi ödevlerin teslimi var?", |
| 44 | "aiHub.celebiExample.student2": "Sınıfım kaç gün devamsızlık yaptı?", | 46 | "aiHub.celebiExample.student2": "Sınıfım kaç gün devamsızlık yaptı?", |
| @@ -381,9 +383,9 @@ export const tr: Dict = { | |||
| 381 | "nav.work": "Mesai", | 383 | "nav.work": "Mesai", |
| 382 | "nav.staffWork": "Personel mesaisi", | 384 | "nav.staffWork": "Personel mesaisi", |
| 383 | "nav.users": "Kullanıcılar ve roller", | 385 | "nav.users": "Kullanıcılar ve roller", |
| 384 | - "nav.studentMarks": "Öğrenci notları", | 386 | + "nav.studentMarks": "Sınav Notları", |
| 385 | - "nav.studentAttendance": "Yoklama", | 387 | + "nav.studentAttendance": "Yoklamalar", |
| 386 | - "nav.studentPomodoro": "Öğrenci pomodoroları", | 388 | + "nav.studentPomodoro": "Pomodorolar", |
| 387 | "nav.settings": "Ayarlar", | 389 | "nav.settings": "Ayarlar", |
| 388 | "nav.terms": "Dönemler", | 390 | "nav.terms": "Dönemler", |
| 389 | "nav.guide": "Rehber", | 391 | "nav.guide": "Rehber", |
| @@ -470,7 +472,10 @@ export const tr: Dict = { | |||
| 470 | "comingSoon.emptyTitle": "Henüz kullanıma açık değil", | 472 | "comingSoon.emptyTitle": "Henüz kullanıma açık değil", |
| 471 | "comingSoon.emptyDescription": "Hezarfen'in bu bölümü hâlâ hazırlanıyor. Yakında tekrar bakın.", | 473 | "comingSoon.emptyDescription": "Hezarfen'in bu bölümü hâlâ hazırlanıyor. Yakında tekrar bakın.", |
| 472 | "roster.student": "Öğrenci", | 474 | "roster.student": "Öğrenci", |
| 475 | + "roster.studentNumber": "Öğrenci No", | ||
| 473 | "roster.studentName": "Öğrenci Adı Soyadı", | 476 | "roster.studentName": "Öğrenci Adı Soyadı", |
| 477 | + "roster.name": "Adı", | ||
| 478 | + "roster.studentClass": "Sınıfı", | ||
| 474 | "roster.teacher": "Öğretmen", | 479 | "roster.teacher": "Öğretmen", |
| 475 | "roster.class": "Sınıf", | 480 | "roster.class": "Sınıf", |
| 476 | "roster.classAll": "Sınıf: Tümü", | 481 | "roster.classAll": "Sınıf: Tümü", |
| @@ -699,7 +704,6 @@ export const tr: Dict = { | |||
| 699 | "aiStudio.library.emptyHint": "Bu alana eklemek için bir ders notundan özet veya podcast oluştur.", | 704 | "aiStudio.library.emptyHint": "Bu alana eklemek için bir ders notundan özet veya podcast oluştur.", |
| 700 | "aiStudio.library.summary": "Yapay zekâ özeti", | 705 | "aiStudio.library.summary": "Yapay zekâ özeti", |
| 701 | "aiStudio.library.podcastCount": "{count} podcast", | 706 | "aiStudio.library.podcastCount": "{count} podcast", |
| 702 | - "aiStudio.library.open": "Nota git", | ||
| 703 | "today.titleStudent": "Bugünkü derslerin", | 707 | "today.titleStudent": "Bugünkü derslerin", |
| 704 | "today.inProgress": "Şimdi", | 708 | "today.inProgress": "Şimdi", |
| 705 | "childHomework.title": "Ödevler", | 709 | "childHomework.title": "Ödevler", |
| @@ -1008,6 +1012,8 @@ export const tr: Dict = { | |||
| 1008 | "podcast.noNotes": "Kullanılabilir ders notu yok.", | 1012 | "podcast.noNotes": "Kullanılabilir ders notu yok.", |
| 1009 | "podcast.noNotesHint": "Ses oluşturmadan önce derslerinizden birine not ekleyin.", | 1013 | "podcast.noNotesHint": "Ses oluşturmadan önce derslerinizden birine not ekleyin.", |
| 1010 | "podcast.format": "Anlatım biçimi", | 1014 | "podcast.format": "Anlatım biçimi", |
| 1015 | + "podcast.stageLabel": "Aşama:", | ||
| 1016 | + "podcast.etaHint": "Tahmini süre: yaklaşık {secs} sn", | ||
| 1011 | "podcast.format.duz_okuma": "Düz okuma", | 1017 | "podcast.format.duz_okuma": "Düz okuma", |
| 1012 | "podcast.format.tek_ogretici": "Tek öğretici", | 1018 | "podcast.format.tek_ogretici": "Tek öğretici", |
| 1013 | "podcast.format.ogrenci_hoca": "Öğrenci ve öğretmen", | 1019 | "podcast.format.ogrenci_hoca": "Öğrenci ve öğretmen", |
| @@ -1102,7 +1108,6 @@ export const tr: Dict = { | |||
| 1102 | "insights.analysis.onTime": "Zamanında", | 1108 | "insights.analysis.onTime": "Zamanında", |
| 1103 | "insights.analysis.details": "Bu analizin dayanağı ne?", | 1109 | "insights.analysis.details": "Bu analizin dayanağı ne?", |
| 1104 | "insights.analysis.detailsHint": "Karşılaştırmaları, eğilimleri ve mevcut verinin sınırlarını keşfet.", | 1110 | "insights.analysis.detailsHint": "Karşılaştırmaları, eğilimleri ve mevcut verinin sınırlarını keşfet.", |
| 1105 | - "insights.analysis.detailsAction": "İncele", | ||
| 1106 | "insights.runs": "Analiz çalıştırmaları", | 1111 | "insights.runs": "Analiz çalıştırmaları", |
| 1107 | "insights.runsSubtitle": "Gece çalışan ve elle sıraya alınan okul analizleri.", | 1112 | "insights.runsSubtitle": "Gece çalışan ve elle sıraya alınan okul analizleri.", |
| 1108 | "insights.runDay": "Çalışma günü", | 1113 | "insights.runDay": "Çalışma günü", |
| @@ -1543,6 +1548,7 @@ export const tr: Dict = { | |||
| 1543 | "admin.createUserHint": "Davet veya kendi kaydı olmadan doğrudan hesap açın.", | 1548 | "admin.createUserHint": "Davet veya kendi kaydı olmadan doğrudan hesap açın.", |
| 1544 | "admin.createUserPassword": "Şifre", | 1549 | "admin.createUserPassword": "Şifre", |
| 1545 | "admin.createUserPasswordHint": "Bu kullanıcı adı başka bir okulda zaten varsa, o hesabın mevcut şifresini girin; hesap bu okula da eklenir.", | 1550 | "admin.createUserPasswordHint": "Bu kullanıcı adı başka bir okulda zaten varsa, o hesabın mevcut şifresini girin; hesap bu okula da eklenir.", |
| 1551 | + "admin.studentNumberHint": "Okulun verdiği öğrenci numarası; okul içinde benzersizdir. Boş bırakılabilir.", | ||
| 1546 | "admin.createUserReserved": "Bu kullanıcı adı ayrılmış. Başka bir ad seçin.", | 1552 | "admin.createUserReserved": "Bu kullanıcı adı ayrılmış. Başka bir ad seçin.", |
| 1547 | "admin.createUserDone": "{username} hesabı oluşturuldu.", | 1553 | "admin.createUserDone": "{username} hesabı oluşturuldu.", |
| 1548 | "admin.username": "Kullanıcı adı", | 1554 | "admin.username": "Kullanıcı adı", |
src/i18n/messages.tsmodified+9 -3
| @@ -33,7 +33,6 @@ export type MessageKey = | |||
| 33 | | "ai.noChats" | 33 | | "ai.noChats" |
| 34 | | "ai.searchCount" | 34 | | "ai.searchCount" |
| 35 | | "ai.noSearchResults" | 35 | | "ai.noSearchResults" |
| 36 | - | "aiHub.description" | ||
| 37 | | "aiHub.tab.studio" | 36 | | "aiHub.tab.studio" |
| 38 | | "aiHub.tab.insights" | 37 | | "aiHub.tab.insights" |
| 39 | | "aiHub.celebiExample.student1" | 38 | | "aiHub.celebiExample.student1" |
| @@ -442,7 +441,10 @@ export type MessageKey = | |||
| 442 | | "comingSoon.emptyTitle" | 441 | | "comingSoon.emptyTitle" |
| 443 | | "comingSoon.emptyDescription" | 442 | | "comingSoon.emptyDescription" |
| 444 | | "roster.student" | 443 | | "roster.student" |
| 444 | + | "roster.studentNumber" | ||
| 445 | | "roster.studentName" | 445 | | "roster.studentName" |
| 446 | + | "roster.name" | ||
| 447 | + | "roster.studentClass" | ||
| 446 | | "roster.teacher" | 448 | | "roster.teacher" |
| 447 | | "roster.class" | 449 | | "roster.class" |
| 448 | | "roster.classAll" | 450 | | "roster.classAll" |
| @@ -690,7 +692,9 @@ export type MessageKey = | |||
| 690 | | "aiStudio.library.emptyHint" | 692 | | "aiStudio.library.emptyHint" |
| 691 | | "aiStudio.library.summary" | 693 | | "aiStudio.library.summary" |
| 692 | | "aiStudio.library.podcastCount" | 694 | | "aiStudio.library.podcastCount" |
| 693 | - | "aiStudio.library.open" | 695 | + | "aiStudio.heading" |
| 696 | + | "aiStudio.pickPrompt" | ||
| 697 | + | "aiStudio.pickPromptHint" | ||
| 694 | | "today.titleStudent" | 698 | | "today.titleStudent" |
| 695 | | "today.inProgress" | 699 | | "today.inProgress" |
| 696 | | "childHomework.title" | 700 | | "childHomework.title" |
| @@ -999,6 +1003,8 @@ export type MessageKey = | |||
| 999 | | "podcast.noNotes" | 1003 | | "podcast.noNotes" |
| 1000 | | "podcast.noNotesHint" | 1004 | | "podcast.noNotesHint" |
| 1001 | | "podcast.format" | 1005 | | "podcast.format" |
| 1006 | + | "podcast.stageLabel" | ||
| 1007 | + | "podcast.etaHint" | ||
| 1002 | | "podcast.format.duz_okuma" | 1008 | | "podcast.format.duz_okuma" |
| 1003 | | "podcast.format.tek_ogretici" | 1009 | | "podcast.format.tek_ogretici" |
| 1004 | | "podcast.format.ogrenci_hoca" | 1010 | | "podcast.format.ogrenci_hoca" |
| @@ -1093,7 +1099,6 @@ export type MessageKey = | |||
| 1093 | | "insights.analysis.onTime" | 1099 | | "insights.analysis.onTime" |
| 1094 | | "insights.analysis.details" | 1100 | | "insights.analysis.details" |
| 1095 | | "insights.analysis.detailsHint" | 1101 | | "insights.analysis.detailsHint" |
| 1096 | - | "insights.analysis.detailsAction" | ||
| 1097 | | "insights.runs" | 1102 | | "insights.runs" |
| 1098 | | "insights.runsSubtitle" | 1103 | | "insights.runsSubtitle" |
| 1099 | | "insights.runDay" | 1104 | | "insights.runDay" |
| @@ -1445,6 +1450,7 @@ export type MessageKey = | |||
| 1445 | | "admin.createUserHint" | 1450 | | "admin.createUserHint" |
| 1446 | | "admin.createUserPassword" | 1451 | | "admin.createUserPassword" |
| 1447 | | "admin.createUserPasswordHint" | 1452 | | "admin.createUserPasswordHint" |
| 1453 | + | "admin.studentNumberHint" | ||
| 1448 | | "admin.createUserReserved" | 1454 | | "admin.createUserReserved" |
| 1449 | | "admin.createUserDone" | 1455 | | "admin.createUserDone" |
| 1450 | | "admin.username" | 1456 | | "admin.username" |
src/pages/admin-user-detail-page.tsxmodified+7 -0
| @@ -1,6 +1,7 @@ | |||
| 1 | import { Link, useLocation, useParams } from "@tanstack/solid-router"; | 1 | import { Link, useLocation, useParams } from "@tanstack/solid-router"; |
| 2 | import { Show, Suspense, createEffect, createMemo, createSignal } from "solid-js"; | 2 | import { Show, Suspense, createEffect, createMemo, createSignal } from "solid-js"; |
| 3 | import { createResource } from "@/lib/create-resource"; | 3 | import { createResource } from "@/lib/create-resource"; |
| 4 | +import { getLimits } from "@/api/limits"; | ||
| 4 | import { getSettings } from "@/api/settings"; | 5 | import { getSettings } from "@/api/settings"; |
| 5 | import { getUserById, getUserProfile, patchUserProfile, patchUserRole } from "@/api/users"; | 6 | import { getUserById, getUserProfile, patchUserProfile, patchUserRole } from "@/api/users"; |
| 6 | import { formatApiError, type Role } from "@/api/client"; | 7 | import { formatApiError, type Role } from "@/api/client"; |
| @@ -43,6 +44,7 @@ function AdminUserDetailContent() { | |||
| 43 | // Branş (and display name/bio) live only on the profile read, not on User. | 44 | // Branş (and display name/bio) live only on the profile read, not on User. |
| 44 | const [profile, { refetch: refetchProfile }] = createResource(id, (userId) => getUserProfile(userId).catch(() => null)); | 45 | const [profile, { refetch: refetchProfile }] = createResource(id, (userId) => getUserProfile(userId).catch(() => null)); |
| 45 | const [settings] = createResource(() => getSettings().catch(() => null)); | 46 | const [settings] = createResource(() => getSettings().catch(() => null)); |
| 47 | + const [limits] = createResource(() => getLimits().catch(() => null)); | ||
| 46 | const [editing, setEditing] = createSignal(false); | 48 | const [editing, setEditing] = createSignal(false); |
| 47 | const [studentsOpen, setStudentsOpen] = createSignal(false); | 49 | const [studentsOpen, setStudentsOpen] = createSignal(false); |
| 48 | const [pendingRole, setPendingRole] = createSignal<Role>("student"); | 50 | const [pendingRole, setPendingRole] = createSignal<Role>("student"); |
| @@ -107,6 +109,9 @@ function AdminUserDetailContent() { | |||
| 107 | <DetailField label={t("profile.email")} value={current().email || "—"} /> | 109 | <DetailField label={t("profile.email")} value={current().email || "—"} /> |
| 108 | <DetailField label={t("profile.phone")} value={current().phone || "—"} /> | 110 | <DetailField label={t("profile.phone")} value={current().phone || "—"} /> |
| 109 | <DetailField label={t("profile.birthDate")} value={current().birth_date || "—"} /> | 111 | <DetailField label={t("profile.birthDate")} value={current().birth_date || "—"} /> |
| 112 | + <Show when={current().role === "student"}> | ||
| 113 | + <DetailField label={t("roster.studentNumber")} value={current().student_number || "—"} /> | ||
| 114 | + </Show> | ||
| 110 | <Show when={hasMinRole(current().role, "teacher")}> | 115 | <Show when={hasMinRole(current().role, "teacher")}> |
| 111 | <DetailField label={t("profile.branch")} value={profile.latest?.branch || "—"} /> | 116 | <DetailField label={t("profile.branch")} value={profile.latest?.branch || "—"} /> |
| 112 | </Show> | 117 | </Show> |
| @@ -143,6 +148,8 @@ function AdminUserDetailContent() { | |||
| 143 | user={current()} | 148 | user={current()} |
| 144 | profile={profile.latest ? { display_name: profile.latest.display_name, bio: profile.latest.bio, branch: profile.latest.branch } : undefined} | 149 | profile={profile.latest ? { display_name: profile.latest.display_name, bio: profile.latest.bio, branch: profile.latest.branch } : undefined} |
| 145 | branches={settings.latest?.branches} | 150 | branches={settings.latest?.branches} |
| 151 | + editStudentNumber | ||
| 152 | + maxStudentNumberLen={limits.latest?.user.max_student_number_len} | ||
| 146 | onSave={(body) => patchUserProfile(current().id, body)} | 153 | onSave={(body) => patchUserProfile(current().id, body)} |
| 147 | onSaved={async () => { | 154 | onSaved={async () => { |
| 148 | setEditing(false); | 155 | setEditing(false); |
src/pages/student-attendance-page.tsxmodified+4 -14
| @@ -11,6 +11,7 @@ import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | |||
| 11 | import { ErrorAlert } from "@/components/ui/error-alert"; | 11 | import { ErrorAlert } from "@/components/ui/error-alert"; |
| 12 | import { IconEye } from "@/components/ui/icons"; | 12 | import { IconEye } from "@/components/ui/icons"; |
| 13 | import { SidePanel } from "@/components/ui/side-panel"; | 13 | import { SidePanel } from "@/components/ui/side-panel"; |
| 14 | +import { studentDirectoryColumns } from "@/components/users/student-directory-columns"; | ||
| 14 | import { TableRowActions } from "@/components/ui/table-row-actions"; | 15 | import { TableRowActions } from "@/components/ui/table-row-actions"; |
| 15 | import { matchesSearch } from "@/lib/search-text"; | 16 | import { matchesSearch } from "@/lib/search-text"; |
| 16 | import { personLabel } from "@/lib/person"; | 17 | import { personLabel } from "@/lib/person"; |
| @@ -62,20 +63,9 @@ function StudentAttendanceContent() { | |||
| 62 | const rows = () => list(); | 63 | const rows = () => list(); |
| 63 | const listLoading = () => list.loading; | 64 | const listLoading = () => list.loading; |
| 64 | const searchPerson = (row: StudentDirectoryRow, query: string) => | 65 | const searchPerson = (row: StudentDirectoryRow, query: string) => |
| 65 | - matchesSearch(query, row.person.display_name, ...row.classes.map((cls) => cls.name)); | 66 | + matchesSearch(query, row.person.display_name, row.person.student_number, ...row.classes.map((cls) => cls.name)); |
| 66 | const columns = createMemo<ColumnDef<StudentDirectoryRow>[]>(() => [ | 67 | const columns = createMemo<ColumnDef<StudentDirectoryRow>[]>(() => [ |
| 67 | - { | 68 | + ...studentDirectoryColumns(t), |
| 68 | - id: "student", | ||
| 69 | - accessorFn: (row) => row.person.display_name || row.person.username, | ||
| 70 | - header: t("roster.studentName"), | ||
| 71 | - cell: (cell) => <span class="font-medium">{cell.row.original.person.display_name || t("exams.nameless")}</span>, | ||
| 72 | - }, | ||
| 73 | - { | ||
| 74 | - id: "class", | ||
| 75 | - accessorFn: (row) => row.classes.map((cls) => cls.name).join(", "), | ||
| 76 | - header: t("roster.class"), | ||
| 77 | - cell: (cell) => <span>{cell.row.original.classes.map((cls) => cls.name).join(", ") || "—"}</span>, | ||
| 78 | - }, | ||
| 79 | { | 69 | { |
| 80 | id: "actions", | 70 | id: "actions", |
| 81 | header: t("common.actions"), | 71 | header: t("common.actions"), |
| @@ -108,7 +98,7 @@ function StudentAttendanceContent() { | |||
| 108 | <Alert variant="destructive">{error()}</Alert> | 98 | <Alert variant="destructive">{error()}</Alert> |
| 109 | </Show> | 99 | </Show> |
| 110 | 100 | ||
| 111 | - <Show when={!listLoading()} fallback={<DataTableSkeleton columns={3} rows={6} />}> | 101 | + <Show when={!listLoading()} fallback={<DataTableSkeleton columns={4} rows={6} />}> |
| 112 | <DataTable | 102 | <DataTable |
| 113 | title={t("nav.studentAttendance")} | 103 | title={t("nav.studentAttendance")} |
| 114 | description={t("attendance.lookup")} | 104 | description={t("attendance.lookup")} |
src/pages/student-marks-page.tsxmodified+4 -14
| @@ -13,6 +13,7 @@ import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | |||
| 13 | import { ErrorAlert } from "@/components/ui/error-alert"; | 13 | import { ErrorAlert } from "@/components/ui/error-alert"; |
| 14 | import { IconEye } from "@/components/ui/icons"; | 14 | import { IconEye } from "@/components/ui/icons"; |
| 15 | import { SidePanel } from "@/components/ui/side-panel"; | 15 | import { SidePanel } from "@/components/ui/side-panel"; |
| 16 | +import { studentDirectoryColumns } from "@/components/users/student-directory-columns"; | ||
| 16 | import { TableRowActions } from "@/components/ui/table-row-actions"; | 17 | import { TableRowActions } from "@/components/ui/table-row-actions"; |
| 17 | import { matchesSearch } from "@/lib/search-text"; | 18 | import { matchesSearch } from "@/lib/search-text"; |
| 18 | import { personLabel } from "@/lib/person"; | 19 | import { personLabel } from "@/lib/person"; |
| @@ -100,20 +101,9 @@ function StudentMarksContent() { | |||
| 100 | }; | 101 | }; |
| 101 | const listLoading = () => list.loading; | 102 | const listLoading = () => list.loading; |
| 102 | const searchPerson = (row: StudentDirectoryRow, query: string) => | 103 | const searchPerson = (row: StudentDirectoryRow, query: string) => |
| 103 | - matchesSearch(query, row.person.display_name, ...row.classes.map((cls) => cls.name)); | 104 | + matchesSearch(query, row.person.display_name, row.person.student_number, ...row.classes.map((cls) => cls.name)); |
| 104 | const columns = createMemo<ColumnDef<StudentDirectoryRow>[]>(() => [ | 105 | const columns = createMemo<ColumnDef<StudentDirectoryRow>[]>(() => [ |
| 105 | - { | 106 | + ...studentDirectoryColumns(t), |
| 106 | - id: "student", | ||
| 107 | - accessorFn: (row) => row.person.display_name || row.person.username, | ||
| 108 | - header: t("roster.studentName"), | ||
| 109 | - cell: (cell) => <span class="font-medium">{cell.row.original.person.display_name || t("exams.nameless")}</span>, | ||
| 110 | - }, | ||
| 111 | - { | ||
| 112 | - id: "class", | ||
| 113 | - accessorFn: (row) => row.classes.map((cls) => cls.name).join(", "), | ||
| 114 | - header: t("roster.class"), | ||
| 115 | - cell: (cell) => <span>{cell.row.original.classes.map((cls) => cls.name).join(", ") || "—"}</span>, | ||
| 116 | - }, | ||
| 117 | { | 107 | { |
| 118 | id: "average", | 108 | id: "average", |
| 119 | header: t("marks.overall"), | 109 | header: t("marks.overall"), |
| @@ -168,7 +158,7 @@ function StudentMarksContent() { | |||
| 168 | <Alert role="status">{t("marks.averageCapped", { cap: MARKS_FETCH_CAP })}</Alert> | 158 | <Alert role="status">{t("marks.averageCapped", { cap: MARKS_FETCH_CAP })}</Alert> |
| 169 | </Show> | 159 | </Show> |
| 170 | 160 | ||
| 171 | - <Show when={!listLoading()} fallback={<DataTableSkeleton columns={4} rows={6} />}> | 161 | + <Show when={!listLoading()} fallback={<DataTableSkeleton columns={5} rows={6} />}> |
| 172 | <DataTable | 162 | <DataTable |
| 173 | title={t("nav.studentMarks")} | 163 | title={t("nav.studentMarks")} |
| 174 | description={t("marks.lookup")} | 164 | description={t("marks.lookup")} |
src/pages/student-pomodoro-page.tsxmodified+4 -14
| @@ -11,6 +11,7 @@ import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | |||
| 11 | import { ErrorAlert } from "@/components/ui/error-alert"; | 11 | import { ErrorAlert } from "@/components/ui/error-alert"; |
| 12 | import { IconEye } from "@/components/ui/icons"; | 12 | import { IconEye } from "@/components/ui/icons"; |
| 13 | import { SidePanel } from "@/components/ui/side-panel"; | 13 | import { SidePanel } from "@/components/ui/side-panel"; |
| 14 | +import { studentDirectoryColumns } from "@/components/users/student-directory-columns"; | ||
| 14 | import { TableRowActions } from "@/components/ui/table-row-actions"; | 15 | import { TableRowActions } from "@/components/ui/table-row-actions"; |
| 15 | import { matchesSearch } from "@/lib/search-text"; | 16 | import { matchesSearch } from "@/lib/search-text"; |
| 16 | import { personLabel } from "@/lib/person"; | 17 | import { personLabel } from "@/lib/person"; |
| @@ -62,20 +63,9 @@ function StudentPomodoroContent() { | |||
| 62 | const rows = () => list(); | 63 | const rows = () => list(); |
| 63 | const listLoading = () => list.loading; | 64 | const listLoading = () => list.loading; |
| 64 | const searchPerson = (row: StudentDirectoryRow, query: string) => | 65 | const searchPerson = (row: StudentDirectoryRow, query: string) => |
| 65 | - matchesSearch(query, row.person.display_name, ...row.classes.map((cls) => cls.name)); | 66 | + matchesSearch(query, row.person.display_name, row.person.student_number, ...row.classes.map((cls) => cls.name)); |
| 66 | const studentColumns = createMemo<ColumnDef<StudentDirectoryRow>[]>(() => [ | 67 | const studentColumns = createMemo<ColumnDef<StudentDirectoryRow>[]>(() => [ |
| 67 | - { | 68 | + ...studentDirectoryColumns(t), |
| 68 | - id: "student", | ||
| 69 | - accessorFn: (row) => row.person.display_name || row.person.username, | ||
| 70 | - header: t("roster.studentName"), | ||
| 71 | - cell: (cell) => <span class="font-medium">{cell.row.original.person.display_name || t("exams.nameless")}</span>, | ||
| 72 | - }, | ||
| 73 | - { | ||
| 74 | - id: "class", | ||
| 75 | - accessorFn: (row) => row.classes.map((cls) => cls.name).join(", "), | ||
| 76 | - header: t("roster.class"), | ||
| 77 | - cell: (cell) => <span>{cell.row.original.classes.map((cls) => cls.name).join(", ") || "—"}</span>, | ||
| 78 | - }, | ||
| 79 | { | 69 | { |
| 80 | id: "actions", | 70 | id: "actions", |
| 81 | header: t("common.actions"), | 71 | header: t("common.actions"), |
| @@ -105,7 +95,7 @@ function StudentPomodoroContent() { | |||
| 105 | <Alert variant="destructive">{error()}</Alert> | 95 | <Alert variant="destructive">{error()}</Alert> |
| 106 | </Show> | 96 | </Show> |
| 107 | 97 | ||
| 108 | - <Show when={!listLoading()} fallback={<DataTableSkeleton columns={3} rows={6} />}> | 98 | + <Show when={!listLoading()} fallback={<DataTableSkeleton columns={4} rows={6} />}> |
| 109 | <DataTable | 99 | <DataTable |
| 110 | title={t("nav.studentPomodoro")} | 100 | title={t("nav.studentPomodoro")} |
| 111 | description={t("pomodoro.lookup")} | 101 | description={t("pomodoro.lookup")} |