Skip to content

Commit 1acd835

Browse files
committed
wip4
1 parent 49cd08a commit 1acd835

26 files changed

Lines changed: 169 additions & 309 deletions

app/src/ai/blocklist/action_model/execute.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -967,35 +967,36 @@ impl BlocklistAIActionExecutor {
967967
| AIAgentActionType::ReadShellCommandOutput { .. }
968968
| AIAgentActionType::TransferShellCommandControlToUser { .. } => {
969969
self.shell_command_executor.update(ctx, |executor, ctx| {
970-
executor.should_autoexecute(input, &team_context_resolver, ctx)
970+
executor.should_autoexecute(input, &team_context_resolver(ctx), ctx)
971971
})
972972
}
973973
AIAgentActionType::ReadFiles(_) => {
974974
self.read_files_executor.update(ctx, |executor, ctx| {
975-
executor.should_autoexecute(input, &team_context_resolver, ctx)
975+
executor.should_autoexecute(input, &team_context_resolver(ctx), ctx)
976976
})
977977
}
978978
AIAgentActionType::UploadArtifact(_) => {
979979
self.upload_artifact_executor.update(ctx, |executor, ctx| {
980-
executor.should_autoexecute(input, &team_context_resolver, ctx)
980+
executor.should_autoexecute(input, &team_context_resolver(ctx), ctx)
981981
})
982982
}
983983
AIAgentActionType::SearchCodebase(_) => {
984984
self.search_codebase_executor.update(ctx, |executor, ctx| {
985-
executor.should_autoexecute(input, &team_context_resolver, ctx)
985+
executor.should_autoexecute(input, &team_context_resolver(ctx), ctx)
986986
})
987987
}
988-
AIAgentActionType::RequestFileEdits { .. } => self
989-
.request_file_edits_executor
990-
.update(ctx, |executor, ctx| {
991-
executor.should_autoexecute(input, &team_context_resolver, ctx)
992-
}),
988+
AIAgentActionType::RequestFileEdits { .. } => {
989+
self.request_file_edits_executor
990+
.update(ctx, |executor, ctx| {
991+
executor.should_autoexecute(input, &team_context_resolver(ctx), ctx)
992+
})
993+
}
993994
AIAgentActionType::Grep { .. } => self.grep_executor.update(ctx, |executor, ctx| {
994-
executor.should_autoexecute(input, &team_context_resolver, ctx)
995+
executor.should_autoexecute(input, &team_context_resolver(ctx), ctx)
995996
}),
996997
AIAgentActionType::FileGlob { .. } | AIAgentActionType::FileGlobV2 { .. } => {
997998
self.file_glob_executor.update(ctx, |executor, ctx| {
998-
executor.should_autoexecute(input, &team_context_resolver, ctx)
999+
executor.should_autoexecute(input, &team_context_resolver(ctx), ctx)
9991000
})
10001001
}
10011002
AIAgentActionType::CallMCPTool { .. } => self
@@ -1025,11 +1026,12 @@ impl BlocklistAIActionExecutor {
10251026
AIAgentActionType::UseComputer(_) => self
10261027
.use_computer_executor
10271028
.update(ctx, |executor, ctx| executor.should_autoexecute(input, ctx)),
1028-
AIAgentActionType::RequestComputerUse(_) => self
1029-
.request_computer_use_executor
1030-
.update(ctx, |executor, ctx| {
1031-
executor.should_autoexecute(input, &team_context_resolver, ctx)
1032-
}),
1029+
AIAgentActionType::RequestComputerUse(_) => {
1030+
self.request_computer_use_executor
1031+
.update(ctx, |executor, ctx| {
1032+
executor.should_autoexecute(input, &team_context_resolver(ctx), ctx)
1033+
})
1034+
}
10331035
AIAgentActionType::StartRecording { .. } => self
10341036
.start_recording_executor
10351037
.update(ctx, |executor, ctx| executor.should_autoexecute(input, ctx)),

app/src/ai/blocklist/action_model/execute/file_glob.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::terminal::model::session::active_session::ActiveSession;
2121
use crate::terminal::model::session::command_executor::shell_quote_arg;
2222
use crate::terminal::model::session::{ExecuteCommandOptions, Session};
2323
use crate::terminal::shell::ShellType;
24-
use crate::workspaces::user_workspaces::TeamContextResolver;
24+
use crate::workspaces::user_workspaces::TeamContext;
2525
use crate::{TelemetryEvent, send_telemetry_from_app_ctx};
2626

2727
const FILE_GLOB_TIMEOUT: Duration = Duration::from_secs(10);
@@ -54,8 +54,8 @@ impl FileGlobExecutor {
5454
pub(super) fn should_autoexecute(
5555
&self,
5656
input: ExecuteActionInput,
57-
team_context_resolver: &TeamContextResolver,
58-
ctx: &mut ModelContext<Self>,
57+
scope: &TeamContext<'_>,
58+
ctx: &ModelContext<Self>,
5959
) -> bool {
6060
let ExecuteActionInput {
6161
action:
@@ -85,13 +85,12 @@ impl FileGlobExecutor {
8585
let absolute_path =
8686
host_native_absolute_path(path.as_str(), &shell, &current_working_directory);
8787

88-
let scope = team_context_resolver(ctx);
8988
BlocklistAIPermissions::as_ref(ctx)
9089
.can_read_files_with_conversation(
9190
&conversation_id,
9291
vec![PathBuf::from(absolute_path)],
9392
Some(self.terminal_view_id),
94-
&scope,
93+
scope,
9594
ctx,
9695
)
9796
.is_allowed()

app/src/ai/blocklist/action_model/execute/grep.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use crate::terminal::ShellLaunchData;
2828
use crate::terminal::model::session::active_session::ActiveSession;
2929
use crate::terminal::model::session::{ExecuteCommandOptions, Session, shell_quote_arg};
3030
use crate::terminal::shell::ShellType;
31-
use crate::workspaces::user_workspaces::TeamContextResolver;
31+
use crate::workspaces::user_workspaces::TeamContext;
3232
use crate::{PrivacySettings, TelemetryEvent, send_telemetry_from_app_ctx};
3333

3434
const GREP_TIMEOUT: Duration = Duration::from_secs(10);
@@ -194,8 +194,8 @@ impl GrepExecutor {
194194
pub(super) fn should_autoexecute(
195195
&self,
196196
input: ExecuteActionInput,
197-
team_context_resolver: &TeamContextResolver,
198-
ctx: &mut ModelContext<Self>,
197+
scope: &TeamContext<'_>,
198+
ctx: &ModelContext<Self>,
199199
) -> bool {
200200
let ExecuteActionInput {
201201
action:
@@ -217,14 +217,13 @@ impl GrepExecutor {
217217
let shell = self.active_session.as_ref(ctx).shell_launch_data(ctx);
218218
let absolute_path = host_native_absolute_path(path, &shell, &current_working_directory);
219219

220-
let scope = team_context_resolver(ctx);
221220
BlocklistAIPermissions::handle(ctx)
222221
.as_ref(ctx)
223222
.can_read_files_with_conversation(
224223
&conversation_id,
225224
vec![PathBuf::from(absolute_path)],
226225
Some(self.terminal_view_id),
227-
&scope,
226+
scope,
228227
ctx,
229228
)
230229
.is_allowed()

app/src/ai/blocklist/action_model/execute/read_files.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::ai::blocklist::BlocklistAIPermissions;
1616
use crate::ai::paths::host_native_absolute_path;
1717
use crate::terminal::model::session::SessionType;
1818
use crate::terminal::model::session::active_session::ActiveSession;
19-
use crate::workspaces::user_workspaces::TeamContextResolver;
19+
use crate::workspaces::user_workspaces::TeamContext;
2020

2121
pub struct ReadFilesExecutor {
2222
active_session: ModelHandle<ActiveSession>,
@@ -34,8 +34,8 @@ impl ReadFilesExecutor {
3434
pub(super) fn should_autoexecute(
3535
&self,
3636
input: ExecuteActionInput,
37-
team_context_resolver: &TeamContextResolver,
38-
ctx: &mut ModelContext<Self>,
37+
scope: &TeamContext<'_>,
38+
ctx: &ModelContext<Self>,
3939
) -> bool {
4040
let ExecuteActionInput {
4141
action:
@@ -58,7 +58,6 @@ impl ReadFilesExecutor {
5858
.cloned();
5959
let shell = self.active_session.as_ref(ctx).shell_launch_data(ctx);
6060

61-
let scope = team_context_resolver(ctx);
6261
BlocklistAIPermissions::as_ref(ctx)
6362
.can_read_files_with_conversation(
6463
&conversation_id,
@@ -73,7 +72,7 @@ impl ReadFilesExecutor {
7372
})
7473
.collect(),
7574
Some(self.terminal_view_id),
76-
&scope,
75+
scope,
7776
ctx,
7877
)
7978
.is_allowed()

app/src/ai/blocklist/action_model/execute/request_computer_use.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::ai::blocklist::BlocklistAIHistoryModel;
1212
use crate::features::FeatureFlag;
1313
use crate::send_telemetry_from_ctx;
1414
use crate::server::telemetry::TelemetryEvent;
15-
use crate::workspaces::user_workspaces::TeamContextResolver;
15+
use crate::workspaces::user_workspaces::TeamContext;
1616

1717
pub struct RequestComputerUseExecutor {
1818
terminal_view_id: EntityId,
@@ -38,18 +38,17 @@ impl RequestComputerUseExecutor {
3838
pub(super) fn should_autoexecute(
3939
&mut self,
4040
input: ExecuteActionInput,
41-
team_context_resolver: &TeamContextResolver,
42-
ctx: &mut ModelContext<Self>,
41+
scope: &TeamContext<'_>,
42+
ctx: &ModelContext<Self>,
4343
) -> bool {
4444
let ExecuteActionInput { action, .. } = input;
4545
let AIAgentActionType::RequestComputerUse(_) = &action.action else {
4646
return false;
4747
};
4848

4949
// Check profile permission
50-
let scope = team_context_resolver(ctx);
5150
let permission = crate::ai::blocklist::BlocklistAIPermissions::as_ref(ctx)
52-
.get_computer_use_setting(Some(self.terminal_view_id), &scope, ctx);
51+
.get_computer_use_setting(Some(self.terminal_view_id), scope, ctx);
5352
if permission.is_always_allow() {
5453
// Track that this action was auto-executed for telemetry in execute()
5554
self.autoexecuted_actions.insert(action.id.clone());

app/src/ai/blocklist/action_model/execute/request_file_edits.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use crate::ai::blocklist::{BlocklistAIPermissions, RequestedEditResolution};
3636
use crate::ai::paths::host_native_absolute_path;
3737
use crate::terminal::model::session::SessionType;
3838
use crate::terminal::model::session::active_session::ActiveSession;
39-
use crate::workspaces::user_workspaces::TeamContextResolver;
39+
use crate::workspaces::user_workspaces::TeamContext;
4040
use crate::{BlocklistAIHistoryModel, safe_warn};
4141

4242
pub struct RequestFileEditsExecutor {
@@ -68,8 +68,8 @@ impl RequestFileEditsExecutor {
6868
pub(super) fn should_autoexecute(
6969
&self,
7070
input: ExecuteActionInput,
71-
team_context_resolver: &TeamContextResolver,
72-
ctx: &mut ModelContext<Self>,
71+
scope: &TeamContext<'_>,
72+
ctx: &ModelContext<Self>,
7373
) -> bool {
7474
let ExecuteActionInput {
7575
action:
@@ -111,13 +111,12 @@ impl RequestFileEditsExecutor {
111111
return true;
112112
}
113113

114-
let scope = team_context_resolver(ctx);
115114
BlocklistAIPermissions::as_ref(ctx)
116115
.can_write_files(
117116
&conversation_id,
118117
&paths,
119118
Some(self.terminal_view_id),
120-
&scope,
119+
scope,
121120
ctx,
122121
)
123122
.is_allowed()

app/src/ai/blocklist/action_model/execute/search_codebase.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::ai::get_relevant_files::controller::{
2424
};
2525
use crate::features::FeatureFlag;
2626
use crate::terminal::model::session::active_session::ActiveSession;
27-
use crate::workspaces::user_workspaces::TeamContextResolver;
27+
use crate::workspaces::user_workspaces::TeamContext;
2828
use crate::{TelemetryEvent, send_telemetry_from_ctx};
2929

3030
pub struct SearchCodebaseExecutor {
@@ -150,8 +150,8 @@ impl SearchCodebaseExecutor {
150150
pub(super) fn should_autoexecute(
151151
&self,
152152
input: ExecuteActionInput,
153-
team_context_resolver: &TeamContextResolver,
154-
ctx: &mut ModelContext<Self>,
153+
scope: &TeamContext<'_>,
154+
ctx: &ModelContext<Self>,
155155
) -> bool {
156156
let ExecuteActionInput {
157157
action:
@@ -166,15 +166,14 @@ impl SearchCodebaseExecutor {
166166
return false;
167167
};
168168

169-
let scope = team_context_resolver(ctx);
170169
self.root_repo_paths.get(id).is_none_or(|root_repo_path| {
171170
// If we have access to read the repo, we can auto-execute the search.
172171
BlocklistAIPermissions::as_ref(ctx)
173172
.can_read_files_with_conversation(
174173
&conversation_id,
175174
vec![root_repo_path.to_owned()],
176175
Some(self.terminal_view_id),
177-
&scope,
176+
scope,
178177
ctx,
179178
)
180179
.is_allowed()

app/src/ai/blocklist/action_model/execute/shell_command.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::terminal::model::block::{
3434
use crate::terminal::model::session::active_session::ActiveSession;
3535
use crate::terminal::model_events::{ModelEvent, ModelEventDispatcher};
3636
use crate::terminal::shell::ShellType;
37-
use crate::workspaces::user_workspaces::TeamContextResolver;
37+
use crate::workspaces::user_workspaces::TeamContext;
3838
use crate::{TelemetryEvent, send_telemetry_from_ctx};
3939

4040
pub struct ShellCommandExecutor {
@@ -108,10 +108,9 @@ impl ShellCommandExecutor {
108108
pub(super) fn should_autoexecute(
109109
&self,
110110
input: ExecuteActionInput,
111-
team_context_resolver: &TeamContextResolver,
112-
ctx: &mut ModelContext<Self>,
111+
scope: &TeamContext<'_>,
112+
ctx: &ModelContext<Self>,
113113
) -> bool {
114-
let scope = team_context_resolver(ctx);
115114
let blocklist_permissions = BlocklistAIPermissions::as_ref(ctx);
116115
match &input.action.action {
117116
AIAgentActionType::RequestCommandOutput {
@@ -135,7 +134,7 @@ impl ShellCommandExecutor {
135134
is_read_only.unwrap_or(false),
136135
*is_risky,
137136
Some(self.terminal_view_id),
138-
&scope,
137+
scope,
139138
ctx,
140139
);
141140
if let CommandExecutionPermission::Allowed(reason) = autoexecution_permission {
@@ -162,7 +161,7 @@ impl ShellCommandExecutor {
162161
let should_autoexecute = match blocklist_permissions.can_write_to_pty(
163162
&input.conversation_id,
164163
Some(self.terminal_view_id),
165-
&scope,
164+
scope,
166165
ctx,
167166
) {
168167
WriteToPtyPermission::AlwaysAllow => true,

app/src/ai/blocklist/action_model/execute/upload_artifact.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use warpui::{Entity, EntityId, ModelContext, ModelHandle};
1313

1414
use super::{ActionExecution, AnyActionExecution, ExecuteActionInput, PreprocessActionInput};
1515
use crate::terminal::model::session::active_session::ActiveSession;
16-
use crate::workspaces::user_workspaces::TeamContextResolver;
16+
use crate::workspaces::user_workspaces::TeamContext;
1717
#[cfg(not(target_family = "wasm"))]
1818
use crate::{
1919
ai::{
@@ -55,8 +55,8 @@ impl UploadArtifactExecutor {
5555
pub(super) fn should_autoexecute(
5656
&self,
5757
input: ExecuteActionInput,
58-
team_context_resolver: &TeamContextResolver,
59-
ctx: &mut ModelContext<Self>,
58+
scope: &TeamContext<'_>,
59+
ctx: &ModelContext<Self>,
6060
) -> bool {
6161
#[cfg(target_family = "wasm")]
6262
{
@@ -78,13 +78,12 @@ impl UploadArtifactExecutor {
7878
};
7979

8080
let resolved_path = self.resolve_path(&request.file_path, ctx);
81-
let scope = team_context_resolver(ctx);
8281
BlocklistAIPermissions::as_ref(ctx)
8382
.can_read_files_with_conversation(
8483
&conversation_id,
8584
vec![resolved_path],
8685
Some(self.terminal_view_id),
87-
&scope,
86+
scope,
8887
ctx,
8988
)
9089
.is_allowed()

app/src/ai/blocklist/action_model/execute/upload_artifact_tests.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,14 @@ fn should_autoexecute_honors_file_read_permissions_for_resolved_path() {
169169
});
170170
let action = build_upload_artifact_action("reports/report.txt");
171171

172+
let team_context_resolver = UserWorkspaces::teamless_context_resolver_for_test();
172173
let should_autoexecute_before = executor.update(&mut app, |executor, ctx| {
173174
executor.should_autoexecute(
174175
ExecuteActionInput {
175176
action: &action,
176177
conversation_id,
177178
},
178-
&UserWorkspaces::teamless_context_resolver_for_test(),
179+
&team_context_resolver(ctx),
179180
ctx,
180181
)
181182
});
@@ -194,7 +195,7 @@ fn should_autoexecute_honors_file_read_permissions_for_resolved_path() {
194195
action: &action,
195196
conversation_id,
196197
},
197-
&UserWorkspaces::teamless_context_resolver_for_test(),
198+
&team_context_resolver(ctx),
198199
ctx,
199200
)
200201
});

0 commit comments

Comments
 (0)