@@ -93,8 +93,6 @@ async fn on_connect(socket: SocketRef, _state: State<AppState>) {
9393
9494 socket. on ( "theme:list" , handle_theme_list) ;
9595 socket. on ( "theme:get" , handle_theme_get) ;
96- socket. on ( "config:get" , handle_config_get) ;
97-
9896 socket. on_disconnect ( on_disconnect)
9997}
10098
@@ -192,7 +190,7 @@ fn build_app_state() -> (
192190 let file2code = Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ;
193191 let socket2data = Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ;
194192 let terminals = Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ;
195- let config = Arc :: new ( Mutex :: new ( config) ) ;
193+ let config = Arc :: new ( config) ;
196194
197195 let state = AppState {
198196 config,
@@ -261,7 +259,7 @@ async fn main() -> Result<()> {
261259 // Prepare ACP filesystem task dependencies (spawned after SocketIo creation)
262260 let acp_fs_file2code = state. file2code . clone ( ) ;
263261 let acp_fs_lsp = state. lsp_manager . clone ( ) ;
264- let acp_fs_config = state. config . lock ( ) . await . clone ( ) ;
262+ let acp_fs_config = state. config . as_ref ( ) . clone ( ) ;
265263
266264 let ( layer, io) = SocketIo :: builder ( ) . with_state ( state. clone ( ) ) . build_layer ( ) ;
267265 let cors = ServiceBuilder :: new ( )
@@ -303,73 +301,8 @@ async fn main() -> Result<()> {
303301 let dir = std:: path:: Path :: new ( "." ) ;
304302 watcher. watch ( dir, RecursiveMode :: Recursive ) ?;
305303
306- // Create a channel for batching/debouncing git status updates
307- let ( git_update_tx, mut git_update_rx) = mpsc:: channel :: < std:: path:: PathBuf > ( 1000 ) ;
308-
309- // Spawn a task to process git status updates in a debounced, batched manner
310- let git_manager_clone = git_manager. clone ( ) ;
311- let socket_clone = io. clone ( ) ;
312- tokio:: spawn ( async move {
313- let mut paths_to_update = HashSet :: new ( ) ;
314-
315- loop {
316- // Wait for the first path to arrive
317- let first_path = match git_update_rx. recv ( ) . await {
318- Some ( path) => path,
319- None => break , // Channel closed
320- } ;
321- paths_to_update. insert ( first_path) ;
322-
323- // Debounce window: wait for 150ms of inactivity, or up to a max timeout (500ms) to prevent starvation
324- let start_time = std:: time:: Instant :: now ( ) ;
325- let max_wait = std:: time:: Duration :: from_millis ( 500 ) ;
326-
327- loop {
328- let elapsed = start_time. elapsed ( ) ;
329- if elapsed >= max_wait {
330- break ;
331- }
332- let remaining = max_wait - elapsed;
333- let step_timeout = std:: time:: Duration :: from_millis ( 50 ) . min ( remaining) ;
334-
335- match tokio:: time:: timeout ( step_timeout, git_update_rx. recv ( ) ) . await {
336- Ok ( Some ( path) ) => {
337- paths_to_update. insert ( path) ;
338- }
339- Ok ( None ) => {
340- // Channel closed
341- break ;
342- }
343- Err ( _) => {
344- // Timeout hit: no events for step_timeout, flush the batch
345- break ;
346- }
347- }
348- }
349-
350- // Process batched paths under a single lock on GitManager
351- if !paths_to_update. is_empty ( ) {
352- let paths: Vec < std:: path:: PathBuf > = paths_to_update. drain ( ) . collect ( ) ;
353- let mut git = git_manager_clone. lock ( ) . await ;
354-
355- // Filter out paths that should be ignored under the lock
356- let paths_to_check: Vec < std:: path:: PathBuf > = paths
357- . into_iter ( )
358- . filter ( |path| !git. should_ignore ( path) )
359- . collect ( ) ;
360-
361- if !paths_to_check. is_empty ( ) {
362- if let Some ( update) = git. check_status_changed_for_paths ( & paths_to_check) {
363- let _ = socket_clone. emit ( "changes:update" , & update. to_json ( ) ) . await ;
364- }
365- }
366- }
367- }
368- } ) ;
369-
370304 let file_states = Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ;
371305 let socket = io. clone ( ) ;
372- let git_update_tx_clone = git_update_tx. clone ( ) ;
373306 tokio:: spawn ( async move {
374307 while let Some ( res) = watch_rx. recv ( ) . await {
375308 match res {
@@ -385,7 +318,7 @@ async fn main() -> Result<()> {
385318 & file2code,
386319 & socket2data,
387320 & file_states,
388- & git_update_tx_clone ,
321+ & git_manager ,
389322 & lsp_manager,
390323 )
391324 . await
0 commit comments