DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
Merge pull request #1108 from evan188199-tech/codex/feat-reading-vocabulary
Bingxi Zhao (Frank)2f26e468b6ca
diff --cc pyproject.tomlindex 70513f2fe,b1c498a8b..a320b5ac0--- a/pyproject.toml+++ b/pyproject.toml@@@ -85,8 -84,7 +85,9 @@@ dependencies =deeptutor = "deeptutor_cli.main:main"[project.entry-points."deeptutor.reading_extensions"]+read_aloud = "deeptutor.reading.read_aloud:ReadAloudExtension"+guided_learning = "deeptutor.reading.study_guidance:StudyGuidanceExtension"+ vocabulary = "deeptutor.reading.vocabulary:VocabularyExtension"[project.optional-dependencies]# Compatibility extra for source installs and older docs. These packages arediff --cc web/components/reading/ReadingExtensionBar.tsxindex 36672e42c,4ce4554a1..24e71d6c1--- a/web/components/reading/ReadingExtensionBar.tsx+++ b/web/components/reading/ReadingExtensionBar.tsx@@@ -162,12 -136,9 +168,15 @@@ export function ReadingExtensionBar(}function builtInActionLabel(extensionId: string, actionId: string) {+ if (extensionId === "read_aloud" && actionId === "read") {+ return "Read aloud";+ }+ if (extensionId === "guided_learning" && actionId === "guide") {+ return "Guide me";+ }+ if (extensionId === "vocabulary" && actionId === "explain") {+ return "Explain vocabulary";+ }return "";}@@@ -190,9 -161,19 +199,22 @@@ function ExtensionResult(const items = Array.isArray(result.payload.items)? result.payload.items.map(String): [];+ const steps = Array.isArray(result.payload.steps)+ ? result.payload.steps.map(String)+ : [];+ const terms: VocabularyTerm[] = Array.isArray(result.payload.terms)+ ? result.payload.terms+ .map((row) => {+ if (typeof row !== "object" || row === null) return null;+ const term = row as Partial<VocabularyTerm>;+ return {+ term: String(term.term || ""),+ meaning: String(term.meaning || ""),+ usage: String(term.usage || ""),+ };+ })+ .filter((row): row is VocabularyTerm => row !== null)+ : [];const body = String(result.payload.body || result.payload.overview || "");return (<section className="relative shrink-0 border-b border-[var(--border)] bg-[var(--card)] px-3 py-3 text-xs text-[var(--foreground)]">@@@ -216,13 -197,24 +238,31 @@@))}</ul>) : null}+ {steps.length ? (+ <ol className="mt-2 list-decimal space-y-1 pl-5">+ {steps.map((step, index) => (+ <li key={`${index}-${step}`}>{step}</li>+ ))}+ </ol>+ ) : null}+ {terms.length ? (+ <dl className="mt-2 space-y-2">+ {terms.map((term, index) => (+ <div+ key={`${index}-${term.term}`}+ className="border-t border-[var(--border)] pt-2 first:border-t-0 first:pt-0"+ >+ <dt className="font-medium">{term.term}</dt>+ <dd className="mt-1 text-[var(--muted-foreground)]">+ {term.meaning}+ </dd>+ <dd className="mt-1 text-[var(--muted-foreground)]">+ {term.usage}+ </dd>+ </div>+ ))}+ </dl>+ ) : null}{questions.map((question, index) => (<div key={question.id || index} className="mt-3"><p className="font-medium">{question.prompt}</p>diff --cc web/tests/reading-extensions.test.tsindex 31249adae,e7e5c5387..05ca7f9ab--- a/web/tests/reading-extensions.test.ts+++ b/web/tests/reading-extensions.test.ts@@@ -41,42 -39,25 +41,57 @@@ test("a malformed extension catalog can);});-test("the built-in vocabulary action is localized", () => {- assert.match(component, /extensionId === "vocabulary" && actionId === "explain"/);- const english = readFileSync(- path.resolve(process.cwd(), "locales/en/app.json"),- "utf8",+test("browser speech is stoppable and cannot continue after navigation", () => {+ assert.match(component, /const \[speaking, setSpeaking\] = useState\(false\)/);+ assert.match(component, /function stopSpeaking\(\)/);+ assert.match(component, /window\.speechSynthesis\?\.cancel\(\)/);+ assert.match(component, /utterance\.onend = \(\) => setSpeaking\(false\)/);+ assert.match(component, /utterance\.onerror = \(\) => setSpeaking\(false\)/);+ assert.match(component, /\}, \[locator, materialId\]\);/);+ assert.match(component, /aria-label=\{t\("Stop reading aloud"\)\}/);+});++test("the built-in read-aloud action is localized", () => {+ assert.match(+ component,+ /extensionId === "read_aloud" && actionId === "read"/,);- const chinese = readFileSync(- path.resolve(process.cwd(), "locales/zh/app.json"),- "utf8",+ assert.match(english, /"Read aloud": "Read aloud"/);+ assert.match(chinese, /"Read aloud": "朗读"/);+ assert.match(english, /"Reading aloud": "Reading aloud"/);+ assert.match(chinese, /"Reading aloud": "正在朗读"/);+ assert.match(english, /"Stop reading aloud": "Stop reading aloud"/);+ assert.match(chinese, /"Stop reading aloud": "停止朗读"/);+});++test("the built-in study-guidance action is localized", () => {+ assert.match(component, /function builtInActionLabel/);+ assert.match(+ component,+ /extensionId === "guided_learning" && actionId === "guide"/,);+ assert.match(component, /t\(builtInLabel\)/);+ assert.match(english, /"Guide me": "Guide me"/);+ assert.match(chinese, /"Guide me": "引导我"/);+});++test("study-guidance steps are visible in the result card", () => {+ assert.match(component, /result\.payload\.steps/);+ assert.match(component, /steps\.map\(\(step, index\) =>/);+ assert.match(component, /list-decimal/);+});++++test("the built-in vocabulary action is localized", () => {++ assert.match(component, /extensionId === "vocabulary" && actionId === "explain"/);+ assert.match(english, /"Explain vocabulary": "Explain vocabulary"/);+ assert.match(chinese, /"Explain vocabulary": "解释词汇"/);+ });++ test("vocabulary terms are visible in the result card", () => {+ assert.match(component, /result\.payload\.terms/);+ assert.match(component, /String\(term\.term \|\| ""\)/);+ assert.match(component, /terms\.map\(\(term, index\) =>/);+ assert.match(component, /<dt className="font-medium">\{term\.term\}<\/dt>/);+ assert.match(component, /\{term\.meaning\}/);+ assert.match(component, /\{term\.usage\}/);+ });