diff --git a/docs/superpowers/plans/2026-09-18-ui-ux-overhaul.md b/docs/superpowers/plans/2026-09-18-ui-ux-overhaul.md new file mode 100644 index 0000000..38c0bdc --- /dev/null +++ b/docs/superpowers/plans/2026-09-18-ui-ux-overhaul.md @@ -0,0 +1,153 @@ +# UI/UX Overhaul — Implementation Plan + +Spec: `docs/superpowers/specs/2026-09-18-ui-ux-overhaul-design.md` +Order: Layer A task by task, one commit each; Layer B and C are outlined and +get their own detailed plan when A lands. + +Every task: load `solidjs-pitfalls` + `ui-conventions` first; `bun run build` +(= `tsc --noEmit && vite build`) and `bun run test` must pass before commit +(`commit-workflow`). + +## Layer A + +### 1. Stop silent list truncation (events, exams, admin users) +- **Files:** `src/pages/events-page.tsx`, `src/pages/exams-page.tsx`, + `src/pages/admin-users-page.tsx`, their tests if present +- **Do:** + 1. Run `check-api-contract` for `GET /events`, `/exams`, `/users`: confirm + `limit`/`offset` + `total` (and which filters are server-side). + 2. Replace `getX({ limit: N })` with `loadListPage` (`src/lib/list-page.ts`): + server mode when no client-only filter is active, client mode otherwise. + 3. Where client mode still fetches everything, fetch without `limit` (full + `items`) instead of a cap. + 4. Grep the remaining `limit: 100|200` caps and list them in the commit body + as follow-ups; do not fix them all in this task. +- **Verify:** unit test for each page's resource with a mocked `total` > page + size shows pagination reaching the last page; `bun run build`. +- **Done when:** no list on these three pages can hide rows beyond a cap. + +### 2. Confirm before emptying trash +- **Files:** `src/pages/messages-page.tsx`, `src/i18n/messages.ts` +- **Do:** wrap `handleEmptyTrash` behind `ConfirmDialog` showing the item + count; destructive variant. +- **Verify:** test — clicking "empty trash" opens the dialog and no + `deleteMessageById` call happens until confirm. +- **Done when:** permanent deletion always needs a second click. + +### 3. In-app back navigation +- **Files:** `src/components/layout/app-shell.tsx`, new + `src/lib/back-target.ts` (+ test) +- **Do:** + 1. Track whether the session has an in-app history entry (router history + length / a flag set on first client navigation). + 2. If yes → `history.back()`; if no → navigate to the route's parent + (derived from pathname segments, falling back to `/`). +- **Verify:** unit test for the parent derivation (`/exams/42` → `/exams`, + `/instances/7` → its hub); manual: open a detail URL in a fresh tab, press + back, stay in the app. +- **Done when:** the back button never leaves the app. + +### 4. Shared breadcrumbs on every detail page +- **Files:** new `src/components/layout/breadcrumbs.tsx` (+ test); the detail + pages: event, homework, meal, class, question, whiteboard, admin-user + (course, exam, instance: migrate their inline crumbs to the component) +- **Do:** component takes `{ label, to? }[]`; hub labels come from + `nav-items.ts`; render in `PageHeader` slot; last crumb is `aria-current="page"`. +- **Verify:** component test (links, aria-current); `rg -l Breadcrumbs src/pages` + lists all 10 detail pages. +- **Done when:** every durable detail page shows hub → resource. + +### 5. Reproduce and contain page-level errors (spec A6) +- **Files:** `src/app.tsx` or the shell route, possibly the + `createResource` keep-latest wrapper +- **Do:** + 1. Reproduce: mock a failing list on `classes-page` in a test and check + whether the root `RootErrorFallback` renders. + 2. If confirmed, add an `ErrorBoundary` inside the shell around the route + outlet (keeps nav), with retry = `reset()`. + 3. If not confirmed, record that in the spec and drop the task. +- **Verify:** the reproduction test now renders the shell + inline error. +- **Done when:** one page's failure no longer blanks the whole app. + +### 6. One data-state contract +- **Files:** new `src/components/ui/data-state.tsx` (+ test), + `src/components/ui/data-table.tsx`, `src/pages/dashboard-page.tsx`, + `src/pages/calendar-page.tsx`, `src/i18n/messages.ts` +- **Do:** + 1. `DataState` renders loading (skeleton) / empty / no-results (with + "clear filters" callback) / error (`ErrorAlert` + retry). + 2. `DataTable`: distinct no-results copy + clear-filters action. + 3. Dashboard: replace `quiet()` swallowing with a per-panel inline error. + 4. Calendar: show loading until sources resolve; show which feed failed. +- **Verify:** tests for each state; dashboard test with one failing source + shows that panel's error and the rest of the board. +- **Done when:** failure never reads as "no data". + +### 7. SidePanel dirty guard + save toast +- **Files:** `src/components/ui/side-panel.tsx` (+ test), `src/i18n/messages.ts`, + then 3 pilot forms (class create, meal create, exam create) +- **Do:** + 1. Add optional `dirty` accessor; on Esc/outside click/close while dirty, + show a discard confirm. + 2. Pilot forms pass `dirty` and call `showToast` on success. + 3. List the remaining ~47 panels as follow-up; migrate in batches later. +- **Verify:** SidePanel test — dirty + Esc keeps panel open and shows confirm. +- **Done when:** pilot forms cannot lose input by accident. + +### 8. Field-level errors (pilot) +- **Files:** `src/components/ui/input.tsx`, `textarea.tsx`, `select.tsx`, + `label.tsx`, same 3 pilot forms +- **Do:** `error` prop → `aria-invalid` + `aria-describedby` + message under + the field; map server validation errors to fields where the API returns a + field name (confirm response shape with `check-api-contract`). +- **Verify:** component test for aria wiring. +- **Done when:** pilot forms show errors next to the field. + +### 9. Accessibility pass +- **Files:** `src/components/layout/command-palette.tsx`, + `src/components/ui/toast.tsx`, `side-panel.tsx`, `dialog.tsx`, + `date-picker.tsx`, the 12 unlabeled icon buttons from the audit, + `app-shell.tsx` (skip link), `src/i18n/messages.ts` +- **Do:** combobox/listbox/option roles + `aria-activedescendant` in the + palette; toast region `role="status" aria-live="polite"`; i18n + "Close"/"Dismiss"; labels on icon buttons; skip-to-content link; + `scroll-padding-top` for the 45px sticky header. +- **Verify:** `rg -n '` 37), one `StatCard` + (`profile-page.tsx:249` vs `dashboard/stat-tile.tsx`). +- Replace 241 raw Tailwind palette classes (calendar 84, role-badge 25). +- Minimum text size 12px; retire `text-[8-10px]` (74 uses). +- Resolve the radius contradiction in docs (`rounded-md` vs `rounded-lg` vs + `rounded-2xl`) and the action-column width (110px vs `w-28`). +- Raw `` in `karne-view.tsx:63`, `marks-report-view.tsx:115` → `DataTable`. +- Mobile: `DataTable` card mode under `sm` with per-column priority; show + horizontal-scroll affordance (scrollbars are hidden globally, `index.css:531`). +- Dashboard: per-section `Suspense` + skeletons instead of one page spinner. +- Unique nav icons (`IconClock` used for 6 items). +- Refresh `docs/ui/navigation-patterns.md` (describes a `/school` hub and + groups that no longer exist). +- A lint/review check for the rules above. + +## Layer C — Professional product experience + +Each item needs a backend contract check (`check-api-contract`) before design +is final; items without an endpoint are out of scope, not faked +(see "never fabricate data"). + +1. **Role "Today" home.** Teacher: today's lessons, roll calls not yet taken, + grading queue. Student: due soon. Admin: school KPIs. Precedent: Google + Classroom's role-tailored homepage, rolled out 2026-07-27 — + https://workspaceupdates.googleblog.com/2026/07/redesigned-google-classroom-homepage-with-tailored-views-based-on-users-role.html + Tension: the dashboard is observation-only today; "Today" links to actions + but does not perform them — stays within the rule. +2. **Exception-based roll call.** Everyone starts Present, the teacher changes + exceptions, then "Complete"; an untaken roll call gets a red badge on its + lesson. Precedent: Veracross — + https://www.iorad.com/player/2241624/Veracross-Portals--How-to-take-attendance +3. **Sentence insights with an action** ("3 students have not submitted + homework → open homework"). Precedent: + https://workspaceupdates.googleblog.com/2025/06/new-class-analytics-and-insights-in-google-classroom.html +4. **Parent feed** per child with type/date filters. Precedents: Brightwheel + http://help.mybrightwheel.com/en/articles/942392-student-activity-feed, + Schoology https://langleyhs.fcps.edu/sites/default/files/media/inline-files/Parent_Communication.pdf +5. **Notification hygiene:** quiet hours for staff, optional digest for + parents. Precedent: ClassDojo + https://help.classdojo.com/hc/en-us/articles/207359446-How-to-Set-or-Edit-Quiet-Hours +6. **Per-role onboarding checklist**, 3–5 items ticked by real events. Source: + https://docs.appcues.com/best-practices/checklist-best-practices + +Why it matters: in TALIS 2024, 48% of teachers in Türkiye name administrative +work as a source of stress — +https://www.oecd.org/content/dam/oecd/en/publications/reports/2025/10/results-from-talis-2024-country-notes_eafd703e/turkiye_f16e16f9/754c2c1a-en.pdf + +## Standards referenced + +- WCAG 2.2 AA additions: 2.4.11 Focus Not Obscured, 2.5.7 Dragging Movements + (whiteboard needs a non-drag path), 2.5.8 Target Size ≥ 24px — + https://www.audioeye.com/post/wcag-22/, + https://w3c.github.io/wcag/understanding/focus-not-obscured-minimum +- Skeleton for page loads, spinner for single elements — + https://www.nngroup.com/articles/skeleton-screens/ +- Empty states teach and offer a path — + https://www.nngroup.com/articles/empty-state-interface-design/ +- Loading buttons keep their label; 16px mobile inputs; focus not hidden under + sticky bars — https://vercel.com/design/guidelines + +## Open questions + +- A1: which list endpoints accept server-side filters/sort today? (check-api-contract) +- A6: reproduce the root-boundary failure before building the fix. +- C1–C5: which endpoints exist for untaken roll calls, grading queue, parent + activity, reminders, notification preferences? +- B: which token vocabulary wins (`shadcn` names or `surface-*`)? + +## Verification + +Per layer: `bun run build`, vitest (dom project) for touched components, +Playwright `e2e/auth-shell.spec.ts`; a live visual pass with `agent-browser` +once E2E credentials are available. diff --git a/src/api/__tests__/insights/insights.test.ts b/src/api/__tests__/insights/insights.test.ts index 2c2f490..a190286 100644 --- a/src/api/__tests__/insights/insights.test.ts +++ b/src/api/__tests__/insights/insights.test.ts @@ -2,6 +2,7 @@ import { afterEach, describe, expect, it, vi } from "vitest"; import { getInsightByUserId, getInsightRuns, + getInsightsPending, getMyInsight, postInsightComputeByUserId, postInsightsRefresh, @@ -84,6 +85,17 @@ describe("insights API", () => { expect(url).toBe("/api/insights/runs"); }); + it("getInsightsPending GETs /insights/pending", async () => { + mockFetchSuccess({ students: ["u1", "u2"] }); + + const result = await getInsightsPending(); + expect(result.students).toEqual(["u1", "u2"]); + + const [url, init] = lastFetchCall(); + expect(url).toBe("/api/insights/pending"); + expect(init?.method).toBe("GET"); + }); + it("postInsightsRefresh POSTs /insights/refresh with the named students", async () => { mockFetchSuccess({ message_id: "m1", status: "pending" }, 202); diff --git a/src/api/__tests__/podcast/podcast.test.ts b/src/api/__tests__/podcast/podcast.test.ts index 59451ca..286cd49 100644 --- a/src/api/__tests__/podcast/podcast.test.ts +++ b/src/api/__tests__/podcast/podcast.test.ts @@ -50,10 +50,7 @@ describe("podcast API", () => { mockFetchSuccess({ job_id: "j1", audio_id: "ses/duz_okuma/j1/episode.mp3", - audio_ids: ["ses/duz_okuma/j1/episode.mp3"], duration_secs: 312.5, - script_id: "s1", - script_ids: ["s1"], format: "duz_okuma", }); diff --git a/src/api/client/types.ts b/src/api/client/types.ts index 46e8f18..b504579 100644 --- a/src/api/client/types.ts +++ b/src/api/client/types.ts @@ -1338,6 +1338,9 @@ export type InsightRun = { failed_modules: string[]; }; +/** The freshest run's pending students, in the service's order. */ +export type InsightPendingList = { students: string[] }; + // --------------------------------------------------------------------------- // podcast — narrating a course note // --------------------------------------------------------------------------- @@ -1370,20 +1373,16 @@ export type PodcastJobStatus = { error_code?: string | null; }; -/** A finished job's artifacts, passed through verbatim. */ +/** A finished job's artifacts. */ export type PodcastJobArtifacts = { job_id: string; /** The produced audio's path inside the school's output root. Display-only: * the stream is addressed by `job_id` (see `podcastAudioUrl`), never by this * path, so a caller cannot name a file outside its own school. */ audio_id: string; - /** One entry per produced chapter; usually `[audio_id]`. */ - audio_ids: string[]; - duration_secs: number; - script_id: string; - /** One entry per script the audio was aligned to. */ - script_ids: string[]; - format: PodcastFormat; + duration_secs?: number | null; + /** The resolved narration format. */ + format?: PodcastFormat | null; }; /** The verdict on a cancel. `false` is not an error — see `postPodcastJobCancel`. */ diff --git a/src/api/insights/getInsightsPending.ts b/src/api/insights/getInsightsPending.ts new file mode 100644 index 0000000..46640c8 --- /dev/null +++ b/src/api/insights/getInsightsPending.ts @@ -0,0 +1,11 @@ +import { client } from "../client"; +import type { InsightPendingList } from "../client"; + +/** + * The students the freshest compute run left pending — where the next run + * starts. Manager+ only, like `getInsightRuns`; answered whole or refused + * with 413, never clipped. + */ +export function getInsightsPending(signal?: AbortSignal): Promise { + return client("/insights/pending", { signal }); +} diff --git a/src/api/insights/index.ts b/src/api/insights/index.ts index fb56464..8110faf 100644 --- a/src/api/insights/index.ts +++ b/src/api/insights/index.ts @@ -3,3 +3,4 @@ export * from "./getInsightByUserId"; export * from "./postInsightComputeByUserId"; export * from "./getInsightRuns"; export * from "./postInsightsRefresh"; +export * from "./getInsightsPending"; diff --git a/src/components/notes/podcast-panel.test.tsx b/src/components/notes/podcast-panel.test.tsx index e2f58d7..cf191da 100644 --- a/src/components/notes/podcast-panel.test.tsx +++ b/src/components/notes/podcast-panel.test.tsx @@ -61,10 +61,7 @@ describe("PodcastPanel", () => { podcastApi.getPodcastJobResultById.mockResolvedValue({ job_id: "pj1", audio_id: "ses/duz_okuma/pj1/episode.mp3", - audio_ids: ["ses/duz_okuma/pj1/episode.mp3"], duration_secs: 42, - script_id: "s1", - script_ids: ["s1"], format: "duz_okuma", }); @@ -87,10 +84,7 @@ describe("PodcastPanel", () => { podcastApi.getPodcastJobResultById.mockResolvedValue({ job_id: "pj1", audio_id: "ses/duz_okuma/pj1/episode.mp3", - audio_ids: ["ses/duz_okuma/pj1/episode.mp3"], duration_secs: 42, - script_id: "s1", - script_ids: ["s1"], format: "duz_okuma", });