item.id),
})),
).toEqual([
- { id: "school", items: ["students-roster", "teachers-roster", "class-groups", "terms", "schedule"] },
+ { id: "school", items: ["students-roster", "teachers-roster", "class-groups", "academic-years", "terms", "schedule"] },
{ id: "teaching", items: ["courses", "homework", "exams", "question-bank", "questions", "notes", "whiteboards"] },
{ id: "tracking", items: ["student-attendance", "student-marks", "student-pomodoros"] },
{ id: "services", items: ["events", "appointments", "school-meals"] },
{ id: "institution", items: ["payments-collection", "staff-work", "work", "users", "license-modules", "settings"] },
- { id: "ai", items: ["celebi"] },
- { id: "soon", items: ["mock-exams", "optical-reading", "reports", "data-protection", "hezarfen-zeka", "sound-studio"] },
+ { id: "ai", items: ["celebi", "ai-hub"] },
+ { id: "soon", items: ["mock-exams", "optical-reading", "reports", "data-protection"] },
]);
});
@@ -65,7 +65,8 @@ test("teacher's sidebar splits into short labelled sections with the soon shelf
{ id: "tracking", items: ["student-attendance", "student-marks", "student-pomodoros"] },
{ id: "teaching", items: ["homework", "exams", "question-bank", "questions", "notes", "whiteboards"] },
{ id: "other", items: ["parent-communication", "appointments", "events", "meals", "work", "settings-teacher"] },
- { id: "soon", items: ["student-analysis", "pending-approvals", "question-generation", "sound-studio"] },
+ { id: "ai", items: ["celebi", "ai-hub"] },
+ { id: "soon", items: ["student-analysis", "pending-approvals", "question-generation"] },
]);
});
@@ -78,9 +79,9 @@ test("student's sidebar splits into short labelled sections with the soon shelf
).toEqual([
{ id: "study", items: ["topic-mastery", "exam-results", "my-homework", "pomodoro"] },
{ id: "teaching", items: ["courses", "notes", "questions", "whiteboards"] },
- { id: "ai", items: ["celebi"] },
+ { id: "ai", items: ["celebi", "ai-hub"] },
{ id: "other", items: ["calendar", "events", "messages", "appointments", "meals", "settings-student"] },
- { id: "soon", items: ["study-plan", "sound-studio"] },
+ { id: "soon", items: ["study-plan"] },
]);
});
@@ -107,6 +108,8 @@ test("parent's sidebar keeps the Figma Öğrencim / Kurum tree plus every backed
).toEqual([
{ id: "my-student", items: ["progress-report", "absence", "child-exam-results", "child-study-plan"] },
{ id: "institution", items: ["payment-statement", "appointments", "messages", "calendar", "events", "meals", "settings-parent"] },
+ // A parent's only AI surface: their children's analysis on the hub.
+ { id: "ai", items: ["ai-hub"] },
]);
});
@@ -141,11 +144,25 @@ test("license modules is a real admin page and the work log includes admin", ()
});
test("entries with no backend yet are flagged soon and route to the shared placeholder", () => {
- const hezarfenZeka = visibleNavGroups("admin")
+ const opticalReading = visibleNavGroups("admin")
.flatMap((g) => g.items)
- .find((i) => i.id === "hezarfen-zeka");
- expect(hezarfenZeka?.soon).toBe(true);
- expect(hezarfenZeka?.to).toBe("/coming-soon/hezarfen-zeka");
+ .find((i) => i.id === "optical-reading");
+ expect(opticalReading?.soon).toBe(true);
+ expect(opticalReading?.to).toBe("/coming-soon/optik-okuma");
+});
+
+// Every AI feature the backend answers for sits on one hub route; Çelebi keeps
+// its own row because it opens the shell panel instead of navigating.
+test("the AI group is the hub plus the Çelebi panel, and nothing is a placeholder", () => {
+ for (const role of ["student", "teacher", "manager", "admin", "parent"] as const) {
+ const ai = visibleNavGroups(role).find((group) => group.id === "ai");
+ expect(ai).toBeDefined();
+ const hub = ai?.items.find((item) => item.id === "ai-hub");
+ expect(hub?.to).toBe("/ai");
+ expect(hub?.soon).toBeFalsy();
+ }
+ expect(routeNavItem("/ai", "student")?.id).toBe("ai-hub");
+ expect(routeLabelKey("/ai", "student")).toBe("nav.hezarfenZeka");
});
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", () => {
expect(teacherPaths).not.toContain("/homework");
expect(teacherPaths).not.toContain("/exams");
expect(teacherPaths).not.toContain("/whiteboards");
- expect(teacherPaths).toContain("/management/classes");
+ // Classes is a module too, so an unbought "classes" nest hides it; the
+ // schedule carries no module and stays.
+ expect(teacherPaths).not.toContain("/management/classes");
+ expect(visibleNavGroups("teacher", ["courses", "classes"]).flatMap((group) => group.items.map((item) => item.to)))
+ .toContain("/management/classes");
expect(teacherPaths).toContain("/calendar");
});
diff --git a/src/components/layout/nav-items.ts b/src/components/layout/nav-items.ts
index 2c5dfc4..d02f936 100644
--- a/src/components/layout/nav-items.ts
+++ b/src/components/layout/nav-items.ts
@@ -30,7 +30,6 @@ import {
IconUserCog,
IconUsers,
IconUtensils,
- IconWaveform,
} from "@/components/ui/icons";
import type { MessageKey } from "@/i18n/messages";
import { hasExactRole, roleInRange } from "@/lib/roles";
@@ -78,12 +77,14 @@ const CELEBI_ITEM: NavItem = {
action: "celebi",
};
-const SOUND_STUDIO_ITEM: NavItem = {
- id: "sound-studio",
- to: "/coming-soon/ses-atolyesi",
- labelKey: "nav.soundStudio",
- Icon: IconWaveform,
- soon: true,
+// The hub gathers the note studio, the insight board and the Çelebi entry —
+// what used to be a sound-studio row, an unreachable insights page and a
+// "yakında" placeholder.
+const AI_HUB_ITEM: NavItem = {
+ id: "ai-hub",
+ to: "/ai",
+ labelKey: "nav.hezarfenZeka",
+ Icon: IconBotSquare,
};
function settingsAction(id: string): NavItem {
@@ -165,15 +166,13 @@ const ADMIN_GROUPS: NavGroup[] = [
id: "ai",
labelKey: "nav.group.ai",
Icon: IconSparkles,
- items: [CELEBI_ITEM],
+ items: [CELEBI_ITEM, AI_HUB_ITEM],
},
soonGroup([
{ id: "mock-exams", to: "/coming-soon/deneme-sinavlari", labelKey: "nav.mockExams", Icon: IconTarget, soon: true, minRole: "manager" },
{ id: "optical-reading", to: "/coming-soon/optik-okuma", labelKey: "nav.opticalReading", Icon: IconScan, soon: true, minRole: "manager" },
{ id: "reports", to: "/coming-soon/raporlar", labelKey: "nav.reports", Icon: IconChartPie, soon: true, minRole: "manager" },
{ id: "data-protection", to: "/coming-soon/kvkk-denetim", labelKey: "nav.dataProtection", Icon: IconShieldCheck, soon: true, minRole: "admin" },
- { id: "hezarfen-zeka", to: "/coming-soon/hezarfen-zeka", labelKey: "nav.hezarfenZeka", Icon: IconBotSquare, soon: true, minRole: "manager" },
- SOUND_STUDIO_ITEM,
]),
];
@@ -224,11 +223,16 @@ const TEACHER_GROUPS: NavGroup[] = [
settingsAction("settings-teacher"),
],
},
+ {
+ id: "ai",
+ labelKey: "nav.group.ai",
+ Icon: IconSparkles,
+ items: [CELEBI_ITEM, AI_HUB_ITEM],
+ },
soonGroup([
{ id: "student-analysis", to: "/coming-soon/ogrenci-analizi", labelKey: "nav.studentAnalysis", Icon: IconChart, soon: true },
{ id: "pending-approvals", to: "/coming-soon/bekleyen-onaylar", labelKey: "nav.pendingApprovals", Icon: IconHelpCircle, soon: true },
{ id: "question-generation", to: "/coming-soon/soru-uretimi", labelKey: "nav.questionGeneration", Icon: IconEdit, soon: true },
- SOUND_STUDIO_ITEM,
]),
];
@@ -259,7 +263,7 @@ const STUDENT_GROUPS: NavGroup[] = [
id: "ai",
labelKey: "nav.group.ai",
Icon: IconSparkles,
- items: [CELEBI_ITEM],
+ items: [CELEBI_ITEM, AI_HUB_ITEM],
},
{
id: "other",
@@ -276,7 +280,6 @@ const STUDENT_GROUPS: NavGroup[] = [
},
soonGroup([
{ id: "study-plan", to: "/coming-soon/calisma-programim", labelKey: "nav.studyPlan", Icon: IconClock, soon: true },
- SOUND_STUDIO_ITEM,
]),
];
@@ -306,6 +309,12 @@ const PARENT_GROUPS: NavGroup[] = [
settingsAction("settings-parent"),
],
},
+ {
+ id: "ai",
+ labelKey: "nav.group.ai",
+ Icon: IconSparkles,
+ items: [AI_HUB_ITEM],
+ },
];
const GROUPS_BY_ROLE: Record = {
diff --git a/src/components/notes/note-reader-panel.tsx b/src/components/notes/note-reader-panel.tsx
index ccde703..0bd65e2 100644
--- a/src/components/notes/note-reader-panel.tsx
+++ b/src/components/notes/note-reader-panel.tsx
@@ -3,6 +3,7 @@ import type { Note } from "@/api/client";
import type { NoteFileSource } from "@/lib/note-source";
import { NoteFilesPanel } from "@/components/notes/note-files-panel";
import { RagOutputsPanel } from "@/components/notes/rag-outputs-panel";
+import { PodcastPanel } from "@/components/notes/podcast-panel";
import { SidePanel } from "@/components/ui/side-panel";
import { toRichTextHtml } from "@/lib/rich-text";
import { useT } from "@/stores/preferences-context";
@@ -39,6 +40,7 @@ export function NoteReaderPanel(props: {
+
)}
diff --git a/src/components/notes/podcast-panel.test.tsx b/src/components/notes/podcast-panel.test.tsx
new file mode 100644
index 0000000..9fca1d7
--- /dev/null
+++ b/src/components/notes/podcast-panel.test.tsx
@@ -0,0 +1,53 @@
+import { cleanup, fireEvent, render, screen, waitFor } from "@solidjs/testing-library";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { PodcastPanel } from "@/components/notes/podcast-panel";
+import { PreferencesProvider } from "@/stores/preferences-context";
+
+const podcastApi = vi.hoisted(() => ({
+ postPodcastJob: vi.fn(),
+ getPodcastJobById: vi.fn(),
+ getPodcastJobResultById: vi.fn(),
+ postPodcastJobCancel: vi.fn(),
+ podcastAudioUrl: vi.fn((id: string) => `/api/podcast/audio?path=${encodeURIComponent(id)}`),
+}));
+
+vi.mock("@/api/podcast", () => podcastApi);
+
+// The panel asks what the AI tier allows as soon as it mounts; without this the
+// real client reaches for a relative URL node's fetch cannot parse.
+const aiApi = vi.hoisted(() => ({
+ getAiCapabilities: vi.fn(async () => ({
+ enabled: true,
+ protocol: "hezarfen.ai.v1",
+ capabilities: [{ capability: "podcast.submit", workers: 1, inflight: 0 }],
+ })),
+}));
+
+vi.mock("@/api/ai", () => aiApi);
+
+describe("PodcastPanel", () => {
+ afterEach(() => {
+ cleanup();
+ sessionStorage.clear();
+ vi.clearAllMocks();
+ });
+
+ it("submits the selected lesson note and narration format", async () => {
+ podcastApi.postPodcastJob.mockResolvedValue({ job_id: "j1", state: "queued", eta_secs: 30 });
+
+ render(() => (
+
+
+
+ ));
+
+ fireEvent.change(screen.getByLabelText("Narration style"), { target: { value: "tek_ogretici" } });
+ fireEvent.click(screen.getByRole("button", { name: "Create podcast" }));
+
+ await waitFor(() => {
+ expect(podcastApi.postPodcastJob).toHaveBeenCalledWith({ source_id: "note-7", format: "tek_ogretici" });
+ });
+ expect(sessionStorage.getItem("hezarfen.podcast.note-7")).toBe("j1");
+ expect(screen.getByText("Waiting in queue")).toBeTruthy();
+ });
+});
diff --git a/src/components/notes/podcast-panel.tsx b/src/components/notes/podcast-panel.tsx
new file mode 100644
index 0000000..3ca58b9
--- /dev/null
+++ b/src/components/notes/podcast-panel.tsx
@@ -0,0 +1,217 @@
+import { For, Show, createEffect, createSignal, onCleanup } from "solid-js";
+import { createResource } from "@/lib/create-resource";
+import { getAiCapabilities } from "@/api/ai";
+import {
+ getPodcastJobById,
+ getPodcastJobResultById,
+ podcastAudioUrl,
+ postPodcastJob,
+ postPodcastJobCancel,
+} from "@/api/podcast";
+import { formatApiError, type PodcastFormat, type PodcastJobArtifacts, type PodcastJobStatus } from "@/api/client";
+import { Alert } from "@/components/ui/alert";
+import { Button } from "@/components/ui/button";
+import { IconWaveform, IconX } from "@/components/ui/icons";
+import { Label } from "@/components/ui/label";
+import { Select } from "@/components/ui/select";
+import { useT } from "@/stores/preferences-context";
+
+const POLL_MS = 2_000;
+
+export function PodcastPanel(props: { noteId: string; active?: boolean }) {
+ const t = useT();
+ const [format, setFormat] = createSignal
("duz_okuma");
+ const [jobId, setJobId] = createSignal("");
+ const [status, setStatus] = createSignal(null);
+ const [artifacts, setArtifacts] = createSignal(null);
+ const [error, setError] = createSignal("");
+ const [submitting, setSubmitting] = createSignal(false);
+ const [cancelling, setCancelling] = createSignal(false);
+ let timer: ReturnType | undefined;
+ let generation = 0;
+
+ // Declared before the resource below: its source runs during setup, so a
+ // later `const active` would be read in its temporal dead zone.
+ const active = () => props.active !== false;
+ const [capabilities] = createResource(() => (active() ? getAiCapabilities() : null));
+ const storageKey = () => `hezarfen.podcast.${props.noteId}`;
+ const stopPolling = () => {
+ if (timer) clearTimeout(timer);
+ timer = undefined;
+ };
+
+ const poll = async (id: string, token: number) => {
+ try {
+ const next = await getPodcastJobById(id);
+ if (token !== generation || !active()) return;
+ setStatus(next);
+ if (next.state === "done") {
+ const result = await getPodcastJobResultById(id);
+ if (token === generation) setArtifacts(result);
+ return;
+ }
+ if (next.state === "failed") {
+ setError(t("podcast.failed"));
+ return;
+ }
+ if (next.state === "cancelled") return;
+ timer = setTimeout(() => void poll(id, token), POLL_MS);
+ } catch (err) {
+ if (token === generation) setError(formatApiError(err));
+ }
+ };
+
+ createEffect(() => {
+ const noteId = props.noteId;
+ const enabled = active();
+ generation += 1;
+ const token = generation;
+ stopPolling();
+ setJobId("");
+ setStatus(null);
+ setArtifacts(null);
+ setError("");
+ if (!enabled || !noteId || typeof sessionStorage === "undefined") return;
+ const stored = sessionStorage.getItem(storageKey());
+ if (stored) {
+ setJobId(stored);
+ void poll(stored, token);
+ }
+ });
+
+ onCleanup(() => {
+ generation += 1;
+ stopPolling();
+ });
+
+ const submit = async () => {
+ if (submitting()) return;
+ generation += 1;
+ const token = generation;
+ stopPolling();
+ setSubmitting(true);
+ setError("");
+ setArtifacts(null);
+ try {
+ const receipt = await postPodcastJob({ source_id: props.noteId, format: format() });
+ if (token !== generation) return;
+ setJobId(receipt.job_id);
+ setStatus({ job_id: receipt.job_id, state: receipt.state, stage: "queued", progress: 0 });
+ if (typeof sessionStorage !== "undefined") sessionStorage.setItem(storageKey(), receipt.job_id);
+ timer = setTimeout(() => void poll(receipt.job_id, token), POLL_MS);
+ } catch (err) {
+ setError(formatApiError(err));
+ } finally {
+ if (token === generation) setSubmitting(false);
+ }
+ };
+
+ const cancel = async () => {
+ const id = jobId();
+ if (!id || cancelling()) return;
+ setCancelling(true);
+ setError("");
+ try {
+ await postPodcastJobCancel(id);
+ generation += 1;
+ stopPolling();
+ setStatus((current) => current ? { ...current, state: "cancelled" } : current);
+ if (typeof sessionStorage !== "undefined") sessionStorage.removeItem(storageKey());
+ } catch (err) {
+ setError(formatApiError(err));
+ } finally {
+ setCancelling(false);
+ }
+ };
+
+ const progress = () => Math.round(Math.min(1, Math.max(0, status()?.progress ?? 0)) * 100);
+ const working = () => ["queued", "running"].includes(status()?.state ?? "");
+ const available = () => {
+ const current = capabilities();
+ if (!current || capabilities.error) return true;
+ return current.enabled && current.capabilities.some((item) => item.capability === "podcast.submit" && item.workers > 0);
+ };
+ const stateLabel = (state: string) => {
+ if (state === "queued") return t("podcast.state.queued");
+ if (state === "running") return t("podcast.state.running");
+ if (state === "done") return t("podcast.state.done");
+ if (state === "failed") return t("podcast.state.failed");
+ if (state === "cancelled") return t("podcast.state.cancelled");
+ return t("podcast.state.running");
+ };
+ const formatOptions = () => [
+ { value: "duz_okuma", label: t("podcast.format.duz_okuma") },
+ { value: "tek_ogretici", label: t("podcast.format.tek_ogretici") },
+ { value: "ogrenci_hoca", label: t("podcast.format.ogrenci_hoca") },
+ ];
+
+ return (
+
+
+
+
+
+
+
{t("podcast.title")}
+
{t("podcast.description")}
+
+
+
+ {(message) => {message()} }
+
+ {t("podcast.unavailable")}
+
+
+
+
+ {t("podcast.format")}
+ setFormat(event.currentTarget.value as PodcastFormat)}
+ >
+
+ {(option) => {option.label} }
+
+
+
+
void submit()}>
+
+ {submitting() ? t("podcast.submitting") : t("podcast.create")}
+
+
+
+
+ {(current) => (
+
+
+ {stateLabel(current().state)}
+ {progress()}%
+
+
+
+ void cancel()}>
+ {t("podcast.cancel")}
+
+
+
+ )}
+
+
+
+ {(result) => (
+
+
{t("podcast.ready")}
+
+ {t("podcast.audioUnsupported")}
+
+
+ )}
+
+
+ );
+}
diff --git a/src/components/notes/rag-output-content.tsx b/src/components/notes/rag-output-content.tsx
new file mode 100644
index 0000000..2a8007e
--- /dev/null
+++ b/src/components/notes/rag-output-content.tsx
@@ -0,0 +1,54 @@
+import { For, Show } from "solid-js";
+
+const SUMMARY_KEYS = ["summary", "ozet", "özet", "content", "text", "answer"];
+const LIST_KEYS = ["keywords", "key_points", "topics", "questions", "highlights"];
+
+function asRecord(value: unknown): Record | null {
+ return value != null && typeof value === "object" && !Array.isArray(value)
+ ? value as Record
+ : null;
+}
+
+function firstText(record: Record | null): string | null {
+ if (!record) return null;
+ for (const key of SUMMARY_KEYS) {
+ const value = record[key];
+ if (typeof value === "string" && value.trim()) return value.trim();
+ }
+ return null;
+}
+
+function firstList(record: Record | null): string[] {
+ if (!record) return [];
+ for (const key of LIST_KEYS) {
+ const value = record[key];
+ if (Array.isArray(value)) {
+ const rows = value.filter((item): item is string => typeof item === "string" && !!item.trim());
+ if (rows.length > 0) return rows;
+ }
+ }
+ return [];
+}
+
+/** Render the useful parts of the AI service's open payload without exposing a JSON dump first. */
+export function RagOutputContent(props: { payload: unknown }) {
+ const record = () => asRecord(props.payload);
+ const summary = () => typeof props.payload === "string" ? props.payload : firstText(record());
+ const points = () => firstList(record());
+
+ return (
+
+
+ {(text) => {text()}
}
+
+
0}>
+
+
+
+ {JSON.stringify(props.payload, null, 2)}
+
+
+ );
+}
diff --git a/src/components/notes/rag-outputs-panel.tsx b/src/components/notes/rag-outputs-panel.tsx
index 996f915..effb7da 100644
--- a/src/components/notes/rag-outputs-panel.tsx
+++ b/src/components/notes/rag-outputs-panel.tsx
@@ -1,16 +1,19 @@
-import { For, Show, Suspense, createSignal } from "solid-js";
+import { For, Show, Suspense, createSignal, onCleanup } from "solid-js";
import { createResource } from "@/lib/create-resource";
+import { getAiCapabilities } from "@/api/ai";
import { formatApiError } from "@/api/client";
import type { RagOutput } from "@/api/client";
import type { NoteFileSource } from "@/lib/note-source";
import { Alert } from "@/components/ui/alert";
+import { Button } from "@/components/ui/button";
import { ConfirmDialog } from "@/components/ui/confirm-dialog";
import { PageSpinner } from "@/components/ui/page-spinner";
import { TableRowActions } from "@/components/ui/table-row-actions";
import { createFlash } from "@/lib/flash";
import { formatDateTime } from "@/lib/format";
import { usePreferences, useT } from "@/stores/preferences-context";
-import { IconTrash } from "@/components/ui/icons";
+import { IconSparkles, IconTrash } from "@/components/ui/icons";
+import { RagOutputContent } from "@/components/notes/rag-output-content";
const RAG_PAGE_SIZE = 10;
@@ -26,13 +29,56 @@ export function RagOutputsPanel(props: {
const [error, setError] = createSignal("");
const [flash, setFlash] = createFlash();
const [deleteTarget, setDeleteTarget] = createSignal(null);
+ const [generating, setGenerating] = createSignal(false);
+ let pollTimer: ReturnType | undefined;
+
+ onCleanup(() => pollTimer && clearTimeout(pollTimer));
const [list, { refetch }] = createResource(
() => (props.active && props.source.listRagOutputs ? props.noteId : null),
async (noteId) => props.source.listRagOutputs!(noteId, { limit: RAG_PAGE_SIZE }),
);
+ const [capabilities] = createResource(
+ () => (props.active && props.source.reindexRag ? true : null),
+ () => getAiCapabilities(),
+ );
const outputs = () => list()?.items ?? [];
+ const available = () => capabilities.error || capabilities()?.enabled !== false;
+
+ const generate = async () => {
+ if (!props.source.reindexRag || generating()) return;
+ setError("");
+ setGenerating(true);
+ const previousId = outputs()[0]?.id;
+ try {
+ await props.source.reindexRag(props.noteId);
+ let attempts = 0;
+ const poll = async () => {
+ if (!props.active) {
+ setGenerating(false);
+ return;
+ }
+ attempts += 1;
+ const next = await refetch();
+ const firstId = next?.items?.[0]?.id;
+ if ((firstId && firstId !== previousId) || attempts >= 24) {
+ setGenerating(false);
+ setFlash(firstId && firstId !== previousId ? t("courseNotes.ragReady") : t("courseNotes.ragQueued"));
+ return;
+ }
+ pollTimer = setTimeout(() => void poll().catch(fail), 2500);
+ };
+ const fail = (err: unknown) => {
+ setGenerating(false);
+ setError(formatApiError(err));
+ };
+ pollTimer = setTimeout(() => void poll().catch(fail), 1500);
+ } catch (err) {
+ setGenerating(false);
+ setError(formatApiError(err));
+ }
+ };
const remove = async () => {
const target = deleteTarget();
@@ -51,13 +97,27 @@ export function RagOutputsPanel(props: {
return (
- {t("courseNotes.ragTitle")}
+
+
+
{t("courseNotes.ragTitle")}
+
{t("courseNotes.ragHint")}
+
+
+ void generate()}>
+
+ {generating() ? t("courseNotes.ragGenerating") : t("courseNotes.ragGenerate")}
+
+
+
{flash()}
{error()}
+
+ {t("courseNotes.ragUnavailable")}
+
}>
{formatApiError(list.error)}
@@ -87,7 +147,7 @@ export function RagOutputsPanel(props: {
-