main.rs

  1#![allow(unused_variables, dead_code, unused_mut)]
  2// todo!() this is to make transition easier.
  3
  4// Allow binary to be called Zed for a nice application menu when running executable directly
  5#![allow(non_snake_case)]
  6
  7use anyhow::{anyhow, Context as _, Result};
  8use backtrace::Backtrace;
  9use cli::FORCE_CLI_MODE_ENV_VAR_NAME;
 10use client::UserStore;
 11use db::kvp::KEY_VALUE_STORE;
 12use editor::Editor;
 13use fs::RealFs;
 14use futures::StreamExt;
 15use gpui::{Action, App, AppContext, AsyncAppContext, Context, SemanticVersion, Task};
 16use isahc::{prelude::Configurable, Request};
 17use language::LanguageRegistry;
 18use log::LevelFilter;
 19
 20use node_runtime::RealNodeRuntime;
 21use parking_lot::Mutex;
 22use serde::{Deserialize, Serialize};
 23use settings::{
 24    default_settings, handle_keymap_file_changes, handle_settings_file_changes, watch_config_file,
 25    Settings, SettingsStore,
 26};
 27use simplelog::ConfigBuilder;
 28use smol::process::Command;
 29use std::{
 30    env,
 31    ffi::OsStr,
 32    fs::OpenOptions,
 33    io::{IsTerminal, Write},
 34    panic,
 35    path::{Path, PathBuf},
 36    sync::{
 37        atomic::{AtomicU32, Ordering},
 38        Arc,
 39    },
 40    thread,
 41    time::{SystemTime, UNIX_EPOCH},
 42};
 43use theme::ActiveTheme;
 44use util::{
 45    async_maybe,
 46    channel::{parse_zed_link, ReleaseChannel, RELEASE_CHANNEL},
 47    http::{self, HttpClient},
 48    paths, ResultExt,
 49};
 50use uuid::Uuid;
 51use workspace::{AppState, WorkspaceStore};
 52use zed2::{
 53    build_window_options, ensure_only_instance, handle_cli_connection, initialize_workspace,
 54    languages, Assets, IsOnlyInstance, OpenListener, OpenRequest,
 55};
 56
 57mod open_listener;
 58
 59fn main() {
 60    menu::init();
 61    zed_actions::init();
 62
 63    let http = http::client();
 64    init_paths();
 65    init_logger();
 66
 67    if ensure_only_instance() != IsOnlyInstance::Yes {
 68        return;
 69    }
 70
 71    log::info!("========== starting zed ==========");
 72    let app = App::production(Arc::new(Assets));
 73
 74    let installation_id = app.background_executor().block(installation_id()).ok();
 75    let session_id = Uuid::new_v4().to_string();
 76    init_panic_hook(&app, installation_id.clone(), session_id.clone());
 77
 78    let fs = Arc::new(RealFs);
 79    let user_settings_file_rx = watch_config_file(
 80        &app.background_executor(),
 81        fs.clone(),
 82        paths::SETTINGS.clone(),
 83    );
 84    let user_keymap_file_rx = watch_config_file(
 85        &app.background_executor(),
 86        fs.clone(),
 87        paths::KEYMAP.clone(),
 88    );
 89
 90    let login_shell_env_loaded = if stdout_is_a_pty() {
 91        Task::ready(())
 92    } else {
 93        app.background_executor().spawn(async {
 94            load_login_shell_environment().await.log_err();
 95        })
 96    };
 97
 98    let (listener, mut open_rx) = OpenListener::new();
 99    let listener = Arc::new(listener);
100    let open_listener = listener.clone();
101    app.on_open_urls(move |urls, _| open_listener.open_urls(&urls));
102    app.on_reopen(move |_cx| {
103        // todo!("workspace")
104        // if cx.has_global::<Weak<AppState>>() {
105        // if let Some(app_state) = cx.global::<Weak<AppState>>().upgrade() {
106        // workspace::open_new(&app_state, cx, |workspace, cx| {
107        //     Editor::new_file(workspace, &Default::default(), cx)
108        // })
109        // .detach();
110        // }
111        // }
112    });
113
114    app.run(move |cx| {
115        cx.set_global(*RELEASE_CHANNEL);
116        cx.set_global(listener.clone());
117
118        load_embedded_fonts(cx);
119
120        let mut store = SettingsStore::default();
121        store
122            .set_default_settings(default_settings().as_ref(), cx)
123            .unwrap();
124        cx.set_global(store);
125        handle_settings_file_changes(user_settings_file_rx, cx);
126        handle_keymap_file_changes(user_keymap_file_rx, cx);
127
128        let client = client::Client::new(http.clone(), cx);
129        let mut languages = LanguageRegistry::new(login_shell_env_loaded);
130        let copilot_language_server_id = languages.next_language_server_id();
131        languages.set_executor(cx.background_executor().clone());
132        languages.set_language_server_download_dir(paths::LANGUAGES_DIR.clone());
133        let languages = Arc::new(languages);
134        let node_runtime = RealNodeRuntime::new(http.clone());
135
136        language::init(cx);
137        languages::init(languages.clone(), node_runtime.clone(), cx);
138        let user_store = cx.build_model(|cx| UserStore::new(client.clone(), http.clone(), cx));
139        let workspace_store = cx.build_model(|cx| WorkspaceStore::new(client.clone(), cx));
140
141        cx.set_global(client.clone());
142
143        theme::init(theme::LoadThemes::All, cx);
144        project::Project::init(&client, cx);
145        client::init(&client, cx);
146        command_palette::init(cx);
147        language::init(cx);
148        editor::init(cx);
149        copilot::init(
150            copilot_language_server_id,
151            http.clone(),
152            node_runtime.clone(),
153            cx,
154        );
155        // assistant::init(cx);
156        // component_test::init(cx);
157
158        // cx.spawn(|cx| watch_themes(fs.clone(), cx)).detach();
159        // cx.spawn(|_| watch_languages(fs.clone(), languages.clone()))
160        //     .detach();
161        // watch_file_types(fs.clone(), cx);
162
163        languages.set_theme(cx.theme().clone());
164        // cx.observe_global::<SettingsStore, _>({
165        //     let languages = languages.clone();
166        //     move |cx| languages.set_theme(theme::current(cx).clone())
167        // })
168        // .detach();
169
170        // client.telemetry().start(installation_id, session_id, cx);
171
172        let app_state = Arc::new(AppState {
173            languages,
174            client: client.clone(),
175            user_store,
176            fs,
177            build_window_options,
178            // background_actions: todo!("ask Mikayla"),
179            workspace_store,
180            node_runtime,
181        });
182        cx.set_global(Arc::downgrade(&app_state));
183
184        // audio::init(Assets, cx);
185        // auto_update::init(http.clone(), client::ZED_SERVER_URL.clone(), cx);
186
187        workspace::init(app_state.clone(), cx);
188        // recent_projects::init(cx);
189
190        go_to_line::init(cx);
191        file_finder::init(cx);
192        // outline::init(cx);
193        // project_symbols::init(cx);
194        project_panel::init(Assets, cx);
195        // channel::init(&client, user_store.clone(), cx);
196        // diagnostics::init(cx);
197        search::init(cx);
198        // semantic_index::init(fs.clone(), http.clone(), languages.clone(), cx);
199        // vim::init(cx);
200        terminal_view::init(cx);
201
202        // journal2::init(app_state.clone(), cx);
203        // language_selector::init(cx);
204        // theme_selector::init(cx);
205        // activity_indicator::init(cx);
206        // language_tools::init(cx);
207        call::init(app_state.client.clone(), app_state.user_store.clone(), cx);
208        collab_ui::init(&app_state, cx);
209        // feedback::init(cx);
210        // welcome::init(cx);
211        // zed::init(&app_state, cx);
212
213        // cx.set_menus(menus::menus());
214        initialize_workspace(app_state.clone(), cx);
215
216        if stdout_is_a_pty() {
217            cx.activate(true);
218            let urls = collect_url_args();
219            if !urls.is_empty() {
220                listener.open_urls(&urls)
221            }
222        } else {
223            upload_previous_panics(http.clone(), cx);
224
225            // TODO Development mode that forces the CLI mode usually runs Zed binary as is instead
226            // of an *app, hence gets no specific callbacks run. Emulate them here, if needed.
227            if std::env::var(FORCE_CLI_MODE_ENV_VAR_NAME).ok().is_some()
228                && !listener.triggered.load(Ordering::Acquire)
229            {
230                listener.open_urls(&collect_url_args())
231            }
232        }
233
234        let mut _triggered_authentication = false;
235
236        fn open_paths_and_log_errs(
237            paths: &[PathBuf],
238            app_state: &Arc<AppState>,
239            cx: &mut AppContext,
240        ) {
241            let task = workspace::open_paths(&paths, &app_state, None, cx);
242            cx.spawn(|cx| async move {
243                if let Some((_window, results)) = task.await.log_err() {
244                    for result in results {
245                        if let Some(Err(e)) = result {
246                            log::error!("Error opening path: {}", e);
247                        }
248                    }
249                }
250            })
251            .detach();
252        }
253
254        match open_rx.try_next() {
255            Ok(Some(OpenRequest::Paths { paths })) => {
256                open_paths_and_log_errs(&paths, &app_state, cx)
257            }
258            Ok(Some(OpenRequest::CliConnection { connection })) => {
259                let app_state = app_state.clone();
260                cx.spawn(move |cx| handle_cli_connection(connection, app_state, cx))
261                    .detach();
262            }
263            Ok(Some(OpenRequest::JoinChannel { channel_id: _ })) => {
264                todo!()
265                // triggered_authentication = true;
266                // let app_state = app_state.clone();
267                // let client = client.clone();
268                // cx.spawn(|mut cx| async move {
269                //     // ignore errors here, we'll show a generic "not signed in"
270                //     let _ = authenticate(client, &cx).await;
271                //     cx.update(|cx| workspace::join_channel(channel_id, app_state, None, cx))
272                //         .await
273                // })
274                // .detach_and_log_err(cx)
275            }
276            Ok(Some(OpenRequest::OpenChannelNotes { channel_id: _ })) => {
277                todo!()
278            }
279            Ok(None) | Err(_) => cx
280                .spawn({
281                    let app_state = app_state.clone();
282                    |cx| async move { restore_or_create_workspace(&app_state, cx).await }
283                })
284                .detach(),
285        }
286
287        let app_state = app_state.clone();
288        cx.spawn(|cx| async move {
289            while let Some(request) = open_rx.next().await {
290                match request {
291                    OpenRequest::Paths { paths } => {
292                        cx.update(|cx| open_paths_and_log_errs(&paths, &app_state, cx))
293                            .ok();
294                    }
295                    OpenRequest::CliConnection { connection } => {
296                        let app_state = app_state.clone();
297                        cx.spawn(move |cx| {
298                            handle_cli_connection(connection, app_state.clone(), cx)
299                        })
300                        .detach();
301                    }
302                    OpenRequest::JoinChannel { channel_id: _ } => {
303                        todo!()
304                    }
305                    OpenRequest::OpenChannelNotes { channel_id: _ } => {
306                        todo!()
307                    }
308                }
309            }
310        })
311        .detach();
312
313        // if !triggered_authentication {
314        //     cx.spawn(|cx| async move { authenticate(client, &cx).await })
315        //         .detach_and_log_err(cx);
316        // }
317    });
318}
319
320// async fn authenticate(client: Arc<Client>, cx: &AsyncAppContext) -> Result<()> {
321//     if stdout_is_a_pty() {
322//         if client::IMPERSONATE_LOGIN.is_some() {
323//             client.authenticate_and_connect(false, &cx).await?;
324//         }
325//     } else if client.has_keychain_credentials(&cx) {
326//         client.authenticate_and_connect(true, &cx).await?;
327//     }
328//     Ok::<_, anyhow::Error>(())
329// }
330
331async fn installation_id() -> Result<String> {
332    let legacy_key_name = "device_id";
333
334    if let Ok(Some(installation_id)) = KEY_VALUE_STORE.read_kvp(legacy_key_name) {
335        Ok(installation_id)
336    } else {
337        let installation_id = Uuid::new_v4().to_string();
338
339        KEY_VALUE_STORE
340            .write_kvp(legacy_key_name.to_string(), installation_id.clone())
341            .await?;
342
343        Ok(installation_id)
344    }
345}
346
347async fn restore_or_create_workspace(app_state: &Arc<AppState>, mut cx: AsyncAppContext) {
348    async_maybe!({
349        if let Some(location) = workspace::last_opened_workspace_paths().await {
350            cx.update(|cx| workspace::open_paths(location.paths().as_ref(), app_state, None, cx))?
351                .await
352                .log_err();
353        } else if matches!(KEY_VALUE_STORE.read_kvp("******* THIS IS A BAD KEY PLEASE UNCOMMENT BELOW TO FIX THIS VERY LONG LINE *******"), Ok(None)) {
354            // todo!(welcome)
355            //} else if matches!(KEY_VALUE_STORE.read_kvp(FIRST_OPEN), Ok(None)) {
356            //todo!()
357            // cx.update(|cx| show_welcome_experience(app_state, cx));
358        } else {
359            cx.update(|cx| {
360                workspace::open_new(app_state, cx, |workspace, cx| {
361                    Editor::new_file(workspace, &Default::default(), cx)
362                })
363                .detach();
364            })?;
365        }
366        anyhow::Ok(())
367    })
368    .await
369    .log_err();
370}
371
372fn init_paths() {
373    std::fs::create_dir_all(&*util::paths::CONFIG_DIR).expect("could not create config path");
374    std::fs::create_dir_all(&*util::paths::LANGUAGES_DIR).expect("could not create languages path");
375    std::fs::create_dir_all(&*util::paths::DB_DIR).expect("could not create database path");
376    std::fs::create_dir_all(&*util::paths::LOGS_DIR).expect("could not create logs path");
377}
378
379fn init_logger() {
380    if stdout_is_a_pty() {
381        env_logger::init();
382    } else {
383        let level = LevelFilter::Info;
384
385        // Prevent log file from becoming too large.
386        const KIB: u64 = 1024;
387        const MIB: u64 = 1024 * KIB;
388        const MAX_LOG_BYTES: u64 = MIB;
389        if std::fs::metadata(&*paths::LOG).map_or(false, |metadata| metadata.len() > MAX_LOG_BYTES)
390        {
391            let _ = std::fs::rename(&*paths::LOG, &*paths::OLD_LOG);
392        }
393
394        let log_file = OpenOptions::new()
395            .create(true)
396            .append(true)
397            .open(&*paths::LOG)
398            .expect("could not open logfile");
399
400        let config = ConfigBuilder::new()
401            .set_time_format_str("%Y-%m-%dT%T") //All timestamps are UTC
402            .build();
403
404        simplelog::WriteLogger::init(level, config, log_file).expect("could not initialize logger");
405    }
406}
407
408#[derive(Serialize, Deserialize)]
409struct LocationData {
410    file: String,
411    line: u32,
412}
413
414#[derive(Serialize, Deserialize)]
415struct Panic {
416    thread: String,
417    payload: String,
418    #[serde(skip_serializing_if = "Option::is_none")]
419    location_data: Option<LocationData>,
420    backtrace: Vec<String>,
421    app_version: String,
422    release_channel: String,
423    os_name: String,
424    os_version: Option<String>,
425    architecture: String,
426    panicked_on: u128,
427    #[serde(skip_serializing_if = "Option::is_none")]
428    installation_id: Option<String>,
429    session_id: String,
430}
431
432#[derive(Serialize)]
433struct PanicRequest {
434    panic: Panic,
435    token: String,
436}
437
438static PANIC_COUNT: AtomicU32 = AtomicU32::new(0);
439
440fn init_panic_hook(app: &App, installation_id: Option<String>, session_id: String) {
441    let is_pty = stdout_is_a_pty();
442    let app_metadata = app.metadata();
443
444    panic::set_hook(Box::new(move |info| {
445        let prior_panic_count = PANIC_COUNT.fetch_add(1, Ordering::SeqCst);
446        if prior_panic_count > 0 {
447            // Give the panic-ing thread time to write the panic file
448            loop {
449                std::thread::yield_now();
450            }
451        }
452
453        let thread = thread::current();
454        let thread_name = thread.name().unwrap_or("<unnamed>");
455
456        let payload = info
457            .payload()
458            .downcast_ref::<&str>()
459            .map(|s| s.to_string())
460            .or_else(|| info.payload().downcast_ref::<String>().map(|s| s.clone()))
461            .unwrap_or_else(|| "Box<Any>".to_string());
462
463        if *util::channel::RELEASE_CHANNEL == ReleaseChannel::Dev {
464            let location = info.location().unwrap();
465            let backtrace = Backtrace::new();
466            eprintln!(
467                "Thread {:?} panicked with {:?} at {}:{}:{}\n{:?}",
468                thread_name,
469                payload,
470                location.file(),
471                location.line(),
472                location.column(),
473                backtrace,
474            );
475            std::process::exit(-1);
476        }
477
478        let app_version = client::ZED_APP_VERSION
479            .or(app_metadata.app_version)
480            .map_or("dev".to_string(), |v| v.to_string());
481
482        let backtrace = Backtrace::new();
483        let mut backtrace = backtrace
484            .frames()
485            .iter()
486            .filter_map(|frame| Some(format!("{:#}", frame.symbols().first()?.name()?)))
487            .collect::<Vec<_>>();
488
489        // Strip out leading stack frames for rust panic-handling.
490        if let Some(ix) = backtrace
491            .iter()
492            .position(|name| name == "rust_begin_unwind")
493        {
494            backtrace.drain(0..=ix);
495        }
496
497        let panic_data = Panic {
498            thread: thread_name.into(),
499            payload: payload.into(),
500            location_data: info.location().map(|location| LocationData {
501                file: location.file().into(),
502                line: location.line(),
503            }),
504            app_version: app_version.clone(),
505            release_channel: RELEASE_CHANNEL.display_name().into(),
506            os_name: app_metadata.os_name.into(),
507            os_version: app_metadata
508                .os_version
509                .as_ref()
510                .map(SemanticVersion::to_string),
511            architecture: env::consts::ARCH.into(),
512            panicked_on: SystemTime::now()
513                .duration_since(UNIX_EPOCH)
514                .unwrap()
515                .as_millis(),
516            backtrace,
517            installation_id: installation_id.clone(),
518            session_id: session_id.clone(),
519        };
520
521        if let Some(panic_data_json) = serde_json::to_string_pretty(&panic_data).log_err() {
522            log::error!("{}", panic_data_json);
523        }
524
525        if !is_pty {
526            if let Some(panic_data_json) = serde_json::to_string(&panic_data).log_err() {
527                let timestamp = chrono::Utc::now().format("%Y_%m_%d %H_%M_%S").to_string();
528                let panic_file_path = paths::LOGS_DIR.join(format!("zed-{}.panic", timestamp));
529                let panic_file = std::fs::OpenOptions::new()
530                    .append(true)
531                    .create(true)
532                    .open(&panic_file_path)
533                    .log_err();
534                if let Some(mut panic_file) = panic_file {
535                    writeln!(&mut panic_file, "{}", panic_data_json).log_err();
536                    panic_file.flush().log_err();
537                }
538            }
539        }
540
541        std::process::abort();
542    }));
543}
544
545fn upload_previous_panics(http: Arc<dyn HttpClient>, cx: &mut AppContext) {
546    let telemetry_settings = *client::TelemetrySettings::get_global(cx);
547
548    cx.background_executor()
549        .spawn(async move {
550            let panic_report_url = format!("{}/api/panic", &*client::ZED_SERVER_URL);
551            let mut children = smol::fs::read_dir(&*paths::LOGS_DIR).await?;
552            while let Some(child) = children.next().await {
553                let child = child?;
554                let child_path = child.path();
555
556                if child_path.extension() != Some(OsStr::new("panic")) {
557                    continue;
558                }
559                let filename = if let Some(filename) = child_path.file_name() {
560                    filename.to_string_lossy()
561                } else {
562                    continue;
563                };
564
565                if !filename.starts_with("zed") {
566                    continue;
567                }
568
569                if telemetry_settings.diagnostics {
570                    let panic_file_content = smol::fs::read_to_string(&child_path)
571                        .await
572                        .context("error reading panic file")?;
573
574                    let panic = serde_json::from_str(&panic_file_content)
575                        .ok()
576                        .or_else(|| {
577                            panic_file_content
578                                .lines()
579                                .next()
580                                .and_then(|line| serde_json::from_str(line).ok())
581                        })
582                        .unwrap_or_else(|| {
583                            log::error!(
584                                "failed to deserialize panic file {:?}",
585                                panic_file_content
586                            );
587                            None
588                        });
589
590                    if let Some(panic) = panic {
591                        let body = serde_json::to_string(&PanicRequest {
592                            panic,
593                            token: client::ZED_SECRET_CLIENT_TOKEN.into(),
594                        })
595                        .unwrap();
596
597                        let request = Request::post(&panic_report_url)
598                            .redirect_policy(isahc::config::RedirectPolicy::Follow)
599                            .header("Content-Type", "application/json")
600                            .body(body.into())?;
601                        let response = http.send(request).await.context("error sending panic")?;
602                        if !response.status().is_success() {
603                            log::error!("Error uploading panic to server: {}", response.status());
604                        }
605                    }
606                }
607
608                // We've done what we can, delete the file
609                std::fs::remove_file(child_path)
610                    .context("error removing panic")
611                    .log_err();
612            }
613            Ok::<_, anyhow::Error>(())
614        })
615        .detach_and_log_err(cx);
616}
617
618async fn load_login_shell_environment() -> Result<()> {
619    let marker = "ZED_LOGIN_SHELL_START";
620    let shell = env::var("SHELL").context(
621        "SHELL environment variable is not assigned so we can't source login environment variables",
622    )?;
623    let output = Command::new(&shell)
624        .args(["-lic", &format!("echo {marker} && /usr/bin/env -0")])
625        .output()
626        .await
627        .context("failed to spawn login shell to source login environment variables")?;
628    if !output.status.success() {
629        Err(anyhow!("login shell exited with error"))?;
630    }
631
632    let stdout = String::from_utf8_lossy(&output.stdout);
633
634    if let Some(env_output_start) = stdout.find(marker) {
635        let env_output = &stdout[env_output_start + marker.len()..];
636        for line in env_output.split_terminator('\0') {
637            if let Some(separator_index) = line.find('=') {
638                let key = &line[..separator_index];
639                let value = &line[separator_index + 1..];
640                env::set_var(key, value);
641            }
642        }
643        log::info!(
644            "set environment variables from shell:{}, path:{}",
645            shell,
646            env::var("PATH").unwrap_or_default(),
647        );
648    }
649
650    Ok(())
651}
652
653fn stdout_is_a_pty() -> bool {
654    std::env::var(FORCE_CLI_MODE_ENV_VAR_NAME).ok().is_none() && std::io::stdout().is_terminal()
655}
656
657fn collect_url_args() -> Vec<String> {
658    env::args()
659        .skip(1)
660        .filter_map(|arg| match std::fs::canonicalize(Path::new(&arg)) {
661            Ok(path) => Some(format!("file://{}", path.to_string_lossy())),
662            Err(error) => {
663                if let Some(_) = parse_zed_link(&arg) {
664                    Some(arg)
665                } else {
666                    log::error!("error parsing path argument: {}", error);
667                    None
668                }
669            }
670        })
671        .collect()
672}
673
674fn load_embedded_fonts(cx: &AppContext) {
675    let asset_source = cx.asset_source();
676    let font_paths = asset_source.list("fonts").unwrap();
677    let embedded_fonts = Mutex::new(Vec::new());
678    let executor = cx.background_executor();
679
680    executor.block(executor.scoped(|scope| {
681        for font_path in &font_paths {
682            if !font_path.ends_with(".ttf") {
683                continue;
684            }
685
686            scope.spawn(async {
687                let font_bytes = asset_source.load(font_path).unwrap().to_vec();
688                embedded_fonts.lock().push(Arc::from(font_bytes));
689            });
690        }
691    }));
692
693    cx.text_system()
694        .add_fonts(&embedded_fonts.into_inner())
695        .unwrap();
696}
697
698// #[cfg(debug_assertions)]
699// async fn watch_themes(fs: Arc<dyn Fs>, mut cx: AsyncAppContext) -> Option<()> {
700//     let mut events = fs
701//         .watch("styles/src".as_ref(), Duration::from_millis(100))
702//         .await;
703//     while (events.next().await).is_some() {
704//         let output = Command::new("npm")
705//             .current_dir("styles")
706//             .args(["run", "build"])
707//             .output()
708//             .await
709//             .log_err()?;
710//         if output.status.success() {
711//             cx.update(|cx| theme_selector::reload(cx))
712//         } else {
713//             eprintln!(
714//                 "build script failed {}",
715//                 String::from_utf8_lossy(&output.stderr)
716//             );
717//         }
718//     }
719//     Some(())
720// }
721
722// #[cfg(debug_assertions)]
723// async fn watch_languages(fs: Arc<dyn Fs>, languages: Arc<LanguageRegistry>) -> Option<()> {
724//     let mut events = fs
725//         .watch(
726//             "crates/zed/src/languages".as_ref(),
727//             Duration::from_millis(100),
728//         )
729//         .await;
730//     while (events.next().await).is_some() {
731//         languages.reload();
732//     }
733//     Some(())
734// }
735
736// #[cfg(debug_assertions)]
737// fn watch_file_types(fs: Arc<dyn Fs>, cx: &mut AppContext) {
738//     cx.spawn(|mut cx| async move {
739//         let mut events = fs
740//             .watch(
741//                 "assets/icons/file_icons/file_types.json".as_ref(),
742//                 Duration::from_millis(100),
743//             )
744//             .await;
745//         while (events.next().await).is_some() {
746//             cx.update(|cx| {
747//                 cx.update_global(|file_types, _| {
748//                     *file_types = project_panel::file_associations::FileAssociations::new(Assets);
749//                 });
750//             })
751//         }
752//     })
753//     .detach()
754// }
755
756// #[cfg(not(debug_assertions))]
757// async fn watch_themes(_fs: Arc<dyn Fs>, _cx: AsyncAppContext) -> Option<()> {
758//     None
759// }
760
761// #[cfg(not(debug_assertions))]
762// async fn watch_languages(_: Arc<dyn Fs>, _: Arc<LanguageRegistry>) -> Option<()> {
763//     None
764//
765
766// #[cfg(not(debug_assertions))]
767// fn watch_file_types(_fs: Arc<dyn Fs>, _cx: &mut AppContext) {}
768
769pub fn background_actions() -> &'static [(&'static str, &'static dyn Action)] {
770    // &[
771    //     ("Go to file", &file_finder::Toggle),
772    //     ("Open command palette", &command_palette::Toggle),
773    //     ("Open recent projects", &recent_projects::OpenRecent),
774    //     ("Change your settings", &zed_actions::OpenSettings),
775    // ]
776    // todo!()
777    &[]
778}