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 chrono::Utc;
 10use cli::FORCE_CLI_MODE_ENV_VAR_NAME;
 11use client::{Client, UserStore};
 12use db::kvp::KEY_VALUE_STORE;
 13use editor::Editor;
 14use fs::RealFs;
 15use futures::StreamExt;
 16use gpui::{Action, App, AppContext, AsyncAppContext, Context, SemanticVersion, Task};
 17use isahc::{prelude::Configurable, Request};
 18use language::LanguageRegistry;
 19use log::LevelFilter;
 20
 21use node_runtime::RealNodeRuntime;
 22use parking_lot::Mutex;
 23use serde::{Deserialize, Serialize};
 24use settings::{
 25    default_settings, handle_keymap_file_changes, handle_settings_file_changes, watch_config_file,
 26    Settings, SettingsStore,
 27};
 28use simplelog::ConfigBuilder;
 29use smol::process::Command;
 30use std::{
 31    env,
 32    ffi::OsStr,
 33    fs::OpenOptions,
 34    io::{IsTerminal, Write},
 35    panic,
 36    path::{Path, PathBuf},
 37    sync::{
 38        atomic::{AtomicU32, Ordering},
 39        Arc, Weak,
 40    },
 41    thread,
 42};
 43use theme::ActiveTheme;
 44use util::{
 45    async_maybe,
 46    channel::{parse_zed_link, AppCommitSha, 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        if cx.has_global::<Weak<AppState>>() {
104            if let Some(app_state) = cx.global::<Weak<AppState>>().upgrade() {
105                workspace::open_new(&app_state, cx, |workspace, cx| {
106                    Editor::new_file(workspace, &Default::default(), cx)
107                })
108                .detach();
109            }
110        }
111    });
112
113    app.run(move |cx| {
114        cx.set_global(*RELEASE_CHANNEL);
115        if let Some(build_sha) = option_env!("ZED_COMMIT_SHA") {
116            cx.set_global(AppCommitSha(build_sha.into()))
117        }
118
119        cx.set_global(listener.clone());
120
121        load_embedded_fonts(cx);
122
123        let mut store = SettingsStore::default();
124        store
125            .set_default_settings(default_settings().as_ref(), cx)
126            .unwrap();
127        cx.set_global(store);
128        handle_settings_file_changes(user_settings_file_rx, cx);
129        handle_keymap_file_changes(user_keymap_file_rx, cx);
130
131        let client = client::Client::new(http.clone(), cx);
132        let mut languages = LanguageRegistry::new(login_shell_env_loaded);
133        let copilot_language_server_id = languages.next_language_server_id();
134        languages.set_executor(cx.background_executor().clone());
135        languages.set_language_server_download_dir(paths::LANGUAGES_DIR.clone());
136        let languages = Arc::new(languages);
137        let node_runtime = RealNodeRuntime::new(http.clone());
138
139        language::init(cx);
140        languages::init(languages.clone(), node_runtime.clone(), cx);
141        let user_store = cx.build_model(|cx| UserStore::new(client.clone(), http.clone(), cx));
142        let workspace_store = cx.build_model(|cx| WorkspaceStore::new(client.clone(), cx));
143
144        cx.set_global(client.clone());
145
146        theme::init(theme::LoadThemes::All, cx);
147        project::Project::init(&client, cx);
148        client::init(&client, cx);
149        command_palette::init(cx);
150        language::init(cx);
151        editor::init(cx);
152        diagnostics::init(cx);
153        copilot::init(
154            copilot_language_server_id,
155            http.clone(),
156            node_runtime.clone(),
157            cx,
158        );
159        // assistant::init(cx);
160        // component_test::init(cx);
161
162        // cx.spawn(|cx| watch_themes(fs.clone(), cx)).detach();
163        // cx.spawn(|_| watch_languages(fs.clone(), languages.clone()))
164        //     .detach();
165        // watch_file_types(fs.clone(), cx);
166
167        languages.set_theme(cx.theme().clone());
168        // cx.observe_global::<SettingsStore, _>({
169        //     let languages = languages.clone();
170        //     move |cx| languages.set_theme(theme::current(cx).clone())
171        // })
172        // .detach();
173
174        client.telemetry().start(installation_id, session_id, cx);
175
176        let app_state = Arc::new(AppState {
177            languages,
178            client: client.clone(),
179            user_store,
180            fs,
181            build_window_options,
182            workspace_store,
183            node_runtime,
184        });
185        cx.set_global(Arc::downgrade(&app_state));
186
187        // audio::init(Assets, cx);
188        auto_update::init(http.clone(), client::ZED_SERVER_URL.clone(), cx);
189
190        workspace::init(app_state.clone(), cx);
191        // recent_projects::init(cx);
192
193        go_to_line::init(cx);
194        file_finder::init(cx);
195        // outline::init(cx);
196        // project_symbols::init(cx);
197        project_panel::init(Assets, cx);
198        // channel::init(&client, user_store.clone(), cx);
199        // diagnostics::init(cx);
200        search::init(cx);
201        // semantic_index::init(fs.clone(), http.clone(), languages.clone(), cx);
202        // vim::init(cx);
203        terminal_view::init(cx);
204
205        // journal2::init(app_state.clone(), cx);
206        // language_selector::init(cx);
207        // theme_selector::init(cx);
208        // activity_indicator::init(cx);
209        // language_tools::init(cx);
210        call::init(app_state.client.clone(), app_state.user_store.clone(), cx);
211        collab_ui::init(&app_state, cx);
212        // feedback::init(cx);
213        // welcome::init(cx);
214        // zed::init(&app_state, cx);
215
216        // cx.set_menus(menus::menus());
217        initialize_workspace(app_state.clone(), cx);
218
219        if stdout_is_a_pty() {
220            cx.activate(true);
221            let urls = collect_url_args();
222            if !urls.is_empty() {
223                listener.open_urls(&urls)
224            }
225        } else {
226            upload_previous_panics(http.clone(), cx);
227
228            // TODO Development mode that forces the CLI mode usually runs Zed binary as is instead
229            // of an *app, hence gets no specific callbacks run. Emulate them here, if needed.
230            if std::env::var(FORCE_CLI_MODE_ENV_VAR_NAME).ok().is_some()
231                && !listener.triggered.load(Ordering::Acquire)
232            {
233                listener.open_urls(&collect_url_args())
234            }
235        }
236
237        let mut triggered_authentication = false;
238
239        fn open_paths_and_log_errs(
240            paths: &[PathBuf],
241            app_state: &Arc<AppState>,
242            cx: &mut AppContext,
243        ) {
244            let task = workspace::open_paths(&paths, &app_state, None, cx);
245            cx.spawn(|cx| async move {
246                if let Some((_window, results)) = task.await.log_err() {
247                    for result in results {
248                        if let Some(Err(e)) = result {
249                            log::error!("Error opening path: {}", e);
250                        }
251                    }
252                }
253            })
254            .detach();
255        }
256
257        match open_rx.try_next() {
258            Ok(Some(OpenRequest::Paths { paths })) => {
259                open_paths_and_log_errs(&paths, &app_state, cx)
260            }
261            Ok(Some(OpenRequest::CliConnection { connection })) => {
262                let app_state = app_state.clone();
263                cx.spawn(move |cx| handle_cli_connection(connection, app_state, cx))
264                    .detach();
265            }
266            Ok(Some(OpenRequest::JoinChannel { channel_id: _ })) => {
267                triggered_authentication = true;
268                let app_state = app_state.clone();
269                let client = client.clone();
270                cx.spawn(|mut cx| async move {
271                    // ignore errors here, we'll show a generic "not signed in"
272                    let _ = authenticate(client, &cx).await;
273                    // cx.update(|cx| workspace::join_channel(channel_id, app_state, None, cx))
274                    // .await
275                    anyhow::Ok(())
276                })
277                .detach_and_log_err(cx)
278            }
279            Ok(Some(OpenRequest::OpenChannelNotes { channel_id: _ })) => {
280                todo!()
281            }
282            Ok(None) | Err(_) => cx
283                .spawn({
284                    let app_state = app_state.clone();
285                    |cx| async move { restore_or_create_workspace(&app_state, cx).await }
286                })
287                .detach(),
288        }
289
290        let app_state = app_state.clone();
291        cx.spawn(|cx| async move {
292            while let Some(request) = open_rx.next().await {
293                match request {
294                    OpenRequest::Paths { paths } => {
295                        cx.update(|cx| open_paths_and_log_errs(&paths, &app_state, cx))
296                            .ok();
297                    }
298                    OpenRequest::CliConnection { connection } => {
299                        let app_state = app_state.clone();
300                        cx.spawn(move |cx| {
301                            handle_cli_connection(connection, app_state.clone(), cx)
302                        })
303                        .detach();
304                    }
305                    OpenRequest::JoinChannel { channel_id: _ } => {
306                        todo!()
307                    }
308                    OpenRequest::OpenChannelNotes { channel_id: _ } => {
309                        todo!()
310                    }
311                }
312            }
313        })
314        .detach();
315
316        if !triggered_authentication {
317            cx.spawn(|cx| async move { authenticate(client, &cx).await })
318                .detach_and_log_err(cx);
319        }
320    });
321}
322
323async fn authenticate(client: Arc<Client>, cx: &AsyncAppContext) -> Result<()> {
324    if stdout_is_a_pty() {
325        if client::IMPERSONATE_LOGIN.is_some() {
326            client.authenticate_and_connect(false, &cx).await?;
327        }
328    } else if client.has_keychain_credentials(&cx) {
329        client.authenticate_and_connect(true, &cx).await?;
330    }
331    Ok::<_, anyhow::Error>(())
332}
333
334async fn installation_id() -> Result<String> {
335    let legacy_key_name = "device_id";
336
337    if let Ok(Some(installation_id)) = KEY_VALUE_STORE.read_kvp(legacy_key_name) {
338        Ok(installation_id)
339    } else {
340        let installation_id = Uuid::new_v4().to_string();
341
342        KEY_VALUE_STORE
343            .write_kvp(legacy_key_name.to_string(), installation_id.clone())
344            .await?;
345
346        Ok(installation_id)
347    }
348}
349
350async fn restore_or_create_workspace(app_state: &Arc<AppState>, mut cx: AsyncAppContext) {
351    async_maybe!({
352        if let Some(location) = workspace::last_opened_workspace_paths().await {
353            cx.update(|cx| workspace::open_paths(location.paths().as_ref(), app_state, None, cx))?
354                .await
355                .log_err();
356        } else if matches!(KEY_VALUE_STORE.read_kvp(FIRST_OPEN), Ok(None)) {
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: i64,
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: Utc::now().timestamp_millis(),
513            backtrace,
514            installation_id: installation_id.clone(),
515            session_id: session_id.clone(),
516        };
517
518        if let Some(panic_data_json) = serde_json::to_string_pretty(&panic_data).log_err() {
519            log::error!("{}", panic_data_json);
520        }
521
522        if !is_pty {
523            if let Some(panic_data_json) = serde_json::to_string(&panic_data).log_err() {
524                let timestamp = chrono::Utc::now().format("%Y_%m_%d %H_%M_%S").to_string();
525                let panic_file_path = paths::LOGS_DIR.join(format!("zed-{}.panic", timestamp));
526                let panic_file = std::fs::OpenOptions::new()
527                    .append(true)
528                    .create(true)
529                    .open(&panic_file_path)
530                    .log_err();
531                if let Some(mut panic_file) = panic_file {
532                    writeln!(&mut panic_file, "{}", panic_data_json).log_err();
533                    panic_file.flush().log_err();
534                }
535            }
536        }
537
538        std::process::abort();
539    }));
540}
541
542fn upload_previous_panics(http: Arc<dyn HttpClient>, cx: &mut AppContext) {
543    let telemetry_settings = *client::TelemetrySettings::get_global(cx);
544
545    cx.background_executor()
546        .spawn(async move {
547            let panic_report_url = format!("{}/api/panic", &*client::ZED_SERVER_URL);
548            let mut children = smol::fs::read_dir(&*paths::LOGS_DIR).await?;
549            while let Some(child) = children.next().await {
550                let child = child?;
551                let child_path = child.path();
552
553                if child_path.extension() != Some(OsStr::new("panic")) {
554                    continue;
555                }
556                let filename = if let Some(filename) = child_path.file_name() {
557                    filename.to_string_lossy()
558                } else {
559                    continue;
560                };
561
562                if !filename.starts_with("zed") {
563                    continue;
564                }
565
566                if telemetry_settings.diagnostics {
567                    let panic_file_content = smol::fs::read_to_string(&child_path)
568                        .await
569                        .context("error reading panic file")?;
570
571                    let panic = serde_json::from_str(&panic_file_content)
572                        .ok()
573                        .or_else(|| {
574                            panic_file_content
575                                .lines()
576                                .next()
577                                .and_then(|line| serde_json::from_str(line).ok())
578                        })
579                        .unwrap_or_else(|| {
580                            log::error!(
581                                "failed to deserialize panic file {:?}",
582                                panic_file_content
583                            );
584                            None
585                        });
586
587                    if let Some(panic) = panic {
588                        let body = serde_json::to_string(&PanicRequest {
589                            panic,
590                            token: client::ZED_SECRET_CLIENT_TOKEN.into(),
591                        })
592                        .unwrap();
593
594                        let request = Request::post(&panic_report_url)
595                            .redirect_policy(isahc::config::RedirectPolicy::Follow)
596                            .header("Content-Type", "application/json")
597                            .body(body.into())?;
598                        let response = http.send(request).await.context("error sending panic")?;
599                        if !response.status().is_success() {
600                            log::error!("Error uploading panic to server: {}", response.status());
601                        }
602                    }
603                }
604
605                // We've done what we can, delete the file
606                std::fs::remove_file(child_path)
607                    .context("error removing panic")
608                    .log_err();
609            }
610            Ok::<_, anyhow::Error>(())
611        })
612        .detach_and_log_err(cx);
613}
614
615async fn load_login_shell_environment() -> Result<()> {
616    let marker = "ZED_LOGIN_SHELL_START";
617    let shell = env::var("SHELL").context(
618        "SHELL environment variable is not assigned so we can't source login environment variables",
619    )?;
620    let output = Command::new(&shell)
621        .args(["-lic", &format!("echo {marker} && /usr/bin/env -0")])
622        .output()
623        .await
624        .context("failed to spawn login shell to source login environment variables")?;
625    if !output.status.success() {
626        Err(anyhow!("login shell exited with error"))?;
627    }
628
629    let stdout = String::from_utf8_lossy(&output.stdout);
630
631    if let Some(env_output_start) = stdout.find(marker) {
632        let env_output = &stdout[env_output_start + marker.len()..];
633        for line in env_output.split_terminator('\0') {
634            if let Some(separator_index) = line.find('=') {
635                let key = &line[..separator_index];
636                let value = &line[separator_index + 1..];
637                env::set_var(key, value);
638            }
639        }
640        log::info!(
641            "set environment variables from shell:{}, path:{}",
642            shell,
643            env::var("PATH").unwrap_or_default(),
644        );
645    }
646
647    Ok(())
648}
649
650fn stdout_is_a_pty() -> bool {
651    std::env::var(FORCE_CLI_MODE_ENV_VAR_NAME).ok().is_none() && std::io::stdout().is_terminal()
652}
653
654fn collect_url_args() -> Vec<String> {
655    env::args()
656        .skip(1)
657        .filter_map(|arg| match std::fs::canonicalize(Path::new(&arg)) {
658            Ok(path) => Some(format!("file://{}", path.to_string_lossy())),
659            Err(error) => {
660                if let Some(_) = parse_zed_link(&arg) {
661                    Some(arg)
662                } else {
663                    log::error!("error parsing path argument: {}", error);
664                    None
665                }
666            }
667        })
668        .collect()
669}
670
671fn load_embedded_fonts(cx: &AppContext) {
672    let asset_source = cx.asset_source();
673    let font_paths = asset_source.list("fonts").unwrap();
674    let embedded_fonts = Mutex::new(Vec::new());
675    let executor = cx.background_executor();
676
677    executor.block(executor.scoped(|scope| {
678        for font_path in &font_paths {
679            if !font_path.ends_with(".ttf") {
680                continue;
681            }
682
683            scope.spawn(async {
684                let font_bytes = asset_source.load(font_path).unwrap().to_vec();
685                embedded_fonts.lock().push(Arc::from(font_bytes));
686            });
687        }
688    }));
689
690    cx.text_system()
691        .add_fonts(&embedded_fonts.into_inner())
692        .unwrap();
693}
694
695// #[cfg(debug_assertions)]
696// async fn watch_themes(fs: Arc<dyn Fs>, mut cx: AsyncAppContext) -> Option<()> {
697//     let mut events = fs
698//         .watch("styles/src".as_ref(), Duration::from_millis(100))
699//         .await;
700//     while (events.next().await).is_some() {
701//         let output = Command::new("npm")
702//             .current_dir("styles")
703//             .args(["run", "build"])
704//             .output()
705//             .await
706//             .log_err()?;
707//         if output.status.success() {
708//             cx.update(|cx| theme_selector::reload(cx))
709//         } else {
710//             eprintln!(
711//                 "build script failed {}",
712//                 String::from_utf8_lossy(&output.stderr)
713//             );
714//         }
715//     }
716//     Some(())
717// }
718
719// #[cfg(debug_assertions)]
720// async fn watch_languages(fs: Arc<dyn Fs>, languages: Arc<LanguageRegistry>) -> Option<()> {
721//     let mut events = fs
722//         .watch(
723//             "crates/zed/src/languages".as_ref(),
724//             Duration::from_millis(100),
725//         )
726//         .await;
727//     while (events.next().await).is_some() {
728//         languages.reload();
729//     }
730//     Some(())
731// }
732
733// #[cfg(debug_assertions)]
734// fn watch_file_types(fs: Arc<dyn Fs>, cx: &mut AppContext) {
735//     cx.spawn(|mut cx| async move {
736//         let mut events = fs
737//             .watch(
738//                 "assets/icons/file_icons/file_types.json".as_ref(),
739//                 Duration::from_millis(100),
740//             )
741//             .await;
742//         while (events.next().await).is_some() {
743//             cx.update(|cx| {
744//                 cx.update_global(|file_types, _| {
745//                     *file_types = project_panel::file_associations::FileAssociations::new(Assets);
746//                 });
747//             })
748//         }
749//     })
750//     .detach()
751// }
752
753// #[cfg(not(debug_assertions))]
754// async fn watch_themes(_fs: Arc<dyn Fs>, _cx: AsyncAppContext) -> Option<()> {
755//     None
756// }
757
758// #[cfg(not(debug_assertions))]
759// async fn watch_languages(_: Arc<dyn Fs>, _: Arc<LanguageRegistry>) -> Option<()> {
760//     None
761//
762
763// #[cfg(not(debug_assertions))]
764// fn watch_file_types(_fs: Arc<dyn Fs>, _cx: &mut AppContext) {}
765
766pub fn background_actions() -> &'static [(&'static str, &'static dyn Action)] {
767    // &[
768    //     ("Go to file", &file_finder::Toggle),
769    //     ("Open command palette", &command_palette::Toggle),
770    //     ("Open recent projects", &recent_projects::OpenRecent),
771    //     ("Change your settings", &zed_actions::OpenSettings),
772    // ]
773    // todo!()
774    &[]
775}