122 lines
4.2 KiB
Markdown
122 lines
4.2 KiB
Markdown
# Story 7.1: Fix Auto-labeling Bug
|
|
|
|
Status: ready-for-dev
|
|
|
|
## Story
|
|
|
|
As a **user**,
|
|
I want **auto-labeling to work when I create a note**,
|
|
so that **notes are automatically tagged with relevant labels without manual intervention**.
|
|
|
|
## Acceptance Criteria
|
|
|
|
1. **Given** a user creates a new note with content,
|
|
2. **When** the note is saved,
|
|
3. **Then** the system should:
|
|
- Automatically analyze the note content for relevant labels
|
|
- Assign suggested labels to the note
|
|
- Display the note in the UI with labels visible
|
|
- NOT require a page refresh to see labels
|
|
|
|
## Tasks / Subtasks
|
|
|
|
- [ ] Investigate current auto-labeling implementation
|
|
- [ ] Check if AI service is being called on note creation
|
|
- [ ] Verify embedding generation is working
|
|
- [ ] Check label suggestion logic
|
|
- [ ] Identify why labels are not being assigned
|
|
- [ ] Fix auto-labeling functionality
|
|
- [ ] Ensure AI service is called during note creation
|
|
- [ ] Verify label suggestions are saved to database
|
|
- [ ] Ensure labels are displayed in UI without refresh
|
|
- [ ] Test auto-labeling with sample notes
|
|
- [ ] Add error handling for auto-labeling failures
|
|
- [ ] Log errors when auto-labeling fails
|
|
- [ ] Fallback to empty labels if AI service unavailable
|
|
- [ ] Display user-friendly error message if needed
|
|
|
|
## Dev Notes
|
|
|
|
### Bug Description
|
|
|
|
**Problem:** When a user creates a note, the auto-labeling feature does not work. Labels are not automatically assigned and notes do not show any labels.
|
|
|
|
**Expected Behavior:**
|
|
- When creating a note, the system should analyze content and suggest relevant labels
|
|
- Labels should be visible immediately after note creation
|
|
- No page refresh should be required to see labels
|
|
|
|
**Current Behavior:**
|
|
- Labels are not being assigned automatically
|
|
- Notes appear without labels even when content suggests relevant tags
|
|
- User may need to refresh to see labels (if they appear at all)
|
|
|
|
### Technical Requirements
|
|
|
|
**Files to Investigate:**
|
|
- `keep-notes/app/actions/notes.ts` - Note creation logic
|
|
- `keep-notes/lib/ai/services/` - AI services for labeling
|
|
- `keep-notes/lib/ai/factory.ts` - AI provider factory
|
|
- `keep-notes/components/Note.tsx` - Note display component
|
|
- `keep-notes/app/api/ai/route.ts` - AI API endpoints
|
|
|
|
**Expected Flow:**
|
|
1. User creates note via `createNote()` server action
|
|
2. Server action calls AI service to generate embeddings
|
|
3. AI service analyzes content for label suggestions
|
|
4. Labels are saved to `Note.labels` field
|
|
5. UI re-renders with new labels visible (optimistic update)
|
|
|
|
**Potential Issues:**
|
|
- AI service not being called during note creation
|
|
- Label suggestion logic missing or broken
|
|
- Labels not being persisted to database
|
|
- UI not re-rendering with label updates
|
|
- Missing revalidatePath() calls
|
|
|
|
### Testing Requirements
|
|
|
|
**Verification Steps:**
|
|
1. Create a new note with content about "programming"
|
|
2. Save the note
|
|
3. Verify labels appear automatically (e.g., "code", "development")
|
|
4. Check database to confirm labels are saved
|
|
5. Test with different types of content
|
|
6. Verify no page refresh is needed to see labels
|
|
|
|
**Test Cases:**
|
|
- Create note about technical topic → should suggest tech labels
|
|
- Create note about meeting → should suggest meeting labels
|
|
- Create note about shopping → should suggest shopping labels
|
|
- Create note with mixed content → should suggest multiple labels
|
|
- Create empty note → should not crash or suggest labels
|
|
|
|
### References
|
|
|
|
- **Note Creation:** `keep-notes/app/actions/notes.ts:310-373`
|
|
- **AI Factory:** `keep-notes/lib/ai/factory.ts`
|
|
- **Project Context:** `_bmad-output/planning-artifacts/project-context.md`
|
|
- **Architecture:** `_bmad-output/planning-artifacts/architecture.md` (Decision 1: Database Schema)
|
|
|
|
## Dev Agent Record
|
|
|
|
### Agent Model Used
|
|
|
|
claude-sonnet-4-5-20250929
|
|
|
|
### Completion Notes List
|
|
|
|
- [x] Created story file with comprehensive bug fix requirements
|
|
- [x] Identified files to investigate
|
|
- [x] Defined expected flow and potential issues
|
|
- [ ] Bug fix pending (see tasks above)
|
|
|
|
### File List
|
|
|
|
**Files to Investigate:**
|
|
- `keep-notes/app/actions/notes.ts`
|
|
- `keep-notes/lib/ai/services/`
|
|
- `keep-notes/lib/ai/factory.ts`
|
|
- `keep-notes/components/Note.tsx`
|
|
- `keep-notes/app/api/ai/route.ts`
|