add technical documentation command #5
+25
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add sc-document.md command for generating both developer and user documentation with automated screenshot integration and cross-referencing capabilities.
Result - dev document
Question Feature Implementation Document
Overview
This is a chat system that enables AI question-and-answer based on video file subtitles. Users can click the "Question" button from the video list to converse with OpenAI GPT about the subtitle content of that video.
Architecture
Frontend (React/TypeScript)
Backend (Rust/Tauri)
Database Schema
chat_sessions table
chat_messages table
API Specification
Tauri Commands
get_or_create_chat_sessionRetrieves or creates a new chat session.
Parameters:
video_id: String- Video IDai_provider: Option<String>- AI provider (default: "openai")model: Option<String>- Model to use (default: "gpt-4.1")Return value:
Implementation logic:
submit_chat_messageSends user message and receives AI response via streaming.
Parameters:
session_id: String- Chat session IDmessage: String- User messageReturn value:
Implementation logic:
Tauri Events
chat_stream_startEmitted when AI response streaming starts
chat_stream_deltaEmitted when AI response chunk is received
chat_stream_endEmitted when AI response is complete
chat_stream_errorEmitted when error occurs during AI response
Frontend Implementation
ChatPanel Component
Main component responsible for chat UI.
Key features:
Props:
State Management
Centralized chat-related state management in App.tsx:
Event Listeners
Subscribe to Tauri events for streaming response handling:
Backend Implementation
OpenAI Client
OpenAI Responses API integration in
ai.rs:Subtitle Snapshot Generation
Read video subtitle files for AI context:
System Prompt
Prompt explaining the AI's role and context:
Security Considerations
API Key Management
Input Validation
Performance Optimization
Database
Memory Management
Error Handling
Common Error Cases
Error Recovery
Testing
Frontend Testing
src/components/__tests__/ChatPanel.test.tsx:Backend Testing
Using Cargo test framework:
Deployment Considerations
Environment Setup
Dependencies
Future Improvements
References
Result - user document
How to Use the Question Feature Guide
Overview
The video organizer's question feature allows you to chat with AI based on the subtitle content of videos. It's useful when you need additional explanations or have questions about the content after watching a video.
Prerequisites
1. OpenAI API Key Setup
You need an OpenAI API key to use the question feature.
Method 1: Environment Variable Setup
Method 2: Register in App Settings
2. Subtitle File Verification
The question feature works based on subtitle files linked to videos. Make sure the following files exist in your video folder:
meta.jsonfile (video metadata).srt,.vtt,.ass, etc.Only videos with subtitle files will have the "❓ Question" button enabled.
Basic Usage
1. Starting Questions
2. Entering and Sending Questions
EnterInput Tips:
Enter: Send messageShift + Enter: Line break (without sending)3. Continuing Conversations
Advanced Features
Question Count Display
You can see how many questions you've asked about a video on the video card.
Streaming Responses
AI responses are displayed in real-time streaming:
Troubleshooting
API Key Related Errors
Symptom: "Please register your OpenAI API key in settings" message appears
Solutions:
OPENAI_API_KEYenvironment variable settingNo Subtitle Files
Symptom: Question button is disabled
Solutions:
.srt,.vtt,.ass, etc.) exist in the video foldermeta.jsonfileChat Session Errors
Symptom: "Failed to prepare chat session" error
Solutions:
Slow Responses
Causes:
Solutions:
Usage Tips
Effective Questioning Methods
Ask Specifically
Focus on Subtitle Content
Utilize Context
Precautions
Related Documentation
Inquiries and Feedback
If you encounter problems using the question feature or have suggestions for improvements, please let us know through GitHub Issues.