improvement(knowledge): make KB modals toast-only for errors#5349
improvement(knowledge): make KB modals toast-only for errors#5349TheodoreSpeaks wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview Create modal: Drops Edit modal: Removes generic Hook: Reviewed by Cursor Bugbot for commit 5fe6348. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThis PR standardizes error-surfacing in the two KB modals to use toasts exclusively, removing inline
Confidence Score: 5/5Safe to merge — the changes remove redundant inline error state and wire server errors through the mutation hooks' onError callbacks, which is the established pattern in this codebase. All three error paths (validation, upload failure, server error) have clear toast coverage. The upload-failure path was the most surgical change — swapping throw uploadError for toast.error + return cleanly avoids re-entering the outer catch. The hook-owns-errors pattern for server errors is already live on the update side; adding it to the create hook is a direct mirror. No logic was removed that was load-bearing. No files require special attention. Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant User
participant CreateModal
participant useCreateKB as useCreateKnowledgeBase
participant useUpload as useKnowledgeUpload
participant useDeleteKB as useDeleteKnowledgeBase
User->>CreateModal: Submit form
alt Validation fails (onInvalid)
CreateModal-->>User: toast.error(first field error)
else Validation passes (onSubmit)
CreateModal->>useCreateKB: mutateAsync(data)
alt Server error
useCreateKB-->>User: toast.error(error.message) via onError
useCreateKB-->>CreateModal: throws (caught, logged only)
else KB created
alt Files selected
CreateModal->>useUpload: uploadFiles(files, kbId)
alt Upload fails
CreateModal->>useDeleteKB: mutateAsync(kbId) [cleanup]
CreateModal-->>User: toast.error("Failed to upload files")
else Upload succeeds
CreateModal-->>User: Modal closes
end
else No files
CreateModal-->>User: Modal closes
end
end
end
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant User
participant CreateModal
participant useCreateKB as useCreateKnowledgeBase
participant useUpload as useKnowledgeUpload
participant useDeleteKB as useDeleteKnowledgeBase
User->>CreateModal: Submit form
alt Validation fails (onInvalid)
CreateModal-->>User: toast.error(first field error)
else Validation passes (onSubmit)
CreateModal->>useCreateKB: mutateAsync(data)
alt Server error
useCreateKB-->>User: toast.error(error.message) via onError
useCreateKB-->>CreateModal: throws (caught, logged only)
else KB created
alt Files selected
CreateModal->>useUpload: uploadFiles(files, kbId)
alt Upload fails
CreateModal->>useDeleteKB: mutateAsync(kbId) [cleanup]
CreateModal-->>User: toast.error("Failed to upload files")
else Upload succeeds
CreateModal-->>User: Modal closes
end
else No files
CreateModal-->>User: Modal closes
end
end
end
Reviews (2): Last reviewed commit: "improvement(knowledge): drop field highl..." | Re-trigger Greptile |
|
Addressed the field-highlighting inconsistency (P2) in 815278f — instead of adding highlighting to the edit modal (its Re: the catch-block note (P1) — replied inline. Short version: server-error toasts are owned by the mutation hook's |
|
@greptile review |
|
Update (5fe6348): reversed the earlier toast-only decision. Surveyed the codebase — inline field-level validation is the dominant pattern (~60 files pass an So both KB modals now follow the norm:
This actually resolves the P2 field-highlighting concern properly (both modals highlight + message the offending field) rather than leveling down to toast-only. |
Summary
onInvalid; removed the inline description/regexPatternfield messages and thesubmitStatusstate +<ChipModalError>block. Upload failures now toast in the catch.onError: toast.errortouseCreateKnowledgeBase(matchinguseUpdateKnowledgeBase) so server errors surface from the hook — the create modal no longer hand-rolls server-error handling.nameError/descriptionError/errorstate and<ChipModalError>(server errors already toast via the update hook'sonError); validation now toasts.Type of Change
Testing
Tested manually.
bun run lint,bun run check:api-validation:strict, andtsc --noEmitall pass.Checklist
🤖 Generated with Claude Code