4.2 KiB
4.2 KiB
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
- Given a user creates a new note with content,
- When the note is saved,
- 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 logickeep-notes/lib/ai/services/- AI services for labelingkeep-notes/lib/ai/factory.ts- AI provider factorykeep-notes/components/Note.tsx- Note display componentkeep-notes/app/api/ai/route.ts- AI API endpoints
Expected Flow:
- User creates note via
createNote()server action - Server action calls AI service to generate embeddings
- AI service analyzes content for label suggestions
- Labels are saved to
Note.labelsfield - 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:
- Create a new note with content about "programming"
- Save the note
- Verify labels appear automatically (e.g., "code", "development")
- Check database to confirm labels are saved
- Test with different types of content
- 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
- Created story file with comprehensive bug fix requirements
- Identified files to investigate
- Defined expected flow and potential issues
- Bug fix pending (see tasks above)
File List
Files to Investigate:
keep-notes/app/actions/notes.tskeep-notes/lib/ai/services/keep-notes/lib/ai/factory.tskeep-notes/components/Note.tsxkeep-notes/app/api/ai/route.ts