12 KiB
Story Writer - Testing Guide & Current Status
Overview
The Story Writer feature is a comprehensive AI-powered story generation system that allows users to create complete stories with multimedia capabilities including images, audio narration, and video composition.
Current Status: ✅ Ready for Testing
✅ Completed Features
-
Core Story Generation
- Premise generation
- Structured outline generation (JSON schema with scenes)
- Story start generation (min 4000 words)
- Story continuation (iterative until completion)
- Full story generation (async with task management)
-
Multimedia Generation
- Image generation for story scenes
- Audio narration generation (TTS) for scenes
- Video composition from images and audio
-
Backend API
- 15+ endpoints for all operations
- Task management with progress tracking
- Authentication and subscription integration
- Error handling and logging
-
Frontend Components
- 5-phase workflow (Setup → Premise → Outline → Writing → Export)
- State management with localStorage persistence
- Phase navigation with prerequisite checking
- Multimedia display (images, audio, video)
-
End-to-End Video Generation
- Complete workflow: Outline → Images → Audio → Video
- Progress tracking with granular updates
- Async task execution with polling support
🔧 Recent Fixes
- Async Function Fix: Fixed
execute_complete_video_generationto be a synchronous function (not async) since it performs blocking operations - Progress Callback: Improved progress tracking with proper mapping of sub-progress to overall progress
- Error Handling: Enhanced error messages and exception logging
- Path Validation: Added validation for image and audio file paths before video generation
Testing Guide
Prerequisites
-
Backend Setup
cd backend pip install -r requirements.txt -
Frontend Setup
cd frontend npm install -
Environment Variables
- Ensure
.envfile is configured with:CLERK_SECRET_KEYfor authenticationGEMINI_API_KEYorHUGGINGFACE_API_KEYfor LLM- Image generation API keys (if using image generation)
- Ensure
-
Dependencies
- MoviePy (for video generation):
pip install moviepy imageio imageio-ffmpeg - gTTS (for audio generation):
pip install gtts - FFmpeg (system dependency for video processing)
- MoviePy (for video generation):
Test Scenarios
1. Basic Story Generation Flow
Steps:
- Navigate to
/story-writer - Fill in the Setup form:
- Select a persona (e.g., "Fantasy Writer")
- Enter story setting (e.g., "A magical kingdom")
- Enter characters (e.g., "A young wizard and a dragon")
- Enter plot elements (e.g., "A quest to find a lost artifact")
- Select writing style, tone, POV, audience, content rating, ending preference
- Click "Generate Premise"
- Review the generated premise
- Click "Generate Outline"
- Review the structured outline with scenes
- Click "Generate Story Start"
- Review the story beginning
- Click "Continue Writing" multiple times until story is complete
- Click "Export Story" to view the complete story
Expected Results:
- Premise is generated successfully
- Structured outline is generated with scene-by-scene details
- Story start is generated (min 4000 words)
- Story continuation works iteratively
- Story completion is detected when "IAMDONE" marker is found
- Complete story is displayed in the Export phase
2. Structured Outline with Images and Audio
Steps:
- Complete steps 1-6 from the basic flow
- In the Outline phase, verify that structured scenes are displayed
- Click "Generate Images" button
- Wait for images to be generated for all scenes
- Click "Generate Audio" button
- Wait for audio narration to be generated for all scenes
- Review the generated images and audio players
Expected Results:
- Images are generated for each scene
- Images are displayed in the Outline phase
- Audio files are generated for each scene
- Audio players are displayed for each scene
- Images and audio are persisted in state
3. Video Generation
Steps:
- Complete steps 1-6 from the basic flow (with images and audio generated)
- Navigate to the Export phase
- Click "Generate Video" button
- Wait for video generation to complete
- Review the generated video
Expected Results:
- Video is generated from images and audio
- Video is displayed in the Export phase
- Video can be downloaded
- Video composition combines all scenes into a single video
4. End-to-End Video Generation (Async)
Steps:
- Navigate to
/story-writer - Fill in the Setup form
- Use the API endpoint
/api/story/generate-complete-video(via Postman or frontend) - Poll the task status using
/api/story/task/{task_id}/status - Retrieve the result using
/api/story/task/{task_id}/result
Expected Results:
- Task is created successfully
- Progress updates are provided at each step:
- 10%: Premise generation
- 20%: Outline generation
- 30-50%: Image generation
- 50-70%: Audio generation
- 70%: Preparing video assets
- 75-95%: Video composition
- 100%: Complete
- Result contains premise, outline, images, audio, and video
- Video URL is provided for serving the video
5. Error Handling
Test Cases:
-
Invalid Story Parameters
- Submit form with missing required fields
- Expected: Validation error message
-
Network Errors
- Disconnect network during generation
- Expected: Error message displayed, state preserved
-
Subscription Limits
- Exceed subscription limits
- Expected: 429 error with appropriate message
-
Missing Dependencies
- Remove MoviePy or gTTS
- Expected: Error message indicating missing dependency
-
File Not Found
- Delete generated images or audio before video generation
- Expected: Error message with details about missing files
6. State Persistence
Steps:
- Complete steps 1-3 from the basic flow
- Refresh the page
- Verify that state is preserved
Expected Results:
- Premise is preserved
- Outline is preserved
- Story content is preserved
- Generated images and audio are preserved
- Phase navigation state is preserved
7. Phase Navigation
Steps:
- Complete the basic flow up to the Writing phase
- Navigate back to the Outline phase
- Modify the outline
- Navigate forward to the Writing phase
- Verify that changes are reflected
Expected Results:
- Backward navigation works correctly
- Forward navigation respects prerequisites
- State is preserved during navigation
- Changes are reflected in subsequent phases
API Endpoint Testing
1. Premise Generation
POST /api/story/generate-premise
Content-Type: application/json
Authorization: Bearer <token>
{
"persona": "Fantasy Writer",
"story_setting": "A magical kingdom",
"character_input": "A young wizard",
"plot_elements": "A quest",
...
}
2. Outline Generation
POST /api/story/generate-outline?premise=<premise>&use_structured=true
Content-Type: application/json
Authorization: Bearer <token>
{
"persona": "Fantasy Writer",
...
}
3. Image Generation
POST /api/story/generate-images
Content-Type: application/json
Authorization: Bearer <token>
{
"scenes": [
{
"scene_number": 1,
"title": "Scene 1",
"image_prompt": "A magical kingdom with a young wizard",
...
}
],
"provider": "gemini",
"width": 1024,
"height": 1024
}
4. Audio Generation
POST /api/story/generate-audio
Content-Type: application/json
Authorization: Bearer <token>
{
"scenes": [
{
"scene_number": 1,
"title": "Scene 1",
"audio_narration": "Once upon a time...",
...
}
],
"provider": "gtts",
"lang": "en",
"slow": false
}
5. Video Generation
POST /api/story/generate-video
Content-Type: application/json
Authorization: Bearer <token>
{
"scenes": [...],
"image_urls": ["/api/story/images/scene_1_image.png", ...],
"audio_urls": ["/api/story/audio/scene_1_audio.mp3", ...],
"story_title": "My Story",
"fps": 24,
"transition_duration": 0.5
}
6. Complete Video Generation (Async)
POST /api/story/generate-complete-video
Content-Type: application/json
Authorization: Bearer <token>
{
"persona": "Fantasy Writer",
...
}
# Response:
{
"task_id": "uuid",
"status": "pending",
"message": "Complete video generation started"
}
# Poll status:
GET /api/story/task/{task_id}/status
# Get result:
GET /api/story/task/{task_id}/result
Known Issues & Limitations
-
Video Generation Dependencies
- Requires FFmpeg to be installed on the system
- MoviePy can be resource-intensive for long videos
- Video generation may take several minutes for multiple scenes
-
Audio Generation
- gTTS requires internet connection
- pyttsx3 is offline but may have lower quality
- Audio generation may take time for long narration texts
-
Image Generation
- Image generation may take time for multiple scenes
- Rate limits may apply based on provider
- Image quality depends on the provider used
-
State Persistence
- Large state objects may cause localStorage issues
- Map serialization is handled but may have edge cases
-
Progress Tracking
- Progress callbacks may not be perfectly granular
- Some operations may not provide detailed progress
Next Steps
Phase 1: End-to-End Testing (Current)
- Fix async function issues
- Improve progress tracking
- Enhance error handling
- Complete manual testing of all flows
- Test with different story parameters
- Test error scenarios
- Test state persistence
Phase 2: CopilotKit Integration (Next)
- Create CopilotKit actions hook
- Create CopilotKit sidebar component
- Integrate CopilotKit into Story Writer
- Test CopilotKit actions
Phase 3: UX Enhancements
- Add loading states and progress indicators
- Improve error messages
- Add animations and transitions
- Enhance responsive design
Phase 4: Advanced Features
- Draft management
- Rich text editing
- Export enhancements (PDF, DOCX, EPUB)
- Story templates
Troubleshooting
Issue: Video generation fails
Solution:
- Verify FFmpeg is installed:
ffmpeg -version - Check that image and audio files exist
- Verify file paths are correct
- Check system resources (memory, disk space)
Issue: Audio generation fails
Solution:
- Verify internet connection (for gTTS)
- Check that gTTS is installed:
pip install gtts - Verify audio narration text is not empty
- Check system audio dependencies
Issue: Image generation fails
Solution:
- Verify image generation API keys are configured
- Check that image prompts are not empty
- Verify provider is available
- Check subscription limits
Issue: State not persisting
Solution:
- Check browser localStorage limits
- Verify state serialization is working
- Check for JavaScript errors in console
- Clear localStorage and try again
Support
For issues or questions:
- Check the logs in
backend/logs/ - Review error messages in the UI
- Check browser console for frontend errors
- Review API responses for backend errors
Conclusion
The Story Writer feature is ready for comprehensive testing. All core functionality is implemented and working. The system supports:
- Complete story generation workflow
- Multimedia generation (images, audio, video)
- Async task management with progress tracking
- State persistence and phase navigation
- Error handling and logging
End users can now test the complete flow and provide feedback for improvements.