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