🧠 gather every AI screen on one /ai hub
Browse files at this commit1f449db80212387bea61ee60dcad09b4e3234d03Parent: a43c7c3- feat
- 🧠 gather every AI screen on one /ai hub
30 changed files +2063 -50
- README.md +2 -1
- docs/ui/figma-migration-coverage.md +3 -1
- src/components/ai/celebi-launcher.tsx +38 -0
- src/components/ai/insights-board.tsx +291 -0
- src/components/ai/note-studio-panel.tsx +109 -0
- src/components/insights/insight-data-list.tsx +57 -0
- src/components/insights/insight-detail.tsx +228 -0
- src/components/insights/insight-runs-table.tsx +113 -0
- src/components/layout/app-shell.tsx +6 -6
- src/components/layout/celebi-composer.tsx +5 -1
- src/components/layout/celebi-panel.tsx +4 -3
- src/components/layout/nav-items.test.ts +32 -11
- src/components/layout/nav-items.ts +22 -13
- src/components/notes/note-reader-panel.tsx +2 -0
- src/components/notes/podcast-panel.test.tsx +53 -0
- src/components/notes/podcast-panel.tsx +217 -0
- src/components/notes/rag-output-content.tsx +54 -0
- src/components/notes/rag-outputs-panel.tsx +64 -4
- src/components/rag/rag-citations.tsx +44 -0
- src/components/rag/rag-composer.tsx +69 -0
- src/components/rag/rag-copy.ts +72 -0
- src/components/rag/rag-message-row.tsx +69 -0
- src/components/rag/rag-thread-list.tsx +87 -0
- src/i18n/messages.ts +285 -3
- src/lib/note-source.ts +3 -1
- src/pages/ai-hub-page.tsx +86 -0
- src/pages/coming-soon-page.tsx +0 -2
- src/routes/router.tsx +30 -2
- src/stores/celebi-panel.ts +13 -0
- vitest.config.ts +5 -2
README.mdmodified+2 -1
| @@ -51,7 +51,7 @@ bun run build | |||
| 51 | 51 | ||
| 52 | Open [http://localhost:5173](http://localhost:5173) in your browser. | 52 | Open [http://localhost:5173](http://localhost:5173) in your browser. |
| 53 | 53 | ||
| 54 | -> **Proxy Note**: Vite server and the production Bun server proxy `/api/*` and WebSocket connections to `BACKEND_ORIGIN` (default: `http://127.0.0.1:7656`, the co-located backend's loopback port), preserving HttpOnly session cookies across same-origin calls. Point it elsewhere with `BACKEND_ORIGIN=… bun run dev`, or with `BACKEND_ORIGIN` in `hezarfen_frontend.env` for the compose stack (see "Run in a container" below). | 54 | +> **Proxy Note**: Vite proxies `/api/*` and WebSocket connections to `BACKEND_ORIGIN`, preserving HttpOnly session cookies across same-origin calls. Local development defaults to `https://hezarfen-backend.dizey.sh`, so `bun run dev` works without a backend process on the laptop; use `BACKEND_ORIGIN=http://127.0.0.1:7656 bun run dev` to target one locally. The production Bun server gets its co-located loopback default from the image and can be overridden through `hezarfen_frontend.env` (see "Run in a container" below). |
| 55 | 55 | ||
| 56 | --- | 56 | --- |
| 57 | 57 | ||
| @@ -106,6 +106,7 @@ It needs three repository secrets — `SSH_PRIVATE_KEY`, `SSH_HOST`, `SSH_USER`, | |||
| 106 | | `/guide` | Authenticated | Redesigned product guide featuring role scope matrix, 6 core feature cards, and pro tips. | | 106 | | `/guide` | Authenticated | Redesigned product guide featuring role scope matrix, 6 core feature cards, and pro tips. | |
| 107 | | `/profile` | Authenticated | User profile management (display name, email, phone, birth date). | | 107 | | `/profile` | Authenticated | User profile management (display name, email, phone, birth date). | |
| 108 | | `/notes` | Student+ | Personal notebook with paper-style cards, Note Import Assistant (PDF/TXT), reader drawer, file attachments, and `.hzdraw` live canvas. | | 108 | | `/notes` | Student+ | Personal notebook with paper-style cards, Note Import Assistant (PDF/TXT), reader drawer, file attachments, and `.hzdraw` live canvas. | |
| 109 | +| `/ai` | Authenticated | AI hub: the note studio (course-note AI outputs plus narrated podcast audio with live job progress, cancellation and playback), the ZEKA analysis board, and the Çelebi entry point. `/sound-studio` redirects to its note-studio tab. | | ||
| 109 | | `/questions`, `/questions/:id` | Student+ | Community Question Bank with solution authoring and teacher verification. | | 110 | | `/questions`, `/questions/:id` | Student+ | Community Question Bank with solution authoring and teacher verification. | |
| 110 | | `/courses`, `/courses/:id` | Student+ | Course catalog, student enrollment, curriculum subjects, homework assignments, and lesson session roll call. | | 111 | | `/courses`, `/courses/:id` | Student+ | Course catalog, student enrollment, curriculum subjects, homework assignments, and lesson session roll call. | |
| 111 | | `/exams`, `/exams/:id` | Student+ | Exam list and details, subject-tagged questions, draft/publish controls, and grading statistics. | | 112 | | `/exams`, `/exams/:id` | Student+ | Exam list and details, subject-tagged questions, draft/publish controls, and grading statistics. | |
docs/ui/figma-migration-coverage.mdmodified+3 -1
| @@ -140,7 +140,9 @@ false actions: | |||
| 140 | 140 | ||
| 141 | - AI recommendation approval queue, evidence history, and rule management. | 141 | - AI recommendation approval queue, evidence history, and rule management. |
| 142 | - AI question generation and institution-level competency analytics. | 142 | - AI question generation and institution-level competency analytics. |
| 143 | -- Ses Atölyesi audio generation, player, quality gate, and listening analytics. | 143 | +- Ses Atölyesi quality gate and listening analytics. Course-note audio generation, |
| 144 | + job progress/cancellation, and the player are implemented on the `/ai` hub's | ||
| 145 | + note-studio tab (the old `/sound-studio` route redirects there). | ||
| 144 | - Student/parent teacher-approved study plans and mastery time series. | 146 | - Student/parent teacher-approved study plans and mastery time series. |
| 145 | - Institution selection and multi-institution session context. | 147 | - Institution selection and multi-institution session context. |
| 146 | - Password reset, remember-me session policy, and SSO. | 148 | - Password reset, remember-me session policy, and SSO. |
src/components/ai/celebi-launcher.tsxadded+38 -0
| @@ -0,0 +1,38 @@ | |||
| 1 | +import { For } from "solid-js"; | ||
| 2 | +import { Button } from "@/components/ui/button"; | ||
| 3 | +import { IconSparkles } from "@/components/ui/icons"; | ||
| 4 | +import { openCelebiPanel } from "@/stores/celebi-panel"; | ||
| 5 | +import { useT } from "@/stores/preferences-context"; | ||
| 6 | + | ||
| 7 | +// Çelebi itself is a shell panel — it follows the viewer across every route, | ||
| 8 | +// so the hub tab opens that one panel instead of mounting a second chat. | ||
| 9 | +export function CelebiLauncher() { | ||
| 10 | + const t = useT(); | ||
| 11 | + const examples = () => [t("aiHub.celebiExample1"), t("aiHub.celebiExample2"), t("aiHub.celebiExample3")]; | ||
| 12 | + | ||
| 13 | + return ( | ||
| 14 | + <section class="mx-auto flex max-w-3xl flex-col items-center gap-5 rounded-xl border border-dashed border-primary/25 bg-primary/[0.03] px-6 py-10 text-center"> | ||
| 15 | + <div class="flex h-12 w-12 items-center justify-center rounded-full bg-primary/10 text-primary"> | ||
| 16 | + <IconSparkles class="h-6 w-6" /> | ||
| 17 | + </div> | ||
| 18 | + <div class="space-y-1"> | ||
| 19 | + <p class="text-base font-semibold text-text-strong">{t("ai.title")}</p> | ||
| 20 | + <p class="text-sm text-muted-foreground">{t("ai.empty")}</p> | ||
| 21 | + </div> | ||
| 22 | + <ul class="grid w-full gap-2 text-left sm:grid-cols-3"> | ||
| 23 | + <For each={examples()}> | ||
| 24 | + {(example) => ( | ||
| 25 | + <li class="rounded-lg border border-border/70 bg-card/80 px-3 py-2 text-xs text-muted-foreground shadow-xs"> | ||
| 26 | + {example} | ||
| 27 | + </li> | ||
| 28 | + )} | ||
| 29 | + </For> | ||
| 30 | + </ul> | ||
| 31 | + <Button size="sm" class="min-w-[7.5rem] rounded-lg" onClick={openCelebiPanel}> | ||
| 32 | + <IconSparkles class="h-4 w-4" /> | ||
| 33 | + {t("ai.askCelebi")} | ||
| 34 | + </Button> | ||
| 35 | + <p class="text-xs text-muted-foreground">{t("aiHub.celebiHint")}</p> | ||
| 36 | + </section> | ||
| 37 | + ); | ||
| 38 | +} | ||
src/components/ai/insights-board.tsxadded+291 -0
| @@ -0,0 +1,291 @@ | |||
| 1 | +import { Show, Suspense, createMemo, createSignal } from "solid-js"; | ||
| 2 | +import { createResource } from "@/lib/create-resource"; | ||
| 3 | +import type { ColumnDef } from "@tanstack/solid-table"; | ||
| 4 | +import { | ||
| 5 | + getInsightByUserId, | ||
| 6 | + getInsightRuns, | ||
| 7 | + getMyInsight, | ||
| 8 | + postInsightComputeByUserId, | ||
| 9 | + postInsightsRefresh, | ||
| 10 | +} from "@/api/insights"; | ||
| 11 | +import { getMyStudents } from "@/api/parents"; | ||
| 12 | +import { getUserSearch } from "@/api/users"; | ||
| 13 | +import { formatApiError, type PersonRef, type Role } from "@/api/client"; | ||
| 14 | +import { InsightDetail } from "@/components/insights/insight-detail"; | ||
| 15 | +import { InsightRunsTable } from "@/components/insights/insight-runs-table"; | ||
| 16 | +import { RosterPersonCell } from "@/components/users/roster-person-cell"; | ||
| 17 | +import { Alert } from "@/components/ui/alert"; | ||
| 18 | +import { Button } from "@/components/ui/button"; | ||
| 19 | +import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | ||
| 20 | +import { ErrorAlert } from "@/components/ui/error-alert"; | ||
| 21 | +import { IconEye, IconRefresh, IconSparkles } from "@/components/ui/icons"; | ||
| 22 | +import { SidePanel } from "@/components/ui/side-panel"; | ||
| 23 | +import { TableRowActions } from "@/components/ui/table-row-actions"; | ||
| 24 | +import { createFlash } from "@/lib/flash"; | ||
| 25 | +import { matchesSearch } from "@/lib/search-text"; | ||
| 26 | +import { personLabel } from "@/lib/person"; | ||
| 27 | +import { hasMinRole } from "@/lib/roles"; | ||
| 28 | +import { useAuth } from "@/stores/auth-context"; | ||
| 29 | +import { usePreferences } from "@/stores/preferences-context"; | ||
| 30 | + | ||
| 31 | +const PAGE_SIZE = 10; | ||
| 32 | + | ||
| 33 | +/** Every insight surface in one board: the viewer's own analysis, the student | ||
| 34 | + * list they may browse, and the school-wide run log for managers. */ | ||
| 35 | +export function InsightsBoard() { | ||
| 36 | + const auth = useAuth(); | ||
| 37 | + const prefs = usePreferences(); | ||
| 38 | + const tx = (key: string, vars?: Record<string, string | number>) => prefs.t(key as never, vars); | ||
| 39 | + const role = () => auth.user()?.role; | ||
| 40 | + const canBrowseStudents = () => role() === "parent" || hasMinRole(role(), "teacher"); | ||
| 41 | + const canManageRuns = () => hasMinRole(role(), "manager"); | ||
| 42 | + const [selectedStudent, setSelectedStudent] = createSignal<PersonRef | null>(null); | ||
| 43 | + const [pageError, setPageError] = createSignal(""); | ||
| 44 | + const [panelError, setPanelError] = createSignal(""); | ||
| 45 | + const [refreshingAll, setRefreshingAll] = createSignal(false); | ||
| 46 | + const [computingStudent, setComputingStudent] = createSignal(false); | ||
| 47 | + const [, flash] = createFlash(); | ||
| 48 | + | ||
| 49 | + const [selfInsight, { refetch: refetchSelfInsight }] = createResource( | ||
| 50 | + () => auth.user()?.id ?? null, | ||
| 51 | + async () => getMyInsight(), | ||
| 52 | + ); | ||
| 53 | + const [students, { refetch: refetchStudents }] = createResource( | ||
| 54 | + () => (canBrowseStudents() ? role() : null), | ||
| 55 | + async (viewerRole: Role) => | ||
| 56 | + viewerRole === "parent" | ||
| 57 | + ? (await getMyStudents({ limit: 200 })).items | ||
| 58 | + : (await getUserSearch("", undefined, "student", { limit: 200 })).items, | ||
| 59 | + ); | ||
| 60 | + const [runs, { refetch: refetchRuns }] = createResource( | ||
| 61 | + () => (canManageRuns() ? true : null), | ||
| 62 | + async () => getInsightRuns({ limit: 100 }), | ||
| 63 | + ); | ||
| 64 | + const [insight, { mutate: mutateInsight, refetch: refetchInsight }] = createResource( | ||
| 65 | + () => selectedStudent()?.id ?? null, | ||
| 66 | + async (userId) => { | ||
| 67 | + if (!userId) return null; | ||
| 68 | + setPanelError(""); | ||
| 69 | + try { | ||
| 70 | + return await getInsightByUserId(userId); | ||
| 71 | + } catch (error) { | ||
| 72 | + setPanelError(formatApiError(error)); | ||
| 73 | + return null; | ||
| 74 | + } | ||
| 75 | + }, | ||
| 76 | + ); | ||
| 77 | + | ||
| 78 | + const refreshPage = async () => { | ||
| 79 | + setPageError(""); | ||
| 80 | + try { | ||
| 81 | + const tasks: Promise<unknown>[] = [Promise.resolve(refetchSelfInsight())]; | ||
| 82 | + if (canBrowseStudents()) tasks.push(Promise.resolve(refetchStudents())); | ||
| 83 | + if (canManageRuns()) tasks.push(Promise.resolve(refetchRuns())); | ||
| 84 | + await Promise.all(tasks); | ||
| 85 | + } catch (error) { | ||
| 86 | + setPageError(formatApiError(error)); | ||
| 87 | + } | ||
| 88 | + }; | ||
| 89 | + | ||
| 90 | + const queueSchoolRefresh = async () => { | ||
| 91 | + if (refreshingAll() || !canManageRuns()) return; | ||
| 92 | + setRefreshingAll(true); | ||
| 93 | + setPageError(""); | ||
| 94 | + try { | ||
| 95 | + await postInsightsRefresh(); | ||
| 96 | + flash(tx("insights.refreshQueued")); | ||
| 97 | + await refetchRuns(); | ||
| 98 | + } catch (error) { | ||
| 99 | + setPageError(formatApiError(error)); | ||
| 100 | + } finally { | ||
| 101 | + setRefreshingAll(false); | ||
| 102 | + } | ||
| 103 | + }; | ||
| 104 | + | ||
| 105 | + const queueStudentCompute = async () => { | ||
| 106 | + const student = selectedStudent(); | ||
| 107 | + if (!student || computingStudent()) return; | ||
| 108 | + setComputingStudent(true); | ||
| 109 | + setPanelError(""); | ||
| 110 | + try { | ||
| 111 | + await postInsightComputeByUserId(student.id); | ||
| 112 | + flash(tx("insights.recomputeQueued", { student: personLabel(student) })); | ||
| 113 | + } catch (error) { | ||
| 114 | + setPanelError(formatApiError(error)); | ||
| 115 | + } finally { | ||
| 116 | + setComputingStudent(false); | ||
| 117 | + } | ||
| 118 | + }; | ||
| 119 | + | ||
| 120 | + const openStudent = (student: PersonRef) => { | ||
| 121 | + setPanelError(""); | ||
| 122 | + mutateInsight(null); | ||
| 123 | + setSelectedStudent(student); | ||
| 124 | + }; | ||
| 125 | + | ||
| 126 | + const columns = createMemo<ColumnDef<PersonRef>[]>(() => [ | ||
| 127 | + { | ||
| 128 | + id: "student", | ||
| 129 | + header: tx("insights.student"), | ||
| 130 | + cell: (cell) => <RosterPersonCell person={cell.row.original} />, | ||
| 131 | + }, | ||
| 132 | + { | ||
| 133 | + id: "actions", | ||
| 134 | + header: tx("common.actions"), | ||
| 135 | + meta: { | ||
| 136 | + headerClass: "w-[110px] min-w-[110px] max-w-[110px] h-[45px] text-center whitespace-nowrap", | ||
| 137 | + cellClass: "w-[110px] min-w-[110px] max-w-[110px] h-[45px] text-center whitespace-nowrap", | ||
| 138 | + }, | ||
| 139 | + cell: (cell) => ( | ||
| 140 | + <TableRowActions | ||
| 141 | + label={tx("common.actions")} | ||
| 142 | + actions={[ | ||
| 143 | + { | ||
| 144 | + label: tx("insights.viewAnalysis"), | ||
| 145 | + icon: <IconEye class="h-4 w-4" />, | ||
| 146 | + onSelect: () => openStudent(cell.row.original), | ||
| 147 | + }, | ||
| 148 | + ]} | ||
| 149 | + /> | ||
| 150 | + ), | ||
| 151 | + }, | ||
| 152 | + ]); | ||
| 153 | + | ||
| 154 | + return ( | ||
| 155 | + <div class="space-y-5"> | ||
| 156 | + <Show when={pageError()}> | ||
| 157 | + <Alert variant="destructive">{pageError()}</Alert> | ||
| 158 | + </Show> | ||
| 159 | + | ||
| 160 | + <Show when={role() === "student"}> | ||
| 161 | + <section class="data-shell space-y-4 p-5"> | ||
| 162 | + <div class="flex flex-wrap items-start justify-between gap-3"> | ||
| 163 | + <div> | ||
| 164 | + <h2 class="text-base font-semibold text-text-strong">{tx("insights.myAnalysis")}</h2> | ||
| 165 | + <p class="mt-1 text-sm text-muted-foreground">{tx("insights.myAnalysisSubtitle")}</p> | ||
| 166 | + </div> | ||
| 167 | + <Button variant="outline" size="sm" class="rounded-lg" onClick={() => void refetchSelfInsight()}> | ||
| 168 | + <IconRefresh class="h-4 w-4" /> | ||
| 169 | + {tx("common.refresh")} | ||
| 170 | + </Button> | ||
| 171 | + </div> | ||
| 172 | + <Suspense fallback={<p class="py-8 text-center text-sm text-muted-foreground">{tx("common.loading")}</p>}> | ||
| 173 | + <Show when={selfInsight.error}> | ||
| 174 | + <ErrorAlert message={formatApiError(selfInsight.error)} onRetry={() => void refetchSelfInsight()} /> | ||
| 175 | + </Show> | ||
| 176 | + <Show when={!selfInsight.error && selfInsight()}> | ||
| 177 | + {(value) => <InsightDetail insight={value()} />} | ||
| 178 | + </Show> | ||
| 179 | + </Suspense> | ||
| 180 | + </section> | ||
| 181 | + </Show> | ||
| 182 | + | ||
| 183 | + <Suspense fallback={<Show when={role() === "teacher"}><p class="py-4 text-center text-sm text-muted-foreground">{tx("common.loading")}</p></Show>}> | ||
| 184 | + <Show when={role() === "teacher" && selfInsight()}> | ||
| 185 | + {(value) => ( | ||
| 186 | + <section class="data-shell space-y-4 p-5"> | ||
| 187 | + <div> | ||
| 188 | + <h2 class="text-base font-semibold text-text-strong">{tx("insights.myRecommendations")}</h2> | ||
| 189 | + <p class="mt-1 text-sm text-muted-foreground">{tx("insights.myRecommendationsSubtitle")}</p> | ||
| 190 | + </div> | ||
| 191 | + <InsightDetail insight={value()} mode="cards" /> | ||
| 192 | + </section> | ||
| 193 | + )} | ||
| 194 | + </Show> | ||
| 195 | + </Suspense> | ||
| 196 | + | ||
| 197 | + <Show when={canBrowseStudents()}> | ||
| 198 | + <section class="data-shell space-y-4 p-4"> | ||
| 199 | + <Suspense fallback={<DataTableSkeleton columns={2} rows={8} />}> | ||
| 200 | + <Show when={students.error}> | ||
| 201 | + <ErrorAlert message={formatApiError(students.error)} onRetry={() => void refetchStudents()} /> | ||
| 202 | + </Show> | ||
| 203 | + <Show when={!students.error}> | ||
| 204 | + <DataTable | ||
| 205 | + title={tx("insights.title")} | ||
| 206 | + description={role() === "parent" ? tx("insights.parentSubtitle") : tx("insights.subtitle")} | ||
| 207 | + actions={ | ||
| 208 | + <> | ||
| 209 | + <Button variant="outline" size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => void refreshPage()}> | ||
| 210 | + <IconRefresh class="h-4 w-4" /> | ||
| 211 | + {tx("common.refresh")} | ||
| 212 | + </Button> | ||
| 213 | + <Show when={canManageRuns()}> | ||
| 214 | + <Button | ||
| 215 | + size="sm" | ||
| 216 | + class="min-w-[7.5rem] rounded-lg" | ||
| 217 | + disabled={refreshingAll()} | ||
| 218 | + onClick={() => void queueSchoolRefresh()} | ||
| 219 | + > | ||
| 220 | + <IconSparkles class="h-4 w-4" /> | ||
| 221 | + {refreshingAll() ? tx("insights.refreshingAll") : tx("insights.refreshAll")} | ||
| 222 | + </Button> | ||
| 223 | + </Show> | ||
| 224 | + </> | ||
| 225 | + } | ||
| 226 | + columns={columns()} | ||
| 227 | + data={students() ?? []} | ||
| 228 | + empty={role() === "parent" ? tx("insights.emptyLinkedStudents") : tx("insights.emptyStudents")} | ||
| 229 | + emptyIllustration="people" | ||
| 230 | + filterPlaceholder={tx("insights.searchStudents")} | ||
| 231 | + filterHint={tx("search.hint.people")} | ||
| 232 | + searchPredicate={(student, query) => matchesSearch(query, student.display_name, student.username)} | ||
| 233 | + enablePagination | ||
| 234 | + pageSize={PAGE_SIZE} | ||
| 235 | + storageKey="insight-students" | ||
| 236 | + onRowClick={openStudent} | ||
| 237 | + /> | ||
| 238 | + </Show> | ||
| 239 | + </Suspense> | ||
| 240 | + </section> | ||
| 241 | + </Show> | ||
| 242 | + | ||
| 243 | + <Show when={canManageRuns()}> | ||
| 244 | + <section class="data-shell p-4"> | ||
| 245 | + <Suspense fallback={<DataTableSkeleton columns={6} rows={5} />}> | ||
| 246 | + <Show when={runs.error}> | ||
| 247 | + <ErrorAlert message={formatApiError(runs.error)} onRetry={() => void refetchRuns()} /> | ||
| 248 | + </Show> | ||
| 249 | + <Show when={!runs.error}> | ||
| 250 | + <InsightRunsTable runs={runs()?.items ?? []} /> | ||
| 251 | + </Show> | ||
| 252 | + </Suspense> | ||
| 253 | + </section> | ||
| 254 | + </Show> | ||
| 255 | + | ||
| 256 | + <SidePanel | ||
| 257 | + size="wide" | ||
| 258 | + open={selectedStudent() != null} | ||
| 259 | + onOpenChange={(open) => { | ||
| 260 | + if (!open) { | ||
| 261 | + setSelectedStudent(null); | ||
| 262 | + mutateInsight(null); | ||
| 263 | + setPanelError(""); | ||
| 264 | + } | ||
| 265 | + }} | ||
| 266 | + title={personLabel(selectedStudent())} | ||
| 267 | + description={tx("insights.studentAnalysis")} | ||
| 268 | + > | ||
| 269 | + <div class="space-y-4"> | ||
| 270 | + <div class="flex flex-wrap justify-end gap-2"> | ||
| 271 | + <Button variant="outline" size="sm" class="rounded-lg" onClick={() => void refetchInsight()}> | ||
| 272 | + <IconRefresh class="h-4 w-4" /> | ||
| 273 | + {tx("common.refresh")} | ||
| 274 | + </Button> | ||
| 275 | + <Button size="sm" class="rounded-lg" disabled={computingStudent()} onClick={() => void queueStudentCompute()}> | ||
| 276 | + <IconSparkles class="h-4 w-4" /> | ||
| 277 | + {computingStudent() ? tx("insights.recomputing") : tx("insights.recompute")} | ||
| 278 | + </Button> | ||
| 279 | + </div> | ||
| 280 | + <Show when={panelError()}> | ||
| 281 | + <ErrorAlert message={panelError()} onRetry={() => void refetchInsight()} /> | ||
| 282 | + </Show> | ||
| 283 | + <Show when={insight.loading && !insight()}> | ||
| 284 | + <p class="py-8 text-center text-sm text-muted-foreground">{tx("common.loading")}</p> | ||
| 285 | + </Show> | ||
| 286 | + <Show when={insight()}>{(value) => <InsightDetail insight={value()} />}</Show> | ||
| 287 | + </div> | ||
| 288 | + </SidePanel> | ||
| 289 | + </div> | ||
| 290 | + ); | ||
| 291 | +} | ||
src/components/ai/note-studio-panel.tsxadded+109 -0
| @@ -0,0 +1,109 @@ | |||
| 1 | +import { Show, Suspense, createMemo, createSignal } from "solid-js"; | ||
| 2 | +import { createResource } from "@/lib/create-resource"; | ||
| 3 | +import { getCourseNotes } from "@/api/course-notes"; | ||
| 4 | +import { getCourses } from "@/api/courses"; | ||
| 5 | +import { getMyCourses } from "@/api/reports"; | ||
| 6 | +import { formatApiError, type CourseNote } from "@/api/client"; | ||
| 7 | +import { PodcastPanel } from "@/components/notes/podcast-panel"; | ||
| 8 | +import { RagOutputsPanel } from "@/components/notes/rag-outputs-panel"; | ||
| 9 | +import { EmptyState } from "@/components/ui/empty-state"; | ||
| 10 | +import { ErrorAlert } from "@/components/ui/error-alert"; | ||
| 11 | +import { IconWaveform } from "@/components/ui/icons"; | ||
| 12 | +import { Label } from "@/components/ui/label"; | ||
| 13 | +import { PageSpinner } from "@/components/ui/page-spinner"; | ||
| 14 | +import { SearchableSelect } from "@/components/ui/searchable-select"; | ||
| 15 | +import { useAuth } from "@/stores/auth-context"; | ||
| 16 | +import { useT } from "@/stores/preferences-context"; | ||
| 17 | +import { courseNoteFiles } from "@/lib/note-source"; | ||
| 18 | +import { hasMinRole } from "@/lib/roles"; | ||
| 19 | + | ||
| 20 | +type StudioNote = CourseNote & { courseTitle: string; courseCreatorId: string }; | ||
| 21 | + | ||
| 22 | +/** Pick a lesson note, then read its AI outputs and produce its podcast — | ||
| 23 | + * the same two panels the note reader shows, gathered on the AI hub. */ | ||
| 24 | +export function NoteStudioPanel() { | ||
| 25 | + const t = useT(); | ||
| 26 | + const auth = useAuth(); | ||
| 27 | + const [selectedId, setSelectedId] = createSignal(""); | ||
| 28 | + const [notes, { refetch }] = createResource( | ||
| 29 | + () => auth.user()?.role ?? null, | ||
| 30 | + async (role) => { | ||
| 31 | + const courses = role === "student" ? await getMyCourses({ limit: 100 }) : await getCourses({ limit: 100 }); | ||
| 32 | + const rows = await Promise.all( | ||
| 33 | + courses.items.map(async (course) => { | ||
| 34 | + try { | ||
| 35 | + const page = await getCourseNotes(course.id, { limit: 100 }); | ||
| 36 | + return page.items.map<StudioNote>((note) => ({ | ||
| 37 | + ...note, | ||
| 38 | + courseTitle: course.title, | ||
| 39 | + courseCreatorId: course.creator.id, | ||
| 40 | + })); | ||
| 41 | + } catch { | ||
| 42 | + return []; | ||
| 43 | + } | ||
| 44 | + }), | ||
| 45 | + ); | ||
| 46 | + return rows.flat(); | ||
| 47 | + }, | ||
| 48 | + ); | ||
| 49 | + const options = createMemo(() => (notes() ?? []).map((note) => ({ value: note.id, label: `${note.courseTitle} · ${note.title}` }))); | ||
| 50 | + const selected = createMemo(() => (notes() ?? []).find((note) => note.id === selectedId()) ?? null); | ||
| 51 | + const canManageSelected = () => { | ||
| 52 | + const note = selected(); | ||
| 53 | + const user = auth.user(); | ||
| 54 | + return !!note && !!user && (hasMinRole(user.role, "manager") || note.courseCreatorId === user.id); | ||
| 55 | + }; | ||
| 56 | + | ||
| 57 | + return ( | ||
| 58 | + <Suspense fallback={<PageSpinner />}> | ||
| 59 | + <Show when={notes.error}> | ||
| 60 | + <ErrorAlert message={formatApiError(notes.error)} onRetry={() => void refetch()} /> | ||
| 61 | + </Show> | ||
| 62 | + <Show when={!notes.error && notes()}> | ||
| 63 | + <Show | ||
| 64 | + when={(notes()?.length ?? 0) > 0} | ||
| 65 | + fallback={<EmptyState kind="notes" title={t("podcast.noNotes")} description={t("podcast.noNotesHint")} />} | ||
| 66 | + > | ||
| 67 | + <div class="mx-auto max-w-3xl space-y-4"> | ||
| 68 | + <section class="data-shell space-y-2 p-4"> | ||
| 69 | + <Label for="sound-studio-note">{t("podcast.source")}</Label> | ||
| 70 | + <SearchableSelect | ||
| 71 | + id="sound-studio-note" | ||
| 72 | + value={selectedId()} | ||
| 73 | + onChange={setSelectedId} | ||
| 74 | + options={options()} | ||
| 75 | + placeholder={t("podcast.selectNote")} | ||
| 76 | + /> | ||
| 77 | + </section> | ||
| 78 | + <Show | ||
| 79 | + when={selected()} | ||
| 80 | + fallback={ | ||
| 81 | + <section class="flex min-h-44 flex-col items-center justify-center gap-3 rounded-xl border border-dashed border-primary/25 bg-primary/[0.03] px-6 py-8 text-center"> | ||
| 82 | + <div class="flex h-11 w-11 items-center justify-center rounded-full bg-primary/10 text-primary"> | ||
| 83 | + <IconWaveform class="h-5 w-5" /> | ||
| 84 | + </div> | ||
| 85 | + <div> | ||
| 86 | + <p class="font-medium text-text-strong">{t("podcast.selectPrompt")}</p> | ||
| 87 | + <p class="mt-1 text-sm text-muted-foreground">{t("podcast.selectPromptHint")}</p> | ||
| 88 | + </div> | ||
| 89 | + </section> | ||
| 90 | + } | ||
| 91 | + > | ||
| 92 | + {(note) => ( | ||
| 93 | + <div class="space-y-4"> | ||
| 94 | + <RagOutputsPanel | ||
| 95 | + noteId={note().id} | ||
| 96 | + source={courseNoteFiles} | ||
| 97 | + canManage={canManageSelected()} | ||
| 98 | + active | ||
| 99 | + /> | ||
| 100 | + <PodcastPanel noteId={note().id} active /> | ||
| 101 | + </div> | ||
| 102 | + )} | ||
| 103 | + </Show> | ||
| 104 | + </div> | ||
| 105 | + </Show> | ||
| 106 | + </Show> | ||
| 107 | + </Suspense> | ||
| 108 | + ); | ||
| 109 | +} | ||
src/components/insights/insight-data-list.tsxadded+57 -0
| @@ -0,0 +1,57 @@ | |||
| 1 | +import { For, Show } from "solid-js"; | ||
| 2 | + | ||
| 3 | +type DataEntry = { path: string; value: string }; | ||
| 4 | + | ||
| 5 | +function humanize(value: string): string { | ||
| 6 | + return value | ||
| 7 | + .replace(/[_-]+/g, " ") | ||
| 8 | + .replace(/\b\w/g, (letter) => letter.toLocaleUpperCase("tr-TR")); | ||
| 9 | +} | ||
| 10 | + | ||
| 11 | +function scalar(value: unknown): string | null { | ||
| 12 | + if (value == null) return "—"; | ||
| 13 | + if (typeof value === "boolean") return String(value); | ||
| 14 | + if (typeof value === "string" || typeof value === "number") return String(value); | ||
| 15 | + return null; | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +function flatten(value: unknown, path = "", depth = 0): DataEntry[] { | ||
| 19 | + const direct = scalar(value); | ||
| 20 | + if (direct != null) return [{ path: path || "Değer", value: direct }]; | ||
| 21 | + if (depth >= 3) return [{ path: path || "Değer", value: JSON.stringify(value) }]; | ||
| 22 | + | ||
| 23 | + if (Array.isArray(value)) { | ||
| 24 | + if (value.length === 0) return []; | ||
| 25 | + return value.flatMap((item, index) => flatten(item, `${path}${path ? " " : ""}${index + 1}`, depth + 1)); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + if (typeof value === "object") { | ||
| 29 | + return Object.entries(value as Record<string, unknown>).flatMap(([key, item]) => | ||
| 30 | + flatten(item, path ? `${path} · ${humanize(key)}` : humanize(key), depth + 1), | ||
| 31 | + ); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + return []; | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +export function InsightDataList(props: { value: unknown; emptyLabel: string }) { | ||
| 38 | + const entries = () => flatten(props.value); | ||
| 39 | + | ||
| 40 | + return ( | ||
| 41 | + <Show | ||
| 42 | + when={entries().length > 0} | ||
| 43 | + fallback={<p class="text-xs text-muted-foreground">{props.emptyLabel}</p>} | ||
| 44 | + > | ||
| 45 | + <dl class="divide-y divide-border-hairline overflow-hidden rounded-lg border border-border-hairline bg-surface-overlay"> | ||
| 46 | + <For each={entries()}> | ||
| 47 | + {(entry) => ( | ||
| 48 | + <div class="grid grid-cols-[minmax(0,1fr)_minmax(5rem,auto)] gap-3 px-3 py-2 text-xs"> | ||
| 49 | + <dt class="min-w-0 break-words text-muted-foreground">{entry.path}</dt> | ||
| 50 | + <dd class="max-w-52 break-words text-right font-medium text-foreground">{entry.value}</dd> | ||
| 51 | + </div> | ||
| 52 | + )} | ||
| 53 | + </For> | ||
| 54 | + </dl> | ||
| 55 | + </Show> | ||
| 56 | + ); | ||
| 57 | +} | ||
src/components/insights/insight-detail.tsxadded+228 -0
| @@ -0,0 +1,228 @@ | |||
| 1 | +import { For, Show } from "solid-js"; | ||
| 2 | +import type { InsightConfidence, StudentInsight } from "@/api/client"; | ||
| 3 | +import { InsightDataList } from "@/components/insights/insight-data-list"; | ||
| 4 | +import { Badge } from "@/components/ui/badge"; | ||
| 5 | +import { EmptyInline } from "@/components/ui/empty-inline"; | ||
| 6 | +import { IconAlert, IconChart, IconSparkles } from "@/components/ui/icons"; | ||
| 7 | +import { cn } from "@/lib/cn"; | ||
| 8 | +import { formatDateTime } from "@/lib/format"; | ||
| 9 | +import { usePreferences } from "@/stores/preferences-context"; | ||
| 10 | + | ||
| 11 | +const percent = (value: number) => `${Math.round(value * 100)}%`; | ||
| 12 | +const clampPercent = (value: number) => Math.min(100, Math.max(0, value * 100)); | ||
| 13 | + | ||
| 14 | +function confidenceVariant(confidence: InsightConfidence) { | ||
| 15 | + if (confidence === "stable") return "success" as const; | ||
| 16 | + if (confidence === "exploratory") return "warning" as const; | ||
| 17 | + return "secondary" as const; | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +export function InsightDetail(props: { insight: StudentInsight; mode?: "full" | "cards" }) { | ||
| 21 | + const prefs = usePreferences(); | ||
| 22 | + const tx = (key: string, vars?: Record<string, string | number>) => prefs.t(key as never, vars); | ||
| 23 | + const confidenceLabel = (confidence: InsightConfidence) => | ||
| 24 | + confidence === "none" || confidence === "exploratory" || confidence === "stable" | ||
| 25 | + ? tx(`insights.confidence.${confidence}`) | ||
| 26 | + : confidence; | ||
| 27 | + const summarySections = () => { | ||
| 28 | + const summary = props.insight.summary; | ||
| 29 | + if (!summary) return []; | ||
| 30 | + return [ | ||
| 31 | + { id: "attendance", label: tx("insights.modules.attendance"), value: summary.attendance }, | ||
| 32 | + { id: "marks", label: tx("insights.modules.marks"), value: summary.marks }, | ||
| 33 | + { id: "study", label: tx("insights.modules.study"), value: summary.study }, | ||
| 34 | + { id: "submission", label: tx("insights.modules.submission"), value: summary.submission }, | ||
| 35 | + ]; | ||
| 36 | + }; | ||
| 37 | + | ||
| 38 | + return ( | ||
| 39 | + <div class="space-y-5"> | ||
| 40 | + <Show when={props.mode !== "cards"}> | ||
| 41 | + <section class="space-y-3"> | ||
| 42 | + <div class="flex items-center justify-between gap-3"> | ||
| 43 | + <div class="flex items-center gap-2"> | ||
| 44 | + <IconSparkles class="h-4 w-4 text-primary" /> | ||
| 45 | + <h3 class="text-sm font-semibold text-text-strong">{tx("insights.summary")}</h3> | ||
| 46 | + </div> | ||
| 47 | + <Show when={props.insight.summary}> | ||
| 48 | + {(summary) => ( | ||
| 49 | + <Badge variant={confidenceVariant(summary().confidence)} class="rounded-full"> | ||
| 50 | + {confidenceLabel(summary().confidence)} | ||
| 51 | + </Badge> | ||
| 52 | + )} | ||
| 53 | + </Show> | ||
| 54 | + </div> | ||
| 55 | + | ||
| 56 | + <Show | ||
| 57 | + when={props.insight.summary} | ||
| 58 | + fallback={ | ||
| 59 | + <EmptyInline | ||
| 60 | + illustration="charts" | ||
| 61 | + size="md" | ||
| 62 | + title={tx("insights.noSummary")} | ||
| 63 | + hint={tx("insights.noSummaryHint")} | ||
| 64 | + /> | ||
| 65 | + } | ||
| 66 | + > | ||
| 67 | + {(summary) => ( | ||
| 68 | + <> | ||
| 69 | + <div class="grid gap-2 sm:grid-cols-2"> | ||
| 70 | + <div class="detail-metric-card"> | ||
| 71 | + <p class="text-xs text-muted-foreground">{tx("insights.computedAt")}</p> | ||
| 72 | + <p class="mono mt-1 text-sm font-medium">{formatDateTime(summary().computed_at, prefs.locale())}</p> | ||
| 73 | + </div> | ||
| 74 | + <div class="detail-metric-card"> | ||
| 75 | + <p class="text-xs text-muted-foreground">{tx("insights.retainUntil")}</p> | ||
| 76 | + <p class="mono mt-1 text-sm font-medium">{formatDateTime(summary().retain_until, prefs.locale())}</p> | ||
| 77 | + </div> | ||
| 78 | + </div> | ||
| 79 | + <div class="grid gap-3 sm:grid-cols-2"> | ||
| 80 | + <For each={summarySections()}> | ||
| 81 | + {(section) => ( | ||
| 82 | + <article class="space-y-3 rounded-xl border border-border-line bg-surface-base p-4"> | ||
| 83 | + <h4 class="text-sm font-semibold text-text-strong">{section.label}</h4> | ||
| 84 | + <Show | ||
| 85 | + when={section.value != null} | ||
| 86 | + fallback={<p class="text-xs text-muted-foreground">{tx("insights.sectionNotComputed")}</p>} | ||
| 87 | + > | ||
| 88 | + <InsightDataList value={section.value} emptyLabel={tx("insights.noEvidence")} /> | ||
| 89 | + </Show> | ||
| 90 | + </article> | ||
| 91 | + )} | ||
| 92 | + </For> | ||
| 93 | + </div> | ||
| 94 | + </> | ||
| 95 | + )} | ||
| 96 | + </Show> | ||
| 97 | + </section> | ||
| 98 | + </Show> | ||
| 99 | + | ||
| 100 | + <Show when={props.mode !== "cards"}> | ||
| 101 | + <section class="space-y-3 border-t border-border-hairline pt-5"> | ||
| 102 | + <div class="flex items-center gap-2"> | ||
| 103 | + <IconAlert class="h-4 w-4 text-warning" /> | ||
| 104 | + <h3 class="text-sm font-semibold text-text-strong">{tx("insights.attention")}</h3> | ||
| 105 | + <Badge variant="warning" class="rounded-full">{props.insight.attention.length}</Badge> | ||
| 106 | + </div> | ||
| 107 | + <Show | ||
| 108 | + when={props.insight.attention.length > 0} | ||
| 109 | + fallback={<EmptyInline title={tx("insights.noAttention")} illustration="empty" />} | ||
| 110 | + > | ||
| 111 | + <div class="space-y-3"> | ||
| 112 | + <For each={props.insight.attention}> | ||
| 113 | + {(item) => ( | ||
| 114 | + <article class="space-y-3 rounded-xl border border-warning/25 bg-warning/5 p-4"> | ||
| 115 | + <div class="flex flex-wrap items-start justify-between gap-2"> | ||
| 116 | + <div class="min-w-0"> | ||
| 117 | + <p class="text-sm font-medium leading-5 text-text-strong">{item.fact}</p> | ||
| 118 | + <p class="mt-1 text-xs text-muted-foreground"> | ||
| 119 | + {item.course || tx("insights.schoolWide")} · {formatDateTime(item.window_from, prefs.locale())} – {formatDateTime(item.window_to, prefs.locale())} | ||
| 120 | + </p> | ||
| 121 | + </div> | ||
| 122 | + <Badge variant="outline" class="rounded-full">{item.trigger}</Badge> | ||
| 123 | + </div> | ||
| 124 | + <InsightDataList value={item.evidence} emptyLabel={tx("insights.noEvidence")} /> | ||
| 125 | + </article> | ||
| 126 | + )} | ||
| 127 | + </For> | ||
| 128 | + </div> | ||
| 129 | + </Show> | ||
| 130 | + </section> | ||
| 131 | + </Show> | ||
| 132 | + | ||
| 133 | + <section class={cn("space-y-3", props.mode !== "cards" && "border-t border-border-hairline pt-5")}> | ||
| 134 | + <div class="flex items-center gap-2"> | ||
| 135 | + <IconSparkles class="h-4 w-4 text-primary" /> | ||
| 136 | + <h3 class="text-sm font-semibold text-text-strong">{tx("insights.recommendations")}</h3> | ||
| 137 | + <Badge variant="secondary" class="rounded-full">{props.insight.cards.length}</Badge> | ||
| 138 | + </div> | ||
| 139 | + <Show | ||
| 140 | + when={props.insight.cards.length > 0} | ||
| 141 | + fallback={<EmptyInline title={tx("insights.noRecommendations")} illustration="empty" />} | ||
| 142 | + > | ||
| 143 | + <div class="space-y-3"> | ||
| 144 | + <For each={props.insight.cards}> | ||
| 145 | + {(card) => ( | ||
| 146 | + <article class="space-y-3 rounded-xl border border-primary/20 bg-primary/5 p-4"> | ||
| 147 | + <div class="flex flex-wrap items-center justify-between gap-2"> | ||
| 148 | + <div class="flex items-center gap-2"> | ||
| 149 | + <Badge class="rounded-full">{card.product}</Badge> | ||
| 150 | + <span class="text-xs text-muted-foreground">{card.rule_id} · v{card.rule_version}</span> | ||
| 151 | + </div> | ||
| 152 | + <Badge variant={confidenceVariant(card.confidence)} class="rounded-full"> | ||
| 153 | + {confidenceLabel(card.confidence)} | ||
| 154 | + </Badge> | ||
| 155 | + </div> | ||
| 156 | + <Show when={card.course || card.scope}> | ||
| 157 | + <p class="text-xs text-muted-foreground">{[card.course, card.scope].filter(Boolean).join(" · ")}</p> | ||
| 158 | + </Show> | ||
| 159 | + <InsightDataList value={card.evidence} emptyLabel={tx("insights.noEvidence")} /> | ||
| 160 | + <p class="text-[11px] text-muted-foreground"> | ||
| 161 | + {tx("insights.expiresAt")}: {formatDateTime(card.expires_at, prefs.locale())} | ||
| 162 | + </p> | ||
| 163 | + </article> | ||
| 164 | + )} | ||
| 165 | + </For> | ||
| 166 | + </div> | ||
| 167 | + </Show> | ||
| 168 | + </section> | ||
| 169 | + | ||
| 170 | + <Show when={props.mode !== "cards"}> | ||
| 171 | + <section class="space-y-3 border-t border-border-hairline pt-5"> | ||
| 172 | + <div class="flex items-center gap-2"> | ||
| 173 | + <IconChart class="h-4 w-4 text-info" /> | ||
| 174 | + <h3 class="text-sm font-semibold text-text-strong">{tx("insights.segments")}</h3> | ||
| 175 | + <Badge variant="info" class="rounded-full">{props.insight.segments.length}</Badge> | ||
| 176 | + </div> | ||
| 177 | + <Show | ||
| 178 | + when={props.insight.segments.length > 0} | ||
| 179 | + fallback={<EmptyInline title={tx("insights.noSegments")} illustration="charts" />} | ||
| 180 | + > | ||
| 181 | + <div class="space-y-3"> | ||
| 182 | + <For each={props.insight.segments}> | ||
| 183 | + {(segment) => ( | ||
| 184 | + <article class="space-y-3 rounded-xl border border-border-line bg-surface-base p-4"> | ||
| 185 | + <div class="flex flex-wrap items-center justify-between gap-2"> | ||
| 186 | + <div> | ||
| 187 | + <p class="text-sm font-semibold text-text-strong">{segment.label}</p> | ||
| 188 | + <p class="text-xs text-muted-foreground">{segment.dimension}</p> | ||
| 189 | + </div> | ||
| 190 | + <Badge variant={confidenceVariant(segment.confidence)} class="rounded-full"> | ||
| 191 | + {confidenceLabel(segment.confidence)} | ||
| 192 | + </Badge> | ||
| 193 | + </div> | ||
| 194 | + <div class="space-y-1.5"> | ||
| 195 | + <div class="flex items-center justify-between text-xs"> | ||
| 196 | + <span class="text-muted-foreground">{tx("insights.accuracy")}</span> | ||
| 197 | + <span class="font-mono font-semibold">{percent(segment.accuracy)}</span> | ||
| 198 | + </div> | ||
| 199 | + <div class="h-2.5 overflow-hidden rounded-full bg-surface-fill"> | ||
| 200 | + <div class="h-full rounded-full bg-info" style={{ width: `${clampPercent(segment.accuracy)}%` }} /> | ||
| 201 | + </div> | ||
| 202 | + </div> | ||
| 203 | + <div class="grid grid-cols-3 gap-2 text-center"> | ||
| 204 | + <div class="rounded-lg bg-surface-overlay px-2 py-2"> | ||
| 205 | + <p class="font-mono text-sm font-semibold">{segment.n_correct}/{segment.n_answers}</p> | ||
| 206 | + <p class="text-[10px] text-muted-foreground">{tx("insights.answers")}</p> | ||
| 207 | + </div> | ||
| 208 | + <div class="rounded-lg bg-surface-overlay px-2 py-2"> | ||
| 209 | + <p class="font-mono text-sm font-semibold">{percent(segment.overall_accuracy)}</p> | ||
| 210 | + <p class="text-[10px] text-muted-foreground">{tx("insights.overall")}</p> | ||
| 211 | + </div> | ||
| 212 | + <div class="rounded-lg bg-surface-overlay px-2 py-2"> | ||
| 213 | + <p class={cn("font-mono text-sm font-semibold", segment.contrast < 0 ? "text-destructive" : "text-success")}> | ||
| 214 | + {segment.contrast > 0 ? "+" : ""}{percent(segment.contrast)} | ||
| 215 | + </p> | ||
| 216 | + <p class="text-[10px] text-muted-foreground">{tx("insights.contrast")}</p> | ||
| 217 | + </div> | ||
| 218 | + </div> | ||
| 219 | + </article> | ||
| 220 | + )} | ||
| 221 | + </For> | ||
| 222 | + </div> | ||
| 223 | + </Show> | ||
| 224 | + </section> | ||
| 225 | + </Show> | ||
| 226 | + </div> | ||
| 227 | + ); | ||
| 228 | +} | ||
src/components/insights/insight-runs-table.tsxadded+113 -0
| @@ -0,0 +1,113 @@ | |||
| 1 | +import { createMemo } from "solid-js"; | ||
| 2 | +import type { ColumnDef } from "@tanstack/solid-table"; | ||
| 3 | +import type { InsightRun } from "@/api/client"; | ||
| 4 | +import { Badge } from "@/components/ui/badge"; | ||
| 5 | +import { DataTable } from "@/components/ui/data-table"; | ||
| 6 | +import { cn } from "@/lib/cn"; | ||
| 7 | +import { formatDateTime, formatDurationMinutes } from "@/lib/format"; | ||
| 8 | +import { usePreferences } from "@/stores/preferences-context"; | ||
| 9 | + | ||
| 10 | +function statusVariant(status: string) { | ||
| 11 | + if (status === "ok") return "success" as const; | ||
| 12 | + if (status === "running") return "info" as const; | ||
| 13 | + if (status === "partial" || status === "skipped") return "warning" as const; | ||
| 14 | + if (status === "failed") return "destructive" as const; | ||
| 15 | + return "secondary" as const; | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +export function InsightRunsTable(props: { runs: InsightRun[] }) { | ||
| 19 | + const prefs = usePreferences(); | ||
| 20 | + const tx = (key: string, vars?: Record<string, string | number>) => prefs.t(key as never, vars); | ||
| 21 | + const statusLabel = (status: string) => | ||
| 22 | + ["running", "ok", "partial", "failed", "skipped"].includes(status) | ||
| 23 | + ? tx(`insights.status.${status}`) | ||
| 24 | + : status; | ||
| 25 | + const columns = createMemo<ColumnDef<InsightRun>[]>(() => [ | ||
| 26 | + { | ||
| 27 | + accessorKey: "run_day", | ||
| 28 | + header: tx("insights.runDay"), | ||
| 29 | + cell: (cell) => ( | ||
| 30 | + <div> | ||
| 31 | + <p class="font-medium text-text-strong">{cell.row.original.run_day}</p> | ||
| 32 | + <p class="text-xs text-muted-foreground">{formatDateTime(cell.row.original.started_at, prefs.locale())}</p> | ||
| 33 | + </div> | ||
| 34 | + ), | ||
| 35 | + }, | ||
| 36 | + { | ||
| 37 | + accessorKey: "status", | ||
| 38 | + header: tx("insights.result"), | ||
| 39 | + cell: (cell) => ( | ||
| 40 | + <Badge variant={statusVariant(cell.row.original.status)} class="rounded-full"> | ||
| 41 | + {statusLabel(cell.row.original.status)} | ||
| 42 | + </Badge> | ||
| 43 | + ), | ||
| 44 | + }, | ||
| 45 | + { | ||
| 46 | + id: "processed", | ||
| 47 | + header: tx("insights.processed"), | ||
| 48 | + accessorFn: (row) => row.students_ok, | ||
| 49 | + meta: { align: "right" }, | ||
| 50 | + cell: (cell) => { | ||
| 51 | + const run = cell.row.original; | ||
| 52 | + return ( | ||
| 53 | + <div class="text-right"> | ||
| 54 | + <p class="mono font-medium tabular-nums">{run.students_ok}/{run.students_total}</p> | ||
| 55 | + <p class="text-[11px] text-muted-foreground">{run.students_failed} / {run.students_skipped}</p> | ||
| 56 | + </div> | ||
| 57 | + ); | ||
| 58 | + }, | ||
| 59 | + }, | ||
| 60 | + { | ||
| 61 | + accessorKey: "rows_written", | ||
| 62 | + header: tx("insights.written"), | ||
| 63 | + meta: { align: "right", cellClass: "mono tabular-nums" }, | ||
| 64 | + }, | ||
| 65 | + { | ||
| 66 | + accessorKey: "duration_ms", | ||
| 67 | + header: tx("insights.duration"), | ||
| 68 | + meta: { align: "right" }, | ||
| 69 | + cell: (cell) => <span class="mono tabular-nums">{formatDurationMinutes(cell.row.original.duration_ms, prefs.locale())}</span>, | ||
| 70 | + }, | ||
| 71 | + { | ||
| 72 | + id: "issues", | ||
| 73 | + header: tx("insights.issues"), | ||
| 74 | + enableSorting: false, | ||
| 75 | + cell: (cell) => { | ||
| 76 | + const run = cell.row.original; | ||
| 77 | + const issueCount = run.pending_students.length + run.failed_modules.length; | ||
| 78 | + return ( | ||
| 79 | + <div class="space-y-1"> | ||
| 80 | + <p class={cn("text-xs", issueCount > 0 || run.budget_exceeded ? "text-warning" : "text-muted-foreground")}> | ||
| 81 | + {issueCount > 0 ? tx("insights.issueCount", { count: issueCount }) : tx("insights.noIssues")} | ||
| 82 | + </p> | ||
| 83 | + {run.budget_exceeded && <p class="text-[11px] text-warning">{tx("insights.budgetExceeded")}</p>} | ||
| 84 | + {run.pending_students.length > 0 && ( | ||
| 85 | + <p class="max-w-56 truncate text-[11px] text-muted-foreground" title={run.pending_students.join(", ")}> | ||
| 86 | + {tx("insights.pendingStudents", { count: run.pending_students.length })} | ||
| 87 | + </p> | ||
| 88 | + )} | ||
| 89 | + {run.failed_modules.length > 0 && ( | ||
| 90 | + <p class="max-w-56 truncate text-[11px] text-muted-foreground" title={run.failed_modules.join(", ")}> | ||
| 91 | + {tx("insights.failedModules", { modules: run.failed_modules.join(", ") })} | ||
| 92 | + </p> | ||
| 93 | + )} | ||
| 94 | + </div> | ||
| 95 | + ); | ||
| 96 | + }, | ||
| 97 | + }, | ||
| 98 | + ]); | ||
| 99 | + | ||
| 100 | + return ( | ||
| 101 | + <DataTable | ||
| 102 | + title={tx("insights.runs")} | ||
| 103 | + description={tx("insights.runsSubtitle")} | ||
| 104 | + columns={columns()} | ||
| 105 | + data={props.runs} | ||
| 106 | + empty={tx("insights.emptyRuns")} | ||
| 107 | + tableClass="min-w-[820px]" | ||
| 108 | + enablePagination | ||
| 109 | + pageSize={10} | ||
| 110 | + storageKey="insight-runs" | ||
| 111 | + /> | ||
| 112 | + ); | ||
| 113 | +} | ||
src/components/layout/app-shell.tsxmodified+6 -6
| @@ -17,6 +17,7 @@ import { IconChevronLeft, IconSparkles } from "@/components/ui/icons"; | |||
| 17 | import { Toaster } from "@/components/ui/toast"; | 17 | import { Toaster } from "@/components/ui/toast"; |
| 18 | import { useAuth } from "@/stores/auth-context"; | 18 | import { useAuth } from "@/stores/auth-context"; |
| 19 | import { useModules } from "@/stores/modules-context"; | 19 | import { useModules } from "@/stores/modules-context"; |
| 20 | +import { celebiPanelOpen, openCelebiPanel, setCelebiPanelOpen } from "@/stores/celebi-panel"; | ||
| 20 | import { commandPaletteOpen, openCommandPalette, setCommandPaletteOpen } from "@/stores/command-palette"; | 21 | import { commandPaletteOpen, openCommandPalette, setCommandPaletteOpen } from "@/stores/command-palette"; |
| 21 | import { ShellFeedProvider } from "@/stores/shell-feed-context"; | 22 | import { ShellFeedProvider } from "@/stores/shell-feed-context"; |
| 22 | import { usePreferences, useT } from "@/stores/preferences-context"; | 23 | import { usePreferences, useT } from "@/stores/preferences-context"; |
| @@ -33,7 +34,6 @@ export function AppShell(props: ParentProps) { | |||
| 33 | const modules = useModules(); | 34 | const modules = useModules(); |
| 34 | const navigate = useNavigate(); | 35 | const navigate = useNavigate(); |
| 35 | const [mobileOpen, setMobileOpen] = createSignal(false); | 36 | const [mobileOpen, setMobileOpen] = createSignal(false); |
| 36 | - const [celebiOpen, setCelebiOpen] = createSignal(false); | ||
| 37 | const [profileOpen, setProfileOpen] = createSignal(false); | 37 | const [profileOpen, setProfileOpen] = createSignal(false); |
| 38 | const collapsed = () => prefs.sidebarCollapsed(); | 38 | const collapsed = () => prefs.sidebarCollapsed(); |
| 39 | const location = useLocation(); | 39 | const location = useLocation(); |
| @@ -90,7 +90,7 @@ export function AppShell(props: ParentProps) { | |||
| 90 | <div class="min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-1.5 py-2.5"> | 90 | <div class="min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-1.5 py-2.5"> |
| 91 | <SideNav | 91 | <SideNav |
| 92 | collapsed={collapsed()} | 92 | collapsed={collapsed()} |
| 93 | - onOpenCelebi={() => setCelebiOpen(true)} | 93 | + onOpenCelebi={() => openCelebiPanel()} |
| 94 | onOpenProfile={() => setProfileOpen(true)} | 94 | onOpenProfile={() => setProfileOpen(true)} |
| 95 | /> | 95 | /> |
| 96 | </div> | 96 | </div> |
| @@ -118,7 +118,7 @@ export function AppShell(props: ParentProps) { | |||
| 118 | open={mobileOpen()} | 118 | open={mobileOpen()} |
| 119 | onClose={() => setMobileOpen(false)} | 119 | onClose={() => setMobileOpen(false)} |
| 120 | onLogout={logout} | 120 | onLogout={logout} |
| 121 | - onOpenCelebi={() => setCelebiOpen(true)} | 121 | + onOpenCelebi={() => openCelebiPanel()} |
| 122 | onOpenProfile={() => setProfileOpen(true)} | 122 | onOpenProfile={() => setProfileOpen(true)} |
| 123 | /> | 123 | /> |
| 124 | </Show> | 124 | </Show> |
| @@ -154,7 +154,7 @@ export function AppShell(props: ParentProps) { | |||
| 154 | class="topbar-ai-control hidden h-9 shrink-0 items-center justify-center gap-2 rounded-md px-3 text-xs font-semibold outline-hidden focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.98] sm:flex" | 154 | class="topbar-ai-control hidden h-9 shrink-0 items-center justify-center gap-2 rounded-md px-3 text-xs font-semibold outline-hidden focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.98] sm:flex" |
| 155 | aria-label={t("ai.askCelebi")} | 155 | aria-label={t("ai.askCelebi")} |
| 156 | title={t("ai.askCelebi")} | 156 | title={t("ai.askCelebi")} |
| 157 | - onClick={() => setCelebiOpen(true)} | 157 | + onClick={() => openCelebiPanel()} |
| 158 | > | 158 | > |
| 159 | <IconSparkles class="h-4 w-4" /> | 159 | <IconSparkles class="h-4 w-4" /> |
| 160 | <span>{t("ai.askCelebi")}</span> | 160 | <span>{t("ai.askCelebi")}</span> |
| @@ -187,11 +187,11 @@ export function AppShell(props: ParentProps) { | |||
| 187 | </Show> | 187 | </Show> |
| 188 | </ShellFeedProvider> | 188 | </ShellFeedProvider> |
| 189 | <Show when={auth.user()}> | 189 | <Show when={auth.user()}> |
| 190 | - <CelebiPanel open={celebiOpen()} onOpenChange={setCelebiOpen} /> | 190 | + <CelebiPanel open={celebiPanelOpen()} onOpenChange={setCelebiPanelOpen} /> |
| 191 | <CommandPalette | 191 | <CommandPalette |
| 192 | open={commandPaletteOpen()} | 192 | open={commandPaletteOpen()} |
| 193 | onOpenChange={setCommandPaletteOpen} | 193 | onOpenChange={setCommandPaletteOpen} |
| 194 | - onOpenCelebi={() => setCelebiOpen(true)} | 194 | + onOpenCelebi={() => openCelebiPanel()} |
| 195 | onOpenProfile={() => setProfileOpen(true)} | 195 | onOpenProfile={() => setProfileOpen(true)} |
| 196 | /> | 196 | /> |
| 197 | <AccountProfileDialog open={profileOpen()} onOpenChange={setProfileOpen} /> | 197 | <AccountProfileDialog open={profileOpen()} onOpenChange={setProfileOpen} /> |
src/components/layout/celebi-composer.tsxmodified+5 -1
| @@ -42,9 +42,13 @@ export function CelebiComposer(props: { | |||
| 42 | // The field itself is transparent over the card, so it names its text and | 42 | // The field itself is transparent over the card, so it names its text and |
| 43 | // caret colors: a control that drops its background inherits neither, and | 43 | // caret colors: a control that drops its background inherits neither, and |
| 44 | // the draft came out unreadable once focused. | 44 | // the draft came out unreadable once focused. |
| 45 | + // | ||
| 46 | + // The strip also sits on the panel's bottom edge rather than floating above | ||
| 47 | + // a band of background, so its own padding stays small and the panel body | ||
| 48 | + // drops its bottom padding (see the SidePanel's bodyClass in celebi-panel). | ||
| 45 | return ( | 49 | return ( |
| 46 | <form | 50 | <form |
| 47 | - class="sticky bottom-0 -mx-5 border-t border-border/60 bg-background px-5 pb-1 pt-3 sm:-mx-6 sm:px-6" | 51 | + class="sticky bottom-0 -mx-5 border-t border-border/60 bg-background px-5 pb-2 pt-3 sm:-mx-6 sm:px-6" |
| 48 | onSubmit={(event) => { | 52 | onSubmit={(event) => { |
| 49 | event.preventDefault(); | 53 | event.preventDefault(); |
| 50 | submit(); | 54 | submit(); |
src/components/layout/celebi-panel.tsxmodified+4 -3
| @@ -13,6 +13,7 @@ import { EmptyInline } from "@/components/ui/empty-inline"; | |||
| 13 | import { IconAlert, IconBotSquare, IconChevronDown, IconChevronLeft, IconCopy, IconEdit, IconMessage, IconPlus } from "@/components/ui/icons"; | 13 | import { IconAlert, IconBotSquare, IconChevronDown, IconChevronLeft, IconCopy, IconEdit, IconMessage, IconPlus } from "@/components/ui/icons"; |
| 14 | import { SidePanel } from "@/components/ui/side-panel"; | 14 | import { SidePanel } from "@/components/ui/side-panel"; |
| 15 | import { cn } from "@/lib/cn"; | 15 | import { cn } from "@/lib/cn"; |
| 16 | +import { matchesSearch } from "@/lib/search-text"; | ||
| 16 | import { usePreferences, useT } from "@/stores/preferences-context"; | 17 | import { usePreferences, useT } from "@/stores/preferences-context"; |
| 17 | 18 | ||
| 18 | type PanelMessage = Pick<ChatbotMessage, "id" | "role" | "status" | "content" | "truncated" | "error_code" | "navigation" | "suggestions">; | 19 | type PanelMessage = Pick<ChatbotMessage, "id" | "role" | "status" | "content" | "truncated" | "error_code" | "navigation" | "suggestions">; |
| @@ -129,9 +130,9 @@ export function CelebiPanel(props: { open: boolean; onOpenChange: (open: boolean | |||
| 129 | lastScrollTop = top; | 130 | lastScrollTop = top; |
| 130 | }; | 131 | }; |
| 131 | const filteredMessages = () => { | 132 | const filteredMessages = () => { |
| 132 | - const query = searchQuery().trim().toLocaleLowerCase(locale()); | 133 | + const query = searchQuery().trim(); |
| 133 | if (!query) return messages(); | 134 | if (!query) return messages(); |
| 134 | - return messages().filter((message) => message.content.toLocaleLowerCase(locale()).includes(query)); | 135 | + return messages().filter((message) => matchesSearch(query, message.content)); |
| 135 | }; | 136 | }; |
| 136 | createEffect(() => { | 137 | createEffect(() => { |
| 137 | const items = messages(); | 138 | const items = messages(); |
| @@ -279,7 +280,7 @@ export function CelebiPanel(props: { open: boolean; onOpenChange: (open: boolean | |||
| 279 | }; | 280 | }; |
| 280 | 281 | ||
| 281 | return ( | 282 | return ( |
| 282 | - <SidePanel open={props.open} onOpenChange={props.onOpenChange} title={t("ai.title")} description={t("ai.description")} bodyClass="overflow-hidden"> | 283 | + <SidePanel open={props.open} onOpenChange={props.onOpenChange} title={t("ai.title")} description={t("ai.description")} bodyClass="overflow-hidden pb-0"> |
| 283 | <div class="flex h-full min-h-0 flex-col"> | 284 | <div class="flex h-full min-h-0 flex-col"> |
| 284 | <div class="mb-3 flex shrink-0 items-center gap-2 border-b border-border pb-3"> | 285 | <div class="mb-3 flex shrink-0 items-center gap-2 border-b border-border pb-3"> |
| 285 | <Show | 286 | <Show |
src/components/layout/nav-items.test.tsmodified+32 -11
| @@ -34,13 +34,13 @@ test("admin's sidebar splits into short labelled sections with the soon shelf la | |||
| 34 | items: group.items.map((item) => item.id), | 34 | items: group.items.map((item) => item.id), |
| 35 | })), | 35 | })), |
| 36 | ).toEqual([ | 36 | ).toEqual([ |
| 37 | - { id: "school", items: ["students-roster", "teachers-roster", "class-groups", "terms", "schedule"] }, | 37 | + { id: "school", items: ["students-roster", "teachers-roster", "class-groups", "academic-years", "terms", "schedule"] }, |
| 38 | { id: "teaching", items: ["courses", "homework", "exams", "question-bank", "questions", "notes", "whiteboards"] }, | 38 | { id: "teaching", items: ["courses", "homework", "exams", "question-bank", "questions", "notes", "whiteboards"] }, |
| 39 | { id: "tracking", items: ["student-attendance", "student-marks", "student-pomodoros"] }, | 39 | { id: "tracking", items: ["student-attendance", "student-marks", "student-pomodoros"] }, |
| 40 | { id: "services", items: ["events", "appointments", "school-meals"] }, | 40 | { id: "services", items: ["events", "appointments", "school-meals"] }, |
| 41 | { id: "institution", items: ["payments-collection", "staff-work", "work", "users", "license-modules", "settings"] }, | 41 | { id: "institution", items: ["payments-collection", "staff-work", "work", "users", "license-modules", "settings"] }, |
| 42 | - { id: "ai", items: ["celebi"] }, | 42 | + { id: "ai", items: ["celebi", "ai-hub"] }, |
| 43 | - { id: "soon", items: ["mock-exams", "optical-reading", "reports", "data-protection", "hezarfen-zeka", "sound-studio"] }, | 43 | + { id: "soon", items: ["mock-exams", "optical-reading", "reports", "data-protection"] }, |
| 44 | ]); | 44 | ]); |
| 45 | }); | 45 | }); |
| 46 | 46 | ||
| @@ -65,7 +65,8 @@ test("teacher's sidebar splits into short labelled sections with the soon shelf | |||
| 65 | { id: "tracking", items: ["student-attendance", "student-marks", "student-pomodoros"] }, | 65 | { id: "tracking", items: ["student-attendance", "student-marks", "student-pomodoros"] }, |
| 66 | { id: "teaching", items: ["homework", "exams", "question-bank", "questions", "notes", "whiteboards"] }, | 66 | { id: "teaching", items: ["homework", "exams", "question-bank", "questions", "notes", "whiteboards"] }, |
| 67 | { id: "other", items: ["parent-communication", "appointments", "events", "meals", "work", "settings-teacher"] }, | 67 | { id: "other", items: ["parent-communication", "appointments", "events", "meals", "work", "settings-teacher"] }, |
| 68 | - { id: "soon", items: ["student-analysis", "pending-approvals", "question-generation", "sound-studio"] }, | 68 | + { id: "ai", items: ["celebi", "ai-hub"] }, |
| 69 | + { id: "soon", items: ["student-analysis", "pending-approvals", "question-generation"] }, | ||
| 69 | ]); | 70 | ]); |
| 70 | }); | 71 | }); |
| 71 | 72 | ||
| @@ -78,9 +79,9 @@ test("student's sidebar splits into short labelled sections with the soon shelf | |||
| 78 | ).toEqual([ | 79 | ).toEqual([ |
| 79 | { id: "study", items: ["topic-mastery", "exam-results", "my-homework", "pomodoro"] }, | 80 | { id: "study", items: ["topic-mastery", "exam-results", "my-homework", "pomodoro"] }, |
| 80 | { id: "teaching", items: ["courses", "notes", "questions", "whiteboards"] }, | 81 | { id: "teaching", items: ["courses", "notes", "questions", "whiteboards"] }, |
| 81 | - { id: "ai", items: ["celebi"] }, | 82 | + { id: "ai", items: ["celebi", "ai-hub"] }, |
| 82 | { id: "other", items: ["calendar", "events", "messages", "appointments", "meals", "settings-student"] }, | 83 | { id: "other", items: ["calendar", "events", "messages", "appointments", "meals", "settings-student"] }, |
| 83 | - { id: "soon", items: ["study-plan", "sound-studio"] }, | 84 | + { id: "soon", items: ["study-plan"] }, |
| 84 | ]); | 85 | ]); |
| 85 | }); | 86 | }); |
| 86 | 87 | ||
| @@ -107,6 +108,8 @@ test("parent's sidebar keeps the Figma Öğrencim / Kurum tree plus every backed | |||
| 107 | ).toEqual([ | 108 | ).toEqual([ |
| 108 | { id: "my-student", items: ["progress-report", "absence", "child-exam-results", "child-study-plan"] }, | 109 | { id: "my-student", items: ["progress-report", "absence", "child-exam-results", "child-study-plan"] }, |
| 109 | { id: "institution", items: ["payment-statement", "appointments", "messages", "calendar", "events", "meals", "settings-parent"] }, | 110 | { id: "institution", items: ["payment-statement", "appointments", "messages", "calendar", "events", "meals", "settings-parent"] }, |
| 111 | + // A parent's only AI surface: their children's analysis on the hub. | ||
| 112 | + { id: "ai", items: ["ai-hub"] }, | ||
| 110 | ]); | 113 | ]); |
| 111 | }); | 114 | }); |
| 112 | 115 | ||
| @@ -141,11 +144,25 @@ test("license modules is a real admin page and the work log includes admin", () | |||
| 141 | }); | 144 | }); |
| 142 | 145 | ||
| 143 | test("entries with no backend yet are flagged soon and route to the shared placeholder", () => { | 146 | test("entries with no backend yet are flagged soon and route to the shared placeholder", () => { |
| 144 | - const hezarfenZeka = visibleNavGroups("admin") | 147 | + const opticalReading = visibleNavGroups("admin") |
| 145 | .flatMap((g) => g.items) | 148 | .flatMap((g) => g.items) |
| 146 | - .find((i) => i.id === "hezarfen-zeka"); | 149 | + .find((i) => i.id === "optical-reading"); |
| 147 | - expect(hezarfenZeka?.soon).toBe(true); | 150 | + expect(opticalReading?.soon).toBe(true); |
| 148 | - expect(hezarfenZeka?.to).toBe("/coming-soon/hezarfen-zeka"); | 151 | + expect(opticalReading?.to).toBe("/coming-soon/optik-okuma"); |
| 152 | +}); | ||
| 153 | + | ||
| 154 | +// Every AI feature the backend answers for sits on one hub route; Çelebi keeps | ||
| 155 | +// its own row because it opens the shell panel instead of navigating. | ||
| 156 | +test("the AI group is the hub plus the Çelebi panel, and nothing is a placeholder", () => { | ||
| 157 | + for (const role of ["student", "teacher", "manager", "admin", "parent"] as const) { | ||
| 158 | + const ai = visibleNavGroups(role).find((group) => group.id === "ai"); | ||
| 159 | + expect(ai).toBeDefined(); | ||
| 160 | + const hub = ai?.items.find((item) => item.id === "ai-hub"); | ||
| 161 | + expect(hub?.to).toBe("/ai"); | ||
| 162 | + expect(hub?.soon).toBeFalsy(); | ||
| 163 | + } | ||
| 164 | + expect(routeNavItem("/ai", "student")?.id).toBe("ai-hub"); | ||
| 165 | + expect(routeLabelKey("/ai", "student")).toBe("nav.hezarfenZeka"); | ||
| 149 | }); | 166 | }); |
| 150 | 167 | ||
| 151 | test("Çelebi and account settings open an existing shell surface instead of navigating", () => { | 168 | test("Çelebi and account settings open an existing shell surface instead of navigating", () => { |
| @@ -224,7 +241,11 @@ test("module gate hides nests the school did not buy", () => { | |||
| 224 | expect(teacherPaths).not.toContain("/homework"); | 241 | expect(teacherPaths).not.toContain("/homework"); |
| 225 | expect(teacherPaths).not.toContain("/exams"); | 242 | expect(teacherPaths).not.toContain("/exams"); |
| 226 | expect(teacherPaths).not.toContain("/whiteboards"); | 243 | expect(teacherPaths).not.toContain("/whiteboards"); |
| 227 | - expect(teacherPaths).toContain("/management/classes"); | 244 | + // Classes is a module too, so an unbought "classes" nest hides it; the |
| 245 | + // schedule carries no module and stays. | ||
| 246 | + expect(teacherPaths).not.toContain("/management/classes"); | ||
| 247 | + expect(visibleNavGroups("teacher", ["courses", "classes"]).flatMap((group) => group.items.map((item) => item.to))) | ||
| 248 | + .toContain("/management/classes"); | ||
| 228 | expect(teacherPaths).toContain("/calendar"); | 249 | expect(teacherPaths).toContain("/calendar"); |
| 229 | }); | 250 | }); |
| 230 | 251 | ||
src/components/layout/nav-items.tsmodified+22 -13
| @@ -30,7 +30,6 @@ import { | |||
| 30 | IconUserCog, | 30 | IconUserCog, |
| 31 | IconUsers, | 31 | IconUsers, |
| 32 | IconUtensils, | 32 | IconUtensils, |
| 33 | - IconWaveform, | ||
| 34 | } from "@/components/ui/icons"; | 33 | } from "@/components/ui/icons"; |
| 35 | import type { MessageKey } from "@/i18n/messages"; | 34 | import type { MessageKey } from "@/i18n/messages"; |
| 36 | import { hasExactRole, roleInRange } from "@/lib/roles"; | 35 | import { hasExactRole, roleInRange } from "@/lib/roles"; |
| @@ -78,12 +77,14 @@ const CELEBI_ITEM: NavItem = { | |||
| 78 | action: "celebi", | 77 | action: "celebi", |
| 79 | }; | 78 | }; |
| 80 | 79 | ||
| 81 | -const SOUND_STUDIO_ITEM: NavItem = { | 80 | +// The hub gathers the note studio, the insight board and the Çelebi entry — |
| 82 | - id: "sound-studio", | 81 | +// what used to be a sound-studio row, an unreachable insights page and a |
| 83 | - to: "/coming-soon/ses-atolyesi", | 82 | +// "yakında" placeholder. |
| 84 | - labelKey: "nav.soundStudio", | 83 | +const AI_HUB_ITEM: NavItem = { |
| 85 | - Icon: IconWaveform, | 84 | + id: "ai-hub", |
| 86 | - soon: true, | 85 | + to: "/ai", |
| 86 | + labelKey: "nav.hezarfenZeka", | ||
| 87 | + Icon: IconBotSquare, | ||
| 87 | }; | 88 | }; |
| 88 | 89 | ||
| 89 | function settingsAction(id: string): NavItem { | 90 | function settingsAction(id: string): NavItem { |
| @@ -165,15 +166,13 @@ const ADMIN_GROUPS: NavGroup[] = [ | |||
| 165 | id: "ai", | 166 | id: "ai", |
| 166 | labelKey: "nav.group.ai", | 167 | labelKey: "nav.group.ai", |
| 167 | Icon: IconSparkles, | 168 | Icon: IconSparkles, |
| 168 | - items: [CELEBI_ITEM], | 169 | + items: [CELEBI_ITEM, AI_HUB_ITEM], |
| 169 | }, | 170 | }, |
| 170 | soonGroup([ | 171 | soonGroup([ |
| 171 | { id: "mock-exams", to: "/coming-soon/deneme-sinavlari", labelKey: "nav.mockExams", Icon: IconTarget, soon: true, minRole: "manager" }, | 172 | { id: "mock-exams", to: "/coming-soon/deneme-sinavlari", labelKey: "nav.mockExams", Icon: IconTarget, soon: true, minRole: "manager" }, |
| 172 | { id: "optical-reading", to: "/coming-soon/optik-okuma", labelKey: "nav.opticalReading", Icon: IconScan, soon: true, minRole: "manager" }, | 173 | { id: "optical-reading", to: "/coming-soon/optik-okuma", labelKey: "nav.opticalReading", Icon: IconScan, soon: true, minRole: "manager" }, |
| 173 | { id: "reports", to: "/coming-soon/raporlar", labelKey: "nav.reports", Icon: IconChartPie, soon: true, minRole: "manager" }, | 174 | { id: "reports", to: "/coming-soon/raporlar", labelKey: "nav.reports", Icon: IconChartPie, soon: true, minRole: "manager" }, |
| 174 | { id: "data-protection", to: "/coming-soon/kvkk-denetim", labelKey: "nav.dataProtection", Icon: IconShieldCheck, soon: true, minRole: "admin" }, | 175 | { id: "data-protection", to: "/coming-soon/kvkk-denetim", labelKey: "nav.dataProtection", Icon: IconShieldCheck, soon: true, minRole: "admin" }, |
| 175 | - { id: "hezarfen-zeka", to: "/coming-soon/hezarfen-zeka", labelKey: "nav.hezarfenZeka", Icon: IconBotSquare, soon: true, minRole: "manager" }, | ||
| 176 | - SOUND_STUDIO_ITEM, | ||
| 177 | ]), | 176 | ]), |
| 178 | ]; | 177 | ]; |
| 179 | 178 | ||
| @@ -224,11 +223,16 @@ const TEACHER_GROUPS: NavGroup[] = [ | |||
| 224 | settingsAction("settings-teacher"), | 223 | settingsAction("settings-teacher"), |
| 225 | ], | 224 | ], |
| 226 | }, | 225 | }, |
| 226 | + { | ||
| 227 | + id: "ai", | ||
| 228 | + labelKey: "nav.group.ai", | ||
| 229 | + Icon: IconSparkles, | ||
| 230 | + items: [CELEBI_ITEM, AI_HUB_ITEM], | ||
| 231 | + }, | ||
| 227 | soonGroup([ | 232 | soonGroup([ |
| 228 | { id: "student-analysis", to: "/coming-soon/ogrenci-analizi", labelKey: "nav.studentAnalysis", Icon: IconChart, soon: true }, | 233 | { id: "student-analysis", to: "/coming-soon/ogrenci-analizi", labelKey: "nav.studentAnalysis", Icon: IconChart, soon: true }, |
| 229 | { id: "pending-approvals", to: "/coming-soon/bekleyen-onaylar", labelKey: "nav.pendingApprovals", Icon: IconHelpCircle, soon: true }, | 234 | { id: "pending-approvals", to: "/coming-soon/bekleyen-onaylar", labelKey: "nav.pendingApprovals", Icon: IconHelpCircle, soon: true }, |
| 230 | { id: "question-generation", to: "/coming-soon/soru-uretimi", labelKey: "nav.questionGeneration", Icon: IconEdit, soon: true }, | 235 | { id: "question-generation", to: "/coming-soon/soru-uretimi", labelKey: "nav.questionGeneration", Icon: IconEdit, soon: true }, |
| 231 | - SOUND_STUDIO_ITEM, | ||
| 232 | ]), | 236 | ]), |
| 233 | ]; | 237 | ]; |
| 234 | 238 | ||
| @@ -259,7 +263,7 @@ const STUDENT_GROUPS: NavGroup[] = [ | |||
| 259 | id: "ai", | 263 | id: "ai", |
| 260 | labelKey: "nav.group.ai", | 264 | labelKey: "nav.group.ai", |
| 261 | Icon: IconSparkles, | 265 | Icon: IconSparkles, |
| 262 | - items: [CELEBI_ITEM], | 266 | + items: [CELEBI_ITEM, AI_HUB_ITEM], |
| 263 | }, | 267 | }, |
| 264 | { | 268 | { |
| 265 | id: "other", | 269 | id: "other", |
| @@ -276,7 +280,6 @@ const STUDENT_GROUPS: NavGroup[] = [ | |||
| 276 | }, | 280 | }, |
| 277 | soonGroup([ | 281 | soonGroup([ |
| 278 | { id: "study-plan", to: "/coming-soon/calisma-programim", labelKey: "nav.studyPlan", Icon: IconClock, soon: true }, | 282 | { id: "study-plan", to: "/coming-soon/calisma-programim", labelKey: "nav.studyPlan", Icon: IconClock, soon: true }, |
| 279 | - SOUND_STUDIO_ITEM, | ||
| 280 | ]), | 283 | ]), |
| 281 | ]; | 284 | ]; |
| 282 | 285 | ||
| @@ -306,6 +309,12 @@ const PARENT_GROUPS: NavGroup[] = [ | |||
| 306 | settingsAction("settings-parent"), | 309 | settingsAction("settings-parent"), |
| 307 | ], | 310 | ], |
| 308 | }, | 311 | }, |
| 312 | + { | ||
| 313 | + id: "ai", | ||
| 314 | + labelKey: "nav.group.ai", | ||
| 315 | + Icon: IconSparkles, | ||
| 316 | + items: [AI_HUB_ITEM], | ||
| 317 | + }, | ||
| 309 | ]; | 318 | ]; |
| 310 | 319 | ||
| 311 | const GROUPS_BY_ROLE: Record<Role, NavGroup[]> = { | 320 | const GROUPS_BY_ROLE: Record<Role, NavGroup[]> = { |
src/components/notes/note-reader-panel.tsxmodified+2 -0
| @@ -3,6 +3,7 @@ import type { Note } from "@/api/client"; | |||
| 3 | import type { NoteFileSource } from "@/lib/note-source"; | 3 | import type { NoteFileSource } from "@/lib/note-source"; |
| 4 | import { NoteFilesPanel } from "@/components/notes/note-files-panel"; | 4 | import { NoteFilesPanel } from "@/components/notes/note-files-panel"; |
| 5 | import { RagOutputsPanel } from "@/components/notes/rag-outputs-panel"; | 5 | import { RagOutputsPanel } from "@/components/notes/rag-outputs-panel"; |
| 6 | +import { PodcastPanel } from "@/components/notes/podcast-panel"; | ||
| 6 | import { SidePanel } from "@/components/ui/side-panel"; | 7 | import { SidePanel } from "@/components/ui/side-panel"; |
| 7 | import { toRichTextHtml } from "@/lib/rich-text"; | 8 | import { toRichTextHtml } from "@/lib/rich-text"; |
| 8 | import { useT } from "@/stores/preferences-context"; | 9 | import { useT } from "@/stores/preferences-context"; |
| @@ -39,6 +40,7 @@ export function NoteReaderPanel(props: { | |||
| 39 | <NoteFilesPanel noteId={n().id} source={props.source} canManage={props.canManage} active={props.open} /> | 40 | <NoteFilesPanel noteId={n().id} source={props.source} canManage={props.canManage} active={props.open} /> |
| 40 | <Show when={props.source.listRagOutputs}> | 41 | <Show when={props.source.listRagOutputs}> |
| 41 | <RagOutputsPanel noteId={n().id} source={props.source} canManage={props.canManage} active={props.open} /> | 42 | <RagOutputsPanel noteId={n().id} source={props.source} canManage={props.canManage} active={props.open} /> |
| 43 | + <PodcastPanel noteId={n().id} active={props.open} /> | ||
| 42 | </Show> | 44 | </Show> |
| 43 | </div> | 45 | </div> |
| 44 | )} | 46 | )} |
src/components/notes/podcast-panel.test.tsxadded+53 -0
| @@ -0,0 +1,53 @@ | |||
| 1 | +import { cleanup, fireEvent, render, screen, waitFor } from "@solidjs/testing-library"; | ||
| 2 | +import { afterEach, describe, expect, it, vi } from "vitest"; | ||
| 3 | +import { PodcastPanel } from "@/components/notes/podcast-panel"; | ||
| 4 | +import { PreferencesProvider } from "@/stores/preferences-context"; | ||
| 5 | + | ||
| 6 | +const podcastApi = vi.hoisted(() => ({ | ||
| 7 | + postPodcastJob: vi.fn(), | ||
| 8 | + getPodcastJobById: vi.fn(), | ||
| 9 | + getPodcastJobResultById: vi.fn(), | ||
| 10 | + postPodcastJobCancel: vi.fn(), | ||
| 11 | + podcastAudioUrl: vi.fn((id: string) => `/api/podcast/audio?path=${encodeURIComponent(id)}`), | ||
| 12 | +})); | ||
| 13 | + | ||
| 14 | +vi.mock("@/api/podcast", () => podcastApi); | ||
| 15 | + | ||
| 16 | +// The panel asks what the AI tier allows as soon as it mounts; without this the | ||
| 17 | +// real client reaches for a relative URL node's fetch cannot parse. | ||
| 18 | +const aiApi = vi.hoisted(() => ({ | ||
| 19 | + getAiCapabilities: vi.fn(async () => ({ | ||
| 20 | + enabled: true, | ||
| 21 | + protocol: "hezarfen.ai.v1", | ||
| 22 | + capabilities: [{ capability: "podcast.submit", workers: 1, inflight: 0 }], | ||
| 23 | + })), | ||
| 24 | +})); | ||
| 25 | + | ||
| 26 | +vi.mock("@/api/ai", () => aiApi); | ||
| 27 | + | ||
| 28 | +describe("PodcastPanel", () => { | ||
| 29 | + afterEach(() => { | ||
| 30 | + cleanup(); | ||
| 31 | + sessionStorage.clear(); | ||
| 32 | + vi.clearAllMocks(); | ||
| 33 | + }); | ||
| 34 | + | ||
| 35 | + it("submits the selected lesson note and narration format", async () => { | ||
| 36 | + podcastApi.postPodcastJob.mockResolvedValue({ job_id: "j1", state: "queued", eta_secs: 30 }); | ||
| 37 | + | ||
| 38 | + render(() => ( | ||
| 39 | + <PreferencesProvider> | ||
| 40 | + <PodcastPanel noteId="note-7" /> | ||
| 41 | + </PreferencesProvider> | ||
| 42 | + )); | ||
| 43 | + | ||
| 44 | + fireEvent.change(screen.getByLabelText("Narration style"), { target: { value: "tek_ogretici" } }); | ||
| 45 | + fireEvent.click(screen.getByRole("button", { name: "Create podcast" })); | ||
| 46 | + | ||
| 47 | + await waitFor(() => { | ||
| 48 | + expect(podcastApi.postPodcastJob).toHaveBeenCalledWith({ source_id: "note-7", format: "tek_ogretici" }); | ||
| 49 | + }); | ||
| 50 | + expect(sessionStorage.getItem("hezarfen.podcast.note-7")).toBe("j1"); | ||
| 51 | + expect(screen.getByText("Waiting in queue")).toBeTruthy(); | ||
| 52 | + }); | ||
| 53 | +}); | ||
src/components/notes/podcast-panel.tsxadded+217 -0
| @@ -0,0 +1,217 @@ | |||
| 1 | +import { For, Show, createEffect, createSignal, onCleanup } from "solid-js"; | ||
| 2 | +import { createResource } from "@/lib/create-resource"; | ||
| 3 | +import { getAiCapabilities } from "@/api/ai"; | ||
| 4 | +import { | ||
| 5 | + getPodcastJobById, | ||
| 6 | + getPodcastJobResultById, | ||
| 7 | + podcastAudioUrl, | ||
| 8 | + postPodcastJob, | ||
| 9 | + postPodcastJobCancel, | ||
| 10 | +} from "@/api/podcast"; | ||
| 11 | +import { formatApiError, type PodcastFormat, type PodcastJobArtifacts, type PodcastJobStatus } from "@/api/client"; | ||
| 12 | +import { Alert } from "@/components/ui/alert"; | ||
| 13 | +import { Button } from "@/components/ui/button"; | ||
| 14 | +import { IconWaveform, IconX } from "@/components/ui/icons"; | ||
| 15 | +import { Label } from "@/components/ui/label"; | ||
| 16 | +import { Select } from "@/components/ui/select"; | ||
| 17 | +import { useT } from "@/stores/preferences-context"; | ||
| 18 | + | ||
| 19 | +const POLL_MS = 2_000; | ||
| 20 | + | ||
| 21 | +export function PodcastPanel(props: { noteId: string; active?: boolean }) { | ||
| 22 | + const t = useT(); | ||
| 23 | + const [format, setFormat] = createSignal<PodcastFormat>("duz_okuma"); | ||
| 24 | + const [jobId, setJobId] = createSignal(""); | ||
| 25 | + const [status, setStatus] = createSignal<PodcastJobStatus | null>(null); | ||
| 26 | + const [artifacts, setArtifacts] = createSignal<PodcastJobArtifacts | null>(null); | ||
| 27 | + const [error, setError] = createSignal(""); | ||
| 28 | + const [submitting, setSubmitting] = createSignal(false); | ||
| 29 | + const [cancelling, setCancelling] = createSignal(false); | ||
| 30 | + let timer: ReturnType<typeof setTimeout> | undefined; | ||
| 31 | + let generation = 0; | ||
| 32 | + | ||
| 33 | + // Declared before the resource below: its source runs during setup, so a | ||
| 34 | + // later `const active` would be read in its temporal dead zone. | ||
| 35 | + const active = () => props.active !== false; | ||
| 36 | + const [capabilities] = createResource(() => (active() ? getAiCapabilities() : null)); | ||
| 37 | + const storageKey = () => `hezarfen.podcast.${props.noteId}`; | ||
| 38 | + const stopPolling = () => { | ||
| 39 | + if (timer) clearTimeout(timer); | ||
| 40 | + timer = undefined; | ||
| 41 | + }; | ||
| 42 | + | ||
| 43 | + const poll = async (id: string, token: number) => { | ||
| 44 | + try { | ||
| 45 | + const next = await getPodcastJobById(id); | ||
| 46 | + if (token !== generation || !active()) return; | ||
| 47 | + setStatus(next); | ||
| 48 | + if (next.state === "done") { | ||
| 49 | + const result = await getPodcastJobResultById(id); | ||
| 50 | + if (token === generation) setArtifacts(result); | ||
| 51 | + return; | ||
| 52 | + } | ||
| 53 | + if (next.state === "failed") { | ||
| 54 | + setError(t("podcast.failed")); | ||
| 55 | + return; | ||
| 56 | + } | ||
| 57 | + if (next.state === "cancelled") return; | ||
| 58 | + timer = setTimeout(() => void poll(id, token), POLL_MS); | ||
| 59 | + } catch (err) { | ||
| 60 | + if (token === generation) setError(formatApiError(err)); | ||
| 61 | + } | ||
| 62 | + }; | ||
| 63 | + | ||
| 64 | + createEffect(() => { | ||
| 65 | + const noteId = props.noteId; | ||
| 66 | + const enabled = active(); | ||
| 67 | + generation += 1; | ||
| 68 | + const token = generation; | ||
| 69 | + stopPolling(); | ||
| 70 | + setJobId(""); | ||
| 71 | + setStatus(null); | ||
| 72 | + setArtifacts(null); | ||
| 73 | + setError(""); | ||
| 74 | + if (!enabled || !noteId || typeof sessionStorage === "undefined") return; | ||
| 75 | + const stored = sessionStorage.getItem(storageKey()); | ||
| 76 | + if (stored) { | ||
| 77 | + setJobId(stored); | ||
| 78 | + void poll(stored, token); | ||
| 79 | + } | ||
| 80 | + }); | ||
| 81 | + | ||
| 82 | + onCleanup(() => { | ||
| 83 | + generation += 1; | ||
| 84 | + stopPolling(); | ||
| 85 | + }); | ||
| 86 | + | ||
| 87 | + const submit = async () => { | ||
| 88 | + if (submitting()) return; | ||
| 89 | + generation += 1; | ||
| 90 | + const token = generation; | ||
| 91 | + stopPolling(); | ||
| 92 | + setSubmitting(true); | ||
| 93 | + setError(""); | ||
| 94 | + setArtifacts(null); | ||
| 95 | + try { | ||
| 96 | + const receipt = await postPodcastJob({ source_id: props.noteId, format: format() }); | ||
| 97 | + if (token !== generation) return; | ||
| 98 | + setJobId(receipt.job_id); | ||
| 99 | + setStatus({ job_id: receipt.job_id, state: receipt.state, stage: "queued", progress: 0 }); | ||
| 100 | + if (typeof sessionStorage !== "undefined") sessionStorage.setItem(storageKey(), receipt.job_id); | ||
| 101 | + timer = setTimeout(() => void poll(receipt.job_id, token), POLL_MS); | ||
| 102 | + } catch (err) { | ||
| 103 | + setError(formatApiError(err)); | ||
| 104 | + } finally { | ||
| 105 | + if (token === generation) setSubmitting(false); | ||
| 106 | + } | ||
| 107 | + }; | ||
| 108 | + | ||
| 109 | + const cancel = async () => { | ||
| 110 | + const id = jobId(); | ||
| 111 | + if (!id || cancelling()) return; | ||
| 112 | + setCancelling(true); | ||
| 113 | + setError(""); | ||
| 114 | + try { | ||
| 115 | + await postPodcastJobCancel(id); | ||
| 116 | + generation += 1; | ||
| 117 | + stopPolling(); | ||
| 118 | + setStatus((current) => current ? { ...current, state: "cancelled" } : current); | ||
| 119 | + if (typeof sessionStorage !== "undefined") sessionStorage.removeItem(storageKey()); | ||
| 120 | + } catch (err) { | ||
| 121 | + setError(formatApiError(err)); | ||
| 122 | + } finally { | ||
| 123 | + setCancelling(false); | ||
| 124 | + } | ||
| 125 | + }; | ||
| 126 | + | ||
| 127 | + const progress = () => Math.round(Math.min(1, Math.max(0, status()?.progress ?? 0)) * 100); | ||
| 128 | + const working = () => ["queued", "running"].includes(status()?.state ?? ""); | ||
| 129 | + const available = () => { | ||
| 130 | + const current = capabilities(); | ||
| 131 | + if (!current || capabilities.error) return true; | ||
| 132 | + return current.enabled && current.capabilities.some((item) => item.capability === "podcast.submit" && item.workers > 0); | ||
| 133 | + }; | ||
| 134 | + const stateLabel = (state: string) => { | ||
| 135 | + if (state === "queued") return t("podcast.state.queued"); | ||
| 136 | + if (state === "running") return t("podcast.state.running"); | ||
| 137 | + if (state === "done") return t("podcast.state.done"); | ||
| 138 | + if (state === "failed") return t("podcast.state.failed"); | ||
| 139 | + if (state === "cancelled") return t("podcast.state.cancelled"); | ||
| 140 | + return t("podcast.state.running"); | ||
| 141 | + }; | ||
| 142 | + const formatOptions = () => [ | ||
| 143 | + { value: "duz_okuma", label: t("podcast.format.duz_okuma") }, | ||
| 144 | + { value: "tek_ogretici", label: t("podcast.format.tek_ogretici") }, | ||
| 145 | + { value: "ogrenci_hoca", label: t("podcast.format.ogrenci_hoca") }, | ||
| 146 | + ]; | ||
| 147 | + | ||
| 148 | + return ( | ||
| 149 | + <section class="space-y-4 rounded-xl border border-border-line bg-surface-base p-4 shadow-xs"> | ||
| 150 | + <div class="flex items-start gap-3"> | ||
| 151 | + <div class="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary"> | ||
| 152 | + <IconWaveform class="h-5 w-5" /> | ||
| 153 | + </div> | ||
| 154 | + <div> | ||
| 155 | + <h2 class="font-semibold">{t("podcast.title")}</h2> | ||
| 156 | + <p class="mt-0.5 text-sm text-muted-foreground">{t("podcast.description")}</p> | ||
| 157 | + </div> | ||
| 158 | + </div> | ||
| 159 | + | ||
| 160 | + <Show when={error()}>{(message) => <Alert variant="destructive">{message()}</Alert>}</Show> | ||
| 161 | + <Show when={!available()}> | ||
| 162 | + <Alert variant="warning">{t("podcast.unavailable")}</Alert> | ||
| 163 | + </Show> | ||
| 164 | + | ||
| 165 | + <div class="grid gap-3 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-end"> | ||
| 166 | + <div class="space-y-1.5"> | ||
| 167 | + <Label for={`podcast-format-${props.noteId}`}>{t("podcast.format")}</Label> | ||
| 168 | + <Select | ||
| 169 | + id={`podcast-format-${props.noteId}`} | ||
| 170 | + class="h-10" | ||
| 171 | + value={format()} | ||
| 172 | + disabled={!available() || working() || submitting()} | ||
| 173 | + onChange={(event) => setFormat(event.currentTarget.value as PodcastFormat)} | ||
| 174 | + > | ||
| 175 | + <For each={formatOptions()}> | ||
| 176 | + {(option) => <option value={option.value}>{option.label}</option>} | ||
| 177 | + </For> | ||
| 178 | + </Select> | ||
| 179 | + </div> | ||
| 180 | + <Button type="button" class="h-10 rounded-lg" disabled={!available() || working() || submitting()} onClick={() => void submit()}> | ||
| 181 | + <IconWaveform class="h-4 w-4" /> | ||
| 182 | + {submitting() ? t("podcast.submitting") : t("podcast.create")} | ||
| 183 | + </Button> | ||
| 184 | + </div> | ||
| 185 | + | ||
| 186 | + <Show when={status()}> | ||
| 187 | + {(current) => ( | ||
| 188 | + <div class="space-y-3 rounded-lg border border-border/70 bg-muted/20 p-3"> | ||
| 189 | + <div class="flex items-center justify-between gap-3 text-sm"> | ||
| 190 | + <span class="font-medium">{stateLabel(current().state)}</span> | ||
| 191 | + <span class="font-mono text-xs tabular-nums text-muted-foreground">{progress()}%</span> | ||
| 192 | + </div> | ||
| 193 | + <div class="h-2 overflow-hidden rounded-full bg-muted" role="progressbar" aria-valuenow={progress()} aria-valuemin="0" aria-valuemax="100"> | ||
| 194 | + <div class="h-full rounded-full bg-primary transition-[width]" style={{ width: `${progress()}%` }} /> | ||
| 195 | + </div> | ||
| 196 | + <Show when={working()}> | ||
| 197 | + <Button type="button" size="sm" variant="outline" class="rounded-lg" disabled={cancelling()} onClick={() => void cancel()}> | ||
| 198 | + <IconX class="h-4 w-4" />{t("podcast.cancel")} | ||
| 199 | + </Button> | ||
| 200 | + </Show> | ||
| 201 | + </div> | ||
| 202 | + )} | ||
| 203 | + </Show> | ||
| 204 | + | ||
| 205 | + <Show when={artifacts()}> | ||
| 206 | + {(result) => ( | ||
| 207 | + <div class="space-y-2 rounded-lg border border-success/25 bg-success/5 p-3"> | ||
| 208 | + <p class="text-sm font-medium">{t("podcast.ready")}</p> | ||
| 209 | + <audio class="w-full" controls preload="metadata" src={podcastAudioUrl(result().audio_id)}> | ||
| 210 | + {t("podcast.audioUnsupported")} | ||
| 211 | + </audio> | ||
| 212 | + </div> | ||
| 213 | + )} | ||
| 214 | + </Show> | ||
| 215 | + </section> | ||
| 216 | + ); | ||
| 217 | +} | ||
src/components/notes/rag-output-content.tsxadded+54 -0
| @@ -0,0 +1,54 @@ | |||
| 1 | +import { For, Show } from "solid-js"; | ||
| 2 | + | ||
| 3 | +const SUMMARY_KEYS = ["summary", "ozet", "özet", "content", "text", "answer"]; | ||
| 4 | +const LIST_KEYS = ["keywords", "key_points", "topics", "questions", "highlights"]; | ||
| 5 | + | ||
| 6 | +function asRecord(value: unknown): Record<string, unknown> | null { | ||
| 7 | + return value != null && typeof value === "object" && !Array.isArray(value) | ||
| 8 | + ? value as Record<string, unknown> | ||
| 9 | + : null; | ||
| 10 | +} | ||
| 11 | + | ||
| 12 | +function firstText(record: Record<string, unknown> | null): string | null { | ||
| 13 | + if (!record) return null; | ||
| 14 | + for (const key of SUMMARY_KEYS) { | ||
| 15 | + const value = record[key]; | ||
| 16 | + if (typeof value === "string" && value.trim()) return value.trim(); | ||
| 17 | + } | ||
| 18 | + return null; | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +function firstList(record: Record<string, unknown> | null): string[] { | ||
| 22 | + if (!record) return []; | ||
| 23 | + for (const key of LIST_KEYS) { | ||
| 24 | + const value = record[key]; | ||
| 25 | + if (Array.isArray(value)) { | ||
| 26 | + const rows = value.filter((item): item is string => typeof item === "string" && !!item.trim()); | ||
| 27 | + if (rows.length > 0) return rows; | ||
| 28 | + } | ||
| 29 | + } | ||
| 30 | + return []; | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +/** Render the useful parts of the AI service's open payload without exposing a JSON dump first. */ | ||
| 34 | +export function RagOutputContent(props: { payload: unknown }) { | ||
| 35 | + const record = () => asRecord(props.payload); | ||
| 36 | + const summary = () => typeof props.payload === "string" ? props.payload : firstText(record()); | ||
| 37 | + const points = () => firstList(record()); | ||
| 38 | + | ||
| 39 | + return ( | ||
| 40 | + <div class="space-y-3 text-sm leading-6"> | ||
| 41 | + <Show when={summary()}> | ||
| 42 | + {(text) => <p class="whitespace-pre-wrap text-foreground">{text()}</p>} | ||
| 43 | + </Show> | ||
| 44 | + <Show when={points().length > 0}> | ||
| 45 | + <ul class="list-disc space-y-1 pl-5 text-foreground/85"> | ||
| 46 | + <For each={points()}>{(point) => <li>{point}</li>}</For> | ||
| 47 | + </ul> | ||
| 48 | + </Show> | ||
| 49 | + <Show when={!summary() && points().length === 0}> | ||
| 50 | + <pre class="overflow-x-auto whitespace-pre-wrap text-xs leading-5">{JSON.stringify(props.payload, null, 2)}</pre> | ||
| 51 | + </Show> | ||
| 52 | + </div> | ||
| 53 | + ); | ||
| 54 | +} | ||
src/components/notes/rag-outputs-panel.tsxmodified+64 -4
| @@ -1,16 +1,19 @@ | |||
| 1 | -import { For, Show, Suspense, createSignal } from "solid-js"; | 1 | +import { For, Show, Suspense, createSignal, onCleanup } from "solid-js"; |
| 2 | import { createResource } from "@/lib/create-resource"; | 2 | import { createResource } from "@/lib/create-resource"; |
| 3 | +import { getAiCapabilities } from "@/api/ai"; | ||
| 3 | import { formatApiError } from "@/api/client"; | 4 | import { formatApiError } from "@/api/client"; |
| 4 | import type { RagOutput } from "@/api/client"; | 5 | import type { RagOutput } from "@/api/client"; |
| 5 | import type { NoteFileSource } from "@/lib/note-source"; | 6 | import type { NoteFileSource } from "@/lib/note-source"; |
| 6 | import { Alert } from "@/components/ui/alert"; | 7 | import { Alert } from "@/components/ui/alert"; |
| 8 | +import { Button } from "@/components/ui/button"; | ||
| 7 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | 9 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; |
| 8 | import { PageSpinner } from "@/components/ui/page-spinner"; | 10 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 9 | import { TableRowActions } from "@/components/ui/table-row-actions"; | 11 | import { TableRowActions } from "@/components/ui/table-row-actions"; |
| 10 | import { createFlash } from "@/lib/flash"; | 12 | import { createFlash } from "@/lib/flash"; |
| 11 | import { formatDateTime } from "@/lib/format"; | 13 | import { formatDateTime } from "@/lib/format"; |
| 12 | import { usePreferences, useT } from "@/stores/preferences-context"; | 14 | import { usePreferences, useT } from "@/stores/preferences-context"; |
| 13 | -import { IconTrash } from "@/components/ui/icons"; | 15 | +import { IconSparkles, IconTrash } from "@/components/ui/icons"; |
| 16 | +import { RagOutputContent } from "@/components/notes/rag-output-content"; | ||
| 14 | 17 | ||
| 15 | const RAG_PAGE_SIZE = 10; | 18 | const RAG_PAGE_SIZE = 10; |
| 16 | 19 | ||
| @@ -26,13 +29,56 @@ export function RagOutputsPanel(props: { | |||
| 26 | const [error, setError] = createSignal(""); | 29 | const [error, setError] = createSignal(""); |
| 27 | const [flash, setFlash] = createFlash(); | 30 | const [flash, setFlash] = createFlash(); |
| 28 | const [deleteTarget, setDeleteTarget] = createSignal<RagOutput | null>(null); | 31 | const [deleteTarget, setDeleteTarget] = createSignal<RagOutput | null>(null); |
| 32 | + const [generating, setGenerating] = createSignal(false); | ||
| 33 | + let pollTimer: ReturnType<typeof setTimeout> | undefined; | ||
| 34 | + | ||
| 35 | + onCleanup(() => pollTimer && clearTimeout(pollTimer)); | ||
| 29 | 36 | ||
| 30 | const [list, { refetch }] = createResource( | 37 | const [list, { refetch }] = createResource( |
| 31 | () => (props.active && props.source.listRagOutputs ? props.noteId : null), | 38 | () => (props.active && props.source.listRagOutputs ? props.noteId : null), |
| 32 | async (noteId) => props.source.listRagOutputs!(noteId, { limit: RAG_PAGE_SIZE }), | 39 | async (noteId) => props.source.listRagOutputs!(noteId, { limit: RAG_PAGE_SIZE }), |
| 33 | ); | 40 | ); |
| 41 | + const [capabilities] = createResource( | ||
| 42 | + () => (props.active && props.source.reindexRag ? true : null), | ||
| 43 | + () => getAiCapabilities(), | ||
| 44 | + ); | ||
| 34 | 45 | ||
| 35 | const outputs = () => list()?.items ?? []; | 46 | const outputs = () => list()?.items ?? []; |
| 47 | + const available = () => capabilities.error || capabilities()?.enabled !== false; | ||
| 48 | + | ||
| 49 | + const generate = async () => { | ||
| 50 | + if (!props.source.reindexRag || generating()) return; | ||
| 51 | + setError(""); | ||
| 52 | + setGenerating(true); | ||
| 53 | + const previousId = outputs()[0]?.id; | ||
| 54 | + try { | ||
| 55 | + await props.source.reindexRag(props.noteId); | ||
| 56 | + let attempts = 0; | ||
| 57 | + const poll = async () => { | ||
| 58 | + if (!props.active) { | ||
| 59 | + setGenerating(false); | ||
| 60 | + return; | ||
| 61 | + } | ||
| 62 | + attempts += 1; | ||
| 63 | + const next = await refetch(); | ||
| 64 | + const firstId = next?.items?.[0]?.id; | ||
| 65 | + if ((firstId && firstId !== previousId) || attempts >= 24) { | ||
| 66 | + setGenerating(false); | ||
| 67 | + setFlash(firstId && firstId !== previousId ? t("courseNotes.ragReady") : t("courseNotes.ragQueued")); | ||
| 68 | + return; | ||
| 69 | + } | ||
| 70 | + pollTimer = setTimeout(() => void poll().catch(fail), 2500); | ||
| 71 | + }; | ||
| 72 | + const fail = (err: unknown) => { | ||
| 73 | + setGenerating(false); | ||
| 74 | + setError(formatApiError(err)); | ||
| 75 | + }; | ||
| 76 | + pollTimer = setTimeout(() => void poll().catch(fail), 1500); | ||
| 77 | + } catch (err) { | ||
| 78 | + setGenerating(false); | ||
| 79 | + setError(formatApiError(err)); | ||
| 80 | + } | ||
| 81 | + }; | ||
| 36 | 82 | ||
| 37 | const remove = async () => { | 83 | const remove = async () => { |
| 38 | const target = deleteTarget(); | 84 | const target = deleteTarget(); |
| @@ -51,13 +97,27 @@ export function RagOutputsPanel(props: { | |||
| 51 | 97 | ||
| 52 | return ( | 98 | return ( |
| 53 | <section class="space-y-3 rounded-lg border border-border/80 bg-card p-4 shadow-xs dark:border-white/8"> | 99 | <section class="space-y-3 rounded-lg border border-border/80 bg-card p-4 shadow-xs dark:border-white/8"> |
| 54 | - <h3 class="text-sm font-semibold">{t("courseNotes.ragTitle")}</h3> | 100 | + <div class="flex flex-wrap items-center justify-between gap-2"> |
| 101 | + <div> | ||
| 102 | + <h3 class="text-sm font-semibold">{t("courseNotes.ragTitle")}</h3> | ||
| 103 | + <p class="mt-0.5 text-xs text-muted-foreground">{t("courseNotes.ragHint")}</p> | ||
| 104 | + </div> | ||
| 105 | + <Show when={props.canManage !== false && props.source.reindexRag}> | ||
| 106 | + <Button type="button" size="sm" variant="outline" class="rounded-lg" disabled={!available() || generating()} onClick={() => void generate()}> | ||
| 107 | + <IconSparkles class="h-4 w-4" /> | ||
| 108 | + {generating() ? t("courseNotes.ragGenerating") : t("courseNotes.ragGenerate")} | ||
| 109 | + </Button> | ||
| 110 | + </Show> | ||
| 111 | + </div> | ||
| 55 | <Show when={flash()}> | 112 | <Show when={flash()}> |
| 56 | <Alert variant="success">{flash()}</Alert> | 113 | <Alert variant="success">{flash()}</Alert> |
| 57 | </Show> | 114 | </Show> |
| 58 | <Show when={error()}> | 115 | <Show when={error()}> |
| 59 | <Alert variant="destructive">{error()}</Alert> | 116 | <Alert variant="destructive">{error()}</Alert> |
| 60 | </Show> | 117 | </Show> |
| 118 | + <Show when={!available()}> | ||
| 119 | + <Alert variant="warning">{t("courseNotes.ragUnavailable")}</Alert> | ||
| 120 | + </Show> | ||
| 61 | <Suspense fallback={<PageSpinner />}> | 121 | <Suspense fallback={<PageSpinner />}> |
| 62 | <Show when={list.error}> | 122 | <Show when={list.error}> |
| 63 | <Alert variant="destructive">{formatApiError(list.error)}</Alert> | 123 | <Alert variant="destructive">{formatApiError(list.error)}</Alert> |
| @@ -87,7 +147,7 @@ export function RagOutputsPanel(props: { | |||
| 87 | </Show> | 147 | </Show> |
| 88 | </span> | 148 | </span> |
| 89 | </div> | 149 | </div> |
| 90 | - <pre class="overflow-x-auto whitespace-pre-wrap text-xs leading-5">{JSON.stringify(output.payload, null, 2)}</pre> | 150 | + <RagOutputContent payload={output.payload} /> |
| 91 | </li> | 151 | </li> |
| 92 | )} | 152 | )} |
| 93 | </For> | 153 | </For> |
src/components/rag/rag-citations.tsxadded+44 -0
| @@ -0,0 +1,44 @@ | |||
| 1 | +import { For, Show } from "solid-js"; | ||
| 2 | +import type { RagCitation } from "@/api/client"; | ||
| 3 | +import { IconBook, IconFileText } from "@/components/ui/icons"; | ||
| 4 | + | ||
| 5 | +export function RagCitations(props: { | ||
| 6 | + citations: RagCitation[]; | ||
| 7 | + labels: { sources: string; source: string; subject: string; pages: string; document: string }; | ||
| 8 | +}) { | ||
| 9 | + return ( | ||
| 10 | + <Show when={props.citations.length > 0}> | ||
| 11 | + <div class="mt-3 border-t border-border/60 pt-3"> | ||
| 12 | + <p class="mb-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground"> | ||
| 13 | + {props.labels.sources} | ||
| 14 | + </p> | ||
| 15 | + <ol class="grid gap-2 sm:grid-cols-2"> | ||
| 16 | + <For each={props.citations}> | ||
| 17 | + {(citation) => ( | ||
| 18 | + <li class="rounded-lg border border-border/70 bg-muted/30 px-3 py-2 text-xs"> | ||
| 19 | + <div class="flex items-start gap-2"> | ||
| 20 | + <span class="mt-0.5 flex h-5 min-w-5 items-center justify-center rounded-md bg-primary/10 px-1 font-mono font-semibold text-primary"> | ||
| 21 | + {citation.n} | ||
| 22 | + </span> | ||
| 23 | + <div class="min-w-0 space-y-1"> | ||
| 24 | + <p class="flex items-center gap-1.5 font-medium text-foreground"> | ||
| 25 | + <Show when={citation.ders} fallback={<IconFileText class="h-3.5 w-3.5" />}> | ||
| 26 | + <IconBook class="h-3.5 w-3.5" /> | ||
| 27 | + </Show> | ||
| 28 | + <span class="truncate">{citation.ders || props.labels.document}</span> | ||
| 29 | + </p> | ||
| 30 | + <Show when={citation.pages.length > 0}> | ||
| 31 | + <p class="text-muted-foreground"> | ||
| 32 | + {props.labels.pages}: <span class="tabular-nums">{citation.pages.join(", ")}</span> | ||
| 33 | + </p> | ||
| 34 | + </Show> | ||
| 35 | + </div> | ||
| 36 | + </div> | ||
| 37 | + </li> | ||
| 38 | + )} | ||
| 39 | + </For> | ||
| 40 | + </ol> | ||
| 41 | + </div> | ||
| 42 | + </Show> | ||
| 43 | + ); | ||
| 44 | +} | ||
src/components/rag/rag-composer.tsxadded+69 -0
| @@ -0,0 +1,69 @@ | |||
| 1 | +import { createEffect } from "solid-js"; | ||
| 2 | +import { Button } from "@/components/ui/button"; | ||
| 3 | +import { IconSend } from "@/components/ui/icons"; | ||
| 4 | +import { Textarea } from "@/components/ui/textarea"; | ||
| 5 | + | ||
| 6 | +const MAX_HEIGHT_PX = 176; | ||
| 7 | + | ||
| 8 | +export function RagComposer(props: { | ||
| 9 | + value: string; | ||
| 10 | + placeholder: string; | ||
| 11 | + sendLabel: string; | ||
| 12 | + hint: string; | ||
| 13 | + disabled: boolean; | ||
| 14 | + onInput: (value: string) => void; | ||
| 15 | + onSubmit: () => void; | ||
| 16 | +}) { | ||
| 17 | + let field: HTMLTextAreaElement | undefined; | ||
| 18 | + | ||
| 19 | + const resize = () => { | ||
| 20 | + if (!field) return; | ||
| 21 | + field.style.height = "auto"; | ||
| 22 | + field.style.height = `${Math.min(field.scrollHeight, MAX_HEIGHT_PX)}px`; | ||
| 23 | + }; | ||
| 24 | + | ||
| 25 | + createEffect(() => { | ||
| 26 | + void props.value; | ||
| 27 | + resize(); | ||
| 28 | + }); | ||
| 29 | + | ||
| 30 | + return ( | ||
| 31 | + <form | ||
| 32 | + class="border-t border-border/70 bg-surface-base px-4 py-3" | ||
| 33 | + onSubmit={(event) => { | ||
| 34 | + event.preventDefault(); | ||
| 35 | + if (!props.disabled) props.onSubmit(); | ||
| 36 | + }} | ||
| 37 | + > | ||
| 38 | + <div class="flex 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"> | ||
| 39 | + <Textarea | ||
| 40 | + ref={field} | ||
| 41 | + rows={1} | ||
| 42 | + maxlength={8000} | ||
| 43 | + value={props.value} | ||
| 44 | + disabled={props.disabled} | ||
| 45 | + 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" | ||
| 47 | + onInput={(event) => props.onInput(event.currentTarget.value)} | ||
| 48 | + onKeyDown={(event) => { | ||
| 49 | + if (event.key === "Enter" && !event.shiftKey) { | ||
| 50 | + event.preventDefault(); | ||
| 51 | + if (!props.disabled) props.onSubmit(); | ||
| 52 | + } | ||
| 53 | + }} | ||
| 54 | + /> | ||
| 55 | + <Button | ||
| 56 | + type="submit" | ||
| 57 | + size="sm" | ||
| 58 | + class="h-8 w-8 shrink-0 rounded-full p-0" | ||
| 59 | + aria-label={props.sendLabel} | ||
| 60 | + title={props.sendLabel} | ||
| 61 | + disabled={props.disabled || !props.value.trim()} | ||
| 62 | + > | ||
| 63 | + <IconSend class="h-4 w-4" /> | ||
| 64 | + </Button> | ||
| 65 | + </div> | ||
| 66 | + <p class="mt-1.5 px-1 text-[11px] leading-4 text-muted-foreground">{props.hint}</p> | ||
| 67 | + </form> | ||
| 68 | + ); | ||
| 69 | +} | ||
src/components/rag/rag-copy.tsadded+72 -0
| @@ -0,0 +1,72 @@ | |||
| 1 | +import type { Locale } from "@/i18n/messages"; | ||
| 2 | + | ||
| 3 | +const copy = { | ||
| 4 | + en: { | ||
| 5 | + title: "Ask your notes", | ||
| 6 | + description: "Ask questions across the course material available to you and review the sources behind each answer.", | ||
| 7 | + newThread: "New chat", | ||
| 8 | + history: "Chat history", | ||
| 9 | + untitled: "Untitled chat", | ||
| 10 | + emptyThreads: "No chats yet", | ||
| 11 | + emptyThreadsHint: "Start a new chat to ask the course corpus a question.", | ||
| 12 | + emptyChat: "What would you like to learn?", | ||
| 13 | + emptyChatHint: "Answers use only the course material available to your account.", | ||
| 14 | + placeholder: "Ask a question about your course notes…", | ||
| 15 | + send: "Send", | ||
| 16 | + composerHint: "Enter to send · Shift+Enter for a new line", | ||
| 17 | + thinking: "Searching your course material…", | ||
| 18 | + sources: "Sources", | ||
| 19 | + source: "Source", | ||
| 20 | + subject: "Subject", | ||
| 21 | + pages: "Pages", | ||
| 22 | + document: "Course document", | ||
| 23 | + rename: "Rename chat", | ||
| 24 | + renameHint: "Give this chat a short, recognisable name.", | ||
| 25 | + renameLabel: "Chat name", | ||
| 26 | + renamePlaceholder: "e.g. Newton's laws", | ||
| 27 | + delete: "Delete chat", | ||
| 28 | + deleteHint: "This permanently deletes the chat and all of its messages.", | ||
| 29 | + deleteConfirm: "Delete chat", | ||
| 30 | + failed: "The answer could not be completed. Please try again.", | ||
| 31 | + failedWithCode: (code: string) => `The answer could not be completed (${code}). Please try again.`, | ||
| 32 | + abstained: "There was not enough course material to answer this question confidently.", | ||
| 33 | + abstainedReason: (reason: string) => `Reason: ${reason}`, | ||
| 34 | + loadingMessages: "Loading messages…", | ||
| 35 | + }, | ||
| 36 | + tr: { | ||
| 37 | + title: "Notlarına sor", | ||
| 38 | + description: "Erişebildiğin ders içeriklerinde soru sor ve her yanıtın dayandığı kaynakları incele.", | ||
| 39 | + newThread: "Yeni sohbet", | ||
| 40 | + history: "Sohbet geçmişi", | ||
| 41 | + untitled: "Başlıksız sohbet", | ||
| 42 | + emptyThreads: "Henüz sohbet yok", | ||
| 43 | + emptyThreadsHint: "Ders arşivine soru sormak için yeni bir sohbet başlat.", | ||
| 44 | + emptyChat: "Ne öğrenmek istersin?", | ||
| 45 | + emptyChatHint: "Yanıtlar yalnızca hesabının erişebildiği ders içeriklerini kullanır.", | ||
| 46 | + placeholder: "Ders notların hakkında bir soru sor…", | ||
| 47 | + send: "Gönder", | ||
| 48 | + composerHint: "Göndermek için Enter · Yeni satır için Shift+Enter", | ||
| 49 | + thinking: "Ders içeriklerinde aranıyor…", | ||
| 50 | + sources: "Kaynaklar", | ||
| 51 | + source: "Kaynak", | ||
| 52 | + subject: "Ders", | ||
| 53 | + pages: "Sayfalar", | ||
| 54 | + document: "Ders belgesi", | ||
| 55 | + rename: "Sohbeti yeniden adlandır", | ||
| 56 | + renameHint: "Bu sohbete kısa ve ayırt edilebilir bir ad ver.", | ||
| 57 | + renameLabel: "Sohbet adı", | ||
| 58 | + renamePlaceholder: "Örn. Newton yasaları", | ||
| 59 | + delete: "Sohbeti sil", | ||
| 60 | + deleteHint: "Bu işlem sohbeti ve tüm mesajlarını kalıcı olarak siler.", | ||
| 61 | + deleteConfirm: "Sohbeti sil", | ||
| 62 | + failed: "Yanıt tamamlanamadı. Lütfen tekrar dene.", | ||
| 63 | + failedWithCode: (code: string) => `Yanıt tamamlanamadı (${code}). Lütfen tekrar dene.`, | ||
| 64 | + abstained: "Bu soruyu güvenle yanıtlamak için yeterli ders içeriği bulunamadı.", | ||
| 65 | + abstainedReason: (reason: string) => `Neden: ${reason}`, | ||
| 66 | + loadingMessages: "Mesajlar yükleniyor…", | ||
| 67 | + }, | ||
| 68 | +} as const; | ||
| 69 | + | ||
| 70 | +export function ragCopy(locale: Locale) { | ||
| 71 | + return copy[locale]; | ||
| 72 | +} | ||
src/components/rag/rag-message-row.tsxadded+69 -0
| @@ -0,0 +1,69 @@ | |||
| 1 | +import { Match, Show, Switch } from "solid-js"; | ||
| 2 | +import type { RagMessage } from "@/api/client"; | ||
| 3 | +import { CelebiMarkdown } from "@/components/layout/celebi-markdown"; | ||
| 4 | +import { IconAlert, IconBotSquare } from "@/components/ui/icons"; | ||
| 5 | +import { RagCitations } from "@/components/rag/rag-citations"; | ||
| 6 | +import { cn } from "@/lib/cn"; | ||
| 7 | + | ||
| 8 | +export function RagMessageRow(props: { | ||
| 9 | + message: RagMessage; | ||
| 10 | + labels: { | ||
| 11 | + thinking: string; | ||
| 12 | + sources: string; | ||
| 13 | + source: string; | ||
| 14 | + subject: string; | ||
| 15 | + pages: string; | ||
| 16 | + document: string; | ||
| 17 | + failed: string; | ||
| 18 | + failedWithCode: (code: string) => string; | ||
| 19 | + abstained: string; | ||
| 20 | + abstainedReason: (reason: string) => string; | ||
| 21 | + }; | ||
| 22 | +}) { | ||
| 23 | + const assistant = () => props.message.role === "assistant"; | ||
| 24 | + const failure = () => props.message.error_code | ||
| 25 | + ? props.labels.failedWithCode(props.message.error_code) | ||
| 26 | + : props.labels.failed; | ||
| 27 | + | ||
| 28 | + return ( | ||
| 29 | + <article class={cn("flex gap-3", assistant() ? "justify-start" : "justify-end")}> | ||
| 30 | + <Show when={assistant()}> | ||
| 31 | + <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"> | ||
| 32 | + <IconBotSquare class="h-4 w-4" /> | ||
| 33 | + </span> | ||
| 34 | + </Show> | ||
| 35 | + <div | ||
| 36 | + class={cn( | ||
| 37 | + "max-w-[min(46rem,88%)] rounded-xl px-4 py-3 text-sm", | ||
| 38 | + assistant() ? "border border-border-line bg-surface-base text-foreground" : "bg-primary text-primary-foreground", | ||
| 39 | + )} | ||
| 40 | + > | ||
| 41 | + <Switch> | ||
| 42 | + <Match when={props.message.status === "pending" && !props.message.content}> | ||
| 43 | + <p class="animate-pulse text-muted-foreground" role="status">{props.labels.thinking}</p> | ||
| 44 | + </Match> | ||
| 45 | + <Match when={props.message.status === "failed"}> | ||
| 46 | + <div class="flex items-start gap-2 text-destructive"> | ||
| 47 | + <IconAlert class="mt-0.5 h-4 w-4 shrink-0" /> | ||
| 48 | + <p>{failure()}</p> | ||
| 49 | + </div> | ||
| 50 | + </Match> | ||
| 51 | + <Match when={props.message.abstained}> | ||
| 52 | + <div class="space-y-1 text-muted-foreground"> | ||
| 53 | + <p>{props.message.content || props.labels.abstained}</p> | ||
| 54 | + <Show when={props.message.reason}> | ||
| 55 | + <p class="text-xs">{props.labels.abstainedReason(props.message.reason)}</p> | ||
| 56 | + </Show> | ||
| 57 | + </div> | ||
| 58 | + </Match> | ||
| 59 | + <Match when={true}> | ||
| 60 | + <CelebiMarkdown text={props.message.content} /> | ||
| 61 | + </Match> | ||
| 62 | + </Switch> | ||
| 63 | + <Show when={assistant()}> | ||
| 64 | + <RagCitations citations={props.message.citations} labels={props.labels} /> | ||
| 65 | + </Show> | ||
| 66 | + </div> | ||
| 67 | + </article> | ||
| 68 | + ); | ||
| 69 | +} | ||
src/components/rag/rag-thread-list.tsxadded+87 -0
| @@ -0,0 +1,87 @@ | |||
| 1 | +import { For, Show, createEffect, createSignal, on } from "solid-js"; | ||
| 2 | +import { createResource } from "@/lib/create-resource"; | ||
| 3 | +import { getRagThreads } from "@/api/rag"; | ||
| 4 | +import type { RagThread } from "@/api/client"; | ||
| 5 | +import { EmptyInline } from "@/components/ui/empty-inline"; | ||
| 6 | +import { IconEdit, IconTrash } from "@/components/ui/icons"; | ||
| 7 | +import { PageSpinner } from "@/components/ui/page-spinner"; | ||
| 8 | +import { PaginationControls } from "@/components/ui/pagination-controls"; | ||
| 9 | +import { cn } from "@/lib/cn"; | ||
| 10 | +import { formatDateTime } from "@/lib/format"; | ||
| 11 | +import type { Locale } from "@/i18n/messages"; | ||
| 12 | + | ||
| 13 | +const THREAD_PAGE_SIZE = 12; | ||
| 14 | + | ||
| 15 | +export function RagThreadList(props: { | ||
| 16 | + activeId?: string; | ||
| 17 | + version: number; | ||
| 18 | + locale: Locale; | ||
| 19 | + labels: { untitled: string; emptyThreads: string; emptyThreadsHint: string; rename: string; delete: string }; | ||
| 20 | + onOpen: (thread: RagThread) => void; | ||
| 21 | + onRename: (thread: RagThread) => void; | ||
| 22 | + onRemove: (thread: RagThread) => void; | ||
| 23 | +}) { | ||
| 24 | + const [page, setPage] = createSignal(0); | ||
| 25 | + const [threads] = createResource( | ||
| 26 | + () => ({ page: page(), version: props.version }), | ||
| 27 | + ({ page }) => getRagThreads({ limit: THREAD_PAGE_SIZE, offset: page * THREAD_PAGE_SIZE }), | ||
| 28 | + ); | ||
| 29 | + const totalPages = () => Math.max(1, Math.ceil((threads.latest?.total ?? 0) / THREAD_PAGE_SIZE)); | ||
| 30 | + | ||
| 31 | + createEffect(on(() => threads.latest, (result) => { | ||
| 32 | + if (result && result.items.length === 0 && page() > 0) setPage(Math.min(page() - 1, totalPages() - 1)); | ||
| 33 | + })); | ||
| 34 | + | ||
| 35 | + return ( | ||
| 36 | + <div class="flex min-h-0 flex-1 flex-col"> | ||
| 37 | + <div class="min-h-0 flex-1 overflow-y-auto overscroll-contain pr-1"> | ||
| 38 | + <Show when={threads.latest} fallback={<PageSpinner />}> | ||
| 39 | + {(result) => ( | ||
| 40 | + <Show | ||
| 41 | + when={result().items.length > 0} | ||
| 42 | + fallback={<EmptyInline class="h-full py-10" size="md" illustration="messages" title={props.labels.emptyThreads} hint={props.labels.emptyThreadsHint} />} | ||
| 43 | + > | ||
| 44 | + <ul class="space-y-1.5"> | ||
| 45 | + <For each={result().items}> | ||
| 46 | + {(thread) => ( | ||
| 47 | + <li class={cn("flex overflow-hidden rounded-lg border border-border", thread.id === props.activeId ? "bg-accent" : "bg-card")}> | ||
| 48 | + <button | ||
| 49 | + type="button" | ||
| 50 | + 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" | ||
| 51 | + onClick={() => props.onOpen(thread)} | ||
| 52 | + > | ||
| 53 | + <span class="w-full truncate text-sm font-medium">{thread.title || props.labels.untitled}</span> | ||
| 54 | + <span class="text-[11px] tabular-nums text-muted-foreground">{formatDateTime(thread.updated_at, props.locale)}</span> | ||
| 55 | + </button> | ||
| 56 | + <button | ||
| 57 | + type="button" | ||
| 58 | + class="flex w-9 shrink-0 items-center justify-center border-l border-border text-muted-foreground transition-colors hover:bg-muted hover:text-foreground" | ||
| 59 | + aria-label={props.labels.rename} | ||
| 60 | + onClick={() => props.onRename(thread)} | ||
| 61 | + > | ||
| 62 | + <IconEdit class="h-3.5 w-3.5" /> | ||
| 63 | + </button> | ||
| 64 | + <button | ||
| 65 | + type="button" | ||
| 66 | + class="flex w-9 shrink-0 items-center justify-center border-l border-border text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive" | ||
| 67 | + aria-label={props.labels.delete} | ||
| 68 | + onClick={() => props.onRemove(thread)} | ||
| 69 | + > | ||
| 70 | + <IconTrash class="h-3.5 w-3.5" /> | ||
| 71 | + </button> | ||
| 72 | + </li> | ||
| 73 | + )} | ||
| 74 | + </For> | ||
| 75 | + </ul> | ||
| 76 | + </Show> | ||
| 77 | + )} | ||
| 78 | + </Show> | ||
| 79 | + </div> | ||
| 80 | + <Show when={totalPages() > 1}> | ||
| 81 | + <div class="mt-3 shrink-0"> | ||
| 82 | + <PaginationControls page={page()} totalPages={totalPages()} onPageChange={setPage} /> | ||
| 83 | + </div> | ||
| 84 | + </Show> | ||
| 85 | + </div> | ||
| 86 | + ); | ||
| 87 | +} | ||
src/i18n/messages.tsmodified+285 -3
| @@ -32,6 +32,13 @@ export type MessageKey = | |||
| 32 | | "ai.chats" | 32 | | "ai.chats" |
| 33 | | "ai.noChats" | 33 | | "ai.noChats" |
| 34 | | "ai.noSearchResults" | 34 | | "ai.noSearchResults" |
| 35 | + | "aiHub.description" | ||
| 36 | + | "aiHub.tab.studio" | ||
| 37 | + | "aiHub.tab.insights" | ||
| 38 | + | "aiHub.celebiExample1" | ||
| 39 | + | "aiHub.celebiExample2" | ||
| 40 | + | "aiHub.celebiExample3" | ||
| 41 | + | "aiHub.celebiHint" | ||
| 35 | | "nav.today" | 42 | | "nav.today" |
| 36 | | "nav.classes" | 43 | | "nav.classes" |
| 37 | | "nav.classGroups" | 44 | | "nav.classGroups" |
| @@ -377,7 +384,6 @@ export type MessageKey = | |||
| 377 | | "nav.opticalReading" | 384 | | "nav.opticalReading" |
| 378 | | "nav.hezarfenZeka" | 385 | | "nav.hezarfenZeka" |
| 379 | | "nav.celebi" | 386 | | "nav.celebi" |
| 380 | - | "nav.soundStudio" | ||
| 381 | | "nav.reports" | 387 | | "nav.reports" |
| 382 | | "nav.licenseModules" | 388 | | "nav.licenseModules" |
| 383 | | "nav.dataProtection" | 389 | | "nav.dataProtection" |
| @@ -859,6 +865,93 @@ export type MessageKey = | |||
| 859 | | "courseNotes.emptyManageHint" | 865 | | "courseNotes.emptyManageHint" |
| 860 | | "courseNotes.ragTitle" | 866 | | "courseNotes.ragTitle" |
| 861 | | "courseNotes.ragEmpty" | 867 | | "courseNotes.ragEmpty" |
| 868 | + | "courseNotes.ragHint" | ||
| 869 | + | "courseNotes.ragGenerate" | ||
| 870 | + | "courseNotes.ragGenerating" | ||
| 871 | + | "courseNotes.ragReady" | ||
| 872 | + | "courseNotes.ragQueued" | ||
| 873 | + | "courseNotes.ragUnavailable" | ||
| 874 | + | "podcast.title" | ||
| 875 | + | "podcast.description" | ||
| 876 | + | "podcast.pageDescription" | ||
| 877 | + | "podcast.source" | ||
| 878 | + | "podcast.selectNote" | ||
| 879 | + | "podcast.selectPrompt" | ||
| 880 | + | "podcast.selectPromptHint" | ||
| 881 | + | "podcast.noNotes" | ||
| 882 | + | "podcast.noNotesHint" | ||
| 883 | + | "podcast.format" | ||
| 884 | + | "podcast.format.duz_okuma" | ||
| 885 | + | "podcast.format.tek_ogretici" | ||
| 886 | + | "podcast.format.ogrenci_hoca" | ||
| 887 | + | "podcast.create" | ||
| 888 | + | "podcast.submitting" | ||
| 889 | + | "podcast.cancel" | ||
| 890 | + | "podcast.ready" | ||
| 891 | + | "podcast.failed" | ||
| 892 | + | "podcast.audioUnsupported" | ||
| 893 | + | "podcast.unavailable" | ||
| 894 | + | "podcast.state.queued" | ||
| 895 | + | "podcast.state.running" | ||
| 896 | + | "podcast.state.done" | ||
| 897 | + | "podcast.state.failed" | ||
| 898 | + | "podcast.state.cancelled" | ||
| 899 | + | "insights.title" | ||
| 900 | + | "insights.subtitle" | ||
| 901 | + | "insights.student" | ||
| 902 | + | "insights.studentAnalysis" | ||
| 903 | + | "insights.searchStudents" | ||
| 904 | + | "insights.emptyStudents" | ||
| 905 | + | "insights.viewAnalysis" | ||
| 906 | + | "insights.refreshAll" | ||
| 907 | + | "insights.refreshingAll" | ||
| 908 | + | "insights.refreshQueued" | ||
| 909 | + | "insights.recompute" | ||
| 910 | + | "insights.recomputing" | ||
| 911 | + | "insights.recomputeQueued" | ||
| 912 | + | "insights.summary" | ||
| 913 | + | "insights.noSummary" | ||
| 914 | + | "insights.noSummaryHint" | ||
| 915 | + | "insights.computedAt" | ||
| 916 | + | "insights.retainUntil" | ||
| 917 | + | "insights.sectionNotComputed" | ||
| 918 | + | "insights.noEvidence" | ||
| 919 | + | "insights.modules.attendance" | ||
| 920 | + | "insights.modules.marks" | ||
| 921 | + | "insights.modules.study" | ||
| 922 | + | "insights.modules.submission" | ||
| 923 | + | "insights.attention" | ||
| 924 | + | "insights.noAttention" | ||
| 925 | + | "insights.schoolWide" | ||
| 926 | + | "insights.recommendations" | ||
| 927 | + | "insights.noRecommendations" | ||
| 928 | + | "insights.expiresAt" | ||
| 929 | + | "insights.segments" | ||
| 930 | + | "insights.noSegments" | ||
| 931 | + | "insights.accuracy" | ||
| 932 | + | "insights.answers" | ||
| 933 | + | "insights.overall" | ||
| 934 | + | "insights.contrast" | ||
| 935 | + | "insights.confidence.none" | ||
| 936 | + | "insights.confidence.exploratory" | ||
| 937 | + | "insights.confidence.stable" | ||
| 938 | + | "insights.runs" | ||
| 939 | + | "insights.runsSubtitle" | ||
| 940 | + | "insights.runDay" | ||
| 941 | + | "insights.result" | ||
| 942 | + | "insights.processed" | ||
| 943 | + | "insights.written" | ||
| 944 | + | "insights.duration" | ||
| 945 | + | "insights.issues" | ||
| 946 | + | "insights.issueCount" | ||
| 947 | + | "insights.noIssues" | ||
| 948 | + | "insights.budgetExceeded" | ||
| 949 | + | "insights.emptyRuns" | ||
| 950 | + | "insights.status.running" | ||
| 951 | + | "insights.status.ok" | ||
| 952 | + | "insights.status.partial" | ||
| 953 | + | "insights.status.failed" | ||
| 954 | + | "insights.status.skipped" | ||
| 862 | | "notes.title" | 955 | | "notes.title" |
| 863 | | "notes.subtitle" | 956 | | "notes.subtitle" |
| 864 | | "notes.new" | 957 | | "notes.new" |
| @@ -1751,6 +1844,7 @@ export type MessageKey = | |||
| 1751 | | "sessions.empty" | 1844 | | "sessions.empty" |
| 1752 | | "sessions.untitled" | 1845 | | "sessions.untitled" |
| 1753 | | "sessions.teacher" | 1846 | | "sessions.teacher" |
| 1847 | + | "sessions.defaultTeacher" | ||
| 1754 | | "sessions.rollCall" | 1848 | | "sessions.rollCall" |
| 1755 | | "sessions.emptyRoster" | 1849 | | "sessions.emptyRoster" |
| 1756 | | "sessions.startRequired" | 1850 | | "sessions.startRequired" |
| @@ -2032,6 +2126,13 @@ const en: Dict = { | |||
| 2032 | "ai.chats": "Chats", | 2126 | "ai.chats": "Chats", |
| 2033 | "ai.noChats": "No chats yet. Start one and it will appear here.", | 2127 | "ai.noChats": "No chats yet. Start one and it will appear here.", |
| 2034 | "ai.noSearchResults": "No messages match your search.", | 2128 | "ai.noSearchResults": "No messages match your search.", |
| 2129 | + "aiHub.description": "Every AI surface in one place: note outputs and podcasts, student analysis, and Çelebi.", | ||
| 2130 | + "aiHub.tab.studio": "Note studio", | ||
| 2131 | + "aiHub.tab.insights": "Analysis", | ||
| 2132 | + "aiHub.celebiExample1": "Which homework is due this week?", | ||
| 2133 | + "aiHub.celebiExample2": "How many days has my class missed?", | ||
| 2134 | + "aiHub.celebiExample3": "Summarise the topics of my next exam.", | ||
| 2135 | + "aiHub.celebiHint": "Çelebi opens as a side panel and stays with you on every page.", | ||
| 2035 | "nav.today": "Today", | 2136 | "nav.today": "Today", |
| 2036 | "nav.classes": "Courses", | 2137 | "nav.classes": "Courses", |
| 2037 | "nav.classGroups": "Classes", | 2138 | "nav.classGroups": "Classes", |
| @@ -2400,7 +2501,6 @@ const en: Dict = { | |||
| 2400 | "nav.opticalReading": "Optical reading", | 2501 | "nav.opticalReading": "Optical reading", |
| 2401 | "nav.hezarfenZeka": "Hezarfen AI", | 2502 | "nav.hezarfenZeka": "Hezarfen AI", |
| 2402 | "nav.celebi": "Çelebi", | 2503 | "nav.celebi": "Çelebi", |
| 2403 | - "nav.soundStudio": "Sound studio", | ||
| 2404 | "nav.reports": "Reports", | 2504 | "nav.reports": "Reports", |
| 2405 | "nav.licenseModules": "License & modules", | 2505 | "nav.licenseModules": "License & modules", |
| 2406 | "nav.dataProtection": "Data protection & audit", | 2506 | "nav.dataProtection": "Data protection & audit", |
| @@ -2864,6 +2964,93 @@ const en: Dict = { | |||
| 2864 | "courseNotes.emptyManageHint": "Write a note the whole class can read, and attach files to it.", | 2964 | "courseNotes.emptyManageHint": "Write a note the whole class can read, and attach files to it.", |
| 2865 | "courseNotes.ragTitle": "AI outputs", | 2965 | "courseNotes.ragTitle": "AI outputs", |
| 2866 | "courseNotes.ragEmpty": "No AI outputs on this note yet.", | 2966 | "courseNotes.ragEmpty": "No AI outputs on this note yet.", |
| 2967 | + "courseNotes.ragHint": "Create a fresh summary from this note and its attachments.", | ||
| 2968 | + "courseNotes.ragGenerate": "Create summary", | ||
| 2969 | + "courseNotes.ragGenerating": "Creating summary…", | ||
| 2970 | + "courseNotes.ragReady": "The new summary is ready.", | ||
| 2971 | + "courseNotes.ragQueued": "Summary generation continues in the background.", | ||
| 2972 | + "courseNotes.ragUnavailable": "The AI summary service is not connected right now. Try again when a worker is available.", | ||
| 2973 | + "podcast.title": "Audio workshop", | ||
| 2974 | + "podcast.description": "Turn a lesson note into a listenable episode.", | ||
| 2975 | + "podcast.pageDescription": "Choose a lesson note, pick a narration style, and create its audio.", | ||
| 2976 | + "podcast.source": "Lesson note", | ||
| 2977 | + "podcast.selectNote": "Choose a lesson note…", | ||
| 2978 | + "podcast.selectPrompt": "Please choose a lesson note", | ||
| 2979 | + "podcast.selectPromptHint": "The narration options will appear here after you select a note above.", | ||
| 2980 | + "podcast.noNotes": "No lesson notes are available.", | ||
| 2981 | + "podcast.noNotesHint": "Add a note to one of your courses before creating audio.", | ||
| 2982 | + "podcast.format": "Narration style", | ||
| 2983 | + "podcast.format.duz_okuma": "Straight reading", | ||
| 2984 | + "podcast.format.tek_ogretici": "Single instructor", | ||
| 2985 | + "podcast.format.ogrenci_hoca": "Student and teacher", | ||
| 2986 | + "podcast.create": "Create podcast", | ||
| 2987 | + "podcast.submitting": "Starting…", | ||
| 2988 | + "podcast.cancel": "Cancel production", | ||
| 2989 | + "podcast.ready": "Your episode is ready.", | ||
| 2990 | + "podcast.failed": "The podcast could not be created. Try again.", | ||
| 2991 | + "podcast.audioUnsupported": "Your browser cannot play this audio.", | ||
| 2992 | + "podcast.unavailable": "Podcast production is not connected right now. Try again when a podcast worker is available.", | ||
| 2993 | + "podcast.state.queued": "Waiting in queue", | ||
| 2994 | + "podcast.state.running": "Creating audio", | ||
| 2995 | + "podcast.state.done": "Ready", | ||
| 2996 | + "podcast.state.failed": "Failed", | ||
| 2997 | + "podcast.state.cancelled": "Cancelled", | ||
| 2998 | + "insights.title": "Hezarfen Intelligence", | ||
| 2999 | + "insights.subtitle": "Review student signals, recommendations, and nightly analysis runs.", | ||
| 3000 | + "insights.student": "Student", | ||
| 3001 | + "insights.studentAnalysis": "Student analysis", | ||
| 3002 | + "insights.searchStudents": "Search students…", | ||
| 3003 | + "insights.emptyStudents": "No students found.", | ||
| 3004 | + "insights.viewAnalysis": "View analysis", | ||
| 3005 | + "insights.refreshAll": "Queue school analysis", | ||
| 3006 | + "insights.refreshingAll": "Queuing…", | ||
| 3007 | + "insights.refreshQueued": "School analysis was queued.", | ||
| 3008 | + "insights.recompute": "Recompute", | ||
| 3009 | + "insights.recomputing": "Queuing…", | ||
| 3010 | + "insights.recomputeQueued": "Analysis for {student} was queued.", | ||
| 3011 | + "insights.summary": "Summary", | ||
| 3012 | + "insights.noSummary": "No analysis yet", | ||
| 3013 | + "insights.noSummaryHint": "Queue a computation to create the first analysis.", | ||
| 3014 | + "insights.computedAt": "Computed at", | ||
| 3015 | + "insights.retainUntil": "Retained until", | ||
| 3016 | + "insights.sectionNotComputed": "This section was not computed.", | ||
| 3017 | + "insights.noEvidence": "No supporting data.", | ||
| 3018 | + "insights.modules.attendance": "Attendance", | ||
| 3019 | + "insights.modules.marks": "Marks", | ||
| 3020 | + "insights.modules.study": "Study", | ||
| 3021 | + "insights.modules.submission": "Submissions", | ||
| 3022 | + "insights.attention": "Attention signals", | ||
| 3023 | + "insights.noAttention": "No attention signal.", | ||
| 3024 | + "insights.schoolWide": "School-wide", | ||
| 3025 | + "insights.recommendations": "Recommendations", | ||
| 3026 | + "insights.noRecommendations": "No recommendation.", | ||
| 3027 | + "insights.expiresAt": "Expires", | ||
| 3028 | + "insights.segments": "Segment profile", | ||
| 3029 | + "insights.noSegments": "No segment profile.", | ||
| 3030 | + "insights.accuracy": "Accuracy", | ||
| 3031 | + "insights.answers": "Answers", | ||
| 3032 | + "insights.overall": "Overall", | ||
| 3033 | + "insights.contrast": "Difference", | ||
| 3034 | + "insights.confidence.none": "Insufficient data", | ||
| 3035 | + "insights.confidence.exploratory": "Exploratory", | ||
| 3036 | + "insights.confidence.stable": "Stable", | ||
| 3037 | + "insights.runs": "Analysis runs", | ||
| 3038 | + "insights.runsSubtitle": "Nightly and manually queued school analyses.", | ||
| 3039 | + "insights.runDay": "Run day", | ||
| 3040 | + "insights.result": "Result", | ||
| 3041 | + "insights.processed": "Successful", | ||
| 3042 | + "insights.written": "Rows written", | ||
| 3043 | + "insights.duration": "Duration", | ||
| 3044 | + "insights.issues": "Issues", | ||
| 3045 | + "insights.issueCount": "{count} issue(s)", | ||
| 3046 | + "insights.noIssues": "No issue", | ||
| 3047 | + "insights.budgetExceeded": "Time budget exceeded", | ||
| 3048 | + "insights.emptyRuns": "No analysis run yet.", | ||
| 3049 | + "insights.status.running": "Running", | ||
| 3050 | + "insights.status.ok": "Completed", | ||
| 3051 | + "insights.status.partial": "Partial", | ||
| 3052 | + "insights.status.failed": "Failed", | ||
| 3053 | + "insights.status.skipped": "Skipped", | ||
| 2867 | "notes.title": "Notebook", | 3054 | "notes.title": "Notebook", |
| 2868 | "notes.subtitle": "Your private notebook for class ideas and reminders.", | 3055 | "notes.subtitle": "Your private notebook for class ideas and reminders.", |
| 2869 | "notes.new": "New note", | 3056 | "notes.new": "New note", |
| @@ -3846,6 +4033,7 @@ const en: Dict = { | |||
| 3846 | "sessions.empty": "No lesson sessions yet.", | 4033 | "sessions.empty": "No lesson sessions yet.", |
| 3847 | "sessions.untitled": "Untitled lesson", | 4034 | "sessions.untitled": "Untitled lesson", |
| 3848 | "sessions.teacher": "Teacher", | 4035 | "sessions.teacher": "Teacher", |
| 4036 | + "sessions.defaultTeacher": "Current user", | ||
| 3849 | "sessions.rollCall": "Roll call", | 4037 | "sessions.rollCall": "Roll call", |
| 3850 | "sessions.emptyRoster": "No enrolled students yet.", | 4038 | "sessions.emptyRoster": "No enrolled students yet.", |
| 3851 | "sessions.startRequired": "Session start date and time are required.", | 4039 | "sessions.startRequired": "Session start date and time are required.", |
| @@ -4043,6 +4231,13 @@ const tr: Dict = { | |||
| 4043 | "ai.chats": "Sohbetler", | 4231 | "ai.chats": "Sohbetler", |
| 4044 | "ai.noChats": "Henüz sohbet yok. Başlattığın sohbetler burada görünür.", | 4232 | "ai.noChats": "Henüz sohbet yok. Başlattığın sohbetler burada görünür.", |
| 4045 | "ai.noSearchResults": "Aramanla eşleşen mesaj yok.", | 4233 | "ai.noSearchResults": "Aramanla eşleşen mesaj yok.", |
| 4234 | + "aiHub.description": "Tüm yapay zekâ araçları tek yerde: not çıktıları ve podcast, öğrenci analizi ve Çelebi.", | ||
| 4235 | + "aiHub.tab.studio": "Not stüdyosu", | ||
| 4236 | + "aiHub.tab.insights": "Analiz", | ||
| 4237 | + "aiHub.celebiExample1": "Bu hafta hangi ödevlerin teslimi var?", | ||
| 4238 | + "aiHub.celebiExample2": "Sınıfım kaç gün devamsızlık yaptı?", | ||
| 4239 | + "aiHub.celebiExample3": "Yaklaşan sınavımın konularını özetle.", | ||
| 4240 | + "aiHub.celebiHint": "Çelebi yan panel olarak açılır ve her sayfada seninle kalır.", | ||
| 4046 | "nav.today": "Bugün", | 4241 | "nav.today": "Bugün", |
| 4047 | "nav.classes": "Dersler", | 4242 | "nav.classes": "Dersler", |
| 4048 | "nav.classGroups": "Şubeler", | 4243 | "nav.classGroups": "Şubeler", |
| @@ -4411,7 +4606,6 @@ const tr: Dict = { | |||
| 4411 | "nav.opticalReading": "Optik okuma", | 4606 | "nav.opticalReading": "Optik okuma", |
| 4412 | "nav.hezarfenZeka": "Hezarfen Zekâ", | 4607 | "nav.hezarfenZeka": "Hezarfen Zekâ", |
| 4413 | "nav.celebi": "Çelebi", | 4608 | "nav.celebi": "Çelebi", |
| 4414 | - "nav.soundStudio": "Ses Atölyesi", | ||
| 4415 | "nav.reports": "Raporlar", | 4609 | "nav.reports": "Raporlar", |
| 4416 | "nav.licenseModules": "Lisans ve modüller", | 4610 | "nav.licenseModules": "Lisans ve modüller", |
| 4417 | "nav.dataProtection": "KVKK ve denetim", | 4611 | "nav.dataProtection": "KVKK ve denetim", |
| @@ -4875,6 +5069,93 @@ const tr: Dict = { | |||
| 4875 | "courseNotes.emptyManageHint": "Tüm sınıfın okuyabileceği bir not yazın, dosya da ekleyebilirsiniz.", | 5069 | "courseNotes.emptyManageHint": "Tüm sınıfın okuyabileceği bir not yazın, dosya da ekleyebilirsiniz.", |
| 4876 | "courseNotes.ragTitle": "YZ çıktıları", | 5070 | "courseNotes.ragTitle": "YZ çıktıları", |
| 4877 | "courseNotes.ragEmpty": "Bu notta henüz YZ çıktısı yok.", | 5071 | "courseNotes.ragEmpty": "Bu notta henüz YZ çıktısı yok.", |
| 5072 | + "courseNotes.ragHint": "Bu not ve eklerinden güncel bir özet oluşturun.", | ||
| 5073 | + "courseNotes.ragGenerate": "Özet oluştur", | ||
| 5074 | + "courseNotes.ragGenerating": "Özet oluşturuluyor…", | ||
| 5075 | + "courseNotes.ragReady": "Yeni özet hazır.", | ||
| 5076 | + "courseNotes.ragQueued": "Özet oluşturma arka planda devam ediyor.", | ||
| 5077 | + "courseNotes.ragUnavailable": "YZ özet servisi şu anda bağlı değil. Bir worker hazır olduğunda tekrar deneyin.", | ||
| 5078 | + "podcast.title": "Ses Atölyesi", | ||
| 5079 | + "podcast.description": "Bir ders notunu dinlenebilir bir bölüme dönüştürün.", | ||
| 5080 | + "podcast.pageDescription": "Ders notunu seçin, anlatım biçimini belirleyin ve ses kaydını oluşturun.", | ||
| 5081 | + "podcast.source": "Ders notu", | ||
| 5082 | + "podcast.selectNote": "Bir ders notu seçin…", | ||
| 5083 | + "podcast.selectPrompt": "Lütfen bir ders notu seçin", | ||
| 5084 | + "podcast.selectPromptHint": "Yukarıdan bir not seçtiğinizde anlatım seçenekleri burada açılacak.", | ||
| 5085 | + "podcast.noNotes": "Kullanılabilir ders notu yok.", | ||
| 5086 | + "podcast.noNotesHint": "Ses oluşturmadan önce derslerinizden birine not ekleyin.", | ||
| 5087 | + "podcast.format": "Anlatım biçimi", | ||
| 5088 | + "podcast.format.duz_okuma": "Düz okuma", | ||
| 5089 | + "podcast.format.tek_ogretici": "Tek öğretici", | ||
| 5090 | + "podcast.format.ogrenci_hoca": "Öğrenci ve öğretmen", | ||
| 5091 | + "podcast.create": "Podcast oluştur", | ||
| 5092 | + "podcast.submitting": "Başlatılıyor…", | ||
| 5093 | + "podcast.cancel": "Üretimi iptal et", | ||
| 5094 | + "podcast.ready": "Bölümünüz hazır.", | ||
| 5095 | + "podcast.failed": "Podcast oluşturulamadı. Tekrar deneyin.", | ||
| 5096 | + "podcast.audioUnsupported": "Tarayıcınız bu sesi oynatamıyor.", | ||
| 5097 | + "podcast.unavailable": "Podcast üretim servisi şu anda bağlı değil. Podcast worker hazır olduğunda tekrar deneyin.", | ||
| 5098 | + "podcast.state.queued": "Sırada bekliyor", | ||
| 5099 | + "podcast.state.running": "Ses oluşturuluyor", | ||
| 5100 | + "podcast.state.done": "Hazır", | ||
| 5101 | + "podcast.state.failed": "Başarısız", | ||
| 5102 | + "podcast.state.cancelled": "İptal edildi", | ||
| 5103 | + "insights.title": "Hezarfen Zeka", | ||
| 5104 | + "insights.subtitle": "Öğrenci sinyallerini, önerileri ve gece analizlerini inceleyin.", | ||
| 5105 | + "insights.student": "Öğrenci", | ||
| 5106 | + "insights.studentAnalysis": "Öğrenci analizi", | ||
| 5107 | + "insights.searchStudents": "Öğrenci ara…", | ||
| 5108 | + "insights.emptyStudents": "Öğrenci bulunamadı.", | ||
| 5109 | + "insights.viewAnalysis": "Analizi görüntüle", | ||
| 5110 | + "insights.refreshAll": "Okul analizini sıraya al", | ||
| 5111 | + "insights.refreshingAll": "Sıraya alınıyor…", | ||
| 5112 | + "insights.refreshQueued": "Okul analizi sıraya alındı.", | ||
| 5113 | + "insights.recompute": "Yeniden hesapla", | ||
| 5114 | + "insights.recomputing": "Sıraya alınıyor…", | ||
| 5115 | + "insights.recomputeQueued": "{student} için analiz sıraya alındı.", | ||
| 5116 | + "insights.summary": "Özet", | ||
| 5117 | + "insights.noSummary": "Henüz analiz yok", | ||
| 5118 | + "insights.noSummaryHint": "İlk analizi oluşturmak için hesaplamayı sıraya alın.", | ||
| 5119 | + "insights.computedAt": "Hesaplanma", | ||
| 5120 | + "insights.retainUntil": "Saklanma sonu", | ||
| 5121 | + "insights.sectionNotComputed": "Bu bölüm hesaplanmadı.", | ||
| 5122 | + "insights.noEvidence": "Destekleyici veri yok.", | ||
| 5123 | + "insights.modules.attendance": "Yoklama", | ||
| 5124 | + "insights.modules.marks": "Notlar", | ||
| 5125 | + "insights.modules.study": "Çalışma", | ||
| 5126 | + "insights.modules.submission": "Teslimler", | ||
| 5127 | + "insights.attention": "Dikkat sinyalleri", | ||
| 5128 | + "insights.noAttention": "Dikkat sinyali yok.", | ||
| 5129 | + "insights.schoolWide": "Okul geneli", | ||
| 5130 | + "insights.recommendations": "Öneriler", | ||
| 5131 | + "insights.noRecommendations": "Öneri yok.", | ||
| 5132 | + "insights.expiresAt": "Geçerlilik sonu", | ||
| 5133 | + "insights.segments": "Segment profili", | ||
| 5134 | + "insights.noSegments": "Segment profili yok.", | ||
| 5135 | + "insights.accuracy": "Doğruluk", | ||
| 5136 | + "insights.answers": "Yanıtlar", | ||
| 5137 | + "insights.overall": "Genel", | ||
| 5138 | + "insights.contrast": "Fark", | ||
| 5139 | + "insights.confidence.none": "Yetersiz veri", | ||
| 5140 | + "insights.confidence.exploratory": "Keşifsel", | ||
| 5141 | + "insights.confidence.stable": "Kararlı", | ||
| 5142 | + "insights.runs": "Analiz çalıştırmaları", | ||
| 5143 | + "insights.runsSubtitle": "Gece çalışan ve elle sıraya alınan okul analizleri.", | ||
| 5144 | + "insights.runDay": "Çalışma günü", | ||
| 5145 | + "insights.result": "Sonuç", | ||
| 5146 | + "insights.processed": "Başarılı", | ||
| 5147 | + "insights.written": "Yazılan satır", | ||
| 5148 | + "insights.duration": "Süre", | ||
| 5149 | + "insights.issues": "Sorunlar", | ||
| 5150 | + "insights.issueCount": "{count} sorun", | ||
| 5151 | + "insights.noIssues": "Sorun yok", | ||
| 5152 | + "insights.budgetExceeded": "Süre bütçesi aşıldı", | ||
| 5153 | + "insights.emptyRuns": "Henüz analiz çalıştırması yok.", | ||
| 5154 | + "insights.status.running": "Çalışıyor", | ||
| 5155 | + "insights.status.ok": "Tamamlandı", | ||
| 5156 | + "insights.status.partial": "Kısmi", | ||
| 5157 | + "insights.status.failed": "Başarısız", | ||
| 5158 | + "insights.status.skipped": "Atlandı", | ||
| 4878 | "notes.title": "Defter", | 5159 | "notes.title": "Defter", |
| 4879 | "notes.subtitle": "Ders fikirleriniz ve hatırlatmalarınız için özel defteriniz.", | 5160 | "notes.subtitle": "Ders fikirleriniz ve hatırlatmalarınız için özel defteriniz.", |
| 4880 | "notes.new": "Yeni not", | 5161 | "notes.new": "Yeni not", |
| @@ -5857,6 +6138,7 @@ const tr: Dict = { | |||
| 5857 | "sessions.empty": "Henüz ders oturumu yok.", | 6138 | "sessions.empty": "Henüz ders oturumu yok.", |
| 5858 | "sessions.untitled": "Konu girilmemiş ders", | 6139 | "sessions.untitled": "Konu girilmemiş ders", |
| 5859 | "sessions.teacher": "Öğretmen", | 6140 | "sessions.teacher": "Öğretmen", |
| 6141 | + "sessions.defaultTeacher": "Mevcut kullanıcı", | ||
| 5860 | "sessions.rollCall": "Yoklama", | 6142 | "sessions.rollCall": "Yoklama", |
| 5861 | "sessions.emptyRoster": "Henüz kayıtlı öğrenci yok.", | 6143 | "sessions.emptyRoster": "Henüz kayıtlı öğrenci yok.", |
| 5862 | "sessions.startRequired": "Oturum başlangıç tarihi ve saati gerekli.", | 6144 | "sessions.startRequired": "Oturum başlangıç tarihi ve saati gerekli.", |
src/lib/note-source.tsmodified+3 -1
| @@ -1,5 +1,5 @@ | |||
| 1 | import type { NoteFile, Page, PageParams, RagOutput } from "@/api/client"; | 1 | import type { NoteFile, Page, PageParams, RagOutput } from "@/api/client"; |
| 2 | -import { deleteCourseNoteFileById, deleteCourseNoteRagOutput, getCourseNoteFileBlob, getCourseNoteFileUrl, getCourseNoteFiles, getCourseNoteRag, postCourseNoteFile } from "@/api/course-notes"; | 2 | +import { deleteCourseNoteFileById, deleteCourseNoteRagOutput, getCourseNoteFileBlob, getCourseNoteFileUrl, getCourseNoteFiles, getCourseNoteRag, postCourseNoteFile, postCourseNoteRagReindex } from "@/api/course-notes"; |
| 3 | import { deleteNoteFileById, getNoteFileBlob, getNoteFileUrl, getNoteFiles, postNoteFile } from "@/api/notes"; | 3 | import { deleteNoteFileById, getNoteFileBlob, getNoteFileUrl, getNoteFiles, postNoteFile } from "@/api/notes"; |
| 4 | 4 | ||
| 5 | /** | 5 | /** |
| @@ -19,6 +19,7 @@ export type NoteFileSource = { | |||
| 19 | /** AI outputs hanging off the note — only course notes have them. */ | 19 | /** AI outputs hanging off the note — only course notes have them. */ |
| 20 | listRagOutputs?: (noteId: string, params?: PageParams, signal?: AbortSignal) => Promise<Page<RagOutput>>; | 20 | listRagOutputs?: (noteId: string, params?: PageParams, signal?: AbortSignal) => Promise<Page<RagOutput>>; |
| 21 | deleteRagOutput?: (noteId: string, outputId: string) => Promise<void>; | 21 | deleteRagOutput?: (noteId: string, outputId: string) => Promise<void>; |
| 22 | + reindexRag?: (noteId: string) => Promise<void>; | ||
| 22 | }; | 23 | }; |
| 23 | 24 | ||
| 24 | export const personalNoteFiles: NoteFileSource = { | 25 | export const personalNoteFiles: NoteFileSource = { |
| @@ -39,4 +40,5 @@ export const courseNoteFiles: NoteFileSource = { | |||
| 39 | fileBlob: getCourseNoteFileBlob, | 40 | fileBlob: getCourseNoteFileBlob, |
| 40 | listRagOutputs: getCourseNoteRag, | 41 | listRagOutputs: getCourseNoteRag, |
| 41 | deleteRagOutput: deleteCourseNoteRagOutput, | 42 | deleteRagOutput: deleteCourseNoteRagOutput, |
| 43 | + reindexRag: postCourseNoteRagReindex, | ||
| 42 | }; | 44 | }; |
src/pages/ai-hub-page.tsxadded+86 -0
| @@ -0,0 +1,86 @@ | |||
| 1 | +import { Show, createMemo, createSignal } from "solid-js"; | ||
| 2 | +import { useNavigate, useSearch } from "@tanstack/solid-router"; | ||
| 3 | +import { CelebiLauncher } from "@/components/ai/celebi-launcher"; | ||
| 4 | +import { InsightsBoard } from "@/components/ai/insights-board"; | ||
| 5 | +import { NoteStudioPanel } from "@/components/ai/note-studio-panel"; | ||
| 6 | +import { PageHeader } from "@/components/layout/page-header"; | ||
| 7 | +import { RouteGuard } from "@/components/layout/route-guard"; | ||
| 8 | +import { IconSparkles, IconChart, IconWaveform } from "@/components/ui/icons"; | ||
| 9 | +import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; | ||
| 10 | +import { useAuth } from "@/stores/auth-context"; | ||
| 11 | +import { useT } from "@/stores/preferences-context"; | ||
| 12 | + | ||
| 13 | +export type AiHubTab = "studio" | "insights" | "celebi"; | ||
| 14 | + | ||
| 15 | +export default function AiHubPage() { | ||
| 16 | + return ( | ||
| 17 | + <RouteGuard> | ||
| 18 | + <AiHubContent /> | ||
| 19 | + </RouteGuard> | ||
| 20 | + ); | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +function AiHubContent() { | ||
| 24 | + const t = useT(); | ||
| 25 | + const auth = useAuth(); | ||
| 26 | + const navigate = useNavigate(); | ||
| 27 | + const search = useSearch({ strict: false }); | ||
| 28 | + const role = () => auth.user()?.role; | ||
| 29 | + // A parent only ever reaches their children's analysis: course notes and | ||
| 30 | + // Çelebi are not theirs to open. | ||
| 31 | + const tabs = createMemo<AiHubTab[]>(() => | ||
| 32 | + role() === "parent" ? ["insights"] : ["studio", "insights", "celebi"], | ||
| 33 | + ); | ||
| 34 | + const requested = () => (search() as { tab?: AiHubTab }).tab; | ||
| 35 | + const [tab, setTab] = createSignal<AiHubTab>( | ||
| 36 | + tabs().includes(requested() as AiHubTab) ? (requested() as AiHubTab) : tabs()[0], | ||
| 37 | + ); | ||
| 38 | + | ||
| 39 | + const label = (value: AiHubTab) => | ||
| 40 | + value === "studio" ? t("aiHub.tab.studio") : value === "insights" ? t("aiHub.tab.insights") : t("nav.celebi"); | ||
| 41 | + | ||
| 42 | + return ( | ||
| 43 | + <div class="space-y-5"> | ||
| 44 | + <PageHeader title={t("nav.hezarfenZeka")} description={t("aiHub.description")} /> | ||
| 45 | + <Tabs | ||
| 46 | + class="space-y-4" | ||
| 47 | + value={tab()} | ||
| 48 | + onChange={(value) => { | ||
| 49 | + const next = tabs().includes(value as AiHubTab) ? (value as AiHubTab) : tabs()[0]; | ||
| 50 | + setTab(next); | ||
| 51 | + void navigate({ to: "/ai", search: { tab: next } }); | ||
| 52 | + }} | ||
| 53 | + > | ||
| 54 | + <Show when={tabs().length > 1}> | ||
| 55 | + <TabsList class="grid w-full grid-cols-3 sm:w-fit"> | ||
| 56 | + <TabsTrigger value="studio" class="min-w-0"> | ||
| 57 | + <IconWaveform class="h-4 w-4" /> | ||
| 58 | + {label("studio")} | ||
| 59 | + </TabsTrigger> | ||
| 60 | + <TabsTrigger value="insights" class="min-w-0"> | ||
| 61 | + <IconChart class="h-4 w-4" /> | ||
| 62 | + {label("insights")} | ||
| 63 | + </TabsTrigger> | ||
| 64 | + <TabsTrigger value="celebi" class="min-w-0"> | ||
| 65 | + <IconSparkles class="h-4 w-4" /> | ||
| 66 | + {label("celebi")} | ||
| 67 | + </TabsTrigger> | ||
| 68 | + </TabsList> | ||
| 69 | + </Show> | ||
| 70 | + <Show when={tabs().includes("studio")}> | ||
| 71 | + <TabsContent value="studio" class="mt-0 border-0 bg-transparent p-0 shadow-none"> | ||
| 72 | + <NoteStudioPanel /> | ||
| 73 | + </TabsContent> | ||
| 74 | + </Show> | ||
| 75 | + <TabsContent value="insights" class="mt-0 border-0 bg-transparent p-0 shadow-none"> | ||
| 76 | + <InsightsBoard /> | ||
| 77 | + </TabsContent> | ||
| 78 | + <Show when={tabs().includes("celebi")}> | ||
| 79 | + <TabsContent value="celebi" class="mt-0 border-0 bg-transparent p-0 shadow-none"> | ||
| 80 | + <CelebiLauncher /> | ||
| 81 | + </TabsContent> | ||
| 82 | + </Show> | ||
| 83 | + </Tabs> | ||
| 84 | + </div> | ||
| 85 | + ); | ||
| 86 | +} | ||
src/pages/coming-soon-page.tsxmodified+0 -2
| @@ -13,8 +13,6 @@ import { useT } from "@/stores/preferences-context"; | |||
| 13 | * sidebar entry's own labelKey in nav-items.ts. | 13 | * sidebar entry's own labelKey in nav-items.ts. |
| 14 | */ | 14 | */ |
| 15 | const COMING_SOON_LABELS: Record<string, MessageKey> = { | 15 | const COMING_SOON_LABELS: Record<string, MessageKey> = { |
| 16 | - "hezarfen-zeka": "nav.hezarfenZeka", | ||
| 17 | - "ses-atolyesi": "nav.soundStudio", | ||
| 18 | "deneme-sinavlari": "nav.mockExams", | 16 | "deneme-sinavlari": "nav.mockExams", |
| 19 | "optik-okuma": "nav.opticalReading", | 17 | "optik-okuma": "nav.opticalReading", |
| 20 | raporlar: "nav.reports", | 18 | raporlar: "nav.reports", |
src/routes/router.tsxmodified+30 -2
| @@ -70,6 +70,7 @@ const ProfilePage = lazyRoute(() => import("@/pages/profile-page")); | |||
| 70 | const PaymentStatementPage = lazyRoute(() => import("@/pages/payment-statement-page")); | 70 | const PaymentStatementPage = lazyRoute(() => import("@/pages/payment-statement-page")); |
| 71 | const WhiteboardsPage = lazyRoute(() => import("@/pages/whiteboards-page")); | 71 | const WhiteboardsPage = lazyRoute(() => import("@/pages/whiteboards-page")); |
| 72 | const WhiteboardPage = lazyRoute(() => import("@/pages/whiteboard-page")); | 72 | const WhiteboardPage = lazyRoute(() => import("@/pages/whiteboard-page")); |
| 73 | +const AiHubPage = lazyRoute(() => import("@/pages/ai-hub-page")); | ||
| 73 | const ComingSoonPage = lazyRoute(() => import("@/pages/coming-soon-page")); | 74 | const ComingSoonPage = lazyRoute(() => import("@/pages/coming-soon-page")); |
| 74 | const StudentsRosterPage = lazyRoute(() => import("@/pages/students-roster-page")); | 75 | const StudentsRosterPage = lazyRoute(() => import("@/pages/students-roster-page")); |
| 75 | const TeachersRosterPage = lazyRoute(() => import("@/pages/teachers-roster-page")); | 76 | const TeachersRosterPage = lazyRoute(() => import("@/pages/teachers-roster-page")); |
| @@ -448,6 +449,33 @@ const whiteboardRoute = createRoute({ | |||
| 448 | component: WhiteboardPage, | 449 | component: WhiteboardPage, |
| 449 | }); | 450 | }); |
| 450 | 451 | ||
| 452 | +// One AI surface: the note studio (AI outputs + podcast), the insight board | ||
| 453 | +// and the Çelebi entry point, which used to sit on three unrelated routes. | ||
| 454 | +const aiHubRoute = createRoute({ | ||
| 455 | + getParentRoute: () => rootRoute, | ||
| 456 | + path: "/ai", | ||
| 457 | + validateSearch: (search: Record<string, unknown>) => ({ | ||
| 458 | + tab: | ||
| 459 | + search.tab === "insights" | ||
| 460 | + ? ("insights" as const) | ||
| 461 | + : search.tab === "celebi" | ||
| 462 | + ? ("celebi" as const) | ||
| 463 | + : search.tab === "studio" | ||
| 464 | + ? ("studio" as const) | ||
| 465 | + : undefined, | ||
| 466 | + }), | ||
| 467 | + component: AiHubPage, | ||
| 468 | +}); | ||
| 469 | + | ||
| 470 | +// The audio workshop had its own route before the hub gathered it. | ||
| 471 | +const soundStudioRoute = createRoute({ | ||
| 472 | + getParentRoute: () => rootRoute, | ||
| 473 | + path: "/sound-studio", | ||
| 474 | + beforeLoad: () => { | ||
| 475 | + throw redirect({ to: "/ai", search: { tab: "studio" } as never }); | ||
| 476 | + }, | ||
| 477 | +}); | ||
| 478 | + | ||
| 451 | const studentsRosterRoute = createRoute({ | 479 | const studentsRosterRoute = createRoute({ |
| 452 | getParentRoute: () => rootRoute, | 480 | getParentRoute: () => rootRoute, |
| 453 | path: "/management/students", | 481 | path: "/management/students", |
| @@ -490,8 +518,6 @@ const builderSchoolDetailRoute = createRoute({ | |||
| 490 | // (so breadcrumbs, back and direct links behave normally) but all render the | 518 | // (so breadcrumbs, back and direct links behave normally) but all render the |
| 491 | // same "not ready" page. Slugs are read back by coming-soon-page.tsx. | 519 | // same "not ready" page. Slugs are read back by coming-soon-page.tsx. |
| 492 | const COMING_SOON_SLUGS = [ | 520 | const COMING_SOON_SLUGS = [ |
| 493 | - "hezarfen-zeka", | ||
| 494 | - "ses-atolyesi", | ||
| 495 | "deneme-sinavlari", | 521 | "deneme-sinavlari", |
| 496 | "optik-okuma", | 522 | "optik-okuma", |
| 497 | "raporlar", | 523 | "raporlar", |
| @@ -564,6 +590,8 @@ const routeTree = rootRoute.addChildren([ | |||
| 564 | paymentStatementRoute, | 590 | paymentStatementRoute, |
| 565 | whiteboardsRoute, | 591 | whiteboardsRoute, |
| 566 | whiteboardRoute, | 592 | whiteboardRoute, |
| 593 | + aiHubRoute, | ||
| 594 | + soundStudioRoute, | ||
| 567 | studentsRosterRoute, | 595 | studentsRosterRoute, |
| 568 | teachersRosterRoute, | 596 | teachersRosterRoute, |
| 569 | licenseModulesRoute, | 597 | licenseModulesRoute, |
src/stores/celebi-panel.tsadded+13 -0
| @@ -0,0 +1,13 @@ | |||
| 1 | +import { createSignal } from "solid-js"; | ||
| 2 | + | ||
| 3 | +// The Çelebi panel is mounted once by the shell, but it is opened from the | ||
| 4 | +// sidebar entry, the command palette and the AI hub page, so its open state is | ||
| 5 | +// a module-level signal rather than a prop threaded through every layer — | ||
| 6 | +// same arrangement as the command palette. | ||
| 7 | +const [celebiPanelOpen, setCelebiPanelOpen] = createSignal(false); | ||
| 8 | + | ||
| 9 | +export { celebiPanelOpen, setCelebiPanelOpen }; | ||
| 10 | + | ||
| 11 | +export function openCelebiPanel() { | ||
| 12 | + setCelebiPanelOpen(true); | ||
| 13 | +} | ||
vitest.config.tsmodified+5 -2
| @@ -4,7 +4,10 @@ import { defineConfig } from "vitest/config"; | |||
| 4 | 4 | ||
| 5 | const alias = { "@": path.resolve(__dirname, "./src") }; | 5 | const alias = { "@": path.resolve(__dirname, "./src") }; |
| 6 | // Live-backend suite, run separately: `bun run test:contract`. | 6 | // Live-backend suite, run separately: `bun run test:contract`. |
| 7 | -const exclude = ["**/node_modules/**", "**/dist/**", "src/api/__tests__/contract/**", "src/components/layout/nav-items.test.ts"]; | 7 | +// nav-items.test.ts is a plain .ts file but asserts on nav entries that carry |
| 8 | +// Solid components, so it runs in the dom project (see its include) — the node | ||
| 9 | +// project excludes it instead. | ||
| 10 | +const exclude = ["**/node_modules/**", "**/dist/**", "src/api/__tests__/contract/**"]; | ||
| 8 | 11 | ||
| 9 | /** | 12 | /** |
| 10 | * Two projects, one `vitest run`: plain logic/API tests stay on the fast node | 13 | * Two projects, one `vitest run`: plain logic/API tests stay on the fast node |
| @@ -22,7 +25,7 @@ export default defineConfig({ | |||
| 22 | globals: true, | 25 | globals: true, |
| 23 | environment: "node", | 26 | environment: "node", |
| 24 | include: ["src/**/*.test.ts"], | 27 | include: ["src/**/*.test.ts"], |
| 25 | - exclude, | 28 | + exclude: [...exclude, "src/components/layout/nav-items.test.ts"], |
| 26 | }, | 29 | }, |
| 27 | }, | 30 | }, |
| 28 | { | 31 | { |