- Unified localStorage key to 'theme-preference' across all components
- Fixed header.tsx using wrong localStorage key ('theme' instead of 'theme-preference')
- Added localStorage hybrid persistence for instant theme changes
- Removed router.refresh() which was causing stale data revert
- Replaced Blue theme with Sepia
- Consolidated auth() calls to prevent race conditions
- Updated UserSettingsData types to include all themes
6.5 KiB
Story 7.1: Fix Auto-labeling Bug
Status: review
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
- Fixed auto-labeling bug by integrating contextualAutoTagService into createNote()
- Added auto-labeling configuration support (AUTO_LABELING_ENABLED, AUTO_LABELING_CONFIDENCE_THRESHOLD)
- Implemented graceful error handling for auto-labeling failures
- Created comprehensive E2E tests for auto-labeling functionality
File List
Modified Files:
keep-notes/app/actions/notes.ts- Added auto-labeling integration to createNote() function
New Files:
keep-notes/tests/bug-auto-labeling.spec.ts- E2E tests for auto-labeling functionality
Change Log
2026-01-17 - Auto-Labeling Bug Fix Implementation
Problem:
Auto-labeling feature was not working when creating new notes. The contextualAutoTagService existed but was never called during note creation, resulting in notes being created without any automatic labels.
Root Cause:
The createNote() function in keep-notes/app/actions/notes.ts did not integrate the auto-labeling service. It only used labels if they were explicitly provided in the data.labels parameter.
Solution:
- Added import of
contextualAutoTagServicefrom AI services - Added
getConfigBooleanimport from config utilities - Integrated auto-labeling logic into
createNote():- Checks if labels are provided
- If no labels and note has a notebookId, calls
contextualAutoTagService.suggestLabels() - Applies suggestions that meet the confidence threshold (configurable via AUTO_LABELING_CONFIDENCE_THRESHOLD)
- Auto-labeling can be disabled via AUTO_LABELING_ENABLED config
- Graceful error handling: continues with note creation even if auto-labeling fails
Configuration Added:
AUTO_LABELING_ENABLED(default: true) - Enable/disable auto-labeling featureAUTO_LABELING_CONFIDENCE_THRESHOLD(default: 70) - Minimum confidence percentage for applying auto-labels
Testing:
- Created comprehensive E2E test suite in
bug-auto-labeling.spec.ts:- Test auto-labeling for programming-related content
- Test auto-labeling for meeting-related content
- Test immediate label display without page refresh (critical requirement)
- Test graceful error handling when auto-labeling fails
- Test auto-labeling in notebook context
Expected Behavior After Fix: When a user creates a note in a notebook:
- System automatically analyzes note content using AI
- Relevant labels are suggested based on notebook's existing labels or new suggestions
- Labels with confidence >= threshold are automatically assigned
- Note displays with labels immediately (no page refresh needed)
- If auto-labeling fails, note is still created successfully