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