@@ -50,6 +50,7 @@ pub struct HeadlessProject {
50
50
pub languages : Arc < LanguageRegistry > ,
51
51
pub extensions : Entity < HeadlessExtensionStore > ,
52
52
pub git_store : Entity < GitStore > ,
53
+ pub environment : Entity < ProjectEnvironment > ,
53
54
// Used mostly to keep alive the toolchain store for RPC handlers.
54
55
// Local variant is used within LSP store, but that's a separate entity.
55
56
pub _toolchain_store : Entity < ToolchainStore > ,
@@ -196,7 +197,7 @@ impl HeadlessProject {
196
197
197
198
let agent_server_store = cx. new ( |cx| {
198
199
let mut agent_server_store =
199
- AgentServerStore :: local ( node_runtime. clone ( ) , fs. clone ( ) , environment, cx) ;
200
+ AgentServerStore :: local ( node_runtime. clone ( ) , fs. clone ( ) , environment. clone ( ) , cx) ;
200
201
agent_server_store. shared ( REMOTE_SERVER_PROJECT_ID , session. clone ( ) , cx) ;
201
202
agent_server_store
202
203
} ) ;
@@ -249,6 +250,7 @@ impl HeadlessProject {
249
250
session. add_entity_request_handler ( Self :: handle_open_new_buffer) ;
250
251
session. add_entity_request_handler ( Self :: handle_find_search_candidates) ;
251
252
session. add_entity_request_handler ( Self :: handle_open_server_settings) ;
253
+ session. add_entity_request_handler ( Self :: handle_get_directory_environment) ;
252
254
session. add_entity_message_handler ( Self :: handle_toggle_lsp_logs) ;
253
255
254
256
session. add_entity_request_handler ( BufferStore :: handle_update_buffer) ;
@@ -289,6 +291,7 @@ impl HeadlessProject {
289
291
languages,
290
292
extensions,
291
293
git_store,
294
+ environment,
292
295
_toolchain_store : toolchain_store,
293
296
}
294
297
}
@@ -758,6 +761,26 @@ impl HeadlessProject {
758
761
759
762
Ok ( proto:: GetProcessesResponse { processes } )
760
763
}
764
+
765
+ async fn handle_get_directory_environment (
766
+ this : Entity < Self > ,
767
+ envelope : TypedEnvelope < proto:: GetDirectoryEnvironment > ,
768
+ mut cx : AsyncApp ,
769
+ ) -> Result < proto:: DirectoryEnvironment > {
770
+ let shell = task:: Shell :: from_proto ( envelope. payload . shell . context ( "missing shell" ) ?) ?;
771
+ let directory = PathBuf :: from ( envelope. payload . directory ) ;
772
+ let environment = this
773
+ . update ( & mut cx, |this, cx| {
774
+ this. environment . update ( cx, |environment, cx| {
775
+ environment. get_directory_environment_for_shell ( & shell, directory. into ( ) , cx)
776
+ } )
777
+ } ) ?
778
+ . await
779
+ . context ( "failed to get directory environment" ) ?
780
+ . into_iter ( )
781
+ . collect ( ) ;
782
+ Ok ( proto:: DirectoryEnvironment { environment } )
783
+ }
761
784
}
762
785
763
786
fn prompt_to_proto (
0 commit comments