mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 20:17:09 +00:00
refactor(inspect): decode trace step's next_action JSON field
Mirrors the trace schema rename of action to next_action. The summary shape exposed to the SPA (action_kind/action_label) keeps its current JSON tags since these are derived labels, not the raw next-action.
This commit is contained in:
1 parent
332e7a034d
commit
7916123458
1 file changed
+17
-17
@@ -61,7 +61,7 @@ func decodeStepSummary(line []byte) (StepSummary, int, error) {
|
|||||||
Index int `json:"step"`
|
Index int `json:"step"`
|
||||||
Timestamp time.Time `json:"timestamp"`
|
Timestamp time.Time `json:"timestamp"`
|
||||||
Screen string `json:"screen,omitempty"`
|
Screen string `json:"screen,omitempty"`
|
||||||
Action *struct {
|
NextAction *struct {
|
||||||
Kind string `json:"kind"`
|
Kind string `json:"kind"`
|
||||||
X int `json:"x,omitempty"`
|
X int `json:"x,omitempty"`
|
||||||
Y int `json:"y,omitempty"`
|
Y int `json:"y,omitempty"`
|
||||||
@@ -73,7 +73,7 @@ func decodeStepSummary(line []byte) (StepSummary, int, error) {
|
|||||||
Text string `json:"text,omitempty"`
|
Text string `json:"text,omitempty"`
|
||||||
Selector string `json:"selector,omitempty"`
|
Selector string `json:"selector,omitempty"`
|
||||||
DurationMillis int `json:"duration_millis,omitempty"`
|
DurationMillis int `json:"duration_millis,omitempty"`
|
||||||
} `json:"action,omitempty"`
|
} `json:"next_action,omitempty"`
|
||||||
Exceptions []json.RawMessage `json:"exceptions,omitempty"`
|
Exceptions []json.RawMessage `json:"exceptions,omitempty"`
|
||||||
Violations []string `json:"violations,omitempty"`
|
Violations []string `json:"violations,omitempty"`
|
||||||
}
|
}
|
||||||
@@ -87,29 +87,29 @@ func decodeStepSummary(line []byte) (StepSummary, int, error) {
|
|||||||
HasViolations: len(partial.Violations) > 0,
|
HasViolations: len(partial.Violations) > 0,
|
||||||
HasExceptions: len(partial.Exceptions) > 0,
|
HasExceptions: len(partial.Exceptions) > 0,
|
||||||
}
|
}
|
||||||
if partial.Action != nil {
|
if partial.NextAction != nil {
|
||||||
summary.ActionKind = partial.Action.Kind
|
summary.ActionKind = partial.NextAction.Kind
|
||||||
switch partial.Action.Kind {
|
switch partial.NextAction.Kind {
|
||||||
case "Tap", "DoubleTap":
|
case "Tap", "DoubleTap":
|
||||||
if partial.Action.Selector != "" {
|
if partial.NextAction.Selector != "" {
|
||||||
summary.ActionLabel = partial.Action.Selector
|
summary.ActionLabel = partial.NextAction.Selector
|
||||||
} else if partial.Action.Text != "" {
|
} else if partial.NextAction.Text != "" {
|
||||||
summary.ActionLabel = partial.Action.Text
|
summary.ActionLabel = partial.NextAction.Text
|
||||||
} else if partial.Action.X != 0 || partial.Action.Y != 0 {
|
} else if partial.NextAction.X != 0 || partial.NextAction.Y != 0 {
|
||||||
summary.ActionLabel = fmt.Sprintf("(%d,%d)", partial.Action.X, partial.Action.Y)
|
summary.ActionLabel = fmt.Sprintf("(%d,%d)", partial.NextAction.X, partial.NextAction.Y)
|
||||||
}
|
}
|
||||||
case "InputText":
|
case "InputText":
|
||||||
summary.ActionLabel = fmt.Sprintf("%q", partial.Action.Text)
|
summary.ActionLabel = fmt.Sprintf("%q", partial.NextAction.Text)
|
||||||
case "Swipe":
|
case "Swipe":
|
||||||
summary.ActionLabel = swipeDirectionLabel(
|
summary.ActionLabel = swipeDirectionLabel(
|
||||||
partial.Action.FromX, partial.Action.FromY,
|
partial.NextAction.FromX, partial.NextAction.FromY,
|
||||||
partial.Action.ToX, partial.Action.ToY,
|
partial.NextAction.ToX, partial.NextAction.ToY,
|
||||||
)
|
)
|
||||||
case "PressKey":
|
case "PressKey":
|
||||||
summary.ActionLabel = partial.Action.Key
|
summary.ActionLabel = partial.NextAction.Key
|
||||||
case "Wait":
|
case "Wait":
|
||||||
if partial.Action.DurationMillis > 0 {
|
if partial.NextAction.DurationMillis > 0 {
|
||||||
summary.ActionLabel = fmt.Sprintf("%dms", partial.Action.DurationMillis)
|
summary.ActionLabel = fmt.Sprintf("%dms", partial.NextAction.DurationMillis)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user