Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/src/ai/blocklist/action_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,9 @@ impl BlocklistAIActionModel {
self.handle_action_result(conversation_id, Arc::new(action_result), None, ctx);
}

pub(super) fn cancel_action_with_id(
/// Cancels a running or pending action by id with the given reason.
/// Public because both frontends' permission cards route Reject here.
pub fn cancel_action_with_id(
&mut self,
conversation_id: AIConversationId,
action_id: &AIAgentActionId,
Expand Down
3 changes: 3 additions & 0 deletions app/src/ai/blocklist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ pub(crate) use action_model::{
pub use action_model::{
BlocklistAIActionEvent, BlocklistAIActionModel, ShellCommandExecutor, ShellCommandExecutorEvent,
};
// Consumed by `tui_export` for the `warp_tui` frontend.
#[cfg_attr(not(feature = "tui"), allow(unused_imports))]
pub use action_model::{RunAgentsExecutor, RunAgentsExecutorEvent, RunAgentsSpawningSnapshot};
#[cfg(any(test, feature = "integration_tests"))]
pub(crate) use block::model::testing::FakeAIBlockModel;
pub(crate) use block::{init, model, AIBlock, AIBlockEvent, RequestedEditResolution};
Expand Down
58 changes: 36 additions & 22 deletions app/src/ai/orchestration/config_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ pub struct OrchestrationConfigState {
pub model_id: String,
pub harness_type: String,
pub execution_mode: RunAgentsExecutionMode,
/// Per-call value hidden from the orchestration editors. Kept outside
/// `execution_mode` so a temporary switch to Local does not discard it.
remote_computer_use_enabled: bool,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is remote_computer_use_enabled stored outside of execution_mode but other fields are not?

/// Drives the picker display and Accept gate. Persisted as
/// `Named(_)` only via `CloudAgentSettings.last_selected_auth_secret`.
pub auth_secret_selection: AuthSecretSelection,
Expand Down Expand Up @@ -92,10 +95,19 @@ impl OrchestrationConfigState {
harness_type: Option<&str>,
execution_mode: &RunAgentsExecutionMode,
) -> Self {
let remote_computer_use_enabled = match execution_mode {
RunAgentsExecutionMode::Local => false,
RunAgentsExecutionMode::Remote {
computer_use_enabled,
..
} => *computer_use_enabled,
};

Self {
model_id: model_id.unwrap_or_default().to_string(),
harness_type: harness_type.unwrap_or_default().to_string(),
execution_mode: execution_mode.clone(),
remote_computer_use_enabled,
auth_secret_selection: AuthSecretSelection::Unset,
}
}
Expand All @@ -116,6 +128,7 @@ impl OrchestrationConfigState {
model_id: config.model_id.clone(),
harness_type: config.harness_type.clone(),
execution_mode,
remote_computer_use_enabled: false,
auth_secret_selection: AuthSecretSelection::Unset,
};
if matches!(state.execution_mode, RunAgentsExecutionMode::Local) {
Expand All @@ -135,10 +148,17 @@ impl OrchestrationConfigState {
self.execution_mode = RunAgentsExecutionMode::Remote {
environment_id: String::new(),
worker_host: ORCHESTRATION_WARP_WORKER_HOST.to_string(),
computer_use_enabled: false,
computer_use_enabled: self.remote_computer_use_enabled,
};
}
} else {
if let RunAgentsExecutionMode::Remote {
computer_use_enabled,
..
} = &self.execution_mode
{
self.remote_computer_use_enabled = *computer_use_enabled;
}
self.execution_mode = RunAgentsExecutionMode::Local;
self.sanitize_for_local_execution();
}
Expand Down Expand Up @@ -204,34 +224,28 @@ impl OrchestrationConfigState {
/// user-approved source of truth — the LLM's run_agents call may
/// omit or set these differently, but the config always wins.
///
/// `computer_use_enabled` is preserved from the current state when
/// both sides are Remote, since it is a per-call flag set by the LLM.
/// `computer_use_enabled` is preserved when the config changes execution
/// mode, since it is a per-call flag rather than part of the approved plan
/// configuration.
pub fn override_from_approved_config(&mut self, config: &OrchestrationConfig) {
self.model_id = config.model_id.clone();
self.harness_type = config.harness_type.clone();

let preserve_computer_use = match (&self.execution_mode, &config.execution_mode) {
(
RunAgentsExecutionMode::Remote {
computer_use_enabled,
..
},
OrchestrationExecutionMode::Remote { .. },
) => Some(*computer_use_enabled),
_ => None,
};
if let RunAgentsExecutionMode::Remote {
computer_use_enabled,
..
} = &self.execution_mode
{
self.remote_computer_use_enabled = *computer_use_enabled;
}

self.execution_mode = Self::from_orchestration_config(config).execution_mode;

if let (
Some(cue),
RunAgentsExecutionMode::Remote {
computer_use_enabled,
..
},
) = (preserve_computer_use, &mut self.execution_mode)
if let RunAgentsExecutionMode::Remote {
computer_use_enabled,
..
} = &mut self.execution_mode
{
*computer_use_enabled = cue;
*computer_use_enabled = self.remote_computer_use_enabled;
}
}

Expand Down
24 changes: 24 additions & 0 deletions app/src/ai/orchestration/config_state_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,30 @@ fn toggle_to_local_sanitizes_disabled_codex() {
));
}

#[test]
fn local_round_trip_preserves_remote_computer_use() {
let mut state = OrchestrationConfigState::from_run_agents_fields(
Some("auto"),
Some("oz"),
&RunAgentsExecutionMode::Remote {
environment_id: "env-1".to_string(),
worker_host: "warp".to_string(),
computer_use_enabled: true,
},
);

state.toggle_execution_mode_to_remote(false);
state.toggle_execution_mode_to_remote(true);

assert!(matches!(
state.execution_mode,
RunAgentsExecutionMode::Remote {
computer_use_enabled: true,
..
}
));
}

#[test]
fn toggle_to_local_preserves_claude() {
let mut state = OrchestrationConfigState::from_run_agents_fields(
Expand Down
50 changes: 50 additions & 0 deletions app/src/ai/orchestration/edit_state_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,56 @@ fn execution_mode_change_prefers_valid_fallback_over_default_model() {
assert_eq!(state.model_id, "fallback");
}

#[test]
fn forcing_oz_before_local_preserves_codex_model_memory() {
let state = OrchestrationConfigState::from_run_agents_fields(
Some("gpt-5"),
Some("codex"),
&remote_mode(),
);
let mut edit_state = OrchestrationEditState {
orchestration_config_state: state,
saved_model_per_harness: HashMap::from([("oz".to_string(), "auto".to_string())]),
};
let model_is_valid = |id: &str, harness: &str, _is_local: bool| match harness {
"oz" => id == "auto",
"codex" => id == "gpt-5",
_ => false,
};
let default_model_id = |harness: &str| match harness {
"oz" => Some("auto".to_string()),
"codex" => Some(String::new()),
_ => None,
};

edit_state.apply_harness_change_core(
"oz",
Some("auto".to_string()),
AuthSecretSelection::Unset,
&model_is_valid,
&default_model_id,
);
edit_state
.orchestration_config_state
.apply_execution_mode_change_core(
false,
Some("auto".to_string()),
None,
&model_is_valid,
&default_model_id,
);

assert_eq!(edit_state.orchestration_config_state.harness_type, "oz");
assert_eq!(edit_state.orchestration_config_state.model_id, "auto");
assert!(matches!(
edit_state.orchestration_config_state.execution_mode,
RunAgentsExecutionMode::Local
));
assert_eq!(
edit_state.saved_model_per_harness.get("codex"),
Some(&"gpt-5".to_string())
);
}
#[test]
fn harness_change_saves_and_restores_per_harness_model_memory() {
let state = OrchestrationConfigState::from_run_agents_fields(
Expand Down
2 changes: 1 addition & 1 deletion app/src/settings/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ pub fn init_private_user_preferences() -> settings::PrivatePreferences {
pub fn init_public_user_preferences() -> (user_preferences::Model, Option<user_preferences::Error>)
{
cfg_if::cfg_if! {
if #[cfg(test)] {
if #[cfg(any(test, feature = "test-util"))] {
(Box::<user_preferences::in_memory::InMemoryPreferences>::default(), None)
} else if #[cfg(target_family = "wasm")] {
(Box::<user_preferences::local_storage::LocalStoragePreferences>::default(), None)
Expand Down
12 changes: 11 additions & 1 deletion app/src/tui_export.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Public app APIs used by the `warp_tui` frontend.

pub use ai::agent::action::{RunAgentsAgentRunConfig, RunAgentsExecutionMode, RunAgentsRequest};
pub use ai::agent::orchestration_config::{OrchestrationConfig, OrchestrationConfigStatus};
pub use repo_metadata::repositories::RepoDetectionSource;
pub use warp_cli::agent::Harness;
use warp_completer::completer::{CompletionContext as _, TopLevelCommandCaseSensitivity};
Expand Down Expand Up @@ -59,13 +61,21 @@ pub use crate::ai::blocklist::{
block_context_from_terminal_model, AIActionStatus, BlocklistAIActionEvent,
BlocklistAIActionModel, BlocklistAIContextModel, BlocklistAIController, BlocklistAIInputModel,
InputConfig, InputModePolicy, InputModePolicyHandle, InputType, InputTypeAutoDetectionSource,
PolicyConfigUpdate, RequestFileEditsExecutor, ShellCommandExecutor, ShellCommandExecutorEvent,
PolicyConfigUpdate, RequestFileEditsExecutor, RunAgentsExecutor, RunAgentsExecutorEvent,
RunAgentsSpawningSnapshot, ShellCommandExecutor, ShellCommandExecutorEvent,
};
pub use crate::ai::connected_self_hosted_workers::{
ConnectedSelfHostedWorkersEvent, ConnectedSelfHostedWorkersModel,
};
#[cfg(feature = "local_fs")]
pub use crate::ai::conversation_export::{
export_conversation_markdown, ConversationFileExport, ConversationFileExportError,
};
pub use crate::ai::get_relevant_files::controller::GetRelevantFilesController;
pub use crate::ai::harness_availability::{
AuthSecretEntry, AuthSecretFetchState, HarnessAvailability, HarnessAvailabilityEvent,
HarnessAvailabilityModel, HarnessModelInfo,
};
pub use crate::ai::llms::{LLMId, LLMInfo, LLMPreferences, LLMPreferencesEvent};
pub use crate::ai::orchestration::{
accept_disabled_reason_with_auth, api_key_snapshot, auth_secret_selection_required,
Expand Down
Loading