feat: Connect Generate page to AI providers and implement Save functionality #23
Labels
No labels
backend
bug
completed
documentation
duplicate
enhancement
feature
frontend
good first issue
help wanted
in-progress
invalid
performance
phase-1
Phase1
Phase2
Phase3
planning
question
refactor
security
test
testing
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Kalle/ATM#23
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The Generate page (
/generate) has two critical gaps:Save button has no functionality: Users can generate a lesson preview but cannot save it to their library. The "Save" and "Edit" buttons in the preview panel have no
onClickhandlers.AI generation is simulated: The lesson generation uses a
setTimeoutwith hardcoded templates instead of leveraging the existing AI provider infrastructure (src/lib/ai/). The OpenAI and Anthropic providers are fully implemented but not connected.Current State
Generate Page (
src/app/[locale]/generate/page.tsx)handleGenerateusessetTimeout(2500)with template strings<button>Save</button>— no handler<button>Edit</button>— no handlerAI Provider Infrastructure (Already Built)
src/lib/ai/OpenAIProvider.ts— Full OpenAI API integrationsrc/lib/ai/AnthropicProvider.ts— Full Anthropic API integrationsrc/lib/ai/providerFactory.ts— Factory pattern for provider selectionsrc/lib/ai/cache.ts— Response cachingDatabase API
DatabaseAPI.createLesson(lesson)— Ready to save lessonsDatabaseAPI.listApiKeys()— Can retrieve stored API keysAIProviderFactory.createProvider(config)— Can create provider instancesProposed Solution
1. Connect AI Provider to Generate Page
2. Implement Save Functionality
3. Implement Edit Functionality
Acceptance Criteria
Priority
HIGH — Core user flow is broken: generate → save is incomplete
Files to Modify
src/app/[locale]/generate/page.tsx— Main implementationsrc/lib/ai/types.ts— Possibly add Feldenkrais-specific typessrc/types/database.ts— Ensure Lesson type compatibilityRelated Issues
✅ Implemented in commit
ebc4448Changes Made
AI Provider Integration:
AIProviderFactoryto create provider instancesSave to Library:
DatabaseAPI.createLesson()Edit Mode:
Error Handling:
Files Modified
src/app/[locale]/generate/page.tsx— Complete AI integration + Save/EditRemaining (Future)