Conversation
Greptile SummaryAdds error handling and user recovery to the AI study-pack generation flow. Introduces an
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| frontend/src/app/page.tsx | Adds error state management and a dismissible error alert UI. Clean implementation with proper accessibility attributes. Minor concern: raw technical error messages may surface to users. |
Sequence Diagram
sequenceDiagram
participant U as User
participant P as page.tsx
participant API as generateStudyMaterials
U->>P: Clicks "Generate study pack"
P->>P: setErrorMessage(null)
P->>P: setLoading(true)
P->>API: generateStudyMaterials(notes)
alt Success
API-->>P: GenerateResponse
P->>P: console.log(response)
else API Error
API-->>P: throws Error
P->>P: setErrorMessage(err.message)
P->>U: Show error alert with Dismiss button
end
P->>P: setLoading(false)
alt User Recovery
U->>P: Types in textarea
P->>P: setErrorMessage(null)
else
U->>P: Clicks Dismiss
P->>P: setErrorMessage(null)
else
U->>P: Resubmits form
P->>P: setErrorMessage(null)
end
Last reviewed commit: 1031f3c
Greptile SummaryAdded comprehensive error handling and user feedback for AI study-pack generation. The PR introduces a
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| frontend/src/app/page.tsx | Added error handling with user-friendly messages, loading state UI, and error recovery via dismiss/typing/retry |
Flowchart
flowchart TD
A[User submits form] --> B{isDisabled?}
B -->|Yes| Z[Return early]
B -->|No| C[Clear error message]
C --> D[Set loading = true]
D --> E[Call generateStudyMaterials API]
E --> F{Success?}
F -->|Yes| G[Log response]
F -->|No| H[Catch error]
H --> I[toUserFriendlyMessage]
I --> J{Is technical error?}
J -->|Yes| K[Show fallback message]
J -->|No| L[Show raw error message]
K --> M[Set errorMessage state]
L --> M
G --> N[Set loading = false]
M --> N
N --> O[UI shows error with Dismiss button]
P[User types in textarea] --> Q[Clear error message]
R[User clicks Dismiss] --> Q
S[User retries submit] --> C
Last reviewed commit: a13ac58
PR Summary
Adds loading and error handling for AI study-pack generation: loading indicator and disabled generate button during the request, user-visible error messages on failure, and clean recovery (error clears on retry, when typing, or via Dismiss).
Overview
During AI generation there was no loading feedback, the button could be clicked again, and failures only appeared in the console. This PR improves UX by showing loading state, blocking duplicate submissions, and surfacing user-friendly errors with clear recovery.
Kept existing loading state and used it to show a spinner and “Generating your study pack…” and to disable the submit button and textarea.
Introduced errorMessage state and set it in the catch from err.message (with a fallback for non-Error throws).
Rendered an error box (destructive styling, role="alert", aria-live="assertive") with the message and a “Dismiss” button (aria-label="Dismiss error").
Cleared the error when the user submits again, when they type in the notes field, or when they click Dismiss.
Error text is the message from the API/throw when it’s an Error (e.g. backend detail or “Request failed with status 500”); the fallback “Something went wrong. Please try again.” is used only for non-Error throws. A later change could map technical messages (e.g. status 500) to a single friendly message if desired.
Dismiss is an underlined text-style button; “Dismiss error” is used as the accessible name for screen readers.
Additional Notes
Loading indicator and disabled button were already present; this PR adds error handling and recovery.
Jira Ticket
Jira Ticket(s) - [SOC-18]