后端:
1. 主动调度 graph + session bridge 收口——把 dry-run / select / preview / confirm / rerun 串成受限 graph,新增 active_schedule_sessions 缓存与聊天拦截,ready_preview 后释放回自由聊天
2. 会话与通知链路对齐——notification 统一绑定 conversation_id,action_url 指向 /assistant/{conversation_id},会话不存在改回 404 语义,避免 wrong param type 误导排障
3. estimated_sections 写入与主动调度消费链路补齐——任务创建、quick task 与随口记入口都透传估计节数,主动调度只消费落库值
前端:
4. AssistantPanel 最小适配主动调度预览与失败态——复用主动调度卡片/微调弹窗,补历史加载失败可见提示与跨账号会话拦截
文档:
5. 更新主动调度缺口分阶段实施计划和实现方案,标记阶段 0-2 收口并同步接力状态
94 lines
2.6 KiB
Go
94 lines
2.6 KiB
Go
package conv
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/LoveLosita/smartflow/backend/model"
|
|
)
|
|
|
|
func UserAddTaskRequestToModel(request *model.UserAddTaskRequest, userID int) *model.Task {
|
|
return &model.Task{
|
|
Title: request.Title,
|
|
Priority: request.PriorityGroup,
|
|
EstimatedSections: model.NormalizeEstimatedSections(&request.EstimatedSections),
|
|
DeadlineAt: request.DeadlineAt,
|
|
UserID: userID,
|
|
}
|
|
}
|
|
|
|
func ModelToUserAddTaskResponse(task *model.Task) *model.UserAddTaskResponse {
|
|
status := "incomplete"
|
|
if task.IsCompleted {
|
|
status = "completed"
|
|
}
|
|
return &model.UserAddTaskResponse{
|
|
ID: task.ID,
|
|
Title: task.Title,
|
|
PriorityGroup: task.Priority,
|
|
EstimatedSections: model.NormalizeEstimatedSections(&task.EstimatedSections),
|
|
DeadlineAt: task.DeadlineAt,
|
|
Status: status,
|
|
CreatedAt: time.Now(), // 创建时间为当前时间
|
|
}
|
|
}
|
|
|
|
func ModelToGetUserTasksResp(tasks []model.Task) []model.GetUserTaskResp {
|
|
var resp []model.GetUserTaskResp
|
|
for _, task := range tasks {
|
|
status := "incomplete"
|
|
if task.IsCompleted {
|
|
status = "completed"
|
|
}
|
|
|
|
deadline := ""
|
|
if task.DeadlineAt != nil {
|
|
deadline = task.DeadlineAt.Format("2006-01-02 15:04:05")
|
|
}
|
|
|
|
urgencyThreshold := ""
|
|
if task.UrgencyThresholdAt != nil {
|
|
urgencyThreshold = task.UrgencyThresholdAt.Format("2006-01-02 15:04:05")
|
|
}
|
|
|
|
resp = append(resp, model.GetUserTaskResp{
|
|
ID: task.ID,
|
|
UserID: task.UserID,
|
|
Title: task.Title,
|
|
PriorityGroup: task.Priority,
|
|
EstimatedSections: model.NormalizeEstimatedSections(&task.EstimatedSections),
|
|
Status: status,
|
|
Deadline: deadline,
|
|
IsCompleted: task.IsCompleted,
|
|
UrgencyThresholdAt: urgencyThreshold,
|
|
})
|
|
}
|
|
return resp
|
|
}
|
|
|
|
// ModelToGetUserTaskResp 将单个 Task 模型转换为 GetUserTaskResp。
|
|
func ModelToGetUserTaskResp(task *model.Task) model.GetUserTaskResp {
|
|
status := "incomplete"
|
|
if task.IsCompleted {
|
|
status = "completed"
|
|
}
|
|
deadline := ""
|
|
if task.DeadlineAt != nil {
|
|
deadline = task.DeadlineAt.Format("2006-01-02 15:04:05")
|
|
}
|
|
urgencyThreshold := ""
|
|
if task.UrgencyThresholdAt != nil {
|
|
urgencyThreshold = task.UrgencyThresholdAt.Format("2006-01-02 15:04:05")
|
|
}
|
|
return model.GetUserTaskResp{
|
|
ID: task.ID,
|
|
UserID: task.UserID,
|
|
Title: task.Title,
|
|
PriorityGroup: task.Priority,
|
|
EstimatedSections: model.NormalizeEstimatedSections(&task.EstimatedSections),
|
|
Status: status,
|
|
Deadline: deadline,
|
|
IsCompleted: task.IsCompleted,
|
|
UrgencyThresholdAt: urgencyThreshold,
|
|
}
|
|
}
|