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