@@ -150,6 +150,7 @@ impl PromptBuilderContext {
150150 }
151151}
152152
153+ #[ allow( clippy:: too_many_arguments) ]
153154pub async fn build_prompt_context_for_workspace (
154155 workspace : & WorkspaceBinding ,
155156 workspace_id : Option < & str > ,
@@ -158,6 +159,7 @@ pub async fn build_prompt_context_for_workspace(
158159 supports_image_understanding : Option < bool > ,
159160 tool_listing_sections : ToolListingSections ,
160161 runtime_context_needs : RuntimeContextNeeds ,
162+ user_context_policy : & UserContextPolicy ,
161163) -> Option < PromptBuilderContext > {
162164 let workspace_path = workspace. root_path_string ( ) ;
163165
@@ -203,6 +205,7 @@ pub async fn build_prompt_context_for_workspace(
203205
204206 #[ cfg( not( feature = "remote-workspace" ) ) ]
205207 {
208+ let _ = user_context_policy;
206209 Some ( base)
207210 }
208211
@@ -232,7 +235,6 @@ pub async fn build_prompt_context_for_workspace(
232235 } ;
233236
234237 let ssh_manager = manager. get_ssh_manager ( ) . await ;
235- let file_service = manager. get_file_service ( ) . await ;
236238 let ( kernel_name, hostname) = if let Some ( ref ssh) = ssh_manager {
237239 if let Some ( info) = ssh. get_server_info ( connection_id) . await {
238240 ( info. os_type , info. hostname )
@@ -242,15 +244,24 @@ pub async fn build_prompt_context_for_workspace(
242244 } else {
243245 ( "Linux" . to_string ( ) , "remote" . to_string ( ) )
244246 } ;
245- let remote_layout = if let Some ( ref fs) = file_service {
246- match build_remote_workspace_layout_preview ( fs, connection_id, & workspace_path, 200 )
247+ let remote_layout = if user_context_policy. includes ( UserContextSection :: ProjectLayout ) {
248+ if let Some ( fs) = manager. get_file_service ( ) . await {
249+ match build_remote_workspace_layout_preview (
250+ & fs,
251+ connection_id,
252+ & workspace_path,
253+ 200 ,
254+ )
247255 . await
248- {
249- Ok ( ( _, preview) ) => Some ( preview) ,
250- Err ( e) => {
251- warn ! ( "Remote workspace layout for prompt failed: {}" , e) ;
252- None
256+ {
257+ Ok ( ( _, preview) ) => Some ( preview) ,
258+ Err ( e) => {
259+ warn ! ( "Remote workspace layout for prompt failed: {}" , e) ;
260+ None
261+ }
253262 }
263+ } else {
264+ None
254265 }
255266 } else {
256267 None
@@ -334,6 +345,15 @@ impl PromptBuilder {
334345 } ) ;
335346 }
336347
348+ if self . context . remote_execution . is_some ( ) {
349+ return render_project_layout ( & ProjectLayoutFacts {
350+ listing : "Remote workspace layout is unavailable." . to_string ( ) ,
351+ reached_limit : false ,
352+ max_entries : self . file_tree_max_entries ,
353+ remote : true ,
354+ } ) ;
355+ }
356+
337357 let formatted_listing = get_formatted_directory_listing (
338358 & self . context . workspace_path ,
339359 self . file_tree_max_entries ,
@@ -1097,6 +1117,7 @@ mod tests {
10971117 None ,
10981118 ToolListingSections :: default ( ) ,
10991119 RuntimeContextNeeds :: default ( ) ,
1120+ & UserContextPolicy :: empty ( ) . with_workspace_context ( ) ,
11001121 )
11011122 . await
11021123 . expect ( "prompt context should build" ) ;
0 commit comments