MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / run_batch_steps

Function run_batch_steps

packages/server/src/api/action_execution.rs:460–528  ·  view source on GitHub ↗
(
    state: AppState,
    udid: String,
    payload: BatchPayload,
)

Source from the content-addressed store, hash-verified

458}
459
460async fn run_batch_steps(
461 state: AppState,
462 udid: String,
463 payload: BatchPayload,
464) -> Result<Value, AppError> {
465 if payload.steps.is_empty() {
466 return Err(AppError::bad_request(
467 "Batch action must include at least one step.",
468 ));
469 }
470 if payload.steps.len() > 256 {
471 return Err(AppError::bad_request(
472 "Batch action cannot contain more than 256 steps.",
473 ));
474 }
475
476 let continue_on_error = payload.continue_on_error.unwrap_or(false);
477 let mut results = Vec::new();
478 let mut failure_count = 0usize;
479 let mut should_warm_after_batch = false;
480 for (index, step) in payload.steps.into_iter().enumerate() {
481 let invalidates_ax_cache = batch_step_invalidates_ax_cache(&step);
482 let should_warm_ax = batch_step_should_warm_ax(&step);
483 if invalidates_ax_cache {
484 state.accessibility_cache.invalidate(&udid);
485 }
486 let started = Instant::now();
487 let result = run_batch_step(state.clone(), udid.clone(), step).await;
488 let elapsed_ms = started.elapsed().as_millis() as u64;
489 match result {
490 Ok(value) => {
491 if should_warm_ax {
492 should_warm_after_batch = true;
493 }
494 results.push(json_value!({
495 "index": index,
496 "ok": true,
497 "elapsedMs": elapsed_ms,
498 "result": value,
499 }));
500 }
501 Err(error) => {
502 failure_count += 1;
503 let message = error.to_string();
504 results.push(json_value!({
505 "index": index,
506 "ok": false,
507 "elapsedMs": elapsed_ms,
508 "error": message,
509 }));
510 if !continue_on_error {
511 return Err(AppError::bad_request(format!(
512 "Batch step {} failed: {}",
513 index + 1,
514 message
515 )));
516 }
517 }

Callers 1

simulator_actionFunction · 0.85

Calls 7

is_emptyMethod · 0.80
invalidateMethod · 0.80
run_batch_stepFunction · 0.70
cloneMethod · 0.65

Tested by

no test coverage detected