Skip to content

P4 audit remediation: frontend correctness / UX - #27

Merged
tyler-rich merged 2 commits into
claude/audit-fixes-2026-07-05-9bqe6n-p3from
claude/audit-fixes-2026-07-05-9bqe6n-p4
Jul 6, 2026
Merged

P4 audit remediation: frontend correctness / UX#27
tyler-rich merged 2 commits into
claude/audit-fixes-2026-07-05-9bqe6n-p3from
claude/audit-fixes-2026-07-05-9bqe6n-p4

Conversation

@tyler-rich

@tyler-rich tyler-rich commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Implements the P4 tier of docs/reviews/full-audit-2026-07-05.md §10 (frontend correctness / UX).

Stacked on #26 (P3). Base is the P3 branch so this PR's diff shows only P4.

Fixes

  • FE-1 — session-expiry handling. The API client dispatches a scrye:auth-invalidated window event on any 401; AuthContext listens and flips user to null, so a dead/revoked session drops the SPA back to <LoginPage> instead of leaving a stale authenticated shell where every widget errors.
  • FE-3 — UTC-as-local timestamps. New lib/dates.ts (parseUtc / formatWhen) is the one place that renders a backend naive-UTC timestamp. Account sessions, the Backups list + schedule last-run, and Scheduled-scans last-run (which previously rendered without a Z, so times were hours off) now use it; the two pages that already appended Z via a private formatWhen (ScanDetail, Scans) are de-duplicated onto the shared helper.
  • FE-4 — restore file label. BackupsPanel's restore file moves from useRef to useState, so the selected filename actually re-renders on the destructive restore flow instead of showing "No file selected".
  • FE-5 — scheduled-scan matrix + role gating. ScheduledScansPanel constrains the scanner Select by target type (a SCANNERS_FOR matrix + auto-correct on target-type change, mirroring New Scan and the backend combo validation) and gates Add/Run/Delete behind an operator/admin check (useAuth). /settings is now a guarded route — a viewer opening the URL is redirected to /, not just missing the nav link.

Notes

  • All client-only; the backend already enforces the same RBAC/validation, so these close UX gaps (stale shells, wrong times, silent destructive-flow labels, invalid-combo 400s, viewer-visible controls) rather than security holes.
  • No frontend test runner exists yet (FE-10 — deferred to P5), so changes are verified by tsc -b, ESLint, Prettier, and a clean vite build.
  • Deviation logged in docs/PLAN.md § Deviations (2026-07-05 P4 entry).

…ore label, RBAC gating

Addresses the P4 tier of docs/reviews/full-audit-2026-07-05.md §10 (frontend
correctness / UX):

- FE-1: the API client emits an auth-invalidated event on any 401 and
  AuthContext drops to the login screen, instead of leaving a stale
  authenticated shell whose every action fails.
- FE-3: a shared lib/dates.ts (parseUtc/formatWhen) renders backend naive-UTC
  timestamps; Account/Backups/Scheduled-scans stop showing UTC as local, and
  the ScanDetail/Scans private helpers are de-duplicated onto it.
- FE-4: BackupsPanel's restore file uses useState (not useRef) so the selected
  file name re-renders on the destructive restore flow.
- FE-5: ScheduledScansPanel constrains the scanner Select by target type
  (SCANNERS_FOR matrix + auto-correct) and gates Add/Run/Delete behind an
  operator/admin check; the /settings route is now guarded (viewers → /).

Verified with tsc, ESLint, Prettier, and a clean vite build (no frontend test
runner yet — FE-10 deferred to P5). Deviation logged in docs/PLAN.md.
…gitignore)

The shared date helper added for FE-3 lives under frontend/src/lib/, which the
generic Python-oriented `lib/` rule in .gitignore silently excluded — so the
file was never committed and CI's fresh checkout failed the frontend build (and
the image build) with "Cannot find module '../../lib/dates'". Add a .gitignore
exception for the frontend source lib directory and commit the file.
@tyler-rich
tyler-rich merged commit 98a6284 into claude/audit-fixes-2026-07-05-9bqe6n-p3 Jul 6, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant