DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(reading): keep age controls visible and accessible on phones (#1419)
Bingxi Zhao (Frank)a2f6470eca51
diff --git a/web/app/globals.css b/web/app/globals.cssindex 77725a1a3..bb752db00 100644--- a/web/app/globals.css+++ b/web/app/globals.css@@ -666,6 +666,16 @@}}+/* Keep transform free for Reading toolbar hover and press motion. */+@keyframes dt-reading-button-enter {+ from {+ opacity: 0;+ }+ to {+ opacity: 1;+ }+}+.animate-fade-in {animation: fade-in 0.35s ease-out forwards;}diff --git a/web/components/reading/ReadingExtensionBar.tsx b/web/components/reading/ReadingExtensionBar.tsxindex 6ff9fd6d8..1ba080fec 100644--- a/web/components/reading/ReadingExtensionBar.tsx+++ b/web/components/reading/ReadingExtensionBar.tsx@@ -194,6 +194,16 @@ export function ReadingExtensionBar({const disabled = busy === key || needsSelection;const builtInLabel = builtInActionLabel(extension.id, action.id);const primaryRank = primaryReadingActionRank(key);+ const shortLabel =+ ageMode === "early"+ ? primaryRank === 0+ ? "Listen"+ : primaryRank === 1+ ? "Look up word"+ : primaryRank === 2+ ? "Quiz"+ : null+ : null;const Icon =(ageMode !== "default" ? PRIMARY_ACTION_ICONS[primaryRank] : null) ?? Sparkles;const iconSize = primaryRank >= 0 && ageMode === "early" ? 18 : 14;@@ -203,6 +213,11 @@ export function ReadingExtensionBar({type="button"disabled={disabled}title={needsSelection ? t("Select text in the document first.") : undefined}+ aria-label={+ shortLabel && builtInLabel+ ? `${t(shortLabel)} — ${t(builtInLabel)}`+ : undefined+ }onClick={() => void run(extension, action)}className={readingActionClass(ageMode, key)}>@@ -214,11 +229,11 @@ export function ReadingExtensionBar({<spanclassName={primaryRank >= 0 && ageMode !== "default"- ? "whitespace-nowrap text-center"+ ? "min-w-0 text-center max-sm:break-words sm:whitespace-nowrap": "truncate text-center"}>- {builtInLabel ? t(builtInLabel) : action.label}+ {shortLabel ? t(shortLabel) : builtInLabel ? t(builtInLabel) : action.label}</span></button>);diff --git a/web/lib/reading-age-presentation.ts b/web/lib/reading-age-presentation.tsindex b12b968e1..29ce44ff1 100644--- a/web/lib/reading-age-presentation.ts+++ b/web/lib/reading-age-presentation.ts@@ -49,11 +49,11 @@ const adultButton =const learnerButtons: Record<Exclude<ReadingAgeMode, "default">, string> = {early:- "min-h-14 min-w-[112px] w-max flex-none flex-col gap-0.5 rounded-[20px] border-2 px-3 py-1 text-xs font-bold leading-tight motion-safe:animate-[fade-in_220ms_ease-out_both] motion-safe:transition-transform motion-safe:hover:-translate-y-0.5 motion-safe:active:translate-y-0.5",+ "min-h-14 min-w-[112px] w-max flex-none flex-col gap-0.5 rounded-[20px] border-2 px-3 py-1 text-xs font-bold leading-tight max-sm:min-w-0 max-sm:w-0 max-sm:flex-1 max-sm:px-1 motion-safe:animate-[dt-reading-button-enter_220ms_ease-out_both] motion-safe:transition-transform motion-safe:hover:-translate-y-0.5 motion-safe:active:translate-y-0.5",young:- "min-h-12 min-w-[100px] w-max flex-none rounded-2xl border-2 px-3 text-sm font-semibold motion-safe:transition-transform motion-safe:hover:-translate-y-0.5 motion-safe:active:scale-[.98]",+ "min-h-12 min-w-[100px] w-max flex-none rounded-2xl border-2 px-3 text-sm font-semibold max-sm:min-w-0 max-sm:w-0 max-sm:flex-1 max-sm:flex-col max-sm:gap-0.5 max-sm:px-1 motion-safe:transition-transform motion-safe:hover:-translate-y-0.5 motion-safe:active:scale-[.98]",older:- "min-h-11 w-max flex-none rounded-xl border px-3 text-sm font-medium motion-safe:transition-transform motion-safe:active:scale-[.99]",+ "min-h-11 w-max flex-none rounded-xl border px-3 text-sm font-medium max-sm:min-w-0 max-sm:w-0 max-sm:flex-1 max-sm:flex-col max-sm:gap-0.5 max-sm:px-1 motion-safe:transition-transform motion-safe:active:scale-[.99]",};const tones: Record<Exclude<ReadingAgeMode, "default">, Record<string, string>> = {diff --git a/web/locales/en/app.json b/web/locales/en/app.jsonindex 644f6cf23..6a4be2a44 100644--- a/web/locales/en/app.json+++ b/web/locales/en/app.json@@ -375,6 +375,8 @@"View": "View","Close": "Close","No speech voice is available in this browser.": "No speech voice is available in this browser.",+ "Listen": "Listen",+ "Look up word": "Look up word","Explain vocabulary": "Explain vocabulary","Quiz me": "Quiz me","Translate to English": "Translate to English",diff --git a/web/locales/zh/app.json b/web/locales/zh/app.jsonindex 934623290..ec7a08e08 100644--- a/web/locales/zh/app.json+++ b/web/locales/zh/app.json@@ -375,6 +375,8 @@"View": "查看","Close": "关闭","No speech voice is available in this browser.": "此浏览器没有可用的语音。",+ "Listen": "听读",+ "Look up word": "查词","Explain vocabulary": "解释词汇","Quiz me": "测一测","Translate to English": "翻译成英文",diff --git a/web/tests/reading-age-presentation.spec.tsx b/web/tests/reading-age-presentation.spec.tsxindex 89a716e78..8afc156fe 100644--- a/web/tests/reading-age-presentation.spec.tsx+++ b/web/tests/reading-age-presentation.spec.tsx@@ -106,12 +106,11 @@ describe("host-owned Reading age presentation", () => {),);const buttons = screen.getAllByRole("button");- expect(buttons.map((button) => button.textContent?.trim())).toEqual([- "Read aloud",- "Explain vocabulary",- "Quiz me",- "Custom action",- ]);+ expect(buttons.map((button) => button.textContent?.trim())).toEqual(+ age === 5+ ? ["Listen", "Look up word", "Quiz", "Custom action"]+ : ["Read aloud", "Explain vocabulary", "Quiz me", "Custom action"],+ );for (const button of buttons.slice(0, 3)) {expect(button).toHaveClass(size);expect(button).toHaveAccessibleName();@@ -120,6 +119,13 @@ describe("host-owned Reading age presentation", () => {expect(buttons[3]).not.toHaveClass(size);expect(buttons[1]).toBeDisabled();expect(onError).not.toHaveBeenCalled();+ if (age === 5) {+ expect(buttons.slice(0, 3).map((button) => button.getAttribute("aria-label"))).toEqual([+ "Listen — Read aloud",+ "Look up word — Explain vocabulary",+ "Quiz — Quiz me",+ ]);+ }});it("keeps adult styling for a standard account and never fetches its learner profile", async () => {@@ -144,7 +150,7 @@ describe("host-owned Reading age presentation", () => {it("keeps the action request and keyboard order free of age metadata", async () => {vi.mocked(getOwnLearnerProfile).mockResolvedValue({ age: 5 });render(<ReadingExtensionBar materialId="material-1" locator={4} onError={vi.fn()} />);- const readButton = await screen.findByRole("button", { name: "Read aloud" });+ const readButton = await screen.findByRole("button", { name: /Listen.*Read aloud/ });await waitFor(() => expect(readButton.closest("[data-reading-presentation]")).toHaveAttribute("data-reading-presentation", "early"));expect(screen.getAllByRole("button")[0]).toBe(readButton);fireEvent.click(readButton);