Fix AI tagging issues and improve error messages

- Fall back to ai_enabled setting if ai_tagging_enabled not set
- Check both tags array and projectTags relationship for untagged projects
- Add detailed logging for debugging
- Show errors in toast instead of just counts
- Handle "no projects to tag" case with appropriate message
- Add early checks for OpenAI config and available tags

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-05 09:24:44 +01:00
parent 6f6d5ef501
commit 7f95f681d6
2 changed files with 77 additions and 23 deletions

View File

@@ -252,9 +252,16 @@ export default function ProjectsPage() {
// AI batch tagging mutation
const batchTagProjects = trpc.tag.batchTagProjects.useMutation({
onSuccess: (result) => {
toast.success(
`AI Tagging complete: ${result.processed} tagged, ${result.skipped} skipped, ${result.failed} failed`
)
if (result.errors && result.errors.length > 0) {
// Show first error if there are any
toast.error(`AI Tagging issue: ${result.errors[0]}`)
} else if (result.processed === 0 && result.skipped === 0 && result.failed === 0) {
toast.info('No projects to tag - all projects in this round already have tags')
} else {
toast.success(
`AI Tagging complete: ${result.processed} tagged, ${result.skipped} skipped, ${result.failed} failed`
)
}
setAiTagDialogOpen(false)
setSelectedRoundForTagging('')
utils.project.list.invalidate()