forge
Explore
Log in

Don't you dare go Hollow

πŸ”Œ close the last gaps against the live API contract

Browse files at this commit

e6e9aade97e56e97bb806524f70c50025ed5d37fBurak BoduroğluParent: 042f95b
  • fix
    • πŸ”Œ close the last gaps against the live API contract
Show full message
fix: πŸ”Œ close the last gaps against the live API contract
- PodcastJobArtifacts matches the live JobArtifacts: drop audio_ids,
  script_id and script_ids, and duration_secs and format are nullable
- add getInsightsPending (GET /insights/pending), with a test
docs/superpowers/plans/2026-09-18-ui-ux-overhaul.mdadded+153 -0
@@ -0,0 +1,153 @@
1+# UI/UX Overhaul β€” Implementation Plan
2+
3+Spec: `docs/superpowers/specs/2026-09-18-ui-ux-overhaul-design.md`
4+Order: Layer A task by task, one commit each; Layer B and C are outlined and
5+get their own detailed plan when A lands.
6+
7+Every task: load `solidjs-pitfalls` + `ui-conventions` first; `bun run build`
8+(= `tsc --noEmit && vite build`) and `bun run test` must pass before commit
9+(`commit-workflow`).
10+
11+## Layer A
12+
13+### 1. Stop silent list truncation (events, exams, admin users)
14+- **Files:** `src/pages/events-page.tsx`, `src/pages/exams-page.tsx`,
15+ `src/pages/admin-users-page.tsx`, their tests if present
16+- **Do:**
17+ 1. Run `check-api-contract` for `GET /events`, `/exams`, `/users`: confirm
18+ `limit`/`offset` + `total` (and which filters are server-side).
19+ 2. Replace `getX({ limit: N })` with `loadListPage` (`src/lib/list-page.ts`):
20+ server mode when no client-only filter is active, client mode otherwise.
21+ 3. Where client mode still fetches everything, fetch without `limit` (full
22+ `items`) instead of a cap.
23+ 4. Grep the remaining `limit: 100|200` caps and list them in the commit body
24+ as follow-ups; do not fix them all in this task.
25+- **Verify:** unit test for each page's resource with a mocked `total` > page
26+ size shows pagination reaching the last page; `bun run build`.
27+- **Done when:** no list on these three pages can hide rows beyond a cap.
28+
29+### 2. Confirm before emptying trash
30+- **Files:** `src/pages/messages-page.tsx`, `src/i18n/messages.ts`
31+- **Do:** wrap `handleEmptyTrash` behind `ConfirmDialog` showing the item
32+ count; destructive variant.
33+- **Verify:** test β€” clicking "empty trash" opens the dialog and no
34+ `deleteMessageById` call happens until confirm.
35+- **Done when:** permanent deletion always needs a second click.
36+
37+### 3. In-app back navigation
38+- **Files:** `src/components/layout/app-shell.tsx`, new
39+ `src/lib/back-target.ts` (+ test)
40+- **Do:**
41+ 1. Track whether the session has an in-app history entry (router history
42+ length / a flag set on first client navigation).
43+ 2. If yes β†’ `history.back()`; if no β†’ navigate to the route's parent
44+ (derived from pathname segments, falling back to `/`).
45+- **Verify:** unit test for the parent derivation (`/exams/42` β†’ `/exams`,
46+ `/instances/7` β†’ its hub); manual: open a detail URL in a fresh tab, press
47+ back, stay in the app.
48+- **Done when:** the back button never leaves the app.
49+
50+### 4. Shared breadcrumbs on every detail page
51+- **Files:** new `src/components/layout/breadcrumbs.tsx` (+ test); the detail
52+ pages: event, homework, meal, class, question, whiteboard, admin-user
53+ (course, exam, instance: migrate their inline crumbs to the component)
54+- **Do:** component takes `{ label, to? }[]`; hub labels come from
55+ `nav-items.ts`; render in `PageHeader` slot; last crumb is `aria-current="page"`.
56+- **Verify:** component test (links, aria-current); `rg -l Breadcrumbs src/pages`
57+ lists all 10 detail pages.
58+- **Done when:** every durable detail page shows hub β†’ resource.
59+
60+### 5. Reproduce and contain page-level errors (spec A6)
61+- **Files:** `src/app.tsx` or the shell route, possibly the
62+ `createResource` keep-latest wrapper
63+- **Do:**
64+ 1. Reproduce: mock a failing list on `classes-page` in a test and check
65+ whether the root `RootErrorFallback` renders.
66+ 2. If confirmed, add an `ErrorBoundary` inside the shell around the route
67+ outlet (keeps nav), with retry = `reset()`.
68+ 3. If not confirmed, record that in the spec and drop the task.
69+- **Verify:** the reproduction test now renders the shell + inline error.
70+- **Done when:** one page's failure no longer blanks the whole app.
71+
72+### 6. One data-state contract
73+- **Files:** new `src/components/ui/data-state.tsx` (+ test),
74+ `src/components/ui/data-table.tsx`, `src/pages/dashboard-page.tsx`,
75+ `src/pages/calendar-page.tsx`, `src/i18n/messages.ts`
76+- **Do:**
77+ 1. `DataState` renders loading (skeleton) / empty / no-results (with
78+ "clear filters" callback) / error (`ErrorAlert` + retry).
79+ 2. `DataTable`: distinct no-results copy + clear-filters action.
80+ 3. Dashboard: replace `quiet()` swallowing with a per-panel inline error.
81+ 4. Calendar: show loading until sources resolve; show which feed failed.
82+- **Verify:** tests for each state; dashboard test with one failing source
83+ shows that panel's error and the rest of the board.
84+- **Done when:** failure never reads as "no data".
85+
86+### 7. SidePanel dirty guard + save toast
87+- **Files:** `src/components/ui/side-panel.tsx` (+ test), `src/i18n/messages.ts`,
88+ then 3 pilot forms (class create, meal create, exam create)
89+- **Do:**
90+ 1. Add optional `dirty` accessor; on Esc/outside click/close while dirty,
91+ show a discard confirm.
92+ 2. Pilot forms pass `dirty` and call `showToast` on success.
93+ 3. List the remaining ~47 panels as follow-up; migrate in batches later.
94+- **Verify:** SidePanel test β€” dirty + Esc keeps panel open and shows confirm.
95+- **Done when:** pilot forms cannot lose input by accident.
96+
97+### 8. Field-level errors (pilot)
98+- **Files:** `src/components/ui/input.tsx`, `textarea.tsx`, `select.tsx`,
99+ `label.tsx`, same 3 pilot forms
100+- **Do:** `error` prop β†’ `aria-invalid` + `aria-describedby` + message under
101+ the field; map server validation errors to fields where the API returns a
102+ field name (confirm response shape with `check-api-contract`).
103+- **Verify:** component test for aria wiring.
104+- **Done when:** pilot forms show errors next to the field.
105+
106+### 9. Accessibility pass
107+- **Files:** `src/components/layout/command-palette.tsx`,
108+ `src/components/ui/toast.tsx`, `side-panel.tsx`, `dialog.tsx`,
109+ `date-picker.tsx`, the 12 unlabeled icon buttons from the audit,
110+ `app-shell.tsx` (skip link), `src/i18n/messages.ts`
111+- **Do:** combobox/listbox/option roles + `aria-activedescendant` in the
112+ palette; toast region `role="status" aria-live="polite"`; i18n
113+ "Close"/"Dismiss"; labels on icon buttons; skip-to-content link;
114+ `scroll-padding-top` for the 45px sticky header.
115+- **Verify:** `rg -n '<button' src | ...` spot-check; tests assert roles;
116+ keyboard-only walkthrough of palette.
117+- **Done when:** audit items A8 are closed.
118+
119+### 10. Contrast-safe text colors
120+- **Files:** `src/index.css`, then usages of `text-primary`/`text-warning`/
121+ `text-success` on light surfaces
122+- **Do:** add `--primary-text`-style darker tokens that reach 4.5:1 on
123+ `--background` in both themes; switch text usages (fills stay).
124+- **Verify:** compute contrast for each token pair (small script or
125+ documented values in `docs/ui/ui-redesign-tokens.md`).
126+- **Done when:** body-size colored text is β‰₯ 4.5:1.
127+
128+### 11. Sorting on server-paged tables
129+- **Files:** `src/components/ui/data-table.tsx`, `payments-page.tsx`,
130+ `question-bank-page.tsx`
131+- **Do:** `DataTable` gets `manualSorting` + `onSortChange`; if the backend
132+ supports sort params (check contract) wire them, otherwise disable sort on
133+ those two tables.
134+- **Verify:** DataTable test β€” manual mode does not reorder rows locally.
135+- **Done when:** no table claims a sort it cannot perform.
136+
137+## Layer B β€” outline (detailed plan after A)
138+Token vocabulary decision + codemod Β· `Card`/error/StatCard consolidation Β·
139+raw palette classes β†’ tokens Β· 12px minimum text Β· radius/action-column doc
140+fix Β· karne/marks tables β†’ `DataTable` Β· DataTable mobile card mode + scroll
141+affordance Β· dashboard per-section Suspense Β· unique nav icons Β·
142+`navigation-patterns.md` refresh Β· lint check.
143+
144+## Layer C β€” outline (contract check first)
145+Run `check-api-contract` for each item; then a separate brainstorm/spec per
146+feature: role "Today" home β†’ exception-based roll call β†’ sentence insights β†’
147+parent feed β†’ notification hygiene β†’ onboarding checklist.
148+
149+## Out of scope
150+- Backend changes (backend repo is read/run only).
151+- Any number or field no endpoint provides (never fabricate).
152+- Migrating all 50 SidePanel forms in Layer A (pilot only).
153+- Visual redesign / new brand palette.
docs/superpowers/specs/2026-09-18-ui-ux-overhaul-design.mdadded+108 -0
@@ -0,0 +1,108 @@
1+# UI/UX Overhaul β€” Design
2+
3+Date: 2026-09-18 Β· Status: approved direction (A β†’ B β†’ C), plan pending
4+
5+## Goal
6+
7+Make Hezarfen feel like a professional product: nothing silently wrong, one way
8+to do each thing, and a home screen that tells each role what to do today.
9+
10+Inputs: a static code audit (subagent), an independent Codex (`gpt-5.6-luna`)
11+audit, and web research. Counts below come from grep over `src/` excluding
12+tests, on 2026-09-18 at commit `896684b`.
13+
14+## Layer A β€” Trust and foundations (do first)
15+
16+Fixes where the UI is wrong, loses data, or hides failure.
17+
18+| # | Problem | Evidence | Fix |
19+|---|---|---|---|
20+| A1 | Lists silently truncated by hard caps with client paging | `events-page.tsx:67` (`limit: 100`), `exams-page.tsx:137` (100), `admin-users-page.tsx:41` (200); ~50 such caps overall | Use `loadListPage` server paging where no client-only filter is active; where a cap stays, show "showing N of total" |
21+| A2 | "Empty trash" deletes without confirmation | `messages-page.tsx:152` | `ConfirmDialog` with count |
22+| A3 | Back button leaves the app on deep links | `app-shell.tsx:133` `window.history.back()` | Navigate to route parent when history has no in-app entry |
23+| A4 | Breadcrumbs only on course, exam and instance details | audit | Breadcrumbs on every durable detail page (event, homework, meal, class, question, whiteboard, admin user) derived from `nav-items.ts` labels |
24+| A5 | Data states inconsistent; dashboard `quiet()` shows failure as "no data"; calendar empty arrays read as "no events" | `dashboard-page.tsx:717`, `calendar-page.tsx:152` | One `DataState` contract: loading / empty / no-results (with "clear filters") / error (with retry) / partial |
25+| A6 | Some list errors may escape to the root `ErrorBoundary` (`app.tsx:61`) and replace the shell with a 500 | audit, **unverified** β€” reproduce first | Route-level error boundary inside the shell |
26+| A7 | 50 `SidePanel` forms: no dirty guard, no field errors (`aria-invalid` used once), mostly silent success (7 toasts) | audit | `SidePanel` dirty guard on Esc/outside click; field-level errors wired with `aria-invalid`/`aria-describedby`; success toast on save |
27+| A8 | A11y gaps: command palette has no ARIA roles; toasts not live regions; 12 unlabeled icon buttons (incl. `date-picker.tsx:149,153`); English "Close"/"Dismiss" labels | audit | combobox/listbox roles, `role="status"` toasts, i18n labels, skip link |
28+| A9 | Contrast: `text-primary` (#00ADD8 on white β‰ˆ 2.6:1) used 104Γ—; warning β‰ˆ 2.1:1 | audit | Darker text variants of brand/semantic colors for text; fills keep current colors |
29+| A10 | Server-paged tables sort only the current page | `payments-page.tsx:637`, `question-bank-page.tsx:250` | Server sort or disable sort on those columns |
30+
31+## Layer B β€” Design-system tightening
32+
33+- One token vocabulary: pick `text-muted-foreground`/`border-border`/`bg-card`
34+ or the `surface-*` set, codemod the other (528/175, 354/104, 89/84 uses).
35+- Consolidate: `Card` (0 uses vs 64 hand-built), one error presentation
36+ (`ErrorAlert` 41 / raw destructive `Alert` 88 / `<p>` 37), one `StatCard`
37+ (`profile-page.tsx:249` vs `dashboard/stat-tile.tsx`).
38+- Replace 241 raw Tailwind palette classes (calendar 84, role-badge 25).
39+- Minimum text size 12px; retire `text-[8-10px]` (74 uses).
40+- Resolve the radius contradiction in docs (`rounded-md` vs `rounded-lg` vs
41+ `rounded-2xl`) and the action-column width (110px vs `w-28`).
42+- Raw `<table>` in `karne-view.tsx:63`, `marks-report-view.tsx:115` β†’ `DataTable`.
43+- Mobile: `DataTable` card mode under `sm` with per-column priority; show
44+ horizontal-scroll affordance (scrollbars are hidden globally, `index.css:531`).
45+- Dashboard: per-section `Suspense` + skeletons instead of one page spinner.
46+- Unique nav icons (`IconClock` used for 6 items).
47+- Refresh `docs/ui/navigation-patterns.md` (describes a `/school` hub and
48+ groups that no longer exist).
49+- A lint/review check for the rules above.
50+
51+## Layer C β€” Professional product experience
52+
53+Each item needs a backend contract check (`check-api-contract`) before design
54+is final; items without an endpoint are out of scope, not faked
55+(see "never fabricate data").
56+
57+1. **Role "Today" home.** Teacher: today's lessons, roll calls not yet taken,
58+ grading queue. Student: due soon. Admin: school KPIs. Precedent: Google
59+ Classroom's role-tailored homepage, rolled out 2026-07-27 β€”
60+ https://workspaceupdates.googleblog.com/2026/07/redesigned-google-classroom-homepage-with-tailored-views-based-on-users-role.html
61+ Tension: the dashboard is observation-only today; "Today" links to actions
62+ but does not perform them β€” stays within the rule.
63+2. **Exception-based roll call.** Everyone starts Present, the teacher changes
64+ exceptions, then "Complete"; an untaken roll call gets a red badge on its
65+ lesson. Precedent: Veracross β€”
66+ https://www.iorad.com/player/2241624/Veracross-Portals--How-to-take-attendance
67+3. **Sentence insights with an action** ("3 students have not submitted
68+ homework β†’ open homework"). Precedent:
69+ https://workspaceupdates.googleblog.com/2025/06/new-class-analytics-and-insights-in-google-classroom.html
70+4. **Parent feed** per child with type/date filters. Precedents: Brightwheel
71+ http://help.mybrightwheel.com/en/articles/942392-student-activity-feed,
72+ Schoology https://langleyhs.fcps.edu/sites/default/files/media/inline-files/Parent_Communication.pdf
73+5. **Notification hygiene:** quiet hours for staff, optional digest for
74+ parents. Precedent: ClassDojo
75+ https://help.classdojo.com/hc/en-us/articles/207359446-How-to-Set-or-Edit-Quiet-Hours
76+6. **Per-role onboarding checklist**, 3–5 items ticked by real events. Source:
77+ https://docs.appcues.com/best-practices/checklist-best-practices
78+
79+Why it matters: in TALIS 2024, 48% of teachers in TΓΌrkiye name administrative
80+work as a source of stress β€”
81+https://www.oecd.org/content/dam/oecd/en/publications/reports/2025/10/results-from-talis-2024-country-notes_eafd703e/turkiye_f16e16f9/754c2c1a-en.pdf
82+
83+## Standards referenced
84+
85+- WCAG 2.2 AA additions: 2.4.11 Focus Not Obscured, 2.5.7 Dragging Movements
86+ (whiteboard needs a non-drag path), 2.5.8 Target Size β‰₯ 24px β€”
87+ https://www.audioeye.com/post/wcag-22/,
88+ https://w3c.github.io/wcag/understanding/focus-not-obscured-minimum
89+- Skeleton for page loads, spinner for single elements β€”
90+ https://www.nngroup.com/articles/skeleton-screens/
91+- Empty states teach and offer a path β€”
92+ https://www.nngroup.com/articles/empty-state-interface-design/
93+- Loading buttons keep their label; 16px mobile inputs; focus not hidden under
94+ sticky bars β€” https://vercel.com/design/guidelines
95+
96+## Open questions
97+
98+- A1: which list endpoints accept server-side filters/sort today? (check-api-contract)
99+- A6: reproduce the root-boundary failure before building the fix.
100+- C1–C5: which endpoints exist for untaken roll calls, grading queue, parent
101+ activity, reminders, notification preferences?
102+- B: which token vocabulary wins (`shadcn` names or `surface-*`)?
103+
104+## Verification
105+
106+Per layer: `bun run build`, vitest (dom project) for touched components,
107+Playwright `e2e/auth-shell.spec.ts`; a live visual pass with `agent-browser`
108+once E2E credentials are available.
src/api/__tests__/insights/insights.test.tsmodified+12 -0
@@ -2,6 +2,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
2 import {2 import {
3 getInsightByUserId,3 getInsightByUserId,
4 getInsightRuns,4 getInsightRuns,
5+ getInsightsPending,
5 getMyInsight,6 getMyInsight,
6 postInsightComputeByUserId,7 postInsightComputeByUserId,
7 postInsightsRefresh,8 postInsightsRefresh,
@@ -84,6 +85,17 @@ describe("insights API", () => {
84 expect(url).toBe("/api/insights/runs");85 expect(url).toBe("/api/insights/runs");
85 });86 });
86 87
88+ it("getInsightsPending GETs /insights/pending", async () => {
89+ mockFetchSuccess({ students: ["u1", "u2"] });
90+
91+ const result = await getInsightsPending();
92+ expect(result.students).toEqual(["u1", "u2"]);
93+
94+ const [url, init] = lastFetchCall();
95+ expect(url).toBe("/api/insights/pending");
96+ expect(init?.method).toBe("GET");
97+ });
98+
87 it("postInsightsRefresh POSTs /insights/refresh with the named students", async () => {99 it("postInsightsRefresh POSTs /insights/refresh with the named students", async () => {
88 mockFetchSuccess({ message_id: "m1", status: "pending" }, 202);100 mockFetchSuccess({ message_id: "m1", status: "pending" }, 202);
89 101
src/api/__tests__/podcast/podcast.test.tsmodified+0 -3
@@ -50,10 +50,7 @@ describe("podcast API", () => {
50 mockFetchSuccess({50 mockFetchSuccess({
51 job_id: "j1",51 job_id: "j1",
52 audio_id: "ses/duz_okuma/j1/episode.mp3",52 audio_id: "ses/duz_okuma/j1/episode.mp3",
53- audio_ids: ["ses/duz_okuma/j1/episode.mp3"],
54 duration_secs: 312.5,53 duration_secs: 312.5,
55- script_id: "s1",
56- script_ids: ["s1"],
57 format: "duz_okuma",54 format: "duz_okuma",
58 });55 });
59 56
src/api/client/types.tsmodified+7 -8
@@ -1338,6 +1338,9 @@ export type InsightRun = {
1338 failed_modules: string[];1338 failed_modules: string[];
1339 };1339 };
1340 1340
1341+/** The freshest run's pending students, in the service's order. */
1342+export type InsightPendingList = { students: string[] };
1343+
1341 // ---------------------------------------------------------------------------1344 // ---------------------------------------------------------------------------
1342 // podcast β€” narrating a course note1345 // podcast β€” narrating a course note
1343 // ---------------------------------------------------------------------------1346 // ---------------------------------------------------------------------------
@@ -1370,20 +1373,16 @@ export type PodcastJobStatus = {
1370 error_code?: string | null;1373 error_code?: string | null;
1371 };1374 };
1372 1375
1373-/** A finished job's artifacts, passed through verbatim. */1376+/** A finished job's artifacts. */
1374 export type PodcastJobArtifacts = {1377 export type PodcastJobArtifacts = {
1375 job_id: string;1378 job_id: string;
1376 /** The produced audio's path inside the school's output root. Display-only:1379 /** The produced audio's path inside the school's output root. Display-only:
1377 * the stream is addressed by `job_id` (see `podcastAudioUrl`), never by this1380 * the stream is addressed by `job_id` (see `podcastAudioUrl`), never by this
1378 * path, so a caller cannot name a file outside its own school. */1381 * path, so a caller cannot name a file outside its own school. */
1379 audio_id: string;1382 audio_id: string;
1380- /** One entry per produced chapter; usually `[audio_id]`. */1383+ duration_secs?: number | null;
1381- audio_ids: string[];1384+ /** The resolved narration format. */
1382- duration_secs: number;1385+ format?: PodcastFormat | null;
1383- script_id: string;
1384- /** One entry per script the audio was aligned to. */
1385- script_ids: string[];
1386- format: PodcastFormat;
1387 };1386 };
1388 1387
1389 /** The verdict on a cancel. `false` is not an error β€” see `postPodcastJobCancel`. */1388 /** The verdict on a cancel. `false` is not an error β€” see `postPodcastJobCancel`. */
src/api/insights/getInsightsPending.tsadded+11 -0
@@ -0,0 +1,11 @@
1+import { client } from "../client";
2+import type { InsightPendingList } from "../client";
3+
4+/**
5+ * The students the freshest compute run left pending β€” where the next run
6+ * starts. Manager+ only, like `getInsightRuns`; answered whole or refused
7+ * with 413, never clipped.
8+ */
9+export function getInsightsPending(signal?: AbortSignal): Promise<InsightPendingList> {
10+ return client<InsightPendingList>("/insights/pending", { signal });
11+}
src/api/insights/index.tsmodified+1 -0
@@ -3,3 +3,4 @@ export * from "./getInsightByUserId";
3 export * from "./postInsightComputeByUserId";3 export * from "./postInsightComputeByUserId";
4 export * from "./getInsightRuns";4 export * from "./getInsightRuns";
5 export * from "./postInsightsRefresh";5 export * from "./postInsightsRefresh";
6+export * from "./getInsightsPending";
src/components/notes/podcast-panel.test.tsxmodified+0 -6
@@ -61,10 +61,7 @@ describe("PodcastPanel", () => {
61 podcastApi.getPodcastJobResultById.mockResolvedValue({61 podcastApi.getPodcastJobResultById.mockResolvedValue({
62 job_id: "pj1",62 job_id: "pj1",
63 audio_id: "ses/duz_okuma/pj1/episode.mp3",63 audio_id: "ses/duz_okuma/pj1/episode.mp3",
64- audio_ids: ["ses/duz_okuma/pj1/episode.mp3"],
65 duration_secs: 42,64 duration_secs: 42,
66- script_id: "s1",
67- script_ids: ["s1"],
68 format: "duz_okuma",65 format: "duz_okuma",
69 });66 });
70 67
@@ -87,10 +84,7 @@ describe("PodcastPanel", () => {
87 podcastApi.getPodcastJobResultById.mockResolvedValue({84 podcastApi.getPodcastJobResultById.mockResolvedValue({
88 job_id: "pj1",85 job_id: "pj1",
89 audio_id: "ses/duz_okuma/pj1/episode.mp3",86 audio_id: "ses/duz_okuma/pj1/episode.mp3",
90- audio_ids: ["ses/duz_okuma/pj1/episode.mp3"],
91 duration_secs: 42,87 duration_secs: 42,
92- script_id: "s1",
93- script_ids: ["s1"],
94 format: "duz_okuma",88 format: "duz_okuma",
95 });89 });
96 90