fix(web): replace native title hints in question bank and reading workspace (#1526)

This commit is contained in:
Bingxi Zhao (Frank)
2026-09-27 05:02:24 +08:00
parent cf44400fc8
commit 105e8b237f
14 changed files with 565 additions and 296 deletions
@@ -4,6 +4,7 @@ import { ListChecks, Loader2, Sparkles, Square, Volume2 } from "lucide-react";
import { useTranslation } from "react-i18next";
import { useReadingActions } from "@/components/reading/reading-actions-context";
import Tooltip from "@/shared/ui/Tooltip";
const READ_ALOUD_KEY = "read_aloud:read";
@@ -26,29 +27,30 @@ export function ReadAloudButton({ disabled }: { disabled?: boolean }) {
? t("Stop reading aloud")
: t("Read this page aloud");
return (
<button
type="button"
disabled={disabled || busy}
onClick={() =>
shared.speaking ? shared.stopSpeaking() : void shared.run(entry)
}
aria-label={label}
aria-pressed={shared.speaking}
title={label}
className={`flex size-7 shrink-0 items-center justify-center rounded-md transition hover:bg-[var(--muted)] disabled:cursor-not-allowed disabled:opacity-40 ${
shared.speaking
? "text-[var(--primary)]"
: "text-[var(--muted-foreground)] hover:text-[var(--foreground)]"
}`}
>
{busy ? (
<Loader2 size={14} className="animate-spin" />
) : shared.speaking ? (
<Square size={11} fill="currentColor" />
) : (
<Volume2 size={14} />
)}
</button>
<Tooltip label={label}>
<button
type="button"
disabled={disabled || busy}
onClick={() =>
shared.speaking ? shared.stopSpeaking() : void shared.run(entry)
}
aria-label={label}
aria-pressed={shared.speaking}
className={`flex size-7 shrink-0 items-center justify-center rounded-md transition hover:bg-[var(--muted)] disabled:cursor-not-allowed disabled:opacity-40 ${
shared.speaking
? "text-[var(--primary)]"
: "text-[var(--muted-foreground)] hover:text-[var(--foreground)]"
}`}
>
{busy ? (
<Loader2 size={14} className="animate-spin" />
) : shared.speaking ? (
<Square size={11} fill="currentColor" />
) : (
<Volume2 size={14} />
)}
</button>
</Tooltip>
);
}
@@ -74,16 +76,17 @@ export function PageToolButtons({
"flex size-7 shrink-0 items-center justify-center rounded-md text-[var(--muted-foreground)] transition hover:bg-[var(--muted)] hover:text-[var(--foreground)] disabled:cursor-not-allowed disabled:opacity-40";
return (
<>
<button
type="button"
disabled={disabled}
onClick={onQuiz}
aria-label={t("Quiz me on this page")}
title={t("Quiz me on this page")}
className={buttonClass}
>
<ListChecks size={14} />
</button>
<Tooltip label={t("Quiz me on this page")}>
<button
type="button"
disabled={disabled}
onClick={onQuiz}
aria-label={t("Quiz me on this page")}
className={buttonClass}
>
<ListChecks size={14} />
</button>
</Tooltip>
{shared.actions
.filter(
(entry) => !entry.needsSelection && entry.key !== READ_ALOUD_KEY,
@@ -91,21 +94,21 @@ export function PageToolButtons({
.map((entry) => {
const busy = shared.busyKey === entry.key;
return (
<button
key={entry.key}
type="button"
disabled={disabled || busy}
onClick={() => void shared.run(entry)}
aria-label={entry.label}
title={entry.label}
className={buttonClass}
>
{busy ? (
<Loader2 size={14} className="animate-spin" />
) : (
<Sparkles size={14} />
)}
</button>
<Tooltip key={entry.key} label={entry.label}>
<button
type="button"
disabled={disabled || busy}
onClick={() => void shared.run(entry)}
aria-label={entry.label}
className={buttonClass}
>
{busy ? (
<Loader2 size={14} className="animate-spin" />
) : (
<Sparkles size={14} />
)}
</button>
</Tooltip>
);
})}
</>
@@ -16,6 +16,7 @@ import {
useReadingActions,
type ReadingActionCard,
} from "@/components/reading/reading-actions-context";
import Tooltip from "@/shared/ui/Tooltip";
/**
* Where a reading action's answer lands: under the conversation, in the same
@@ -98,15 +99,16 @@ function ActionCard({
<h3 className="min-w-0 flex-1 truncate text-[12px] font-semibold text-[var(--foreground)]">
{title}
</h3>
<button
type="button"
onClick={onDismiss}
aria-label={t("Dismiss")}
title={t("Dismiss")}
className="inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--muted-foreground)] transition hover:bg-[var(--muted)] hover:text-[var(--foreground)]"
>
<X size={12} />
</button>
<Tooltip label={t("Dismiss")}>
<button
type="button"
onClick={onDismiss}
aria-label={t("Dismiss")}
className="inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--muted-foreground)] transition hover:bg-[var(--muted)] hover:text-[var(--foreground)]"
>
<X size={12} />
</button>
</Tooltip>
</header>
{card.quote ? (
<blockquote className="mx-3 mt-1 line-clamp-3 border-l-2 border-[var(--primary)] pl-2.5 text-[11.5px] leading-relaxed text-[var(--muted-foreground)]">
@@ -29,6 +29,7 @@ import {
} from "@/lib/ask-user-state";
import { notify } from "@/lib/notifications";
import { setReadingViewport } from "@/lib/reading-turn-state";
import Tooltip from "@/shared/ui/Tooltip";
export function ReadingComposer({
placeholder,
@@ -188,15 +189,16 @@ function QuotedPassage({
<p className="line-clamp-2 min-w-0 flex-1 border-l-2 border-[color-mix(in_srgb,var(--primary)_45%,transparent)] pl-2.5 text-[12.5px] leading-relaxed text-[var(--muted-foreground)]">
{quote}
</p>
<button
type="button"
aria-label={t("Remove quoted passage")}
title={t("Remove quoted passage")}
onClick={onRemove}
className="-mr-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--muted-foreground)] transition hover:bg-[var(--muted)] hover:text-[var(--foreground)]"
>
<X size={12} />
</button>
<Tooltip label={t("Remove quoted passage")}>
<button
type="button"
aria-label={t("Remove quoted passage")}
onClick={onRemove}
className="-mr-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--muted-foreground)] transition hover:bg-[var(--muted)] hover:text-[var(--foreground)]"
>
<X size={12} />
</button>
</Tooltip>
</div>
);
}
@@ -4,6 +4,7 @@ import { scopedUrl } from "@/lib/workspace-scope";
import { READING_HOME, readingFolderRoute, readingSessionIdFromPath } from "@/lib/learning-routes";
import { browserStorage } from "@/shared/storage";
import Tooltip from "@/shared/ui/Tooltip";
import Link from "next/link";
import dynamic from "next/dynamic";
@@ -491,39 +492,44 @@ export function ReadingWorkspacePage() {
{/* The outline opens on the left, so its switch lives on the left:
it sat at the far right, next to the companion's, and a learner
had to guess which of two panel icons was which. */}
<button
type="button"
onClick={() => toggleNavigator(!navigatorOpen)}
className={`flex size-7 shrink-0 items-center justify-center rounded-md transition hover:bg-[var(--muted)] ${
navigatorOpen
? "text-[var(--primary)]"
: "text-[var(--muted-foreground)] hover:text-[var(--foreground)]"
}`}
aria-label={
navigatorOpen ? t("Collapse contents") : t("Expand contents")
}
title={navigatorOpen ? t("Collapse contents") : t("Expand contents")}
aria-expanded={navigatorOpen}
>
{navigatorOpen ? <PanelLeftClose size={14} /> : <PanelLeftOpen size={14} />}
</button>
<button
type="button"
onClick={() => setShowRename(true)}
className="max-w-[240px] shrink-0 truncate font-serif text-[13.5px] font-semibold tracking-[-0.01em] transition hover:text-[var(--primary)]"
title={t("Rename collection")}
>
{workspace.title}
</button>
<button
type="button"
onClick={() => setShowAddSource(true)}
className="flex size-7 shrink-0 items-center justify-center rounded-md text-[var(--muted-foreground)] transition hover:bg-[var(--muted)] hover:text-[var(--primary)]"
aria-label={t("Add material")}
title={t("Add material")}
>
<Plus size={14} />
</button>
<Tooltip label={navigatorOpen ? t("Collapse contents") : t("Expand contents")}>
<button
type="button"
onClick={() => toggleNavigator(!navigatorOpen)}
className={`flex size-7 shrink-0 items-center justify-center rounded-md transition hover:bg-[var(--muted)] ${
navigatorOpen
? "text-[var(--primary)]"
: "text-[var(--muted-foreground)] hover:text-[var(--foreground)]"
}`}
aria-label={
navigatorOpen ? t("Collapse contents") : t("Expand contents")
}
aria-expanded={navigatorOpen}
>
{navigatorOpen ? <PanelLeftClose size={14} /> : <PanelLeftOpen size={14} />}
</button>
</Tooltip>
<span className="inline-flex min-w-0 max-w-[240px] shrink-0">
<Tooltip label={t("Rename collection")} suppressed={showRename}>
<button
type="button"
onClick={() => setShowRename(true)}
className="min-w-0 max-w-[240px] truncate font-serif text-[13.5px] font-semibold tracking-[-0.01em] transition hover:text-[var(--primary)]"
>
{workspace.title}
</button>
</Tooltip>
</span>
<Tooltip label={t("Add material")}>
<button
type="button"
onClick={() => setShowAddSource(true)}
className="flex size-7 shrink-0 items-center justify-center rounded-md text-[var(--muted-foreground)] transition hover:bg-[var(--muted)] hover:text-[var(--primary)]"
aria-label={t("Add material")}
>
<Plus size={14} />
</button>
</Tooltip>
<div className="ml-auto flex shrink-0 items-center gap-0.5">
{notice && (
@@ -538,24 +544,23 @@ export function ReadingWorkspacePage() {
/>
{/* An icon, like every other control on this bar: as the only
labelled button it read as the page's primary action. */}
<button
type="button"
onClick={() => (learning ? closeLearning() : openLearning())}
className={`flex size-7 shrink-0 items-center justify-center rounded-md transition hover:bg-[var(--muted)] ${
learning
? "text-[var(--primary)]"
: "text-[var(--muted-foreground)] hover:text-[var(--foreground)]"
}`}
aria-pressed={learning}
aria-label={t(
learning ? "Exit learning mode" : "Fullscreen learning",
)}
title={t(
learning ? "Exit learning mode" : "Fullscreen learning",
)}
>
{learning ? <Minimize2 size={14} /> : <Expand size={14} />}
</button>
<Tooltip label={t(learning ? "Exit learning mode" : "Fullscreen learning")}>
<button
type="button"
onClick={() => (learning ? closeLearning() : openLearning())}
className={`flex size-7 shrink-0 items-center justify-center rounded-md transition hover:bg-[var(--muted)] ${
learning
? "text-[var(--primary)]"
: "text-[var(--muted-foreground)] hover:text-[var(--foreground)]"
}`}
aria-pressed={learning}
aria-label={t(
learning ? "Exit learning mode" : "Fullscreen learning",
)}
>
{learning ? <Minimize2 size={14} /> : <Expand size={14} />}
</button>
</Tooltip>
<WorkspaceMenu
sections={menuSections}
collection={collectionMenu}
@@ -563,16 +568,17 @@ export function ReadingWorkspacePage() {
{/* Past conversations are in the app sidebar with every other one;
this bar only starts a fresh one. Beside the companion's switch,
since that is the column it clears. */}
<button
type="button"
onClick={newConversation}
disabled={!activeConversation}
className="flex size-7 shrink-0 items-center justify-center rounded-md text-[var(--muted-foreground)] transition hover:bg-[var(--muted)] hover:text-[var(--foreground)] disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent"
aria-label={t("New conversation")}
title={t("New conversation")}
>
<SquarePen size={14} />
</button>
<Tooltip label={t("New conversation")}>
<button
type="button"
onClick={newConversation}
disabled={!activeConversation}
className="flex size-7 shrink-0 items-center justify-center rounded-md text-[var(--muted-foreground)] transition hover:bg-[var(--muted)] hover:text-[var(--foreground)] disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent"
aria-label={t("New conversation")}
>
<SquarePen size={14} />
</button>
</Tooltip>
<button
type="button"
onClick={() => toggleCompanion(!companionOpen)}
@@ -32,6 +32,7 @@ import {
type ReadingWorkspaceTab,
} from "@/lib/reading-workspace-api";
import { formatMediaTime, timeFromSourceHref } from "@/lib/reading-media-time";
import Tooltip from "@/shared/ui/Tooltip";
import { AnnotationList } from "../AnnotationList";
import { iconForMaterial } from "./WorkspaceChrome";
import { type TranscriptRow } from "./types";
@@ -408,15 +409,16 @@ export function SourceNavigator({
)}
</button>
)}
<button
type="button"
onClick={() => onRemoveMaterial(candidate)}
className="mr-1 shrink-0 rounded-md p-1 text-[var(--muted-foreground)] transition hover:bg-[var(--muted)] hover:text-[var(--destructive)]"
aria-label={t("Remove from collection")}
title={t("Remove from collection")}
>
<X size={10} />
</button>
<Tooltip label={t("Remove from collection")}>
<button
type="button"
onClick={() => onRemoveMaterial(candidate)}
className="mr-1 shrink-0 rounded-md p-1 text-[var(--muted-foreground)] transition hover:bg-[var(--muted)] hover:text-[var(--destructive)]"
aria-label={t("Remove from collection")}
>
<X size={10} />
</button>
</Tooltip>
</div>
{expanded && (
@@ -10,6 +10,7 @@ import {
type WorkspaceMenuSection,
} from "@/components/reading/workspace-menu-context";
import { MenuItem } from "./WorkspaceChrome";
import Tooltip from "@/shared/ui/Tooltip";
export type WorkspaceMenuSections = Partial<
Record<WorkspaceMenuSection, WorkspaceMenuItem[]>
@@ -69,17 +70,18 @@ export function WorkspaceMenu({
return (
<div className="relative">
<button
type="button"
onClick={() => setOpen((current) => !current)}
className="flex size-7 items-center justify-center rounded-md text-[var(--muted-foreground)] transition hover:bg-[var(--muted)]"
aria-label={t("More")}
title={t("More")}
aria-haspopup="menu"
aria-expanded={open}
>
<MoreHorizontal size={14} />
</button>
<Tooltip label={t("More")} suppressed={open}>
<button
type="button"
onClick={() => setOpen((current) => !current)}
className="flex size-7 items-center justify-center rounded-md text-[var(--muted-foreground)] transition hover:bg-[var(--muted)]"
aria-label={t("More")}
aria-haspopup="menu"
aria-expanded={open}
>
<MoreHorizontal size={14} />
</button>
</Tooltip>
{open && (
<>
<div className="fixed inset-0 z-30" onClick={() => setOpen(false)} />
@@ -5,6 +5,7 @@ import { CheckSquare, FolderMinus, X } from "lucide-react";
import type { NotebookCategory } from "@/lib/notebook-api";
import CategoryMenu from "./CategoryMenu";
import type { BankScope } from "./useQuestionBank";
import Tooltip from "@/shared/ui/Tooltip";
interface BankSelectionBarProps {
count: number;
@@ -79,14 +80,16 @@ export default function BankSelectionBar({
</button>
)}
<button
type="button"
onClick={onClear}
title={t("Clear selection")}
className="rounded-lg p-1.5 text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]/60 hover:text-[var(--foreground)]"
>
<X className="h-3.5 w-3.5" />
</button>
<Tooltip label={t("Clear selection")} side="top">
<button
type="button"
onClick={onClear}
aria-label={t("Clear selection")}
className="rounded-lg p-1.5 text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]/60 hover:text-[var(--foreground)]"
>
<X className="h-3.5 w-3.5" />
</button>
</Tooltip>
</div>
);
}
@@ -14,6 +14,7 @@ import type {
ScoreTrend,
} from "@/lib/notebook-api";
import type { BankSort, ReviewFilters } from "./useQuestionBank";
import Tooltip from "@/shared/ui/Tooltip";
interface BankToolbarProps {
search: string;
@@ -61,28 +62,33 @@ export default function BankToolbar({
{refreshing ? (
<Loader2 className="absolute right-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 animate-spin text-[var(--muted-foreground)]" />
) : search ? (
<button
type="button"
onClick={() => onSearchChange("")}
title={t("Clear")}
className="absolute right-2.5 top-1/2 -translate-y-1/2 rounded p-0.5 text-[var(--muted-foreground)] transition-colors hover:text-[var(--foreground)]"
>
<X className="h-3.5 w-3.5" />
</button>
<span className="absolute right-2.5 top-1/2 -translate-y-1/2">
<Tooltip label={t("Clear")}>
<button
type="button"
onClick={() => onSearchChange("")}
aria-label={t("Clear")}
className="rounded p-0.5 text-[var(--muted-foreground)] transition-colors hover:text-[var(--foreground)]"
>
<X className="h-3.5 w-3.5" />
</button>
</Tooltip>
</span>
) : null}
</div>
<button
type="button"
onClick={() => onSortChange(sort === "recent" ? "oldest" : "recent")}
title={t("Toggle sort order")}
className="inline-flex shrink-0 items-center gap-1.5 rounded-lg border border-[var(--border)] bg-[var(--card)] px-2.5 py-1.5 text-[12px] text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]/60 hover:text-[var(--foreground)]"
>
<ArrowDownWideNarrow
className={`h-3.5 w-3.5 transition-transform ${sort === "oldest" ? "rotate-180" : ""}`}
/>
{sort === "recent" ? t("Newest first") : t("Oldest first")}
</button>
<Tooltip label={t("Toggle sort order")}>
<button
type="button"
onClick={() => onSortChange(sort === "recent" ? "oldest" : "recent")}
className="inline-flex shrink-0 items-center gap-1.5 rounded-lg border border-[var(--border)] bg-[var(--card)] px-2.5 py-1.5 text-[12px] text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]/60 hover:text-[var(--foreground)]"
>
<ArrowDownWideNarrow
className={`h-3.5 w-3.5 transition-transform ${sort === "oldest" ? "rotate-180" : ""}`}
/>
{sort === "recent" ? t("Newest first") : t("Oldest first")}
</button>
</Tooltip>
<select
value={filters.source}
@@ -148,7 +154,6 @@ export default function BankToolbar({
<button
type="button"
onClick={onToggleManager}
title={t("Manage tags")}
className={`inline-flex shrink-0 items-center gap-1.5 rounded-lg border px-2.5 py-1.5 text-[12px] transition-colors ${
managerOpen
? "border-[var(--primary)]/40 bg-[var(--primary)]/10 text-[var(--primary)]"
@@ -4,6 +4,7 @@ import { useCallback, useState } from "react";
import { useTranslation } from "react-i18next";
import { Check, Pencil, Plus, Trash2, X } from "lucide-react";
import type { NotebookCategory } from "@/lib/notebook-api";
import Tooltip from "@/shared/ui/Tooltip";
interface CategoryManagerProps {
categories: NotebookCategory[];
@@ -75,23 +76,27 @@ export default function CategoryManager({
}}
className="min-w-0 flex-1 rounded-md border border-[var(--border)] bg-[var(--background)] px-2 py-1 text-[12.5px] text-[var(--foreground)] outline-none focus:border-[var(--primary)]/50"
/>
<button
type="button"
disabled={busy}
onClick={() => void commitRename()}
title={t("Save")}
className="rounded-md p-1 text-[var(--primary)] transition-colors hover:bg-[var(--muted)] disabled:opacity-40"
>
<Check size={13} />
</button>
<button
type="button"
onClick={() => setRenaming(null)}
title={t("Cancel")}
className="rounded-md p-1 text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]"
>
<X size={13} />
</button>
<Tooltip label={t("Save")}>
<button
type="button"
disabled={busy}
onClick={() => void commitRename()}
aria-label={t("Save")}
className="rounded-md p-1 text-[var(--primary)] transition-colors hover:bg-[var(--muted)] disabled:opacity-40"
>
<Check size={13} />
</button>
</Tooltip>
<Tooltip label={t("Cancel")}>
<button
type="button"
onClick={() => setRenaming(null)}
aria-label={t("Cancel")}
className="rounded-md p-1 text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)]"
>
<X size={13} />
</button>
</Tooltip>
</>
) : (
<>
@@ -101,37 +106,41 @@ export default function CategoryManager({
{category.entry_count}
</span>
</span>
<button
type="button"
onClick={() =>
setRenaming({ id: category.id, name: category.name })
}
title={t("Rename")}
className="rounded-md p-1 text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)] hover:text-[var(--foreground)]"
>
<Pencil size={13} />
</button>
<button
type="button"
disabled={busy}
onClick={() => {
// Deleting a category unfiles its questions; it never
// deletes them. Say so — the wording is the whole point
// of the prompt.
if (
window.confirm(
t(
"Delete this tag? The questions themselves stay in your bank.",
),
<Tooltip label={t("Rename")}>
<button
type="button"
onClick={() =>
setRenaming({ id: category.id, name: category.name })
}
aria-label={t("Rename")}
className="rounded-md p-1 text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)] hover:text-[var(--foreground)]"
>
<Pencil size={13} />
</button>
</Tooltip>
<Tooltip label={t("Delete")}>
<button
type="button"
disabled={busy}
onClick={() => {
// Deleting a category unfiles its questions; it never
// deletes them. Say so — the wording is the whole point
// of the prompt.
if (
window.confirm(
t(
"Delete this tag? The questions themselves stay in your bank.",
),
)
)
)
void run(() => onDelete(category.id));
}}
title={t("Delete")}
className="rounded-md p-1 text-[var(--muted-foreground)] transition-colors hover:bg-red-50 hover:text-red-500 disabled:opacity-40 dark:hover:bg-red-950/30"
>
<Trash2 size={13} />
</button>
void run(() => onDelete(category.id));
}}
aria-label={t("Delete")}
className="rounded-md p-1 text-[var(--muted-foreground)] transition-colors hover:bg-red-50 hover:text-red-500 disabled:opacity-40 dark:hover:bg-red-950/30"
>
<Trash2 size={13} />
</button>
</Tooltip>
</>
)}
</div>
@@ -161,6 +170,7 @@ export default function CategoryManager({
<button
type="button"
disabled={busy || !newName.trim()}
aria-label={t("Add tag")}
onClick={() =>
void run(() => onCreate(newName)).then((ok) => {
if (ok) setNewName("");
@@ -5,6 +5,7 @@ import { useTranslation } from "react-i18next";
import { Check, FolderPlus, Loader2, Plus } from "lucide-react";
import { notify } from "@/lib/notifications";
import type { NotebookCategory } from "@/lib/notebook-api";
import Tooltip from "@/shared/ui/Tooltip";
interface CategoryMenuProps {
categories: NotebookCategory[];
@@ -105,26 +106,29 @@ export default function CategoryMenu({
return (
<div ref={rootRef} className="relative">
<button
type="button"
disabled={disabled}
onClick={() => setOpen((v) => !v)}
title={t("Add tag")}
className={`inline-flex items-center gap-1.5 rounded-lg text-[11.5px] font-medium transition-colors disabled:opacity-40 ${
variant === "outlined" ? "border px-2 py-1.5" : "p-1.5"
} ${
open
? variant === "outlined"
? "border-[var(--primary)]/40 bg-[var(--primary)]/10 text-[var(--primary)]"
: "bg-[var(--muted)]/60 text-[var(--primary)]"
: variant === "outlined"
? "border-[var(--border)] text-[var(--muted-foreground)] hover:bg-[var(--muted)]/60 hover:text-[var(--foreground)]"
: "text-[var(--muted-foreground)] hover:bg-[var(--muted)]/60 hover:text-[var(--foreground)]"
}`}
>
<FolderPlus className="h-3.5 w-3.5" />
{label ? <span>{label}</span> : null}
</button>
<Tooltip label={t("Add tag")} suppressed={open}>
<button
type="button"
disabled={disabled}
onClick={() => setOpen((v) => !v)}
aria-label={label || t("Add tag")}
aria-expanded={open}
className={`inline-flex items-center gap-1.5 rounded-lg text-[11.5px] font-medium transition-colors disabled:opacity-40 ${
variant === "outlined" ? "border px-2 py-1.5" : "p-1.5"
} ${
open
? variant === "outlined"
? "border-[var(--primary)]/40 bg-[var(--primary)]/10 text-[var(--primary)]"
: "bg-[var(--muted)]/60 text-[var(--primary)]"
: variant === "outlined"
? "border-[var(--border)] text-[var(--muted-foreground)] hover:bg-[var(--muted)]/60 hover:text-[var(--foreground)]"
: "text-[var(--muted-foreground)] hover:bg-[var(--muted)]/60 hover:text-[var(--foreground)]"
}`}
>
<FolderPlus className="h-3.5 w-3.5" />
{label ? <span>{label}</span> : null}
</button>
</Tooltip>
{open && (
<div
@@ -184,19 +188,21 @@ export default function CategoryMenu({
placeholder={t("New tag…")}
className="min-w-0 flex-1 rounded-lg border border-[var(--border)] bg-[var(--background)] px-2.5 py-1.5 text-[12px] text-[var(--foreground)] outline-none transition-colors placeholder:text-[var(--muted-foreground)] focus:border-[var(--primary)]/50"
/>
<button
type="button"
disabled={busy || !name.trim()}
onClick={() => void handleCreate()}
title={t("Create and add")}
className="shrink-0 rounded-lg bg-[var(--primary)] p-1.5 text-white transition-opacity disabled:opacity-30"
>
{busy ? (
<Loader2 className="h-3.5 w-3.5 animate-spin" />
) : (
<Plus className="h-3.5 w-3.5" />
)}
</button>
<Tooltip label={t("Create and add")}>
<button
type="button"
disabled={busy || !name.trim()}
onClick={() => void handleCreate()}
aria-label={t("Create and add")}
className="shrink-0 rounded-lg bg-[var(--primary)] p-1.5 text-white transition-opacity disabled:opacity-30"
>
{busy ? (
<Loader2 className="h-3.5 w-3.5 animate-spin" />
) : (
<Plus className="h-3.5 w-3.5" />
)}
</button>
</Tooltip>
</div>
</div>
)}
@@ -18,6 +18,7 @@ import { optionIsAnswer } from "@/lib/question-bank-answers";
import { bookRoute, masterySessionRoute } from "@/lib/learning-routes";
import CategoryMenu from "./CategoryMenu";
import { practiceMarkdown } from "@/lib/practice-content";
import Tooltip from "@/shared/ui/Tooltip";
const SOURCE_LABELS: Record<NotebookEntry["source"], string> = {
deep_question: "Deep Question",
@@ -286,47 +287,53 @@ export default function QuestionCard({
onUnpick={onUnfile}
onCreate={onCreateAndFile}
/>
<button
type="button"
onClick={onToggleBookmark}
disabled={disabled}
title={entry.bookmarked ? t("Remove Bookmark") : t("Bookmark")}
className={`rounded-lg p-1.5 transition-colors disabled:opacity-40 ${
entry.bookmarked
? "text-[var(--primary)]"
: "text-[var(--muted-foreground)] hover:bg-[var(--muted)]/60 hover:text-[var(--foreground)]"
}`}
>
<Bookmark className="h-3.5 w-3.5" fill={entry.bookmarked ? "currentColor" : "none"} />
</button>
{showReviewState && (
<Tooltip label={entry.bookmarked ? t("Remove Bookmark") : t("Bookmark")}>
<button
type="button"
onClick={onToggleResolved}
onClick={onToggleBookmark}
disabled={disabled}
title={entry.resolved ? t("Reopen Review") : t("Mark Resolved")}
aria-label={entry.bookmarked ? t("Remove Bookmark") : t("Bookmark")}
className={`rounded-lg p-1.5 transition-colors disabled:opacity-40 ${
entry.resolved
? "text-green-600 dark:text-green-400"
entry.bookmarked
? "text-[var(--primary)]"
: "text-[var(--muted-foreground)] hover:bg-[var(--muted)]/60 hover:text-[var(--foreground)]"
}`}
>
{entry.resolved ? (
<RotateCcw className="h-3.5 w-3.5" />
) : (
<CheckCheck className="h-3.5 w-3.5" />
)}
<Bookmark className="h-3.5 w-3.5" fill={entry.bookmarked ? "currentColor" : "none"} />
</button>
</Tooltip>
{showReviewState && (
<Tooltip label={entry.resolved ? t("Reopen Review") : t("Mark Resolved")}>
<button
type="button"
onClick={onToggleResolved}
disabled={disabled}
aria-label={entry.resolved ? t("Reopen Review") : t("Mark Resolved")}
className={`rounded-lg p-1.5 transition-colors disabled:opacity-40 ${
entry.resolved
? "text-green-600 dark:text-green-400"
: "text-[var(--muted-foreground)] hover:bg-[var(--muted)]/60 hover:text-[var(--foreground)]"
}`}
>
{entry.resolved ? (
<RotateCcw className="h-3.5 w-3.5" />
) : (
<CheckCheck className="h-3.5 w-3.5" />
)}
</button>
</Tooltip>
)}
<button
type="button"
onClick={onDelete}
disabled={disabled}
title={t("Delete")}
className="rounded-lg p-1.5 text-[var(--muted-foreground)] transition-colors hover:bg-red-50 hover:text-red-500 disabled:opacity-40 dark:hover:bg-red-950/30"
>
<Trash2 className="h-3.5 w-3.5" />
</button>
<Tooltip label={t("Delete")}>
<button
type="button"
onClick={onDelete}
disabled={disabled}
aria-label={t("Delete")}
className="rounded-lg p-1.5 text-[var(--muted-foreground)] transition-colors hover:bg-red-50 hover:text-red-500 disabled:opacity-40 dark:hover:bg-red-950/30"
>
<Trash2 className="h-3.5 w-3.5" />
</button>
</Tooltip>
</div>
</div>
@@ -466,15 +473,17 @@ export default function QuestionCard({
className="inline-flex items-center gap-1 rounded-md border border-[var(--border)] bg-[var(--muted)]/40 py-0.5 pl-2 pr-1 text-[var(--muted-foreground)]"
>
{category.name}
<button
type="button"
onClick={() => void onUnfile(category.id)}
disabled={disabled}
title={t("Remove tag")}
className="rounded p-0.5 transition-colors hover:bg-[var(--muted)] hover:text-[var(--foreground)] disabled:opacity-40"
>
<X className="h-2.5 w-2.5" />
</button>
<Tooltip label={t("Remove tag")}>
<button
type="button"
onClick={() => void onUnfile(category.id)}
disabled={disabled}
aria-label={t("Remove tag")}
className="rounded p-0.5 transition-colors hover:bg-[var(--muted)] hover:text-[var(--foreground)] disabled:opacity-40"
>
<X className="h-2.5 w-2.5" />
</button>
</Tooltip>
</span>
))}
{hasConversationSession && entry.source !== "import" && (
@@ -0,0 +1,92 @@
{
"app/(admin)/admin/users/page.tsx": ["2062b4d5ddb4c30d","472e77d1046643e1","5db5f4b744aa129d"],
"app/(utility)/session-handoff/page.tsx": ["ea0758b3abef58d5"],
"app/(workspace)/co-writer/page.tsx": ["c4b460087174c7d1"],
"app/(workspace)/kanban/page.tsx": ["9fbc9c11a1180034","a7565e650e5aba54","aeccd7575e9820b7"],
"app/(workspace)/learning/books/components/BookChatPanel.tsx": ["4dd0ddd866978e50"],
"app/(workspace)/learning/books/components/BookCreator.tsx": ["4a81c6dfb255ee77"],
"app/(workspace)/learning/books/components/BookHealthBanner.tsx": ["39044f87184bce61","805a5d47c999eaea"],
"app/(workspace)/learning/books/components/BookLibrary.tsx": ["94d4fce96270ab32"],
"app/(workspace)/learning/books/components/BookSidebar.tsx": ["5cc9cef7cc744776","9726d994424b74b4","a0e52ce02849fb58","fa3b55fb791ae302"],
"app/(workspace)/learning/books/components/LearningCapturePanel.tsx": ["f263bc4350540dcf"],
"app/(workspace)/learning/books/components/PageOutlineNav.tsx": ["438c97f8d456752d","542eab7e9945df98"],
"app/(workspace)/learning/books/components/PageReader.tsx": ["451d97ffd70b2cce","53b7fc0beb53cf4d","9a0ebb5a90deee8e"],
"app/(workspace)/learning/books/components/blocks/BlockRenderer.tsx": ["104d0957f4b4f517","40a02aeb89b2f7ab","48d62d6823995f15","6a981344f3174a7c","76e9fa63f5b286ff","f2109d5b66da4b67"],
"app/(workspace)/learning/books/components/blocks/DeepDiveBlock.tsx": ["085a7b26057b8828"],
"app/(workspace)/learning/books/components/blocks/UserNoteBlock.tsx": ["94600886694d29f8"],
"app/(workspace)/partners/[partnerId]/page.tsx": ["087215314c6987da","504883adb4c02e80","550e828ba3bbf720","5cdc5fa3c2a39503","67d0cac91be25bd1","e6e304c6f49e7795"],
"app/(workspace)/partners/groups/[groupId]/page.tsx": ["aefb4192588e78e5"],
"components/agents/ConnectedAgents.tsx": ["8d1b1b9a9ab7f1d3"],
"components/auth/LogoutButton.tsx": ["fe803f9f9c035c7b"],
"components/chat/MyAgentsPicker.tsx": ["9de41a24dfd55c5a"],
"components/chat/home/ChatComposer.tsx": ["8a2e4aeb0d05841e","b9d19f8a62dbe1dc","c4cdd71599b0a6e5"],
"components/chat/home/ComposerRail.tsx": ["064d6f5464f66ecc"],
"components/chat/home/ModelSelector.tsx": ["3152db27d320353d","9cfe996e2a7ef139","da77f8a2bb413fd7"],
"components/chat/home/SelectedResources.tsx": ["104c56119ad6d653"],
"components/chat/home/SessionActivityPanel.tsx": ["c4e6fa254275dd34"],
"components/chat/home/SessionViewerPanel.tsx": ["3fbe3782aa64cd06","50553880b9e5710c","6df6a6968069c06d","7457e0cbd0b881b9"],
"components/chat/home/StarterSuggestions.tsx": ["31b4f8d5b0483a5e"],
"components/chat/preview/FilePreviewDrawer.tsx": ["4a8b532fc93d841e","801709683650aed7","a6508430d1c2c5b0"],
"components/chat/preview/previewers/XlsxPreview.tsx": ["644e66fec714a278"],
"components/cli-apps/CliAppsSection.tsx": ["4297890756842a8d"],
"components/common/GeogebraOpenCTA.tsx": ["c922f34a7cbab6fc"],
"components/knowledge/CreateKbModal.tsx": ["f0b47e25abfa183a"],
"components/knowledge/FileDropZone.tsx": ["b090b69445b9626c"],
"components/knowledge/KbDocumentList.tsx": ["0cb9a2f0be64dc21","22f74a32c8edf442","2d2d8d0a367709a3","9e8b922f0bd9649e","c70d02d3d88edea7","cf62e1c80305f6d2","d586e779faf3fe93","e1b1b9985a06297e","e9ab1ad073047aec","f493f2282f2d952c"],
"components/knowledge/KbFilePreview.tsx": ["3fcd4dcde9a8c49f","74872960f708a6a5","74872960f708a6a5","d899aee2a951ffda"],
"components/knowledge/KbGitHubSourcesSection.tsx": ["a45507814306d2b0"],
"components/knowledge/KbIndexVersionsSection.tsx": ["cca712cf150b8e34"],
"components/knowledge/KbLinkedFoldersSection.tsx": ["02bdc6724cac8ecb","0e03400573df5031","5a86fb5a135080df"],
"components/knowledge/KbUpdateHistory.tsx": ["16f6d96751e34943"],
"components/knowledge/KbWebSourcesSection.tsx": ["05e0e41adba1dff1","36c0e1d57f9215fe","5432c20c4bd61669"],
"components/knowledge/KnowledgeBaseDetail.tsx": ["3a15884928eef782"],
"components/learning/practice/PracticeInsights.tsx": ["3b4b2336e855eea4"],
"components/memory/MemoryRunPanel.tsx": ["060a159e01bddd43","4e6edc77c87d1d60","55172231371dae47","6af569ad63057100","c6f3fe36c916e65c","d99a915c7452ea52"],
"components/memory/MemorySection.tsx": ["607d03f9841c16ed","607d03f9841c16ed","8ef98453cb691350"],
"components/notebook/NotebookConsole.tsx": ["ce6e5b9219b029ca"],
"components/notebook/NotebookRecordRow.tsx": ["224834fc8c082451"],
"components/partners/AssetPicker.tsx": ["ce740dd43aa500fe"],
"components/partners/PartnerArchives.tsx": ["58540567c02eb130","73792ac6d7f0e598","857df68488445e96"],
"components/partners/PartnerChannels.tsx": ["4e6c301b7c8893de"],
"components/partners/PartnerComposer.tsx": ["4dd0ddd866978e50","89c6cfcb9ec5af55"],
"components/partners/SoulPicker.tsx": ["d89d6e61f57764c9"],
"components/partners/group/GroupComposer.tsx": ["ab299ea7f4504c51","b6d0dbdef35684e7"],
"components/partners/group/GroupSessionPicker.tsx": ["bb3aae75b685744f"],
"components/partners/group/PartnerSeat.tsx": ["04e2114ac19fdaf5","c5e52a4103c00279"],
"components/partners/schema-form.tsx": ["7cf112e40158bc18"],
"components/quiz/QuizConfigPanel.tsx": ["6cfc3e0690b46adb","f52fe91070af5cb1"],
"components/quiz/QuizViewer.tsx": ["10fe5ac34f0e5b5c","155eb455409f5fee","5914ded12426314c","68d30d274f1cfd3f","867faa22062895ed","f34db87829bd639a"],
"components/reading/AnnotationLayer.tsx": ["2ea1d9af29459edb"],
"components/reading/AnnotationList.tsx": ["9f2a45a2887e1a3f"],
"components/reading/ReaderDisplayControls.tsx": ["f7ceaa362f776884"],
"components/reading/ReaderPane.tsx": ["5287ce04aaaee4f8","f7ceaa362f776884"],
"components/reading/ReadingExtensionBar.tsx": ["090161977d5e7acf","b03082aae3a3777b"],
"components/reading/library/FolderDialog.tsx": ["289f0e3e0693cd09"],
"components/reading/library/ReadingFolder.tsx": ["314253c02a6ff29a","79a4406eb0165bf7"],
"components/reading/workspace/SourceNavigator.tsx": ["77d599c76a538534","942c1a2294e92e5a"],
"components/settings/CodeBuddyAuthCard.tsx": ["7471c9e2a8e28339"],
"components/settings/ModelsWorkspace.tsx": ["ce53e95e372ce024"],
"components/settings/ProvidersWorkspace.tsx": ["6a01d5cc51cde922"],
"components/settings/RegistryControls.tsx": ["d2e5a59d961d98ba"],
"components/settings/ServiceConfigEditor.tsx": ["8ae3f2f23cc44037"],
"components/settings/SettingsToolbar.tsx": ["66830400e0fd25e6"],
"components/space/ArchivedConversations.tsx": ["1e3aeb7319e5f65a","5f4cfea0cda04a3e"],
"components/space/MyAgentsSection.tsx": ["9d284f1f46bbdc41","df7468919c9a7ea8"],
"components/space/PersonasSection.tsx": ["1be81f8b4229bc9e","6746a68137fe2391","89ef0ac70d058a20"],
"components/space/SkillsSection.tsx": ["6581aa3354cc6d2d","6746a68137fe2391","789eee2908c10770","ad71bc1aca08d1a5","d1c86b5ddb329174"],
"components/space/learning/MasteryStudy.tsx": ["67d0cac91be25bd1"],
"components/space/learning/ModeSwitch.tsx": ["6c98276670c94312"],
"components/space/learning/PathTitle.tsx": ["142069af8906d16c","85b37242c76f46a3","ac6d10ef156c74dd"],
"components/space/learning/ReviewTrail.tsx": ["67432e520fac2bd8"],
"components/space/learning/StudyOutline.tsx": ["b61001c8756d0f9d","ea2c9a7f429a8944"],
"components/visualize/VisualizationViewer.tsx": ["b58434ec29492df8","be23e619c1d2e3e3","ed6a8d0dc50cedcc"],
"components/visualize/VisualizeConfigPanel.tsx": ["1927f8cc6fe4ecb1"],
"components/workspaces/WorkspaceChatGroups.tsx": ["c3c3c760376dc6d6"],
"components/workspaces/WorkspacePill.tsx": ["30841304e8b58ccc","53da125ababd5a38","c3990b73bc43d246"],
"features/chat/components/ChatWorkspace.tsx": ["01c3aa61603e3336"],
"features/co-writer/components/CoWriterWorkspace.tsx": ["0219f3bd0cfce757","369bed5cfffcda93","53f44662b8d95095","ab73950bcdb666a5","b34363d5acaef69f","c8340c792e0fc256","d4b48fe0bd46c01d","e66eeeac83db6144"],
"features/settings/components/UsageActivity.tsx": ["044bb0f681e7b117"],
"features/settings/sections/ArchivedChatsSettingsSection.tsx": ["3b6ca9ed135e8910"],
"features/settings/sections/ToolsSettingsSection.tsx": ["89d0d5d67ee69c8f"],
"features/settings/sections/WorkspaceSettingsSection.tsx": ["8ddce9eae1d2450c","be4c3b734823542f","e71d8dc6e998551d"]
}
+94
View File
@@ -0,0 +1,94 @@
import assert from "node:assert/strict";
import { createHash } from "node:crypto";
import { readFileSync, readdirSync } from "node:fs";
import path from "node:path";
import test from "node:test";
import ts from "typescript";
type TitleDebt = Record<string, string[]>;
const root = process.cwd();
// Existing native hints remain in this debt snapshot. Deleting one needs no
// fixture update; adding one fails even when another file was cleaned up.
const baseline: TitleDebt = JSON.parse(
readFileSync(path.join(root, "tests/native-button-title-baseline.json"), "utf8"),
);
function sourceFiles(directory: string): string[] {
return readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
const file = path.join(directory, entry.name);
if (entry.isDirectory()) return sourceFiles(file);
return entry.name.endsWith(".tsx") ? [file] : [];
});
}
function attribute(
node: ts.JsxOpeningElement | ts.JsxSelfClosingElement,
name: string,
): ts.JsxAttribute | undefined {
return node.attributes.properties.find(
(property): property is ts.JsxAttribute =>
ts.isJsxAttribute(property) && property.name.getText() === name,
);
}
function signature(
node: ts.JsxOpeningElement | ts.JsxSelfClosingElement,
source: ts.SourceFile,
): string {
// Ignore styling and line movement. The hint and action identify a legacy
// control; adding another control with the same pair still exceeds its
// allowed occurrence count.
const details = ["title", "onClick", "aria-label"]
.map((name) => attribute(node, name)?.initializer?.getText(source) ?? "")
.map((value) => value.replace(/\s+/g, " ").trim())
.join("|");
return createHash("sha256").update(details).digest("hex").slice(0, 16);
}
test("new native button titles must use the shared Tooltip", () => {
const violations: string[] = [];
for (const sourceRoot of [
"app",
"components",
"context",
"features",
"hooks",
"lib",
"shared",
]) {
for (const file of sourceFiles(path.join(root, sourceRoot))) {
const relative = path.relative(root, file).split(path.sep).join("/");
const source = ts.createSourceFile(
file,
readFileSync(file, "utf8"),
ts.ScriptTarget.Latest,
true,
ts.ScriptKind.TSX,
);
const allowed = [...(baseline[relative] ?? [])];
const visit = (node: ts.Node) => {
if (
(ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) &&
node.tagName.getText(source) === "button" &&
attribute(node, "title")
) {
const hash = signature(node, source);
const index = allowed.indexOf(hash);
if (index >= 0) allowed.splice(index, 1);
else {
const line = source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1;
violations.push(`${relative}:${line}`);
}
}
ts.forEachChild(node, visit);
};
visit(source);
}
}
assert.deepEqual(
violations,
[],
"Replace new <button title> hints with @/shared/ui/Tooltip and an accessible button name",
);
});
+33
View File
@@ -0,0 +1,33 @@
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { expect, it, vi } from "vitest";
import CategoryManager from "@/components/space/question-bank/CategoryManager";
vi.mock("react-i18next", () => ({
useTranslation: () => ({ t: (value: string) => value }),
}));
it("names tag actions and exposes their hints without native titles", async () => {
render(
<CategoryManager
categories={[{ id: 1, name: "Algebra", created_at: 1, entry_count: 2 }]}
onCreate={vi.fn(async () => true)}
onRename={vi.fn(async () => true)}
onDelete={vi.fn(async () => true)}
/>,
);
const rename = screen.getByRole("button", { name: "Rename" });
expect(rename).not.toHaveAttribute("title");
expect(document.getElementById(rename.getAttribute("aria-describedby")!)).toHaveTextContent(
"Rename",
);
fireEvent.focus(rename);
await waitFor(() =>
expect(document.body.querySelector('[role="tooltip"].fixed')).toHaveTextContent("Rename"),
);
fireEvent.click(rename);
expect(screen.getByRole("button", { name: "Save" })).not.toHaveAttribute("title");
expect(screen.getByRole("button", { name: "Cancel" })).not.toHaveAttribute("title");
});