fix(canvas): 创作工作台 - 恢复异步媒体任务并完善输入与预览交互
This commit is contained in:
1 parent
3fb5545c11
commit
8ec10669f1
6 files changed
+165
-8
No files matched your search
@@ -420,7 +420,7 @@ func (r *Repository) Tasks(userID string, limit int, projectID string, activeOnl
|
||||
if limit <= 0 || limit > 100 {
|
||||
limit = 50
|
||||
}
|
||||
query := r.db.Select("id", "session_id", "project_id", "type", "status", "stage", "progress", "prompt", "operation", "provider", "model", "result_json", "billing_order_id", "attempts", "started_at", "completed_at", "created_at", "updated_at").
|
||||
query := r.db.Select("id", "session_id", "project_id", "type", "status", "stage", "progress", "prompt", "operation", "provider", "model", "input_json", "result_json", "billing_order_id", "attempts", "started_at", "completed_at", "created_at", "updated_at").
|
||||
Where("user_id = ?", userID)
|
||||
if strings.TrimSpace(projectID) != "" {
|
||||
query = query.Where("project_id = ?", strings.TrimSpace(projectID))
|
||||
|
||||
@@ -89,6 +89,14 @@ type TaskSummary struct {
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
Billing *TaskBillingSummary `json:"billing,omitempty"`
|
||||
ClientContext *TaskClientContext `json:"clientContext,omitempty"`
|
||||
}
|
||||
|
||||
type TaskClientContext struct {
|
||||
ConversationID string `json:"conversationId"`
|
||||
MessageID string `json:"messageId"`
|
||||
BatchIndex int `json:"batchIndex,omitempty"`
|
||||
BatchCount int `json:"batchCount,omitempty"`
|
||||
}
|
||||
|
||||
type TaskBillingSummary struct {
|
||||
@@ -608,6 +616,29 @@ func taskSummaryForOutput(task model.Task) TaskSummary {
|
||||
CompletedAt: task.CompletedAt,
|
||||
CreatedAt: task.CreatedAt,
|
||||
UpdatedAt: task.UpdatedAt,
|
||||
ClientContext: taskClientContext(task.InputJSON),
|
||||
}
|
||||
}
|
||||
|
||||
// 列表只暴露创作页恢复所需的关联 ID,不下发完整任务输入或其他 metadata。
|
||||
func taskClientContext(raw string) *TaskClientContext {
|
||||
var input struct {
|
||||
Metadata struct {
|
||||
Source string `json:"source"`
|
||||
ConversationID string `json:"conversationId"`
|
||||
MessageID string `json:"messageId"`
|
||||
BatchIndex int `json:"batchIndex"`
|
||||
BatchCount int `json:"batchCount"`
|
||||
} `json:"metadata"`
|
||||
}
|
||||
if json.Unmarshal([]byte(raw), &input) != nil || input.Metadata.Source != "create-page" || input.Metadata.ConversationID == "" || input.Metadata.MessageID == "" {
|
||||
return nil
|
||||
}
|
||||
return &TaskClientContext{
|
||||
ConversationID: input.Metadata.ConversationID,
|
||||
MessageID: input.Metadata.MessageID,
|
||||
BatchIndex: input.Metadata.BatchIndex,
|
||||
BatchCount: input.Metadata.BatchCount,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user