docs: update task plan with SDK limitations

- Mark video list hook as not needed (already uses useTemplates)
- Document SDK limitations: no message list API, no user info API
- Add SDK Support column to findings.md
- Clarify which features need backend customization

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
imeepos 2026-01-21 11:48:50 +08:00
parent 7fd5f3da44
commit ec548ed95f
2 changed files with 199 additions and 0 deletions

121
findings.md Normal file
View File

@ -0,0 +1,121 @@
# Findings: Backend Integration Research
## Date: 2026-01-21
## Project Structure
- **Package Manager:** bun
- **Base URL:** https://api.mixvideo.bowong.cc
- **Owner ID:** t0m9cketSQdCA6cHXI9mXQLJPM9LDIw5
- **SDK Location:** node_modules/@repo/sdk
## @repo/sdk Analysis
### Architecture
- **Pattern:** Dependency Injection with Better Auth integration
- **Controllers:** 23 total (Activity, Template, Project, Chat, File, etc.)
- **Access Methods:**
1. Better Auth style: `authClient.loomart.xxx`
2. DI style: `root.get(Controller)`
### Key Controllers
1. **TemplateController** - Template CRUD, workflow execution
2. **CategoryController** - Category management with templates
3. **ProjectController** - Project management
4. **ChatController** - Chat functionality
5. **FileController** - File management
6. **ActivityController** - Activity tracking
7. **TemplateSocialController** - Likes, views, social features
8. **TemplateGenerationController** - Generation tracking
9. **AICharacterController** - AI character management
10. **AigcController** - AIGC operations
## Current State Management
### Zustand Stores (Only 1)
- **useCategoriesStore** (hooks/use-categories.ts)
- Global cache for categories
- Has loading/error/hasLoaded states
- Prevents redundant API calls
### Custom Hooks Pattern (15 hooks)
Most screens use local state via custom hooks:
- use-templates.ts - Template list with pagination
- use-template-detail.ts - Single template
- use-template-actions.ts - Like, view actions
- use-template-generations.ts - Generation history
- use-activates.ts - Activity list
- use-tags.ts - Tag management
- use-search-history.ts - Search history
## API Integration Patterns
### Pattern 1: Better Auth Client (Primary)
```typescript
import { authClient, loomart } from '@/lib/auth'
const result = await loomart.template.list(params)
```
### Pattern 2: DI Container
```typescript
import { root } from '@repo/core'
import { TemplateController } from '@repo/sdk'
const template = root.get(TemplateController)
const result = await template.list(params)
```
### Pattern 3: Error Handling
```typescript
const { data, error } = await handleError(async () => await apiCall())
```
## Frontend Screens Inventory
### Tab Screens (5)
| Screen | Path | Needs API | SDK Support | Notes |
|--------|------|-----------|-------------|-------|
| Home | (tabs)/index.tsx | ✅ Categories, Templates | ✅ TemplateController, CategoryController | Has basic integration |
| Video | (tabs)/video.tsx | ✅ Video list | ✅ TemplateController | Already uses useTemplates |
| Message | (tabs)/message.tsx | ✅ Chat/messages | ❌ No list API | ChatController只有chat()和listModels(),没有消息列表接口 |
| My Profile | (tabs)/my.tsx | ✅ User data | ⚠️ 需确认 | 需要用户信息接口 |
### Main Screens (15)
| Screen | Path | Needs API | Notes |
|--------|------|-----------|-------|
| Auth | auth.tsx | ✅ Login/signup | Has Better Auth |
| Membership | membership.tsx | ✅ Subscription | Needs Stripe |
| Template Detail | templateDetail.tsx | ✅ Template data | Has integration |
| Generate Video | generateVideo.tsx | ✅ Generation API | Needs progress |
| Generation Record | generationRecord.tsx | ✅ History list | Needs pagination |
| Works List | worksList.tsx | ✅ User works | Needs pagination |
| Search Template | searchTemplate.tsx | ✅ Search API | Needs debounce |
| Search Results | searchResults.tsx | ✅ Results list | Needs pagination |
| Search Works | searchWorks.tsx | ✅ Works search | Needs pagination |
| Search Works Results | searchWorksResults.tsx | ✅ Results list | Needs pagination |
| Channels | channels.tsx | ✅ Category data | Needs refresh |
| Change Password | changePassword.tsx | ✅ Auth API | Has integration |
| Privacy | privacy.tsx | ❌ Static | No API needed |
| Terms | terms.tsx | ❌ Static | No API needed |
## Key Discoveries
1. **Minimal Global State:** Only 1 Zustand store (categories), rest uses local state
2. **Hook-Based Architecture:** 15 custom hooks handle API calls
3. **Existing Patterns:** Some screens already have API integration
4. **Missing Features:**
- Loading states inconsistent across screens
- No pull-to-refresh on most screens
- Pagination exists in hooks but not all screens use it
- No error retry mechanisms
- No optimistic updates
5. **SDK限制**
- ❌ ChatController没有消息列表接口只有chat()和listModels()
- ❌ 没有用户信息相关的Controller
- ✅ Video页面已正确使用TemplateController不需要单独的视频hook
## Technical Constraints
1. **Multi-tenant:** All requests need `x-ownerid` header
2. **Authentication:** Token stored in expo-secure-store
3. **Design Width:** 375px (need to convert styles to Tailwind)
4. **No Redux:** Project uses minimal global state approach
5. **Better Auth:** Primary auth method, SDK integrated as plugin

78
task_plan.md Normal file
View File

@ -0,0 +1,78 @@
# Task Plan: Backend Integration & UI Optimization
## Goal
Integrate @repo/sdk backend APIs into the existing Expo frontend and add essential UI optimizations (loading states, refresh, pagination).
## Context
- Frontend pages are complete
- Need to connect to @repo/sdk backend
- Add loading/refresh/nextPage logic
- Tech stack: Expo + React Native + Zustand + TailwindCSS
## Phases
### Phase 1: Discovery [completed]
- [x] Locate @repo/sdk package and understand its API structure
- [x] Identify all frontend pages/screens that need backend integration
- [x] Map out current state management structure (Zustand stores)
- [x] Document API endpoints and data models
**Key Findings:**
- 23 controllers available in @repo/sdk
- 19 screens total (15 need API, 4 static)
- Only 1 Zustand store (categories)
- 15 custom hooks already exist
- Some screens have partial integration
### Phase 2: Enhance Existing Hooks [pending]
- [ ] Review existing hooks (use-templates, use-template-detail, etc.)
- [ ] Add missing loading states where needed
- [ ] Add refresh functionality to hooks
- [ ] Ensure pagination is properly implemented
- [ ] Add error retry mechanisms
### Phase 3: Create Missing Hooks [pending]
- [x] ~~Video list hook~~ - 不需要video.tsx已使用useTemplates
- [ ] ⚠️ Messages/chat hook - SDK无消息列表接口需要与后端确认或定制开发
- [ ] ⚠️ User profile hook - 需要确认SDK中是否有用户信息接口
- [ ] Works list hook enhancements (for worksList.tsx)
- [ ] 审查其他页面是否需要新的hooks
### Phase 4: UI Integration - Tab Screens [pending]
- [ ] Home tab: Add refresh, loading states
- [ ] Video tab: Add pagination, loading, refresh
- [ ] Message tab: Add real-time updates, loading
- [ ] My Profile tab: Add refresh, loading states
### Phase 5: UI Integration - Main Screens [pending]
- [ ] Generation Record: Add pagination, refresh
- [ ] Works List: Add pagination, refresh
- [ ] Search screens: Add debounce, pagination, loading
- [ ] Template Detail: Add loading states
- [ ] Generate Video: Add progress tracking
### Phase 6: Global UI Components [pending]
- [ ] Create reusable RefreshControl component
- [ ] Create reusable LoadingState component
- [ ] Create reusable ErrorState component with retry
- [ ] Create reusable PaginationLoader component
### Phase 7: Testing & Validation [pending]
- [ ] Test all API integrations
- [ ] Verify loading states
- [ ] Test refresh functionality
- [ ] Validate pagination behavior
- [ ] Test error handling and retry
## Decisions Log
| Decision | Rationale | Date |
|----------|-----------|------|
| - | - | - |
## Errors Encountered
| Error | Attempt | Resolution |
|-------|---------|------------|
| - | - | - |
## Files Modified
- (To be populated as work progresses)