code: func fixComponent(comp *BuildComponent, buildFinished time.Time, stripPrefix string, collapseGreen bool) {
  	// If the build is finished but the step is not finished.
  	if !buildFinished.IsZero() && comp.ExecutionTime.Finished.IsZero() {
  		// Then set the finish time to be the same as the build finish time.
  		comp.ExecutionTime.Finished = buildFinished
  		comp.ExecutionTime.Duration = buildFinished.Sub(comp.ExecutionTime.Started)
  		comp.Status = model.InfraFailure
  	}
  
  	// Fix substeps recursively.
  	for _, substep := range comp.Children {
  		fixComponent(
  			substep, buildFinished, comp.Label.String()+".", collapseGreen)
  	}
  
  	// When parent step finishes running, compute its final status as worst
  	// status, as determined by statusPrecendence map above, among direct children
  	// and its own status.
  	if comp.Status.Terminal() {
  		for _, substep := range comp.Children {
  			substepStatusPrecedence, ok := statusPrecendence[substep.Status]
  			if ok && substepStatusPrecedence < statusPrecendence[comp.Status] {
  				comp.Status = substep.Status
  			}
  		}
  	}
  
  	comp.Collapsed = collapseGreen && comp.Status == model.Success
  
  	// Strip parent component name from the title.
  	if comp.Label != nil {
  		comp.Label.Label = strings.TrimPrefix(comp.Label.Label, stripPrefix)
  	}
  }
docs: // fixComponent fixes possible display inconsistencies with the build, including:
  //
  // * If the build is complete, all open steps should be closed.
  // * Parent steps containing failed steps should also be marked as failed.
  // * Components' Collapsed field is set based on StepDisplayPref field.
  // * Parent step name prefix is trimmed from the nested substeps.
  // * Enforce correct values for StepDisplayPref (set to Collapsed if incorrect).