From d824559774d58da36cb5e08dbb6558b9a0091c39 Mon Sep 17 00:00:00 2001 From: XZH Date: Sun, 30 Aug 2026 17:49:21 -0700 Subject: [PATCH] feat(learner): add personal learning progress view --- web/app/(utility)/settings/progress/page.tsx | 20 +++++++++++++++++++ .../settings/navigation/settings-nav.ts | 8 ++++++++ web/lib/learning-records-api.ts | 11 ++++++++++ 3 files changed, 39 insertions(+) create mode 100644 web/app/(utility)/settings/progress/page.tsx create mode 100644 web/lib/learning-records-api.ts diff --git a/web/app/(utility)/settings/progress/page.tsx b/web/app/(utility)/settings/progress/page.tsx new file mode 100644 index 000000000..4d436aaa9 --- /dev/null +++ b/web/app/(utility)/settings/progress/page.tsx @@ -0,0 +1,20 @@ +"use client"; + +import { useEffect, useState } from "react"; +import { useTranslation } from "react-i18next"; + +import { listLearningRecords, type LearningRecord } from "@/lib/learning-records-api"; + +function label(record: LearningRecord): string { + return String(record.title ?? record.material_title ?? record.material_id ?? "Learning activity"); +} + +export default function LearningProgressPage() { + const { t } = useTranslation(); + const [records, setRecords] = useState(null); + const [error, setError] = useState(false); + + useEffect(() => { void listLearningRecords().then(setRecords).catch(() => setError(true)); }, []); + + return

{t("Learning progress")}

{t("Review your own reading and learning activity.")}

{error ?

{t("Unable to load learning progress")}

: records === null ?

{t("Loading progress")}

: records.length === 0 ?

{t("No learning activity yet")}

:
    {records.map((record, index) =>
  • {label(record)}{String(record.action ?? record.kind ?? "")}
  • )}
}
; +} diff --git a/web/features/settings/navigation/settings-nav.ts b/web/features/settings/navigation/settings-nav.ts index 96aa66b96..a88515138 100644 --- a/web/features/settings/navigation/settings-nav.ts +++ b/web/features/settings/navigation/settings-nav.ts @@ -24,6 +24,7 @@ import { ShieldCheck, SlidersHorizontal, Sparkles, + ChartNoAxesCombined, UserRound, Wrench, type LucideIcon, @@ -471,6 +472,13 @@ export const SETTINGS_CATEGORIES: SettingsCategory[] = [ href: "/settings#agents", children: AGENT_CHILDREN, }, + { + key: "progress", + label: { zh: "学习进度", en: "Learning progress" }, + blurb: { zh: "查看自己的阅读与学习记录。", en: "Review your reading and learning activity." }, + icon: ChartNoAxesCombined, + href: "/settings/progress", + }, { key: "learner-profile", learnerOnly: true, diff --git a/web/lib/learning-records-api.ts b/web/lib/learning-records-api.ts new file mode 100644 index 000000000..e86ce981b --- /dev/null +++ b/web/lib/learning-records-api.ts @@ -0,0 +1,11 @@ +import { apiFetch, apiUrl } from "@/lib/api"; + +export interface LearningRecord { + [key: string]: unknown; +} + +export async function listLearningRecords(): Promise { + const response = await apiFetch(apiUrl("/api/v1/learning/records")); + if (!response.ok) throw new Error("Failed to load learning progress"); + return response.json() as Promise; +}