feat(ai): implement intelligent auto-tagging system
- Added multi-provider AI infrastructure (OpenAI/Ollama) - Implemented real-time tag suggestions with debounced analysis - Created AI diagnostics and database maintenance tools in Settings - Added automated garbage collection for orphan labels - Refined UX with deterministic color hashing and interactive ghost tags
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import { createContext, useContext, useState, useEffect, ReactNode } from 'react'
|
||||
import { LabelColorName, LABEL_COLORS } from '@/lib/types'
|
||||
import { getHashColor } from '@/lib/utils'
|
||||
|
||||
export interface Label {
|
||||
id: string
|
||||
@@ -28,11 +29,10 @@ export function LabelProvider({ children }: { children: ReactNode }) {
|
||||
const [labels, setLabels] = useState<Label[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
// Fetch labels from API
|
||||
const fetchLabels = async () => {
|
||||
try {
|
||||
setLoading(true)
|
||||
const response = await fetch('/api/labels')
|
||||
const response = await fetch('/api/labels', { cache: 'no-store' })
|
||||
const data = await response.json()
|
||||
if (data.success && data.data) {
|
||||
setLabels(data.data)
|
||||
@@ -50,9 +50,7 @@ export function LabelProvider({ children }: { children: ReactNode }) {
|
||||
|
||||
const addLabel = async (name: string, color?: LabelColorName) => {
|
||||
try {
|
||||
// Get existing label color if not provided
|
||||
const existingColor = getLabelColorHelper(name)
|
||||
const labelColor = color || existingColor
|
||||
const labelColor = color || getHashColor(name);
|
||||
|
||||
const response = await fetch('/api/labels', {
|
||||
method: 'POST',
|
||||
@@ -130,4 +128,4 @@ export function useLabels() {
|
||||
throw new Error('useLabels must be used within a LabelProvider')
|
||||
}
|
||||
return context
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user