From c10206512de1fcfbfd040d5d2f1d48e342640666 Mon Sep 17 00:00:00 2001 From: weichen Date: Mon, 21 Sep 2026 03:05:49 +0000 Subject: [PATCH] fix(taskrun): serialize RunRecord with snake_case json tags The task run API was emitting PascalCase fields, so the client never saw status or error_message and treated every disconnect as a network error. Co-authored-by: Cursor --- internal/taskrun/types.go | 42 ++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/internal/taskrun/types.go b/internal/taskrun/types.go index 6a2a3c83..b7a7ab1e 100644 --- a/internal/taskrun/types.go +++ b/internal/taskrun/types.go @@ -24,27 +24,29 @@ type CreateRequest struct { } // RunRecord 运行实例状态。 +// JSON 键与前端约定及 task_runs 列名一致;缺标签时 encoding/json 会输出 PascalCase, +// 前端读 status/error_message 会得到 undefined,断线恢复分支全部失效。 type RunRecord struct { - RunID string - SessionID string - ProjectID int64 - UserID int64 - ClientTurnID string - IdempotencyKey string // 新 run 稳定键;旧行保持 NULL 不参与唯一索引 - TaskKey string - Stage string - WorkflowInstanceID int64 - StageInstanceID int64 - WorkflowStageKey string - Status string // pending | running | completed | failed | cancelled | pending_author_confirmation | blocked_pending_governance | … - WorkspaceID string - AssistantMsgID int64 - WorkerID string - LeaseExpiresAt *time.Time - CreatedAt time.Time - UpdatedAt time.Time - ErrorMessage string - Attempt int + RunID string `json:"run_id"` + SessionID string `json:"session_id"` + ProjectID int64 `json:"project_id"` + UserID int64 `json:"user_id"` + ClientTurnID string `json:"client_turn_id"` + IdempotencyKey string `json:"idempotency_key"` + TaskKey string `json:"task_key"` + Stage string `json:"stage"` + WorkflowInstanceID int64 `json:"workflow_instance_id"` + StageInstanceID int64 `json:"stage_instance_id"` + WorkflowStageKey string `json:"workflow_stage_key"` + Status string `json:"status"` // pending | running | completed | failed | cancelled | pending_author_confirmation | blocked_pending_governance | … + WorkspaceID string `json:"workspace_id"` + AssistantMsgID int64 `json:"assistant_message_id"` + WorkerID string `json:"worker_id"` + LeaseExpiresAt *time.Time `json:"lease_expires_at"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` + ErrorMessage string `json:"error_message"` + Attempt int `json:"attempt"` } // BuildTaskRunIdempotencyKey 新创建用稳定幂等键;空 client_turn 不设键。