      update_line_data(s, road_edges[i], 0.025, 0, &scene.road_edge_vertices[i], max_distance);
    }
  
    // update path
    const float lead_d = scene.lead_data[0].getStatus() ? scene.lead_data[0].getDRel() * 2. : MAX_DRAW_DISTANCE;
    float path_length = (lead_d > 0.) ? lead_d - fmin(lead_d * 0.35, 10.) : MAX_DRAW_DISTANCE;
    path_length = fmin(path_length, max_distance);
    update_line_data(s, model.getPosition(), 0.5, 1.22, &scene.track_vertices, path_length);
  }
  
  static void update_sockets(UIState *s) {
    SubMaster &sm = *(s->sm);
    if (sm.update(0) == 0) return;
 
</s> remove     update_line_data(s, road_edges[i], 0.025, 0, &scene.road_edge_vertices[i], max_distance);
 </s> add     update_line_data(s, road_edges[i], 0.025, 0, &scene.road_edge_vertices[i], max_idx); </s> remove     update_line_data(s, lane_lines[i], 0.025 * scene.lane_line_probs[i], 0, &scene.lane_line_vertices[i], max_distance);
 </s> add     update_line_data(s, lane_lines[i], 0.025 * scene.lane_line_probs[i], 0, &scene.lane_line_vertices[i], max_idx); </s> remove                              float y_off, float z_off, line_vertices_data *pvd, float max_distance) {
 </s> add                              float y_off, float z_off, line_vertices_data *pvd, int max_idx) { </s> remove   const float max_distance = fmin(model.getPosition().getX()[TRAJECTORY_SIZE - 1], MAX_DRAW_DISTANCE);
 </s> add   auto model_position = model.getPosition();
  const float max_distance = std::clamp(model_position.getX()[TRAJECTORY_SIZE - 1],
                                        MIN_DRAW_DISTANCE, MAX_DRAW_DISTANCE);

  int max_idx = get_path_length_idx(model_position, max_distance); </s> remove   int max_idx = -1;
 </s> add 
  if (scene.lead_data[0].getStatus()) {
    const float lead_d = scene.lead_data[0].getDRel() * 2.;
    const float path_length = std::clamp((float)(lead_d - fmin(lead_d * 0.35, 10.)),
                                         0.0f, max_distance);
    max_idx = get_path_length_idx(model_position, path_length);
  }
  update_line_data(s, model_position, 0.5, 1.22, &scene.track_vertices, max_idx);
      update_line_data(s, road_edges[i], 0.025, 0, &scene.road_edge_vertices[i], max_distance);
    }
  
    // update path
  if (scene.lead_data[0].getStatus()) {
    const float lead_d = scene.lead_data[0].getDRel() * 2.;
    const float path_length = std::clamp((float)(lead_d - fmin(lead_d * 0.35, 10.)),
                                         0.0f, max_distance);
    max_idx = get_path_length_idx(model_position, path_length);
  }
  update_line_data(s, model_position, 0.5, 1.22, &scene.track_vertices, max_idx);
  if (scene.lead_data[0].getStatus()) {
    const float lead_d = scene.lead_data[0].getDRel() * 2.;
    const float path_length = std::clamp((float)(lead_d - fmin(lead_d * 0.35, 10.)),
                                         0.0f, max_distance);
    max_idx = get_path_length_idx(model_position, path_length);
  }
  update_line_data(s, model_position, 0.5, 1.22, &scene.track_vertices, max_idx);
  if (scene.lead_data[0].getStatus()) {
    const float lead_d = scene.lead_data[0].getDRel() * 2.;
    const float path_length = std::clamp((float)(lead_d - fmin(lead_d * 0.35, 10.)),
                                         0.0f, max_distance);
    max_idx = get_path_length_idx(model_position, path_length);
  }
  update_line_data(s, model_position, 0.5, 1.22, &scene.track_vertices, max_idx);
  if (scene.lead_data[0].getStatus()) {
    const float lead_d = scene.lead_data[0].getDRel() * 2.;
    const float path_length = std::clamp((float)(lead_d - fmin(lead_d * 0.35, 10.)),
                                         0.0f, max_distance);
    max_idx = get_path_length_idx(model_position, path_length);
  }
  update_line_data(s, model_position, 0.5, 1.22, &scene.track_vertices, max_idx);
  }
  
  static void update_sockets(UIState *s) {
    SubMaster &sm = *(s->sm);
    if (sm.update(0) == 0) return;
keep keep keep keep replace replace replace replace keep keep keep keep keep
 ui/update_line_data: use max_idx as paramater instead of max_distance (#20256) 
selfdrive/ui/ui.cc