fix: update StartTime to use UnixMilli for better precision across step functions

This commit is contained in:
lilong.129
2025-06-18 13:51:44 +08:00
parent 3d2707fa36
commit a890981e2d
10 changed files with 16 additions and 16 deletions

View File

@@ -1 +1 @@
v5.0.0-beta-2506181201
v5.0.0-beta-2506181351

View File

@@ -58,7 +58,7 @@ type TStep struct {
// one step contains one or multiple actions
type ActionResult struct {
option.MobileAction `json:",inline"`
StartTime int64 `json:"start_time"` // action start time
StartTime int64 `json:"start_time"` // action start time in millisecond(ms)
Elapsed int64 `json:"elapsed_ms"` // action elapsed time(ms)
Error error `json:"error"` // action execution result
Plannings []*uixt.PlanningExecutionResult `json:"plannings,omitempty"` // store planning results for start_to_goal actions
@@ -69,7 +69,7 @@ type ActionResult struct {
type StepResult struct {
Name string `json:"name" yaml:"name"` // step name
Identifier string `json:"identifier,omitempty" yaml:"identifier,omitempty"` // step identifier
StartTime int64 `json:"start_time" yaml:"time"` // step start time
StartTime int64 `json:"start_time" yaml:"time"` // step start time in millisecond(ms)
StepType StepType `json:"step_type" yaml:"step_type"` // step type, testcase/request/transaction/rendezvous
Success bool `json:"success" yaml:"success"` // step execution result
Elapsed int64 `json:"elapsed_ms" yaml:"elapsed_ms"` // step execution time in millisecond(ms)

View File

@@ -54,7 +54,7 @@ func runStepFunction(r *SessionRunner, step IStep) (stepResult *StepResult, err
StepType: step.Type(),
Success: false,
ContentSize: 0,
StartTime: start.Unix(),
StartTime: start.UnixMilli(),
}
defer func() {
attachments := uixt.Attachments{}

View File

@@ -285,7 +285,7 @@ func runStepRequest(r *SessionRunner, step IStep) (stepResult *StepResult, err e
StepType: step.Type(),
Success: false,
ContentSize: 0,
StartTime: start.Unix(),
StartTime: start.UnixMilli(),
}
defer func() {

View File

@@ -95,7 +95,7 @@ func runStepShell(r *SessionRunner, step IStep) (stepResult *StepResult, err err
StepType: step.Type(),
Success: false,
ContentSize: 0,
StartTime: start.Unix(),
StartTime: start.UnixMilli(),
}
defer func() {
stepResult.Elapsed = time.Since(start).Milliseconds()

View File

@@ -51,7 +51,7 @@ func (s *StepTestCaseWithOptionalArgs) Run(r *SessionRunner) (stepResult *StepRe
Name: s.Name(),
StepType: s.Type(),
Success: false,
StartTime: start.Unix(),
StartTime: start.UnixMilli(),
}
defer func() {

View File

@@ -709,7 +709,7 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err
StepType: step.Type(),
Success: false,
ContentSize: 0,
StartTime: start.Unix(),
StartTime: start.UnixMilli(),
}
var stepVariables map[string]interface{}
@@ -781,7 +781,7 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err
Method: option.ACTION_GetForegroundApp,
Params: "[ForDebug] check foreground app",
},
StartTime: startTime.Unix(),
StartTime: startTime.UnixMilli(),
}
subActionResults, err1 := uiDriver.ExecuteAction(
context.Background(), actionResult.MobileAction)
@@ -815,7 +815,7 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err
Method: option.ACTION_ClosePopups,
Params: "[ForDebug] close popups handler",
},
StartTime: startTime.Unix(),
StartTime: startTime.UnixMilli(),
}
subActionResults, err2 := uiDriver.ExecuteAction(
context.Background(), actionResult.MobileAction)
@@ -844,7 +844,7 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err
actionStartTime := time.Now()
actionResult := &ActionResult{
MobileAction: action,
StartTime: actionStartTime.Unix(), // action 开始时间
StartTime: actionStartTime.UnixMilli(), // action 开始时间
}
if action.Params, err = s.caseRunner.parser.Parse(action.Params, stepVariables); err != nil {
if !code.IsErrorPredefined(err) {

View File

@@ -381,7 +381,7 @@ func runStepWebSocket(r *SessionRunner, step IStep) (stepResult *StepResult, err
StepType: step.Type(),
Success: false,
ContentSize: 0,
StartTime: start.Unix(),
StartTime: start.UnixMilli(),
}
defer func() {

View File

@@ -59,7 +59,7 @@ func (dExt *XTDriver) StartToGoal(ctx context.Context, prompt string, opts ...op
ModelName: "",
Error: err.Error(),
},
StartTime: planningStartTime.Unix(),
StartTime: planningStartTime.UnixMilli(),
Elapsed: time.Since(planningStartTime).Milliseconds(),
}
allPlannings = append(allPlannings, errorResult)
@@ -67,7 +67,7 @@ func (dExt *XTDriver) StartToGoal(ctx context.Context, prompt string, opts ...op
}
// Set planning execution timing
planningResult.StartTime = planningStartTime.Unix()
planningResult.StartTime = planningStartTime.UnixMilli()
planningResult.SubActions = []*SubActionResult{}
// Check if task is finished BEFORE executing actions
@@ -96,7 +96,7 @@ func (dExt *XTDriver) StartToGoal(ctx context.Context, prompt string, opts ...op
subActionResult := &SubActionResult{
ActionName: toolCall.Function.Name,
Arguments: toolCall.Function.Arguments,
StartTime: subActionStartTime.Unix(),
StartTime: subActionStartTime.UnixMilli(),
}
// Use defer to ensure sub-action is always processed and added to results

View File

@@ -132,7 +132,7 @@ func (dExt *XTDriver) ExecuteAction(ctx context.Context, action option.MobileAct
subActionResult := &SubActionResult{
ActionName: string(action.Method),
Arguments: action.Params,
StartTime: subActionStartTime.Unix(),
StartTime: subActionStartTime.UnixMilli(),
}
// Execute via MCP tool