Conversation
…ion (#882) * fix(kb-tag-slots): finding next slot, create versus edit differentiation * remove unused test file * fix lint
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
There was a problem hiding this comment.
Greptile Summary
This PR implements a comprehensive fix for knowledge base tag slot allocation reliability issues. The changes move tag slot allocation logic from unreliable client-side implementation to a robust server-side system.
Core Changes:
- Server-side slot allocation: New API endpoint
/next-available-slothandles slot finding with proper database queries and field type validation - Database constraints: Added unique composite index on
knowledge_base_id+display_nameto prevent duplicate tag names within knowledge bases - Field type system: Restructured slot management with
TAG_SLOT_CONFIGto support different field types (currently 'text', designed for future expansion to date/number) - Edit vs Create differentiation: Added
_originalDisplayNamefield to properly handle tag definition updates without creating new slots unnecessarily - Enhanced UI: New
useNextAvailableSlothook provides clean client interface with loading states and comprehensive slot information
System Integration:
The changes integrate across multiple layers: database schema updates, API route enhancements, React hooks, and UI components. The slot allocation now uses a configuration-driven approach mapping field types to specific database columns (tag1, tag2, etc.) with proper limits. Transaction-based operations ensure data consistency during bulk tag operations. The system maintains backward compatibility while providing a foundation for future field type expansion.
Confidence score: 4/5
- This PR addresses a real reliability issue with a well-architected server-side solution that should significantly improve tag management
- Score reflects good overall approach but concerns about type assertions to 'any' and some code duplication that could affect maintainability
- Pay close attention to the API route files where type safety was compromised with
anyassertions
Context used:
Context - Avoid using type assertions to 'any' in TypeScript. Instead, ensure proper type definitions are used to maintain type safety. (link)
11 files reviewed, 6 comments
apps/sim/app/api/knowledge/[id]/documents/[documentId]/tag-definitions/route.ts
Show resolved
Hide resolved
apps/sim/app/api/knowledge/[id]/documents/[documentId]/tag-definitions/route.ts
Show resolved
Hide resolved
...m/app/workspace/[workspaceId]/knowledge/components/document-tag-entry/document-tag-entry.tsx
Show resolved
Hide resolved
v0.3.20: KB Tag fixes
Summary
Type of Change
Checklist