From 67d033ef5241389806e576849287e5e5d4b59559 Mon Sep 17 00:00:00 2001
From: Prateek Chaplot
Date: Mon, 23 Nov 2026 18:24:23 +0530
Subject: [PATCH] feat(ui): add keyboard accessibility and error-copy pass
Move every user-visible string into strings.ts (section 11) and give each API error code a plain-language corrective action in ErrorBanner. Add a skip link and main landmark, focus management for errors, a named progress bar, aria-busy on the generate section, and an inline delete confirmation in History.
Task T4.2 from docs/ARCHITECTURE.md section 14.
---
docs/ARCHITECTURE.md | 1 +
docs/TASKS.md | 9 +-
frontend/src/App.test.tsx | 13 ++
frontend/src/App.tsx | 26 +--
frontend/src/components/DownloadBar.tsx | 13 +-
frontend/src/components/ErrorBanner.test.tsx | 39 ++++
frontend/src/components/ErrorBanner.tsx | 70 ++++++--
frontend/src/components/GenerateBar.test.tsx | 6 +
frontend/src/components/GenerateBar.tsx | 44 +++--
frontend/src/components/HistoryPanel.test.tsx | 37 +++-
frontend/src/components/HistoryPanel.tsx | 136 ++++++++++----
frontend/src/components/InputPanel.tsx | 20 ++-
frontend/src/components/PlaybackPanel.tsx | 39 ++--
frontend/src/components/SubtitleView.tsx | 19 +-
frontend/src/components/VoicePanel.tsx | 22 ++-
frontend/src/components/validation.ts | 13 +-
frontend/src/strings.test.ts | 82 +++++++++
frontend/src/strings.ts | 170 ++++++++++++++++++
frontend/src/styles.css | 25 +++
19 files changed, 638 insertions(+), 146 deletions(-)
create mode 100644 frontend/src/components/ErrorBanner.test.tsx
create mode 100644 frontend/src/strings.test.ts
create mode 100644 frontend/src/strings.ts
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index ca766c7..c20afb4 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -213,6 +213,7 @@ tts/
│ └── src/
│ ├── main.tsx # mount
│ ├── App.tsx # single page layout
+│ ├── strings.ts # every user-visible string (section 11, NFR-04)
│ ├── api/
│ │ ├── client.ts # typed fetch wrapper, error envelope decoding
│ │ ├── mock.ts # MockApi implementing ApiInterface (VITE_API_MODE=mock)
diff --git a/docs/TASKS.md b/docs/TASKS.md
index f3b821e..1264d08 100644
--- a/docs/TASKS.md
+++ b/docs/TASKS.md
@@ -35,7 +35,7 @@ Statuses: done (PR merged) · doing (branch open, pending review) · remaining
| ID | Task | Branch | Verification | Status |
|---|---|---|---|---|
-| _(empty)_ | | | | |
+| T4.2 | Accessibility + error-copy pass | `arch/tts/t4.2` | 111 Vitest (18 new); ESLint; `tsc --noEmit`; Prettier (CRLF); live Vite build; 23/23 keyboard-only AC15 checks against the built bundle with the real voice; 196 pytest unit; `git diff --check` | Awaiting PR review |
## Remaining
@@ -61,7 +61,6 @@ _T4.1 done — see Done._
| ID | Task | Files | Deps | Acceptance criteria (summary) |
|---|---|---|---|---|
-| T4.2 | Accessibility + error-copy pass | `frontend/src/components/`, `frontend/src/strings.ts` | T3.1–T3.3 | Keyboard-only workflow manually verified and recorded |
| T4.3 | Observability polish | `src/tts/config.py`, `src/tts/jobs/manager.py` | P2 | Failure reason logged without full input text |
### P5 — Verification + docs
@@ -145,3 +144,9 @@ _T4.1 done — see Done._
- T4.1 mock parity decision (closes T1.4's follow-up): the mock stays as shipped. `mock.ts:buildCues` has no sentence grouping, no 1 200 ms floor, and no audio-duration cap, and its in-memory history is unbounded. Both are accepted **mock-only simplifications** and are recorded here instead of mirrored, because the mock is a P3 scaffold that only runs under `VITE_API_MODE=mock` and `mock.ts` is not one of T4.1's owned files; live behavior (`tts.subtitles.cues`, DAL eviction) is the binding contract.
- T4.1 observation for T5.2 (`KNOWN_LIMITATIONS.md`): words whose phonemes do not reconcile become zero-width `aligned=false` entries, so the highlight is empty while they are spoken — the fixture sentence "Hello world. This is a live check. Numbers like 42 stay honest." produced 2 unaligned words (`This`, `a`) and a highlight gap between `world.` and `is`. This is the FR-05 honest-degradation path (and the words render `.unaligned`), but it is visible to users and should be documented rather than debugged.
- T4.1 environment: this checkout was bare at task start (no `gh`, `.venv`, `frontend/node_modules`, Playwright browsers, or Piper voice); setup was re-run and the voice copied into an isolated `TTS_DATA_DIR=.venv\tts-data` so neither the live run nor the eviction check touched `%LOCALAPPDATA%\tts`. On Windows the Vite dev server binds `localhost` (IPv6) rather than `127.0.0.1`, and `npm run dev -- --port 5173` misparses the port as Vite's root, so the proxy check used `npx vite --port 5173` and `http://localhost:5173`. Prettier's CRLF check also needs the equals form on npm 11: `npx prettier --check . --end-of-line=crlf` (the T2.3 form `npm run format:check -- --end-of-line crlf` now fails with "No files matching the pattern were found: crlf").
+- T4.2 decisions: §11's "all strings live in one `strings.ts`" is now enforced — `frontend/src/strings.ts` holds every user-visible literal plus interpolating helpers (`characterCount`, `countLabel`, `statusGenerating`, `jumpLabel`, history labels) and the delete-confirm copy. Copy was moved verbatim (no wording changes) so the frozen aria-label contracts from T2.2/T3.3/T5.1 AC13 (`Open generation: …`, `Delete generation: …`, `N saved generation(s)`) are unchanged. `App.tsx` gained an additive import for the header/tagline/badge/footer copy and `styles.css` gained `.skip-link`, `.banner .error-guidance`, and `.history-confirm` rules; neither file is owned by T4.2, so this is recorded here. §6's frontend tree gained the `strings.ts` line in the same PR.
+- T4.2 error copy: `errorGuidance(code)` maps all 15 §9.1 codes to a plain-language corrective action with a fallback for unknown codes; `ErrorBannerContent` (exported, prop-driven) renders heading + server message + "What you can do: …" and is static-markup testable. `ErrorBanner` keeps `role="alert"`, focuses the heading (`tabIndex={-1}`) when an error appears, and Dismiss restores focus to the previously focused element when it is still connected. Errors cleared by other reducer actions (`SET_INPUT`, `GENERATION_CREATED`, …) do not move focus — only the explicit Dismiss does.
+- T4.2 accessibility: skip link is the first tab stop and targets `` (footer stays outside the landmark); the generate section exposes `aria-busy`; `