Initial public release of Warp.

Repo-Sync-Origin: warpdotdev/warp-internal@12af1d983b
This commit is contained in:
David Stern
2026-04-28 08:43:33 -05:00
commit 0dbd3d567a
4982 changed files with 1431549 additions and 0 deletions
+100
View File
@@ -0,0 +1,100 @@
use std::{collections::HashMap, sync::Arc};
use super::*;
use crate::ai::agent::{task::TaskId, AIAgentActionResultType};
fn make_action_result(id: &str) -> Arc<AIAgentActionResult> {
Arc::new(AIAgentActionResult {
id: AIAgentActionId::from(id.to_owned()),
task_id: TaskId::new("task".to_owned()),
result: AIAgentActionResultType::InitProject,
})
}
fn count_startable_actions_for_pass(phases: &[(RunningActionPhase, bool)]) -> usize {
let mut current_phase = None;
let mut count = 0;
for (phase, can_autoexecute) in phases {
if let Some(current_phase) = current_phase {
if !can_start_action_with_current_phase(current_phase, *phase, *can_autoexecute) {
break;
}
}
count += 1;
current_phase = Some(*phase);
if matches!(*phase, RunningActionPhase::Serial) {
break;
}
}
count
}
#[test]
fn parallel_phase_only_admits_matching_autoexecutable_actions() {
let phase =
RunningActionPhase::Parallel(execute::ParallelExecutionPolicy::ReadOnlyLocalContext);
assert!(can_start_action_with_current_phase(phase, phase, true));
assert!(!can_start_action_with_current_phase(phase, phase, false));
assert!(!can_start_action_with_current_phase(
phase,
RunningActionPhase::Serial,
true
));
assert!(!can_start_action_with_current_phase(
RunningActionPhase::Serial,
phase,
true
));
}
#[test]
fn phased_scheduling_stops_at_serial_barrier_and_resumes_afterward() {
let read_only_phase =
RunningActionPhase::Parallel(execute::ParallelExecutionPolicy::ReadOnlyLocalContext);
let actions = vec![
(read_only_phase, true),
(read_only_phase, true),
(RunningActionPhase::Serial, true),
(read_only_phase, true),
(read_only_phase, true),
];
assert_eq!(count_startable_actions_for_pass(&actions), 2);
assert_eq!(count_startable_actions_for_pass(&actions[2..]), 1);
assert_eq!(count_startable_actions_for_pass(&actions[3..]), 2);
}
#[test]
fn finished_results_stay_in_original_action_order() {
let action_order = HashMap::from([
(AIAgentActionId::from("first".to_owned()), 0),
(AIAgentActionId::from("second".to_owned()), 1),
(AIAgentActionId::from("third".to_owned()), 2),
]);
let mut finished_results = [
make_action_result("third"),
make_action_result("first"),
make_action_result("second"),
];
finished_results
.sort_by_key(|result| action_order.get(&result.id).copied().unwrap_or(usize::MAX));
assert_eq!(
finished_results[0].id,
AIAgentActionId::from("first".to_owned())
);
assert_eq!(
finished_results[1].id,
AIAgentActionId::from("second".to_owned())
);
assert_eq!(
finished_results[2].id,
AIAgentActionId::from("third".to_owned())
);
}