refactor(api): knowledge → src/api modules (Effort 1)#59
Conversation
Mechanical move of the knowledge feature from src/hooks/queries/knowledge to src/api/knowledge, adding queryOptions factories for the query hooks. No behavior change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K513rsQz6Lg1HbbfYiafrE
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Summary by QodoRefactor knowledge feature into src/api modules with queryOptions factories Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
109 rules 1. handleKnowledgeToggle uses mutateAsync try/catch
|
| async function handleKnowledgeToggle(artistId: string) { | ||
| if (!user) { | ||
| return { requiresAuth: true }; | ||
| } | ||
|
|
||
| const isKnown = userKnowledge[artistId]; | ||
|
|
||
| try { | ||
| await knowledgeToggleMutation.mutateAsync({ | ||
| artistId, | ||
| userId: user.id, | ||
| isKnown, | ||
| }); | ||
| return { requiresAuth: false }; | ||
| } catch (error) { | ||
| console.error("failed toggling knowledge", error); | ||
| return { requiresAuth: false }; | ||
| } |
There was a problem hiding this comment.
1. handleknowledgetoggle uses mutateasync try/catch 📘 Rule violation ⚙ Maintainability
handleKnowledgeToggle wraps knowledgeToggleMutation.mutateAsync(...) in a try/catch to handle
success/error paths. This violates the requirement to use callback-based `mutate(variables, {
onSuccess, onError })` for mutation handling.
Agent Prompt
## Issue description
`handleKnowledgeToggle` currently uses `mutateAsync` with a surrounding `try/catch`. The mutation should instead be invoked via `mutate` with `onSuccess`/`onError` callbacks.
## Issue Context
This hook currently returns `{ requiresAuth: boolean }` for both success and failure; preserve that behavior while moving handling into callbacks.
## Fix Focus Areas
- src/api/knowledge/useKnowledge.ts[10-27]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Triage of Qodo's two findings: 1. 2. No code changes here. Generated by Claude Code |
…Query The mechanical move changed knowledgeKeys.user(userId || "") to userKnowledgeQuery(userId!), shifting the disabled-state cache key from ["...", ""] to ["...", undefined]. Restore ?? "" to keep the move behavior-neutral, matching main. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K513rsQz6Lg1HbbfYiafrE
|
Correction to my earlier triage of finding 2 (the Fixed in (Finding 1 — the pre-existing Generated by Claude Code |
Mechanical move of the
knowledgefeature fromsrc/hooks/queries/knowledgetosrc/api/knowledge, addingqueryOptionsfactories for the query hooks. No behavior change. Part of #52.Manual verification
pnpm run lintpasses (0 warnings, 0 errors).pnpm testpasses (20 test files, 290 tests).pnpm run buildpasses.hooks/queries/knowledgeremain in src.Generated by Claude Code