fix: comprehensive Sora & GDrive code review fixes

P0 fixes:
- StorageType: UploadFromURL now returns actual storageType, fixing
  GDrive tasks being incorrectly recorded as "s3"
- Concurrency: selectAccount returns ReleaseFunc to caller, fixing
  premature slot release before task creation
- Race condition: applyRecoveredToken uses copy-on-write for
  account.Credentials map to prevent concurrent write panic
- GetCameoStatus: use direct HTTP call to populate missing fields
  (StatusMessage, InstructionSetHint, InstructionSet)
- Frontend: progress bar uses reactive now.value instead of
  non-reactive Date.now()

P1 fixes:
- EditImage: pass req.Image through to CreateImageRequest
- ListPending: add LIMIT 200 to prevent unbounded queries
- Worker encapsulation: add ListPendingTasks/UpdateTask proxy methods
  to SoraTaskService, worker no longer accesses repo directly
- Frontend polling: add retry counter (3 attempts) before giving up

P2-P3 fixes:
- QuotaBar: handle both quota_source and source field names
- i18n: replace hardcoded Chinese labels in SoraPromptBar and
  example prompts in SoraGeneratePage with i18n keys
- Fix regenrate → regenerate i18n typo
- SoraMediaPreview: skip Escape handler when not visible
- SoraGeneratePage: void handleGenerate promise in handleRetry

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
erioandClaude Opus 4.6 committed 2026-03-08 01:02:55 +08:00
1 parent f9695ca83f
commit 597c19e80b
18 files changed
+168 -81

No files matched your search

+6 -6
View File
@@ -81,7 +81,7 @@ func (w *SoraTaskWorker) pollAll() {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
tasks, err := w.taskService.repo.ListPending(ctx)
tasks, err := w.taskService.ListPendingTasks(ctx)
if err != nil {
logger.LegacyPrintf("service.sora_task_worker", "[PollAll] list pending tasks error: %v", err)
return
@@ -137,14 +137,14 @@ func (w *SoraTaskWorker) tryStoreMedia(ctx context.Context, task *SoraTask) {
}
if w.objectStorage != nil && w.objectStorage.Enabled(ctx) {
key, _, err := w.objectStorage.UploadFromURL(ctx, 0, task.VideoURL)
key, _, storageType, err := w.objectStorage.UploadFromURL(ctx, 0, task.VideoURL)
if err != nil {
logger.LegacyPrintf("service.sora_task_worker",
"[StoreMedia] task=%s object storage upload error: %v", task.ID, err)
} else {
task.StoredKey = key
task.StorageType = w.objectStorage.StorageType()
if updateErr := w.taskService.repo.Update(ctx, task); updateErr != nil {
task.StorageType = storageType
if updateErr := w.taskService.UpdateTask(ctx, task); updateErr != nil {
logger.LegacyPrintf("service.sora_task_worker",
"[StoreMedia] task=%s update stored_key error: %v", task.ID, updateErr)
}
@@ -162,7 +162,7 @@ func (w *SoraTaskWorker) tryStoreMedia(ctx context.Context, task *SoraTask) {
if len(stored) > 0 && stored[0] != task.VideoURL {
task.StoredKey = stored[0]
task.StorageType = "local"
if updateErr := w.taskService.repo.Update(ctx, task); updateErr != nil {
if updateErr := w.taskService.UpdateTask(ctx, task); updateErr != nil {
logger.LegacyPrintf("service.sora_task_worker",
"[StoreMedia] task=%s update stored_key error: %v", task.ID, updateErr)
}
@@ -176,7 +176,7 @@ func (w *SoraTaskWorker) markTaskFailed(ctx context.Context, task *SoraTask, mes
task.ErrorMessage = message
task.ErrorType = "server_error"
task.CompletedAt = &now
if updateErr := w.taskService.repo.Update(ctx, task); updateErr != nil {
if updateErr := w.taskService.UpdateTask(ctx, task); updateErr != nil {
logger.LegacyPrintf("service.sora_task_worker",
"[PollOne] task=%s update failed: %v", task.ID, updateErr)
}