Skip to content

fix(history): show an error state instead of the empty "no attempts" message when loading fails #69

Description

@nastaso

Context

When a signed-in user opens Exam History and the exam_attempts fetch fails (a transient network or RLS error), loadHistory logs the error, leaves attempts as [], and clears loading. The render then shows the empty-state message "No exam attempts yet. Take your first practice exam!", so a returning user who actually has history is told they have none. The page cannot tell "no history" apart from "failed to load".

Scope

  • File: src/pages/_History.tsx.
  • loadHistory (around line 216): the catch (around line 233) currently only calls logError. Add an error state set there.
  • Render (around line 542): when the new error state is set, show a distinct "Could not load your history. Retry." card with a retry button instead of the empty state. The empty state should only render after a successful load with genuinely zero attempts.
  • Keep it minimal and in-file. Do not change the query, scoring, or any Supabase call shape.

Acceptance criteria

  • A failed history load renders a clearly different "could not load / retry" UI, not the "no attempts yet" empty state.
  • The empty state still shows for a real zero-attempt user.
  • Retry re-runs loadHistory.
  • npm run lint and npm run test pass; no new dependencies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is welcome

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions