diff --git a/Cargo.lock b/Cargo.lock index 5280fc72d074c22414b603a9b7092f2005f07a85..cf194de172d1968f202c03aff2fddf214cd10e45 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9,6 +9,7 @@ dependencies = [ "action_log", "agent-client-protocol", "anyhow", + "async-channel 2.5.0", "base64 0.22.1", "buffer_diff", "chrono", @@ -33,7 +34,6 @@ dependencies = [ "serde", "serde_json", "settings", - "smol", "task", "telemetry", "terminal", @@ -148,6 +148,8 @@ dependencies = [ "agent_servers", "agent_settings", "anyhow", + "async-channel 2.5.0", + "async-io", "chrono", "client", "clock", @@ -194,7 +196,6 @@ dependencies = [ "settings", "shell_command_parser", "smallvec", - "smol", "sqlez", "streaming_diff", "strsim", @@ -256,6 +257,7 @@ dependencies = [ "action_log", "agent-client-protocol", "anyhow", + "async-channel 2.5.0", "async-trait", "chrono", "client", @@ -280,7 +282,6 @@ dependencies = [ "serde", "serde_json", "settings", - "smol", "task", "tempfile", "terminal", @@ -327,6 +328,7 @@ dependencies = [ "agent_settings", "ai_onboarding", "anyhow", + "async-channel 2.5.0", "audio", "base64 0.22.1", "buffer_diff", @@ -347,6 +349,7 @@ dependencies = [ "file_icons", "fs", "futures 0.3.32", + "futures-lite 1.13.0", "fuzzy", "git", "gpui", @@ -392,7 +395,6 @@ dependencies = [ "serde_json", "serde_json_lenient", "settings", - "smol", "streaming_diff", "task", "telemetry", @@ -890,7 +892,7 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8034a681df4aed8b8edbd7fbe472401ecf009251c8b40556b304567052e294c5" dependencies = [ - "async-lock 3.4.2", + "async-lock", "blocking", "futures-lite 2.6.1", ] @@ -904,7 +906,7 @@ dependencies = [ "async-channel 2.5.0", "async-executor", "async-io", - "async-lock 3.4.2", + "async-lock", "blocking", "futures-lite 2.6.1", "once_cell", @@ -928,15 +930,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "async-lock" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" -dependencies = [ - "event-listener 2.5.3", -] - [[package]] name = "async-lock" version = "3.4.2" @@ -976,7 +969,7 @@ checksum = "fc50921ec0055cdd8a16de48773bfeec5c972598674347252c0399676be7da75" dependencies = [ "async-channel 2.5.0", "async-io", - "async-lock 3.4.2", + "async-lock", "async-signal", "async-task", "blocking", @@ -1004,7 +997,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43c070bbf59cd3570b6b2dd54cd772527c7c3620fce8be898406dd3ed6adc64c" dependencies = [ "async-io", - "async-lock 3.4.2", + "async-lock", "atomic-waker", "cfg-if", "futures-core", @@ -1025,7 +1018,7 @@ dependencies = [ "async-channel 1.9.0", "async-global-executor", "async-io", - "async-lock 3.4.2", + "async-lock", "async-process", "crossbeam-utils", "futures-channel", @@ -2899,6 +2892,7 @@ name = "client" version = "0.1.0" dependencies = [ "anyhow", + "async-channel 2.5.0", "async-tungstenite", "base64 0.22.1", "chrono", @@ -2966,6 +2960,7 @@ name = "cloud_api_client" version = "0.1.0" dependencies = [ "anyhow", + "async-lock", "cloud_api_types", "futures 0.3.32", "gpui", @@ -2973,7 +2968,6 @@ dependencies = [ "http_client", "parking_lot", "serde_json", - "smol", "thiserror 2.0.17", "yawc", ] @@ -3120,6 +3114,7 @@ version = "0.44.0" dependencies = [ "agent", "anyhow", + "async-channel 2.5.0", "async-trait", "async-tungstenite", "aws-config", @@ -3485,15 +3480,19 @@ name = "context_server" version = "0.1.0" dependencies = [ "anyhow", + "async-channel 2.5.0", + "async-process", "async-trait", "base64 0.22.1", "collections", "futures 0.3.32", + "futures-lite 1.13.0", "gpui", "http_client", "log", "net", "parking_lot", + "pollster 0.4.0", "postage", "rand 0.9.2", "schemars", @@ -3502,7 +3501,6 @@ dependencies = [ "settings", "sha2", "slotmap", - "smol", "tempfile", "terminal", "tiny_http", @@ -4031,6 +4029,7 @@ dependencies = [ name = "crashes" version = "0.1.0" dependencies = [ + "async-process", "cfg-if", "crash-handler", "futures 0.3.32", @@ -4042,7 +4041,6 @@ dependencies = [ "release_channel", "serde", "serde_json", - "smol", "system_specs", "windows 0.61.3", "zstd", @@ -4540,7 +4538,6 @@ dependencies = [ "log", "paths", "release_channel", - "smol", "sqlez", "sqlez_macros", "tempfile", @@ -5371,6 +5368,7 @@ dependencies = [ "file_icons", "fs", "futures 0.3.32", + "futures-lite 1.13.0", "fuzzy", "git", "gpui", @@ -5401,7 +5399,6 @@ dependencies = [ "serde_json", "settings", "smallvec", - "smol", "snippet", "sum_tree", "task", @@ -6461,6 +6458,7 @@ version = "0.1.0" dependencies = [ "anyhow", "ashpd", + "async-channel 2.5.0", "async-tar", "async-trait", "collections", @@ -7125,6 +7123,7 @@ version = "0.1.0" dependencies = [ "anyhow", "askpass", + "async-channel 2.5.0", "async-trait", "collections", "derive_more", @@ -7174,6 +7173,7 @@ name = "git_graph" version = "0.1.0" dependencies = [ "anyhow", + "async-channel 2.5.0", "collections", "db", "editor", @@ -7190,7 +7190,6 @@ dependencies = [ "serde_json", "settings", "smallvec", - "smol", "theme", "theme_settings", "time", @@ -7237,6 +7236,7 @@ dependencies = [ "editor", "file_icons", "futures 0.3.32", + "futures-lite 1.13.0", "fuzzy", "git", "gpui", @@ -7264,7 +7264,6 @@ dependencies = [ "serde_json", "settings", "smallvec", - "smol", "strum 0.27.2", "telemetry", "theme", @@ -9289,6 +9288,7 @@ dependencies = [ "encoding_rs", "fs", "futures 0.3.32", + "futures-lite 1.13.0", "fuzzy", "globset", "gpui", @@ -9311,7 +9311,6 @@ dependencies = [ "settings", "shellexpand 2.1.2", "smallvec", - "smol", "streaming-iterator", "strsim", "sum_tree", @@ -9409,6 +9408,7 @@ name = "language_model_core" version = "0.1.0" dependencies = [ "anyhow", + "async-lock", "cloud_llm_client", "futures 0.3.32", "gpui_shared_string", @@ -9417,7 +9417,6 @@ dependencies = [ "schemars", "serde", "serde_json", - "smol", "strum 0.27.2", "thiserror 2.0.17", ] @@ -9429,6 +9428,7 @@ dependencies = [ "ai_onboarding", "anthropic", "anyhow", + "async-lock", "aws-config", "aws-credential-types", "aws_http_client", @@ -9470,7 +9470,6 @@ dependencies = [ "serde", "serde_json", "settings", - "smol", "strum 0.27.2", "tiktoken-rs", "tokio", @@ -9498,7 +9497,6 @@ dependencies = [ "semver", "serde", "serde_json", - "smol", "thiserror 2.0.17", "x_ai", ] @@ -10725,6 +10723,7 @@ dependencies = [ "clock", "collections", "ctor", + "futures-lite 1.13.0", "gpui", "indoc", "itertools 0.14.0", @@ -10737,7 +10736,6 @@ dependencies = [ "serde", "settings", "smallvec", - "smol", "sum_tree", "text", "theme", @@ -11011,7 +11009,7 @@ dependencies = [ "channel", "client", "component", - "db", + "futures-lite 1.13.0", "gpui", "rpc", "sum_tree", @@ -11605,7 +11603,7 @@ dependencies = [ "ashpd", "async-fs", "async-io", - "async-lock 3.4.2", + "async-lock", "blocking", "cbc", "cipher", @@ -11849,6 +11847,7 @@ name = "outline" version = "0.1.0" dependencies = [ "editor", + "futures 0.3.32", "fuzzy", "gpui", "indoc", @@ -11861,7 +11860,6 @@ dependencies = [ "rope", "serde_json", "settings", - "smol", "theme", "theme_settings", "ui", @@ -11875,10 +11873,12 @@ name = "outline_panel" version = "0.1.0" dependencies = [ "anyhow", + "async-channel 2.5.0", "collections", "db", "editor", "file_icons", + "futures 0.3.32", "fuzzy", "gpui", "itertools 0.14.0", @@ -11894,7 +11894,6 @@ dependencies = [ "serde_json", "settings", "smallvec", - "smol", "theme", "theme_settings", "ui", @@ -13242,6 +13241,7 @@ dependencies = [ "aho-corasick", "anyhow", "askpass", + "async-channel 2.5.0", "async-trait", "base64 0.22.1", "buffer_diff", @@ -14206,7 +14206,6 @@ dependencies = [ "serde", "serde_json", "settings", - "smol", "task", "telemetry", "ui", @@ -14419,6 +14418,7 @@ dependencies = [ "agent", "anyhow", "askpass", + "async-channel 2.5.0", "cargo_toml", "clap", "client", @@ -15509,6 +15509,7 @@ dependencies = [ "editor", "fs", "futures 0.3.32", + "futures-lite 1.13.0", "gpui", "itertools 0.14.0", "language", @@ -15520,7 +15521,6 @@ dependencies = [ "serde", "serde_json", "settings", - "smol", "theme", "theme_settings", "tracing", @@ -16046,6 +16046,7 @@ dependencies = [ "agent_settings", "agent_ui", "anyhow", + "async-channel 2.5.0", "chrono", "client", "clock", @@ -16073,7 +16074,6 @@ dependencies = [ "serde", "serde_json", "settings", - "smol", "theme", "theme_settings", "ui", @@ -16258,7 +16258,7 @@ dependencies = [ "async-executor", "async-fs", "async-io", - "async-lock 3.4.2", + "async-lock", "async-net", "async-process", "blocking", @@ -16425,7 +16425,7 @@ dependencies = [ "libsqlite3-sys", "log", "parking_lot", - "smol", + "pollster 0.4.0", "sqlformat", "thread_local", "util", @@ -17359,7 +17359,6 @@ dependencies = [ "serde", "serde_json", "settings", - "smol", "theme", "theme_settings", "ui", @@ -17529,8 +17528,10 @@ version = "0.1.0" dependencies = [ "alacritty_terminal", "anyhow", + "async-channel 2.5.0", "collections", "futures 0.3.32", + "futures-lite 1.13.0", "gpui", "itertools 0.14.0", "libc", @@ -17542,7 +17543,6 @@ dependencies = [ "schemars", "serde", "settings", - "smol", "sysinfo 0.37.2", "task", "theme", @@ -21690,6 +21690,7 @@ dependencies = [ "feature_flags", "fs", "futures 0.3.32", + "futures-lite 1.13.0", "git", "gpui", "http_client", @@ -21731,7 +21732,8 @@ name = "worktree" version = "0.1.0" dependencies = [ "anyhow", - "async-lock 2.8.0", + "async-channel 2.5.0", + "async-lock", "chardetng", "clock", "collections", @@ -21754,7 +21756,6 @@ dependencies = [ "serde_json", "settings", "smallvec", - "smol", "sum_tree", "text", "tracing", @@ -22087,7 +22088,7 @@ dependencies = [ "async-broadcast", "async-executor", "async-io", - "async-lock 3.4.2", + "async-lock", "async-process", "async-recursion", "async-task", diff --git a/Cargo.toml b/Cargo.toml index 9825c8319a7bb3440782b155d9952619096bdfd5..5ea242e225fa1e16bb2e6b9b7161982405ff1e97 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -506,13 +506,15 @@ async-compat = "0.2.1" async-compression = { version = "0.4", features = ["bzip2", "gzip", "futures-io"] } async-dispatcher = "0.1" async-fs = "2.1" -async-lock = "2.1" +async-io = "2.6.0" +async-lock = "3.4.2" async-pipe = { git = "https://github.com/zed-industries/async-pipe-rs", rev = "82d00a04211cf4e1236029aa03e6b6ce2a74c553" } async-recursion = "1.0.0" async-tar = "0.5.1" async-task = "4.7" async-trait = "0.1" async-tungstenite = "0.31.0" +async-process = "2.5.0" async_zip = { version = "0.0.18", features = ["deflate", "deflate64"] } aws-config = { version = "1.8.10", features = ["behavior-version-latest"] } aws-credential-types = { version = "1.2.8", features = [ diff --git a/crates/acp_thread/Cargo.toml b/crates/acp_thread/Cargo.toml index 7ef53bc522708680e64cfcc9ce2860990bfd7d13..f5d5ac6900650a5308a4b700d44764365a66fcc1 100644 --- a/crates/acp_thread/Cargo.toml +++ b/crates/acp_thread/Cargo.toml @@ -18,6 +18,7 @@ test-support = ["gpui/test-support", "project/test-support", "dep:parking_lot", [dependencies] action_log.workspace = true agent-client-protocol.workspace = true +async-channel.workspace = true base64.workspace = true anyhow.workspace = true buffer_diff.workspace = true @@ -40,7 +41,6 @@ prompt_store.workspace = true serde.workspace = true serde_json.workspace = true settings.workspace = true -smol.workspace = true task.workspace = true telemetry.workspace = true terminal.workspace = true diff --git a/crates/acp_thread/src/acp_thread.rs b/crates/acp_thread/src/acp_thread.rs index 7fb48c132f971fd3449d116b22bd4437c1ebf611..7027714b438c7eae25da35fd5424940683fe367c 100644 --- a/crates/acp_thread/src/acp_thread.rs +++ b/crates/acp_thread/src/acp_thread.rs @@ -2992,6 +2992,7 @@ fn markdown_for_raw_output( mod tests { use super::*; use anyhow::anyhow; + use futures::stream::StreamExt as _; use futures::{channel::mpsc, future::LocalBoxFuture, select}; use gpui::{App, AsyncApp, TestAppContext, WeakEntity}; use indoc::indoc; @@ -2999,7 +3000,6 @@ mod tests { use rand::{distr, prelude::*}; use serde_json::json; use settings::SettingsStore; - use smol::stream::StreamExt as _; use std::{ any::Any, cell::RefCell, @@ -3204,7 +3204,7 @@ mod tests { // Create a real PTY terminal that runs a command which prints output then sleeps // We use printf instead of echo and chain with && sleep to ensure proper execution - let (completion_tx, _completion_rx) = smol::channel::unbounded(); + let (completion_tx, _completion_rx) = async_channel::unbounded(); let (program, args) = ShellBuilder::new(&Shell::System, false).build( Some("printf 'output_before_kill\\n' && sleep 60".to_owned()), &[], diff --git a/crates/acp_thread/src/connection.rs b/crates/acp_thread/src/connection.rs index 32bb8abde9aa5f67563780a7fe4993028f0df346..e451f9d74f47223e6ef45c0708edebf0eb721f1b 100644 --- a/crates/acp_thread/src/connection.rs +++ b/crates/acp_thread/src/connection.rs @@ -318,7 +318,7 @@ pub trait AgentSessionList { Task::ready(Err(anyhow::anyhow!("delete_sessions not supported"))) } - fn watch(&self, _cx: &mut App) -> Option> { + fn watch(&self, _cx: &mut App) -> Option> { None } diff --git a/crates/agent/Cargo.toml b/crates/agent/Cargo.toml index a5a4c2742a444bf2e8b0a12b0bb233c6e51684f2..ce472fd9e36ee9f5bf824c53035422ba3ba4f69e 100644 --- a/crates/agent/Cargo.toml +++ b/crates/agent/Cargo.toml @@ -19,6 +19,7 @@ workspace = true [dependencies] acp_thread.workspace = true action_log.workspace = true +async-channel.workspace = true agent-client-protocol.workspace = true agent_servers.workspace = true agent_settings.workspace = true @@ -59,7 +60,6 @@ serde_json.workspace = true settings.workspace = true shell_command_parser.workspace = true smallvec.workspace = true -smol.workspace = true sqlez.workspace = true streaming_diff.workspace = true strsim.workspace = true @@ -77,6 +77,7 @@ zed_env_vars.workspace = true zstd.workspace = true [dev-dependencies] +async-io.workspace = true agent_servers = { workspace = true, "features" = ["test-support"] } client = { workspace = true, "features" = ["test-support"] } clock = { workspace = true, "features" = ["test-support"] } diff --git a/crates/agent/src/agent.rs b/crates/agent/src/agent.rs index fe62d851ef1ba71c787aa6ec516b0b6b67449d67..1b9c74487e46146896a8d189ff686fd09c2b71ec 100644 --- a/crates/agent/src/agent.rs +++ b/crates/agent/src/agent.rs @@ -1647,14 +1647,14 @@ impl acp_thread::AgentTelemetry for NativeAgentConnection { pub struct NativeAgentSessionList { thread_store: Entity, - updates_tx: smol::channel::Sender, - updates_rx: smol::channel::Receiver, + updates_tx: async_channel::Sender, + updates_rx: async_channel::Receiver, _subscription: Subscription, } impl NativeAgentSessionList { fn new(thread_store: Entity, cx: &mut App) -> Self { - let (tx, rx) = smol::channel::unbounded(); + let (tx, rx) = async_channel::unbounded(); let this_tx = tx.clone(); let subscription = cx.observe(&thread_store, move |_, _| { this_tx @@ -1706,7 +1706,7 @@ impl AgentSessionList for NativeAgentSessionList { fn watch( &self, _cx: &mut App, - ) -> Option> { + ) -> Option> { Some(self.updates_rx.clone()) } diff --git a/crates/agent/src/edit_agent/evals.rs b/crates/agent/src/edit_agent/evals.rs index ba8b7ed867ea26bcdcdee7f8bf20390c2f9592b3..c1c2886f84e0aab08fd548b0f33e811ebbe9e630 100644 --- a/crates/agent/src/edit_agent/evals.rs +++ b/crates/agent/src/edit_agent/evals.rs @@ -1670,7 +1670,7 @@ async fn retry_on_rate_limit(mut request: impl AsyncFnMut() -> Result) -> eprintln!("Attempt #{attempt}: Retry after {retry_after:?} + jitter of {jitter:?}"); // This code does not use the gpui::executor #[allow(clippy::disallowed_methods)] - smol::Timer::after(retry_after + jitter).await; + async_io::Timer::after(retry_after + jitter).await; } else { return response; } diff --git a/crates/agent/src/tools/evals/streaming_edit_file.rs b/crates/agent/src/tools/evals/streaming_edit_file.rs index 0c6290ec098f9c37a0f6a077daf0a041c013d8ff..3156fd253978bc887a451635dc48ca21894c11f5 100644 --- a/crates/agent/src/tools/evals/streaming_edit_file.rs +++ b/crates/agent/src/tools/evals/streaming_edit_file.rs @@ -729,7 +729,7 @@ async fn retry_on_rate_limit(mut request: impl AsyncFnMut() -> Result) -> let jitter = retry_after.mul_f64(rand::rng().random_range(0.0..1.0)); eprintln!("Attempt #{attempt}: Retry after {retry_after:?} + jitter of {jitter:?}"); #[allow(clippy::disallowed_methods)] - smol::Timer::after(retry_after + jitter).await; + async_io::Timer::after(retry_after + jitter).await; } else { return response; } diff --git a/crates/agent_servers/Cargo.toml b/crates/agent_servers/Cargo.toml index 5fbf1e821cb4a41f09c433ec05fdde9fbbde1a9f..f6a5e5066771ef53767376a7701b0a12fc0e5094 100644 --- a/crates/agent_servers/Cargo.toml +++ b/crates/agent_servers/Cargo.toml @@ -20,6 +20,7 @@ doctest = false acp_tools.workspace = true acp_thread.workspace = true action_log.workspace = true +async-channel.workspace = true agent-client-protocol.workspace = true anyhow.workspace = true async-trait.workspace = true @@ -44,7 +45,6 @@ reqwest_client = { workspace = true, optional = true } serde.workspace = true serde_json.workspace = true settings.workspace = true -smol.workspace = true task.workspace = true tempfile.workspace = true thiserror.workspace = true diff --git a/crates/agent_servers/src/acp.rs b/crates/agent_servers/src/acp.rs index dbcaabed1cf1971a6e281d8d31f8dad25dfb7434..e4e20fcabae31568674723b51ba488a2fbd5ae7a 100644 --- a/crates/agent_servers/src/acp.rs +++ b/crates/agent_servers/src/acp.rs @@ -85,13 +85,13 @@ pub struct AcpSession { pub struct AcpSessionList { connection: Rc, - updates_tx: smol::channel::Sender, - updates_rx: smol::channel::Receiver, + updates_tx: async_channel::Sender, + updates_rx: async_channel::Receiver, } impl AcpSessionList { fn new(connection: Rc) -> Self { - let (tx, rx) = smol::channel::unbounded(); + let (tx, rx) = async_channel::unbounded(); Self { connection, updates_tx: tx, @@ -150,7 +150,7 @@ impl AgentSessionList for AcpSessionList { fn watch( &self, _cx: &mut App, - ) -> Option> { + ) -> Option> { Some(self.updates_rx.clone()) } diff --git a/crates/agent_ui/Cargo.toml b/crates/agent_ui/Cargo.toml index 78f035106d37faa16a1494a138dfa38ed304dd8d..7ea7f23b2fa779a8a6e2bee5d7cf4c476bc2d62b 100644 --- a/crates/agent_ui/Cargo.toml +++ b/crates/agent_ui/Cargo.toml @@ -30,6 +30,7 @@ acp_thread.workspace = true action_log.workspace = true agent-client-protocol.workspace = true agent.workspace = true +async-channel.workspace = true agent_servers.workspace = true agent_settings.workspace = true ai_onboarding.workspace = true @@ -54,6 +55,7 @@ feature_flags.workspace = true file_icons.workspace = true fs.workspace = true futures.workspace = true +futures-lite.workspace = true git.workspace = true fuzzy.workspace = true gpui.workspace = true @@ -91,7 +93,6 @@ serde.workspace = true serde_json.workspace = true serde_json_lenient.workspace = true settings.workspace = true -smol.workspace = true streaming_diff.workspace = true task.workspace = true telemetry.workspace = true diff --git a/crates/agent_ui/src/buffer_codegen.rs b/crates/agent_ui/src/buffer_codegen.rs index d5288c564d7211a986fa6347e2b74782c58d9c75..8be5aa52bc686256a773e8f94bb30c576a234373 100644 --- a/crates/agent_ui/src/buffer_codegen.rs +++ b/crates/agent_ui/src/buffer_codegen.rs @@ -3,6 +3,7 @@ use agent_settings::AgentSettings; use anyhow::{Context as _, Result}; use collections::HashSet; use editor::{Anchor, AnchorRangeExt, MultiBuffer, MultiBufferSnapshot, ToOffset as _, ToPoint}; +use futures::FutureExt; use futures::{ SinkExt, Stream, StreamExt, TryStreamExt as _, channel::mpsc, @@ -28,7 +29,6 @@ use rope::Rope; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use settings::Settings as _; -use smol::future::FutureExt; use std::{ cmp, future::Future, diff --git a/crates/agent_ui/src/inline_assistant.rs b/crates/agent_ui/src/inline_assistant.rs index f2beb719cc7e5638cfc36f339419bda405a8e773..0eb769c09ec5940308cfc135a8465ce38ac0b749 100644 --- a/crates/agent_ui/src/inline_assistant.rs +++ b/crates/agent_ui/src/inline_assistant.rs @@ -1862,12 +1862,12 @@ pub mod evals { use eval_utils::{EvalOutput, NoProcessor}; use fs::FakeFs; use futures::channel::mpsc; + use futures::stream::StreamExt as _; use gpui::{AppContext, TestAppContext, UpdateGlobal as _}; use language::Buffer; use language_model::{LanguageModelRegistry, SelectedModel}; use project::Project; use prompt_store::PromptBuilder; - use smol::stream::StreamExt as _; use std::str::FromStr; use std::sync::Arc; use util::test::marked_text_ranges; diff --git a/crates/agent_ui/src/thread_history.rs b/crates/agent_ui/src/thread_history.rs index 7b7a3e60211896bf717fb3dfb2670d92b7409281..d9e00e30d341e4831d403c68e1894725406c6890 100644 --- a/crates/agent_ui/src/thread_history.rs +++ b/crates/agent_ui/src/thread_history.rs @@ -222,6 +222,7 @@ impl ThreadHistory { mod tests { use super::*; use acp_thread::AgentSessionListResponse; + use futures_lite::future::yield_now; use gpui::TestAppContext; use std::{ any::Any, @@ -239,13 +240,13 @@ mod tests { #[derive(Clone)] struct TestSessionList { sessions: Vec, - updates_tx: smol::channel::Sender, - updates_rx: smol::channel::Receiver, + updates_tx: async_channel::Sender, + updates_rx: async_channel::Receiver, } impl TestSessionList { fn new(sessions: Vec) -> Self { - let (tx, rx) = smol::channel::unbounded(); + let (tx, rx) = async_channel::unbounded(); Self { sessions, updates_tx: tx, @@ -267,7 +268,7 @@ mod tests { Task::ready(Ok(AgentSessionListResponse::new(self.sessions.clone()))) } - fn watch(&self, _cx: &mut App) -> Option> { + fn watch(&self, _cx: &mut App) -> Option> { Some(self.updates_rx.clone()) } @@ -286,8 +287,8 @@ mod tests { second_page_sessions: Vec, requested_cursors: Arc>>>, async_responses: bool, - updates_tx: smol::channel::Sender, - updates_rx: smol::channel::Receiver, + updates_tx: async_channel::Sender, + updates_rx: async_channel::Receiver, } impl PaginatedTestSessionList { @@ -295,7 +296,7 @@ mod tests { first_page_sessions: Vec, second_page_sessions: Vec, ) -> Self { - let (tx, rx) = smol::channel::unbounded(); + let (tx, rx) = async_channel::unbounded(); Self { first_page_sessions, second_page_sessions, @@ -353,7 +354,7 @@ mod tests { if self.async_responses { cx.foreground_executor().spawn(async move { - smol::future::yield_now().await; + yield_now().await; Ok(respond()) }) } else { @@ -361,7 +362,7 @@ mod tests { } } - fn watch(&self, _cx: &mut App) -> Option> { + fn watch(&self, _cx: &mut App) -> Option> { Some(self.updates_rx.clone()) } diff --git a/crates/agent_ui/src/thread_metadata_store.rs b/crates/agent_ui/src/thread_metadata_store.rs index 4ba68b400a60320e95bfd645ee662f6483dc6cf4..807ead57e3e839f3c6b4550f743e4515e60b9576 100644 --- a/crates/agent_ui/src/thread_metadata_store.rs +++ b/crates/agent_ui/src/thread_metadata_store.rs @@ -411,8 +411,8 @@ pub struct ThreadMetadataStore { threads_by_main_paths: HashMap>, reload_task: Option>>, session_subscriptions: HashMap, - pending_thread_ops_tx: smol::channel::Sender, - in_flight_archives: HashMap, smol::channel::Sender<()>)>, + pending_thread_ops_tx: async_channel::Sender, + in_flight_archives: HashMap, async_channel::Sender<()>)>, _db_operations_task: Task<()>, } @@ -448,7 +448,7 @@ impl ThreadMetadataStore { let thread = std::thread::current(); let test_name = thread.name().unwrap_or("unknown_test"); let db_name = format!("THREAD_METADATA_DB_{}", test_name); - let db = smol::block_on(db::open_test_db::(&db_name)); + let db = gpui::block_on(db::open_test_db::(&db_name)); let thread_store = cx.new(|cx| Self::new(ThreadMetadataDb(db), cx)); cx.set_global(GlobalThreadMetadataStore(thread_store)); } @@ -633,7 +633,7 @@ impl ThreadMetadataStore { pub fn archive( &mut self, session_id: &acp::SessionId, - archive_job: Option<(Task<()>, smol::channel::Sender<()>)>, + archive_job: Option<(Task<()>, async_channel::Sender<()>)>, cx: &mut Context, ) { self.update_archived(session_id, true, cx); @@ -908,7 +908,7 @@ impl ThreadMetadataStore { }) .detach(); - let (tx, rx) = smol::channel::unbounded(); + let (tx, rx) = async_channel::unbounded(); let _db_operations_task = cx.background_spawn({ let db = db.clone(); async move { @@ -1441,7 +1441,7 @@ mod tests { fn clear_thread_metadata_remote_connection_backfill(cx: &mut TestAppContext) { let kvp = cx.update(|cx| KeyValueStore::global(cx)); - smol::block_on(kvp.delete_kvp("thread-metadata-remote-connection-backfill".to_string())) + gpui::block_on(kvp.delete_kvp("thread-metadata-remote-connection-backfill".to_string())) .unwrap(); } @@ -1464,7 +1464,7 @@ mod tests { let thread = std::thread::current(); let test_name = thread.name().unwrap_or("unknown_test"); let db_name = format!("THREAD_METADATA_DB_{}", test_name); - let db = ThreadMetadataDb(smol::block_on(db::open_test_db::( + let db = ThreadMetadataDb(gpui::block_on(db::open_test_db::( &db_name, ))); diff --git a/crates/agent_ui/src/threads_archive_view.rs b/crates/agent_ui/src/threads_archive_view.rs index 6e73584ef87f11810e4c860cc6ff4c8d8ff015a9..844d1710547fb7a724ea5c087fdeee944ee5eeb1 100644 --- a/crates/agent_ui/src/threads_archive_view.rs +++ b/crates/agent_ui/src/threads_archive_view.rs @@ -1065,7 +1065,7 @@ impl PickerDelegate for ProjectPickerDelegate { }) .collect(); - let mut sibling_matches = smol::block_on(fuzzy::match_strings( + let mut sibling_matches = gpui::block_on(fuzzy::match_strings( &sibling_candidates, query, smart_case, @@ -1099,7 +1099,7 @@ impl PickerDelegate for ProjectPickerDelegate { }) .collect(); - let mut recent_matches = smol::block_on(fuzzy::match_strings( + let mut recent_matches = gpui::block_on(fuzzy::match_strings( &recent_candidates, query, smart_case, diff --git a/crates/client/Cargo.toml b/crates/client/Cargo.toml index 532fe38f7df1f686730ed862a81806e9a531e156..0a3c49d1237823d4bfc85512d0f2cbc99ed1fc31 100644 --- a/crates/client/Cargo.toml +++ b/crates/client/Cargo.toml @@ -17,6 +17,7 @@ test-support = ["clock/test-support", "collections/test-support", "gpui/test-sup [dependencies] anyhow.workspace = true +async-channel.workspace = true async-tungstenite = { workspace = true, features = ["tokio", "tokio-rustls-manual-roots"] } base64.workspace = true chrono = { workspace = true, features = ["serde"] } diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index 05ca974f80438542b232262dd375e0e38ab4327c..ba3219e08bb0d86fe25a385f8d4d7b159770e85e 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -2164,8 +2164,8 @@ mod tests { }); let server = FakeServer::for_client(user_id, &client, cx).await; - let (done_tx1, done_rx1) = smol::channel::unbounded(); - let (done_tx2, done_rx2) = smol::channel::unbounded(); + let (done_tx1, done_rx1) = async_channel::unbounded(); + let (done_tx2, done_rx2) = async_channel::unbounded(); AnyProtoClient::from(client.clone()).add_entity_message_handler( move |entity: Entity, _: TypedEnvelope, cx| { match entity.read_with(&cx, |entity, _| entity.id) { @@ -2235,8 +2235,8 @@ mod tests { let server = FakeServer::for_client(user_id, &client, cx).await; let entity = cx.new(|_| TestEntity::default()); - let (done_tx1, _done_rx1) = smol::channel::unbounded(); - let (done_tx2, done_rx2) = smol::channel::unbounded(); + let (done_tx1, _done_rx1) = async_channel::unbounded(); + let (done_tx2, done_rx2) = async_channel::unbounded(); let subscription1 = client.add_message_handler( entity.downgrade(), move |_, _: TypedEnvelope, _| { @@ -2270,7 +2270,7 @@ mod tests { let server = FakeServer::for_client(user_id, &client, cx).await; let entity = cx.new(|_| TestEntity::default()); - let (done_tx, done_rx) = smol::channel::unbounded(); + let (done_tx, done_rx) = async_channel::unbounded(); let subscription = client.add_message_handler( entity.clone().downgrade(), move |entity: Entity, _: TypedEnvelope, mut cx| { diff --git a/crates/cloud_api_client/Cargo.toml b/crates/cloud_api_client/Cargo.toml index cf293d83f848e1266dec977c0925af7f66608ce6..716276ccf44a3728c7013741129e92207e68201c 100644 --- a/crates/cloud_api_client/Cargo.toml +++ b/crates/cloud_api_client/Cargo.toml @@ -20,6 +20,6 @@ gpui_tokio.workspace = true http_client.workspace = true parking_lot.workspace = true serde_json.workspace = true -smol.workspace = true +async-lock.workspace = true thiserror.workspace = true yawc.workspace = true diff --git a/crates/cloud_api_client/src/llm_token.rs b/crates/cloud_api_client/src/llm_token.rs index 711e0d51b89bf34db255d7cb1e58483c9de340fc..662c88ab03064bd6314dda94fec89764c3441d28 100644 --- a/crates/cloud_api_client/src/llm_token.rs +++ b/crates/cloud_api_client/src/llm_token.rs @@ -1,7 +1,7 @@ use std::sync::Arc; +use async_lock::{RwLock, RwLockUpgradableReadGuard, RwLockWriteGuard}; use cloud_api_types::OrganizationId; -use smol::lock::{RwLock, RwLockUpgradableReadGuard, RwLockWriteGuard}; use crate::{ClientApiError, CloudApiClient}; diff --git a/crates/collab/Cargo.toml b/crates/collab/Cargo.toml index 0703d88a2c0f2fd456141faa47243ad774a473e0..f96b71c380ca549867f9559c545896650f468a6e 100644 --- a/crates/collab/Cargo.toml +++ b/crates/collab/Cargo.toml @@ -76,6 +76,7 @@ uuid.workspace = true [dev-dependencies] agent = { workspace = true, features = ["test-support"] } async-trait.workspace = true +async-channel.workspace = true buffer_diff.workspace = true call = { workspace = true, features = ["test-support"] } diff --git a/crates/collab/tests/integration/editor_tests.rs b/crates/collab/tests/integration/editor_tests.rs index 2ce3abf48f12b2ede1f0340e2e438d3df0704985..e87b880144a9b199da7940609fc00d2aa96a7549 100644 --- a/crates/collab/tests/integration/editor_tests.rs +++ b/crates/collab/tests/integration/editor_tests.rs @@ -2732,9 +2732,9 @@ async fn test_lsp_pull_diagnostics( let closure_workspace_diagnostics_pulls_result_ids = workspace_diagnostics_pulls_result_ids.clone(); let (workspace_diagnostic_cancel_tx, closure_workspace_diagnostic_cancel_rx) = - smol::channel::bounded::<()>(1); + async_channel::bounded::<()>(1); let (closure_workspace_diagnostic_received_tx, workspace_diagnostic_received_rx) = - smol::channel::bounded::<()>(1); + async_channel::bounded::<()>(1); let capabilities = lsp::ServerCapabilities { diagnostic_provider: Some(lsp::DiagnosticServerCapabilities::Options( diff --git a/crates/context_server/Cargo.toml b/crates/context_server/Cargo.toml index 0a9c94a54d70196c0a0fee04dec249ea367d56c0..f151d396636a65763525b198e06c77c5e78bb5de 100644 --- a/crates/context_server/Cargo.toml +++ b/crates/context_server/Cargo.toml @@ -16,10 +16,13 @@ test-support = ["gpui/test-support"] [dependencies] anyhow.workspace = true +async-channel.workspace = true +async-process.workspace = true async-trait.workspace = true base64.workspace = true collections.workspace = true futures.workspace = true +futures-lite.workspace = true gpui.workspace = true http_client = { workspace = true, features = ["test-support"] } log.workspace = true @@ -33,7 +36,6 @@ serde.workspace = true settings.workspace = true sha2.workspace = true slotmap.workspace = true -smol.workspace = true tempfile.workspace = true tiny_http.workspace = true url = { workspace = true, features = ["serde"] } @@ -42,3 +44,4 @@ terminal.workspace = true [dev-dependencies] gpui = { workspace = true, features = ["test-support"] } +pollster.workspace = true diff --git a/crates/context_server/src/client.rs b/crates/context_server/src/client.rs index 974c25d72977196520f0a1ffcbebd06555f63a62..676baef97326b45abfeea845744f7aede7891a08 100644 --- a/crates/context_server/src/client.rs +++ b/crates/context_server/src/client.rs @@ -1,13 +1,13 @@ use anyhow::{Context as _, Result, anyhow}; use collections::HashMap; use futures::{FutureExt, StreamExt, channel::oneshot, future, select}; +use futures_lite::future::yield_now; use gpui::{AppContext as _, AsyncApp, BackgroundExecutor, Task}; use parking_lot::Mutex; use postage::barrier; use serde::{Deserialize, Serialize, de::DeserializeOwned}; use serde_json::{Value, value::RawValue}; use slotmap::SlotMap; -use smol::channel; use std::{ fmt, path::PathBuf, @@ -49,7 +49,7 @@ pub enum RequestId { pub(crate) struct Client { server_id: ContextServerId, next_id: AtomicI32, - outbound_tx: channel::Sender, + outbound_tx: async_channel::Sender, name: Arc, subscription_set: Arc>, response_handlers: Arc>>>, @@ -197,7 +197,7 @@ impl Client { request_timeout: Option, cx: AsyncApp, ) -> Result { - let (outbound_tx, outbound_rx) = channel::unbounded::(); + let (outbound_tx, outbound_rx) = async_channel::unbounded::(); let (output_done_tx, output_done_rx) = barrier::channel(); let subscription_set = Arc::new(Mutex::new(NotificationSubscriptionSet::default())); @@ -304,7 +304,7 @@ impl Client { } } - smol::future::yield_now().await; + yield_now().await; Ok(()) } @@ -324,7 +324,7 @@ impl Client { /// writes them to the server's stdin, and manages the lifecycle of response handlers. async fn handle_output( transport: Arc, - outbound_rx: channel::Receiver, + outbound_rx: async_channel::Receiver, output_done_tx: barrier::Sender, response_handlers: Arc>>>, last_transport_error: Arc>>, diff --git a/crates/context_server/src/listener.rs b/crates/context_server/src/listener.rs index ad70c6d32e1ef65dcc85ea5c49f0aeacdc2c1098..2e395e493cc98a24d31bc845a4e38416f51de652 100644 --- a/crates/context_server/src/listener.rs +++ b/crates/context_server/src/listener.rs @@ -1,6 +1,8 @@ use ::serde::{Deserialize, Serialize}; use anyhow::{Context as _, Result}; use collections::HashMap; +use futures::AsyncReadExt; +use futures::stream::StreamExt; use futures::{ AsyncBufReadExt, AsyncRead, AsyncWrite, AsyncWriteExt, FutureExt, channel::mpsc::{UnboundedReceiver, UnboundedSender, unbounded}, @@ -12,7 +14,6 @@ use net::async_net::{UnixListener, UnixStream}; use schemars::JsonSchema; use serde::de::DeserializeOwned; use serde_json::{json, value::RawValue}; -use smol::stream::StreamExt; use std::{ any::TypeId, cell::RefCell, @@ -201,7 +202,7 @@ impl McpServer { handlers: Rc>>, cx: &mut AsyncApp, ) { - let (read, write) = smol::io::split(stream); + let (read, write) = stream.split(); let (incoming_tx, mut incoming_rx) = unbounded(); let (outgoing_tx, outgoing_rx) = unbounded(); diff --git a/crates/context_server/src/oauth.rs b/crates/context_server/src/oauth.rs index 1a314de2fca9b9987336decb15b208ffd7759dea..de6b7d50e8a0209cf6c5333bca7189ac69bcff3f 100644 --- a/crates/context_server/src/oauth.rs +++ b/crates/context_server/src/oauth.rs @@ -1962,7 +1962,7 @@ mod tests { #[test] fn test_fetch_protected_resource_metadata() { - smol::block_on(async { + gpui::block_on(async { let client = make_fake_http_client(|req| { Box::pin(async move { let uri = req.uri().to_string(); @@ -2008,7 +2008,7 @@ mod tests { #[test] fn test_fetch_protected_resource_metadata_prefers_www_authenticate_url() { - smol::block_on(async { + gpui::block_on(async { let client = make_fake_http_client(|req| { Box::pin(async move { let uri = req.uri().to_string(); @@ -2046,7 +2046,7 @@ mod tests { #[test] fn test_fetch_protected_resource_metadata_rejects_cross_origin_url() { - smol::block_on(async { + gpui::block_on(async { let client = make_fake_http_client(|req| { Box::pin(async move { let uri = req.uri().to_string(); @@ -2089,7 +2089,7 @@ mod tests { #[test] fn test_fetch_auth_server_metadata() { - smol::block_on(async { + gpui::block_on(async { let client = make_fake_http_client(|req| { Box::pin(async move { let uri = req.uri().to_string(); @@ -2134,7 +2134,7 @@ mod tests { #[test] fn test_fetch_auth_server_metadata_falls_back_to_oidc() { - smol::block_on(async { + gpui::block_on(async { let client = make_fake_http_client(|req| { Box::pin(async move { let uri = req.uri().to_string(); @@ -2167,7 +2167,7 @@ mod tests { #[test] fn test_fetch_auth_server_metadata_rejects_issuer_mismatch() { - smol::block_on(async { + gpui::block_on(async { let client = make_fake_http_client(|req| { Box::pin(async move { let uri = req.uri().to_string(); @@ -2205,7 +2205,7 @@ mod tests { #[test] fn test_full_discover_with_cimd() { - smol::block_on(async { + gpui::block_on(async { let client = make_fake_http_client(|req| { Box::pin(async move { let uri = req.uri().to_string(); @@ -2257,7 +2257,7 @@ mod tests { #[test] fn test_full_discover_with_dcr_fallback() { - smol::block_on(async { + gpui::block_on(async { let client = make_fake_http_client(|req| { Box::pin(async move { let uri = req.uri().to_string(); @@ -2320,7 +2320,7 @@ mod tests { #[test] fn test_discover_fails_without_pkce_support() { - smol::block_on(async { + gpui::block_on(async { let client = make_fake_http_client(|req| { Box::pin(async move { let uri = req.uri().to_string(); @@ -2370,7 +2370,7 @@ mod tests { #[test] fn test_exchange_code_success() { - smol::block_on(async { + gpui::block_on(async { let client = make_fake_http_client(|req| { Box::pin(async move { let uri = req.uri().to_string(); @@ -2420,7 +2420,7 @@ mod tests { #[test] fn test_refresh_tokens_success() { - smol::block_on(async { + gpui::block_on(async { let client = make_fake_http_client(|req| { Box::pin(async move { let uri = req.uri().to_string(); @@ -2459,7 +2459,7 @@ mod tests { #[test] fn test_exchange_code_failure() { - smol::block_on(async { + gpui::block_on(async { let client = make_fake_http_client(|_req| { Box::pin(async move { json_response(400, r#"{"error": "invalid_grant"}"#) }) }); @@ -2494,7 +2494,7 @@ mod tests { #[test] fn test_perform_dcr() { - smol::block_on(async { + gpui::block_on(async { let client = make_fake_http_client(|_req| { Box::pin(async move { json_response( @@ -2522,7 +2522,7 @@ mod tests { #[test] fn test_perform_dcr_failure() { - smol::block_on(async { + gpui::block_on(async { let client = make_fake_http_client(|_req| { Box::pin( async move { json_response(403, r#"{"error": "registration_not_allowed"}"#) }, @@ -2693,7 +2693,7 @@ mod tests { #[test] fn test_mcp_oauth_provider_refresh_without_refresh_token_returns_false() { - smol::block_on(async { + gpui::block_on(async { let session = make_test_session("token", None, None); let provider = McpOAuthTokenProvider::new( session, @@ -2710,7 +2710,7 @@ mod tests { #[test] fn test_mcp_oauth_provider_refresh_updates_session_and_notifies_channel() { - smol::block_on(async { + gpui::block_on(async { let session = make_test_session("old-access", Some("my-refresh-token"), None); let (tx, mut rx) = futures::channel::mpsc::unbounded(); @@ -2744,7 +2744,7 @@ mod tests { #[test] fn test_mcp_oauth_provider_refresh_preserves_old_refresh_token_when_server_omits_it() { - smol::block_on(async { + gpui::block_on(async { let session = make_test_session("old-access", Some("original-refresh"), None); let (tx, mut rx) = futures::channel::mpsc::unbounded(); @@ -2776,7 +2776,7 @@ mod tests { #[test] fn test_mcp_oauth_provider_refresh_returns_false_on_http_error() { - smol::block_on(async { + gpui::block_on(async { let session = make_test_session("old-access", Some("my-refresh"), None); let http_client = make_fake_http_client(|_req| { diff --git a/crates/context_server/src/transport/http.rs b/crates/context_server/src/transport/http.rs index 3e002983b5e49026d668c8baabfe8f856e4c5fe7..47e31c7abc7b1dbab82836e9c106137dbd591619 100644 --- a/crates/context_server/src/transport/http.rs +++ b/crates/context_server/src/transport/http.rs @@ -5,7 +5,6 @@ use futures::{Stream, StreamExt}; use gpui::BackgroundExecutor; use http_client::{AsyncBody, HttpClient, Request, Response, http::Method}; use parking_lot::Mutex as SyncMutex; -use smol::channel; use std::{pin::Pin, sync::Arc}; use crate::oauth::{self, OAuthTokenProvider, WwwAuthenticate}; @@ -43,10 +42,10 @@ pub struct HttpTransport { endpoint: String, session_id: Arc>>, executor: BackgroundExecutor, - response_tx: channel::Sender, - response_rx: channel::Receiver, - error_tx: channel::Sender, - error_rx: channel::Receiver, + response_tx: async_channel::Sender, + response_rx: async_channel::Receiver, + error_tx: async_channel::Sender, + error_rx: async_channel::Receiver, /// Static headers to include in every request (e.g. from server config). headers: HashMap, /// When set, the transport attaches `Authorization: Bearer` headers and @@ -71,8 +70,8 @@ impl HttpTransport { executor: BackgroundExecutor, token_provider: Option>, ) -> Self { - let (response_tx, response_rx) = channel::unbounded(); - let (error_tx, error_rx) = channel::unbounded(); + let (response_tx, response_rx) = async_channel::unbounded(); + let (error_tx, error_rx) = async_channel::unbounded(); Self { http_client, @@ -241,62 +240,63 @@ impl HttpTransport { let error_tx = self.error_tx.clone(); // Spawn a task to handle the SSE stream - smol::spawn(async move { - let reader = futures::io::BufReader::new(response.body_mut()); - let mut lines = futures::AsyncBufReadExt::lines(reader); - - let mut data_buffer = Vec::new(); - let mut in_message = false; - - while let Some(line_result) = lines.next().await { - match line_result { - Ok(line) => { - if line.is_empty() { - // Empty line signals end of event - if !data_buffer.is_empty() { - let message = data_buffer.join("\n"); - - // Filter out ping messages and empty data - if !message.trim().is_empty() && message != "ping" { - if let Err(e) = response_tx.send(message).await { - log::error!("Failed to send SSE message: {}", e); - break; + self.executor + .spawn(async move { + let reader = futures::io::BufReader::new(response.body_mut()); + let mut lines = futures::AsyncBufReadExt::lines(reader); + + let mut data_buffer = Vec::new(); + let mut in_message = false; + + while let Some(line_result) = lines.next().await { + match line_result { + Ok(line) => { + if line.is_empty() { + // Empty line signals end of event + if !data_buffer.is_empty() { + let message = data_buffer.join("\n"); + + // Filter out ping messages and empty data + if !message.trim().is_empty() && message != "ping" { + if let Err(e) = response_tx.send(message).await { + log::error!("Failed to send SSE message: {}", e); + break; + } } + data_buffer.clear(); } - data_buffer.clear(); - } - in_message = false; - } else if let Some(data) = line.strip_prefix("data: ") { - // Handle data lines - let data = data.trim(); - if !data.is_empty() { - // Check if this is a ping message - if data == "ping" { - log::trace!("Received SSE ping"); - continue; + in_message = false; + } else if let Some(data) = line.strip_prefix("data: ") { + // Handle data lines + let data = data.trim(); + if !data.is_empty() { + // Check if this is a ping message + if data == "ping" { + log::trace!("Received SSE ping"); + continue; + } + data_buffer.push(data.to_string()); + in_message = true; } - data_buffer.push(data.to_string()); - in_message = true; + } else if line.starts_with("event:") + || line.starts_with("id:") + || line.starts_with("retry:") + { + // Ignore other SSE fields + continue; + } else if in_message { + // Continuation of data + data_buffer.push(line); } - } else if line.starts_with("event:") - || line.starts_with("id:") - || line.starts_with("retry:") - { - // Ignore other SSE fields - continue; - } else if in_message { - // Continuation of data - data_buffer.push(line); } - } - Err(e) => { - let _ = error_tx.send(format!("SSE stream error: {}", e)).await; - break; + Err(e) => { + let _ = error_tx.send(format!("SSE stream error: {}", e)).await; + break; + } } } - } - }) - .detach(); + }) + .detach(); Ok(()) } diff --git a/crates/context_server/src/transport/stdio_transport.rs b/crates/context_server/src/transport/stdio_transport.rs index c3af1aa8745a074ad545cad0518d2ffea2822b65..b7e5dbfbeec57ca6840471e08f97e36214096fb2 100644 --- a/crates/context_server/src/transport/stdio_transport.rs +++ b/crates/context_server/src/transport/stdio_transport.rs @@ -2,6 +2,7 @@ use std::path::PathBuf; use std::pin::Pin; use anyhow::{Context as _, Result}; +use async_process::Child; use async_trait::async_trait; use futures::io::{BufReader, BufWriter}; use futures::{ @@ -9,8 +10,6 @@ use futures::{ }; use gpui::AsyncApp; use settings::Settings as _; -use smol::channel; -use smol::process::Child; use terminal::terminal_settings::TerminalSettings; use util::TryFutureExt as _; use util::shell_builder::ShellBuilder; @@ -19,9 +18,9 @@ use crate::client::ModelContextServerBinary; use crate::transport::Transport; pub struct StdioTransport { - stdout_sender: channel::Sender, - stdin_receiver: channel::Receiver, - stderr_receiver: channel::Receiver, + stdout_sender: async_channel::Sender, + stdin_receiver: async_channel::Receiver, + stderr_receiver: async_channel::Receiver, server: Child, } @@ -55,9 +54,9 @@ impl StdioTransport { let stdout = server.stdout.take().unwrap(); let stderr = server.stderr.take().unwrap(); - let (stdin_sender, stdin_receiver) = channel::unbounded::(); - let (stdout_sender, stdout_receiver) = channel::unbounded::(); - let (stderr_sender, stderr_receiver) = channel::unbounded::(); + let (stdin_sender, stdin_receiver) = async_channel::unbounded::(); + let (stdout_sender, stdout_receiver) = async_channel::unbounded::(); + let (stderr_sender, stderr_receiver) = async_channel::unbounded::(); cx.spawn(async move |_| Self::handle_output(stdin, stdout_receiver).log_err().await) .detach(); @@ -76,7 +75,7 @@ impl StdioTransport { }) } - async fn handle_input(stdin: Stdout, inbound_rx: channel::Sender) + async fn handle_input(stdin: Stdout, inbound_rx: async_channel::Sender) where Stdout: AsyncRead + Unpin + Send + 'static, { @@ -95,7 +94,7 @@ impl StdioTransport { async fn handle_output( stdin: Stdin, - outbound_rx: channel::Receiver, + outbound_rx: async_channel::Receiver, ) -> Result<()> where Stdin: AsyncWrite + Unpin + Send + 'static, @@ -112,7 +111,7 @@ impl StdioTransport { Ok(()) } - async fn handle_err(stderr: Stderr, stderr_tx: channel::Sender) + async fn handle_err(stderr: Stderr, stderr_tx: async_channel::Sender) where Stderr: AsyncRead + Unpin + Send + 'static, { diff --git a/crates/crashes/Cargo.toml b/crates/crashes/Cargo.toml index 2c13dc83c5a88c3504da6f8be48c1d75c8e43652..6886e5808aa5423b5f6e00c66756d0ac32381275 100644 --- a/crates/crashes/Cargo.toml +++ b/crates/crashes/Cargo.toml @@ -6,6 +6,7 @@ edition.workspace = true license = "GPL-3.0-or-later" [dependencies] +async-process.workspace = true cfg-if.workspace = true crash-handler.workspace = true futures.workspace = true @@ -14,7 +15,6 @@ minidumper.workspace = true parking_lot.workspace = true paths.workspace = true release_channel.workspace = true -smol.workspace = true serde.workspace = true serde_json.workspace = true system_specs.workspace = true diff --git a/crates/crashes/src/crashes.rs b/crates/crashes/src/crashes.rs index 9f18088b0ec2e709ff420b8e107e61dd7424e643..9abe7eb8b402f36c07398a88390d728afbdb063f 100644 --- a/crates/crashes/src/crashes.rs +++ b/crates/crashes/src/crashes.rs @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize}; use std::mem; #[cfg(not(target_os = "windows"))] -use smol::process::Command; +use async_process::Command; use system_specs::GpuSpecs; #[cfg(target_os = "macos")] @@ -57,7 +57,11 @@ fn should_install_crash_handler() -> bool { /// The synchronous portion (signal handlers, panic hook) runs inline. /// The async keepalive task is passed to `spawn` so the caller decides /// which executor to schedule it on. -pub fn init(crash_init: InitCrashHandler, spawn: impl FnOnce(BoxFuture<'static, ()>)) { +pub fn init + Send + Sync + 'static>( + crash_init: InitCrashHandler, + spawn: impl FnOnce(BoxFuture<'static, ()>), + wait_timer: impl (Fn(Duration) -> F) + Send + Sync + 'static, +) { if !should_install_crash_handler() { let old_hook = panic::take_hook(); panic::set_hook(Box::new(move |info| { @@ -102,12 +106,18 @@ pub fn init(crash_init: InitCrashHandler, spawn: impl FnOnce(BoxFuture<'static, info!("crash signal handlers installed"); - spawn(Box::pin(connect_and_keepalive(crash_init, handler))); + spawn(Box::pin(connect_and_keepalive( + crash_init, handler, wait_timer, + ))); } /// Spawn the crash-handler subprocess, connect the IPC client, and run the /// keepalive ping loop. Called on a background executor by [`init`]. -async fn connect_and_keepalive(crash_init: InitCrashHandler, handler: CrashHandler) { +async fn connect_and_keepalive + Send + Sync + 'static>( + crash_init: InitCrashHandler, + handler: CrashHandler, + wait_timer: impl (Fn(Duration) -> F) + Send + Sync + 'static, +) { let exe = env::current_exe().expect("unable to find ourselves"); let zed_pid = process::id(); let socket_name = paths::temp_dir().join(format!("zed-crash-handler-{zed_pid}")); @@ -134,9 +144,7 @@ async fn connect_and_keepalive(crash_init: InitCrashHandler, handler: CrashHandl break; } elapsed += retry_frequency; - // Crash reporting is called outside of gpui in the remote server right now - #[allow(clippy::disallowed_methods)] - smol::Timer::after(retry_frequency).await; + wait_timer(retry_frequency).await; } let client = maybe_client.unwrap(); let client = Arc::new(client); @@ -157,9 +165,7 @@ async fn connect_and_keepalive(crash_init: InitCrashHandler, handler: CrashHandl loop { client.ping().ok(); - // Crash reporting is called outside of gpui in the remote server right now - #[allow(clippy::disallowed_methods)] - smol::Timer::after(Duration::from_secs(10)).await; + wait_timer(Duration::from_secs(10)).await; } } diff --git a/crates/db/Cargo.toml b/crates/db/Cargo.toml index 2fc790181a86392ef545818ce04ca0efcf87713c..36e914715bb3093449695e0e71c30aad9d429340 100644 --- a/crates/db/Cargo.toml +++ b/crates/db/Cargo.toml @@ -23,7 +23,6 @@ inventory.workspace = true log.workspace = true paths.workspace = true release_channel.workspace = true -smol.workspace = true sqlez.workspace = true sqlez_macros.workspace = true util.workspace = true diff --git a/crates/db/src/db.rs b/crates/db/src/db.rs index 1ed6aa080757cf99dd90a685489bdf3dd6e94e0b..2811de348d4c979d79582ff0b612bf06dc6be2a3 100644 --- a/crates/db/src/db.rs +++ b/crates/db/src/db.rs @@ -9,7 +9,6 @@ use gpui::{App, AppContext, Global}; pub use indoc::indoc; pub use inventory; pub use paths::database_dir; -pub use smol; pub use sqlez; pub use sqlez_macros; pub use uuid; @@ -18,6 +17,7 @@ pub use release_channel::RELEASE_CHANNEL; use sqlez::domain::Migrator; use sqlez::thread_safe_connection::ThreadSafeConnection; use sqlez_macros::sql; +use std::fs::create_dir_all; use std::future::Future; use std::path::Path; use std::sync::atomic::AtomicBool; @@ -62,7 +62,7 @@ impl AppDatabase { pub fn new() -> Self { let db_dir = database_dir(); let scope = RELEASE_CHANNEL.dev_name(); - let connection = smol::block_on(open_db::(db_dir, scope)); + let connection = gpui::block_on(open_db::(db_dir, scope)); Self(connection) } @@ -71,7 +71,7 @@ impl AppDatabase { #[cfg(any(test, feature = "test-support"))] pub fn test_new() -> Self { let name = format!("test-db-{}", uuid::Uuid::new_v4()); - let connection = smol::block_on(open_test_db::(&name)); + let connection = gpui::block_on(open_test_db::(&name)); Self(connection) } @@ -151,8 +151,7 @@ pub async fn open_db(db_dir: &Path, scope: &str) -> Threa let main_db_dir = db_dir.join(format!("0-{}", scope)); let connection = maybe!(async { - smol::fs::create_dir_all(&main_db_dir) - .await + create_dir_all(&main_db_dir) .context("Could not create db directory") .log_err()?; let db_path = main_db_dir.join(Path::new(DB_FILE_NAME)); @@ -379,7 +378,7 @@ mod tests { for _ in 0..10 { let tmp_path = tempdir.path().to_path_buf(); let guard = thread::spawn(move || { - let good_db = smol::block_on(open_db::( + let good_db = gpui::block_on(open_db::( tmp_path.as_path(), release_channel::ReleaseChannel::Dev.dev_name(), )); diff --git a/crates/db/src/kvp.rs b/crates/db/src/kvp.rs index 8d86ac7fc4b7b62de05583b28784da251b0efe74..ab56ce801de536ae2941506ce69ae2529801992b 100644 --- a/crates/db/src/kvp.rs +++ b/crates/db/src/kvp.rs @@ -243,7 +243,7 @@ impl std::ops::Deref for GlobalKeyValueStore { static GLOBAL_KEY_VALUE_STORE: std::sync::LazyLock = std::sync::LazyLock::new(|| { let db_dir = crate::database_dir(); - GlobalKeyValueStore(smol::block_on(crate::open_db::( + GlobalKeyValueStore(gpui::block_on(crate::open_db::( db_dir, "global", ))) }); diff --git a/crates/edit_prediction_cli/src/main.rs b/crates/edit_prediction_cli/src/main.rs index d144f998ff27b90e3009f82c367bf4699db4341e..ce7977a1ef584f3a0086adf9402064f512a6ccd4 100644 --- a/crates/edit_prediction_cli/src/main.rs +++ b/crates/edit_prediction_cli/src/main.rs @@ -970,7 +970,7 @@ fn main() { match &command { Command::ImportBatch(import_args) => { - smol::block_on(async { + gpui::block_on(async { match import_args.provider { BatchProvider::Anthropic => { let client = anthropic_client::AnthropicClient::batch(&paths::LLM_CACHE_DB) @@ -1029,7 +1029,7 @@ fn main() { output_dir, fresh: synth_args.fresh, }; - smol::block_on(async { + gpui::block_on(async { if let Err(e) = run_synthesize(config).await { eprintln!("Error: {:?}", e); std::process::exit(1); diff --git a/crates/editor/Cargo.toml b/crates/editor/Cargo.toml index 1b2e32f19896df4863d6fd12d02b5eea6579bc97..e97cc68c2f956e6f3e15629c97d4f799e5d7e429 100644 --- a/crates/editor/Cargo.toml +++ b/crates/editor/Cargo.toml @@ -46,6 +46,7 @@ emojis.workspace = true feature_flags.workspace = true file_icons.workspace = true futures.workspace = true +futures-lite.workspace = true fuzzy.workspace = true fs.workspace = true git.workspace = true @@ -75,7 +76,6 @@ serde.workspace = true serde_json.workspace = true settings.workspace = true smallvec.workspace = true -smol.workspace = true snippet.workspace = true sum_tree.workspace = true task.workspace = true diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rs index 7cb8040e282a47d27cf5d7b33e5453295b4f645f..df40821c628952749a4cd09474ca6c35a0bf4afb 100644 --- a/crates/editor/src/display_map.rs +++ b/crates/editor/src/display_map.rs @@ -2577,9 +2577,9 @@ pub mod tests { }; use lsp::LanguageServerId; + use futures::stream::StreamExt; use rand::{Rng, prelude::*}; use settings::{SettingsContent, SettingsStore}; - use smol::stream::StreamExt; use std::{env, sync::Arc}; use text::PointUtf16; use theme::{LoadThemes, SyntaxTheme}; diff --git a/crates/editor/src/display_map/wrap_map.rs b/crates/editor/src/display_map/wrap_map.rs index 4ff11b1ef67971c5159a81278a5afaaaea171a28..44a4689b28564c74fedb2229d1e75ac236195e51 100644 --- a/crates/editor/src/display_map/wrap_map.rs +++ b/crates/editor/src/display_map/wrap_map.rs @@ -4,10 +4,11 @@ use super::{ fold_map::{Chunk, FoldRows}, tab_map::{self, TabEdit, TabPoint, TabSnapshot}, }; + +use futures_lite::future::yield_now; use gpui::{App, AppContext as _, Context, Entity, Font, LineWrapper, Pixels, Task}; use language::{LanguageAwareStyling, Point}; use multi_buffer::{MultiBufferSnapshot, RowInfo}; -use smol::future::yield_now; use std::{cmp, collections::VecDeque, mem, ops::Range, sync::LazyLock, time::Duration}; use sum_tree::{Bias, Cursor, Dimensions, SumTree}; use text::Patch; @@ -205,7 +206,7 @@ impl WrapMap { }]; if total_rows < WRAP_YIELD_ROW_INTERVAL { - let edits = smol::block_on(new_snapshot.update( + let edits = gpui::block_on(new_snapshot.update( tab_snapshot, &tab_edits, wrap_width, @@ -299,7 +300,7 @@ impl WrapMap { < WRAP_YIELD_ROW_INTERVAL && let Some((tab_snapshot, tab_edits)) = pending_edits.pop_back() { - let wrap_edits = smol::block_on(snapshot.update( + let wrap_edits = gpui::block_on(snapshot.update( tab_snapshot, &tab_edits, wrap_width, @@ -1357,10 +1358,10 @@ mod tests { display_map::{fold_map::FoldMap, inlay_map::InlayMap, tab_map::TabMap}, test::test_font, }; + use futures::stream::StreamExt; use gpui::{LineFragment, px, test::observe}; use rand::prelude::*; use settings::SettingsStore; - use smol::stream::StreamExt; use std::{cmp, env, num::NonZeroU32}; use text::Rope; use theme::LoadThemes; diff --git a/crates/editor/src/hover_popover.rs b/crates/editor/src/hover_popover.rs index 55350a9c679a10ea8597ae8c923c33af34d71360..5b375af35fab1c8470f4b79e47b40afc8c72f1a7 100644 --- a/crates/editor/src/hover_popover.rs +++ b/crates/editor/src/hover_popover.rs @@ -1196,12 +1196,12 @@ mod tests { test::editor_lsp_test_context::EditorLspTestContext, }; use collections::BTreeSet; + use futures::stream::StreamExt; use gpui::App; use indoc::indoc; use markdown::parser::MarkdownEvent; use project::InlayId; use settings::InlayHintSettingsContent; - use smol::stream::StreamExt; use std::sync::atomic; use std::sync::atomic::AtomicUsize; use text::Bias; diff --git a/crates/editor/src/lsp_ext.rs b/crates/editor/src/lsp_ext.rs index 6f9f94bc72227f7f30bdca1c9ae1ce436f3d5aa4..60f0dd305ef81af8d706928a720a6d9ae618582c 100644 --- a/crates/editor/src/lsp_ext.rs +++ b/crates/editor/src/lsp_ext.rs @@ -3,6 +3,7 @@ use std::time::Duration; use crate::Editor; use collections::{HashMap, HashSet}; +use futures_lite::FutureExt as _; use gpui::AsyncApp; use gpui::{App, Entity, Task}; use language::Buffer; @@ -14,7 +15,6 @@ use project::LocationLink; use project::Project; use project::TaskSourceKind; use project::lsp_store::lsp_ext_command::GetLspRunnables; -use smol::future::FutureExt as _; use task::ResolvedTask; use task::TaskContext; use text::BufferId; diff --git a/crates/editor/src/test/editor_lsp_test_context.rs b/crates/editor/src/test/editor_lsp_test_context.rs index d1e5270d6c76e166a33a41df2843138f4b12c411..854a800d7101d77aecb10f52792149836856f6f5 100644 --- a/crates/editor/src/test/editor_lsp_test_context.rs +++ b/crates/editor/src/test/editor_lsp_test_context.rs @@ -13,6 +13,7 @@ use serde_json::json; use crate::{Editor, ToPoint}; use collections::HashSet; use futures::Future; +use futures::stream::StreamExt; use gpui::{Context, Entity, Focusable as _, VisualTestContext, Window}; use indoc::indoc; use language::{ @@ -21,7 +22,6 @@ use language::{ }; use lsp::{notification, request}; use project::Project; -use smol::stream::StreamExt; use workspace::{AppState, MultiWorkspace, Workspace, WorkspaceHandle}; use super::editor_test_context::{AssertionContextManager, EditorTestContext}; diff --git a/crates/fs/Cargo.toml b/crates/fs/Cargo.toml index e7b8dcd4ebda7810ef8087e112ae43819702bdf6..28a519e252eaba1b2392dfb404ee6e7446bf1021 100644 --- a/crates/fs/Cargo.toml +++ b/crates/fs/Cargo.toml @@ -19,6 +19,7 @@ path = "tests/integration/main.rs" [dependencies] anyhow.workspace = true +async-channel.workspace = true async-tar.workspace = true async-trait.workspace = true collections.workspace = true diff --git a/crates/fs/src/fake_git_repo.rs b/crates/fs/src/fake_git_repo.rs index 1b4e89102f942c3b4e5526b914c67c271a47ee2e..47d6876e6d99e4ce8365f8ed18946ebc58ff3595 100644 --- a/crates/fs/src/fake_git_repo.rs +++ b/crates/fs/src/fake_git_repo.rs @@ -1,6 +1,8 @@ use crate::{FakeFs, FakeFsEntry, Fs, RemoveOptions, RenameOptions}; use anyhow::{Context as _, Result, bail}; +use async_channel::Sender; use collections::{HashMap, HashSet}; +use futures::FutureExt as _; use futures::future::{self, BoxFuture, join_all}; use git::{ Oid, RunHook, @@ -21,7 +23,6 @@ use gpui::{AsyncApp, BackgroundExecutor, SharedString, Task}; use ignore::gitignore::GitignoreBuilder; use parking_lot::Mutex; use rope::Rope; -use smol::{channel::Sender, future::FutureExt as _}; use std::{path::PathBuf, sync::Arc, sync::atomic::AtomicBool}; use text::LineEnding; use util::{paths::PathStyle, rel_path::RelPath}; @@ -47,7 +48,7 @@ pub struct FakeCommitSnapshot { #[derive(Debug, Clone)] pub struct FakeGitRepositoryState { pub commit_history: Vec, - pub event_emitter: smol::channel::Sender, + pub event_emitter: async_channel::Sender, pub unmerged_paths: HashMap, pub head_contents: HashMap, pub index_contents: HashMap, @@ -68,7 +69,7 @@ pub struct FakeGitRepositoryState { } impl FakeGitRepositoryState { - pub fn new(event_emitter: smol::channel::Sender) -> Self { + pub fn new(event_emitter: async_channel::Sender) -> Self { FakeGitRepositoryState { event_emitter, head_contents: Default::default(), diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs index e44f557646239da5dd84354e364422cf16e14233..fe5548ef72397b20d9e00ddbb6776c1331f69789 100644 --- a/crates/fs/src/fs.rs +++ b/crates/fs/src/fs.rs @@ -1070,7 +1070,7 @@ impl Fs for RealFs { use util::{ResultExt as _, paths::SanitizedPath}; let executor = self.executor.clone(); - let (tx, rx) = smol::channel::unbounded(); + let (tx, rx) = async_channel::unbounded(); let pending_paths: Arc>> = Default::default(); let watcher = Arc::new(fs_watcher::FsWatcher::new(tx, pending_paths.clone())); @@ -1307,8 +1307,8 @@ struct FakeFsState { root: FakeFsEntry, next_inode: u64, next_mtime: SystemTime, - git_event_tx: smol::channel::Sender, - event_txs: Vec<(PathBuf, smol::channel::Sender>)>, + git_event_tx: async_channel::Sender, + event_txs: Vec<(PathBuf, async_channel::Sender>)>, events_paused: bool, buffered_events: Vec, metadata_call_count: usize, @@ -1578,7 +1578,7 @@ impl FakeFs { const SYSTEMTIME_INTERVAL: Duration = Duration::from_nanos(100); pub fn new(executor: gpui::BackgroundExecutor) -> Arc { - let (tx, rx) = smol::channel::bounded::(10); + let (tx, rx) = async_channel::bounded::(10); let this = Arc::new_cyclic(|this| Self { this: this.clone(), @@ -2543,7 +2543,7 @@ impl FakeFsEntry { #[cfg(feature = "test-support")] struct FakeWatcher { - tx: smol::channel::Sender>, + tx: async_channel::Sender>, original_path: PathBuf, fs_state: Arc>, prefixes: Mutex>, @@ -3012,7 +3012,7 @@ impl Fs for FakeFs { Arc, ) { self.simulate_random_delay().await; - let (tx, rx) = smol::channel::unbounded(); + let (tx, rx) = async_channel::unbounded(); let path = path.to_path_buf(); self.state.lock().event_txs.push((path.clone(), tx.clone())); let executor = self.executor.clone(); diff --git a/crates/fs/src/fs_watcher.rs b/crates/fs/src/fs_watcher.rs index 02a6b0878110ba1298821ffdf2fb5babecfc81d3..7aa307ae7b6f08cc84f5c78d07ba40118e68c44c 100644 --- a/crates/fs/src/fs_watcher.rs +++ b/crates/fs/src/fs_watcher.rs @@ -11,14 +11,14 @@ use util::{ResultExt, paths::SanitizedPath}; use crate::{PathEvent, PathEventKind, Watcher}; pub struct FsWatcher { - tx: smol::channel::Sender<()>, + tx: async_channel::Sender<()>, pending_path_events: Arc>>, registrations: Mutex, WatcherRegistrationId>>, } impl FsWatcher { pub fn new( - tx: smol::channel::Sender<()>, + tx: async_channel::Sender<()>, pending_path_events: Arc>>, ) -> Self { Self { diff --git a/crates/fs/tests/integration/fs.rs b/crates/fs/tests/integration/fs.rs index 97ec90bea09651bc888dfdea332ad6a4964ede2f..b27e4113fd6cf7445ca63c6ff0222e2b647f040e 100644 --- a/crates/fs/tests/integration/fs.rs +++ b/crates/fs/tests/integration/fs.rs @@ -439,7 +439,7 @@ async fn test_realfs_atomic_write(executor: BackgroundExecutor) { // drop(file); // We still hold the file handle here let content = std::fs::read_to_string(&file_to_be_replaced).unwrap(); assert_eq!(content, "Hello"); - smol::block_on(fs.atomic_write(file_to_be_replaced.clone(), "World".into())).unwrap(); + gpui::block_on(fs.atomic_write(file_to_be_replaced.clone(), "World".into())).unwrap(); let content = std::fs::read_to_string(&file_to_be_replaced).unwrap(); assert_eq!(content, "World"); } @@ -449,7 +449,7 @@ async fn test_realfs_atomic_write_non_existing_file(executor: BackgroundExecutor let fs = RealFs::new(None, executor); let temp_dir = TempDir::new().unwrap(); let file_to_be_replaced = temp_dir.path().join("file.txt"); - smol::block_on(fs.atomic_write(file_to_be_replaced.clone(), "Hello".into())).unwrap(); + gpui::block_on(fs.atomic_write(file_to_be_replaced.clone(), "Hello".into())).unwrap(); let content = std::fs::read_to_string(&file_to_be_replaced).unwrap(); assert_eq!(content, "Hello"); } @@ -594,7 +594,7 @@ async fn test_realfs_broken_symlink_metadata(executor: BackgroundExecutor) { let path = tempdir.path(); let fs = RealFs::new(None, executor); let symlink_path = path.join("symlink"); - smol::block_on(fs.create_symlink(&symlink_path, PathBuf::from("file_a.txt"))).unwrap(); + gpui::block_on(fs.create_symlink(&symlink_path, PathBuf::from("file_a.txt"))).unwrap(); let metadata = fs .metadata(&symlink_path) .await @@ -614,7 +614,7 @@ async fn test_realfs_symlink_loop_metadata(executor: BackgroundExecutor) { let path = tempdir.path(); let fs = RealFs::new(None, executor); let symlink_path = path.join("symlink"); - smol::block_on(fs.create_symlink(&symlink_path, PathBuf::from("symlink"))).unwrap(); + gpui::block_on(fs.create_symlink(&symlink_path, PathBuf::from("symlink"))).unwrap(); let metadata = fs .metadata(&symlink_path) .await diff --git a/crates/git/Cargo.toml b/crates/git/Cargo.toml index 23a937bf1fa17481eb5e130b3e083274dd3f1d16..a96d8cbe0a9a0b8dfefab83dbb4f16c46747910e 100644 --- a/crates/git/Cargo.toml +++ b/crates/git/Cargo.toml @@ -32,6 +32,7 @@ rope.workspace = true schemars.workspace = true serde.workspace = true smallvec.workspace = true +async-channel.workspace = true smol.workspace = true sum_tree.workspace = true text.workspace = true diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs index b1b9af106d93e02ee61fdc436dce7d95f9a7c107..16f52d70ee5ca0deb013ff803f05b40ff9358f8c 100644 --- a/crates/git/src/repository.rs +++ b/crates/git/src/repository.rs @@ -3,6 +3,7 @@ use crate::stash::GitStash; use crate::status::{DiffTreeType, GitStatus, StatusCode, TreeDiff}; use crate::{Oid, RunHook, SHORT_SHA_LENGTH}; use anyhow::{Context as _, Result, anyhow, bail}; +use async_channel::Sender; use collections::HashMap; use futures::channel::oneshot; use futures::future::BoxFuture; @@ -15,7 +16,6 @@ use rope::Rope; use schemars::JsonSchema; use serde::Deserialize; use smallvec::SmallVec; -use smol::channel::Sender; use smol::io::{AsyncBufReadExt, AsyncReadExt, BufReader}; use text::LineEnding; @@ -124,7 +124,7 @@ struct CommitDataRequest { } pub struct CommitDataReader { - request_tx: smol::channel::Sender, + request_tx: async_channel::Sender, _task: Task<()>, } @@ -2998,7 +2998,7 @@ impl GitRepository for RealGitRepository { fn commit_data_reader(&self) -> Result { let git_binary = self.git_binary()?; - let (request_tx, request_rx) = smol::channel::bounded::(64); + let (request_tx, request_rx) = async_channel::bounded::(64); let task = self.executor.spawn(async move { if let Err(error) = run_commit_data_reader(git_binary, request_rx).await { @@ -3024,7 +3024,7 @@ impl GitRepository for RealGitRepository { async fn run_commit_data_reader( git: GitBinary, - request_rx: smol::channel::Receiver, + request_rx: async_channel::Receiver, ) -> Result<()> { let mut process = git .build_command(&["cat-file", "--batch"]) diff --git a/crates/git_graph/Cargo.toml b/crates/git_graph/Cargo.toml index e9e31a8361e367275c994e125ae6e04cbd652fc3..b9bde8a8fd5cfc575869e44233ad93992e48a486 100644 --- a/crates/git_graph/Cargo.toml +++ b/crates/git_graph/Cargo.toml @@ -21,6 +21,7 @@ test-support = [ [dependencies] anyhow.workspace = true +async-channel.workspace = true collections.workspace = true db.workspace = true editor.workspace = true @@ -33,7 +34,6 @@ project.workspace = true search.workspace = true settings.workspace = true smallvec.workspace = true -smol.workspace = true theme.workspace = true theme_settings.workspace = true time.workspace = true diff --git a/crates/git_graph/src/git_graph.rs b/crates/git_graph/src/git_graph.rs index 370da2a8394f396138d5584d661488f75c3cf1ba..1182a4a8a52e5ccecba67d7eef1071f444822134 100644 --- a/crates/git_graph/src/git_graph.rs +++ b/crates/git_graph/src/git_graph.rs @@ -1396,7 +1396,7 @@ impl GitGraph { return; } - let (request_tx, request_rx) = smol::channel::unbounded::(); + let (request_tx, request_rx) = async_channel::unbounded::(); repo.update(cx, |repo, cx| { repo.search_commits( diff --git a/crates/git_ui/Cargo.toml b/crates/git_ui/Cargo.toml index 6927ae16a5c4aa50e5d91563dbb84b1f2e085fd0..399d876f11b7d9aacf6a1c9d2c738d4e7361c6bd 100644 --- a/crates/git_ui/Cargo.toml +++ b/crates/git_ui/Cargo.toml @@ -28,6 +28,7 @@ db.workspace = true editor.workspace = true file_icons.workspace = true futures.workspace = true +futures-lite.workspace = true fuzzy.workspace = true git.workspace = true gpui.workspace = true @@ -52,7 +53,6 @@ serde.workspace = true serde_json.workspace = true settings.workspace = true smallvec.workspace = true -smol.workspace = true strum.workspace = true telemetry.workspace = true theme.workspace = true diff --git a/crates/git_ui/src/project_diff.rs b/crates/git_ui/src/project_diff.rs index 8fa4680593a7565c84efd7503f6cf9d188d3be35..4eb30995f1501b6e31be36595c3d75d291b2a871 100644 --- a/crates/git_ui/src/project_diff.rs +++ b/crates/git_ui/src/project_diff.rs @@ -14,6 +14,7 @@ use editor::{ multibuffer_context_lines, scroll::Autoscroll, }; +use futures_lite::future::yield_now; use git::repository::DiffType; use git::{ @@ -34,7 +35,6 @@ use project::{ }, }; use settings::{Settings, SettingsStore}; -use smol::future::yield_now; use std::any::{Any, TypeId}; use std::sync::Arc; use theme::ActiveTheme; diff --git a/crates/gpui/src/gpui.rs b/crates/gpui/src/gpui.rs index dbb57f46efc37678c07dfd4f02bb3faebc60c9a3..9f307f56b8fadc44377bfcc63fd2849bca50d403 100644 --- a/crates/gpui/src/gpui.rs +++ b/crates/gpui/src/gpui.rs @@ -122,6 +122,8 @@ pub use util::{FutureExt, Timeout}; pub use view::*; pub use window::*; +pub use pollster::block_on; + /// The context trait, allows the different contexts in GPUI to be used /// interchangeably for certain operations. pub trait AppContext { diff --git a/crates/gpui/src/test.rs b/crates/gpui/src/test.rs index ddcc3d27bd04d2fd82b3367a2fee6930e86ef356..ca182ff25dea2cf041ede6e8ef25efe7ecaef006 100644 --- a/crates/gpui/src/test.rs +++ b/crates/gpui/src/test.rs @@ -186,7 +186,7 @@ pub fn observe(entity: &Entity, cx: &mut TestAppContext) -> Obser let (tx, rx) = async_channel::unbounded(); let _subscription = cx.update(|cx| { cx.observe(entity, move |_, _| { - let _ = pollster::block_on(tx.send(())); + let _ = gpui::block_on(tx.send(())); }) }); let rx = Box::pin(rx); diff --git a/crates/gpui_wgpu/src/wgpu_atlas.rs b/crates/gpui_wgpu/src/wgpu_atlas.rs index 55f6edee21b9f2da02268c66c665c34d5b52066a..a7d40e046d14a6be09c859476059d603a2ada775 100644 --- a/crates/gpui_wgpu/src/wgpu_atlas.rs +++ b/crates/gpui_wgpu/src/wgpu_atlas.rs @@ -358,8 +358,8 @@ impl WgpuAtlasTexture { #[cfg(all(test, not(target_family = "wasm")))] mod tests { use super::*; + use gpui::block_on; use gpui::{ImageId, RenderImageParams}; - use pollster::block_on; use std::sync::Arc; fn test_device_and_queue() -> anyhow::Result<(Arc, Arc)> { diff --git a/crates/gpui_wgpu/src/wgpu_context.rs b/crates/gpui_wgpu/src/wgpu_context.rs index 7c03c4752ebf2e76b04c384722f4a9c17054487a..beda78fd1d8e9122c545a7f3b6d3678b749e6135 100644 --- a/crates/gpui_wgpu/src/wgpu_context.rs +++ b/crates/gpui_wgpu/src/wgpu_context.rs @@ -42,7 +42,7 @@ impl WgpuContext { // Select an adapter by actually testing surface configuration with the real device. // This is the only reliable way to determine compatibility on hybrid GPU systems. let (adapter, device, queue, dual_source_blending) = - pollster::block_on(Self::select_adapter_and_device( + gpui::block_on(Self::select_adapter_and_device( &instance, device_id_filter, surface, diff --git a/crates/language/Cargo.toml b/crates/language/Cargo.toml index 1392ed63f64b7d3e3f6ebb9f629168f6096c5b61..b4d24765de9c904eca0777ca00a6b8def5e3d6e0 100644 --- a/crates/language/Cargo.toml +++ b/crates/language/Cargo.toml @@ -35,6 +35,7 @@ ec4rs.workspace = true encoding_rs.workspace = true fs.workspace = true futures.workspace = true +futures-lite.workspace = true fuzzy.workspace = true globset.workspace = true gpui.workspace = true @@ -55,7 +56,6 @@ serde_json.workspace = true settings.workspace = true shellexpand.workspace = true smallvec.workspace = true -smol.workspace = true streaming-iterator.workspace = true strsim.workspace = true sum_tree.workspace = true diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index 698efbfeed8363d38aa79f5afd93ba00b42e80b4..de481f843900300c56389368a9b0a04ecd61cea9 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -27,6 +27,7 @@ use collections::{HashMap, HashSet}; use encoding_rs::Encoding; use fs::MTime; use futures::channel::oneshot; +use futures_lite::future::yield_now; use gpui::{ App, AppContext as _, Context, Entity, EventEmitter, HighlightStyle, SharedString, StyledText, Task, TextStyle, @@ -36,7 +37,6 @@ use lsp::LanguageServerId; use parking_lot::Mutex; use settings::WorktreeId; use smallvec::SmallVec; -use smol::future::yield_now; use std::{ any::Any, borrow::Cow, diff --git a/crates/language/src/buffer_tests.rs b/crates/language/src/buffer_tests.rs index 9f4562bf547f389c5ecc5ca29470ac4e49da0e04..a13678a27d2821c72f7557cbabc9342ac4b191a2 100644 --- a/crates/language/src/buffer_tests.rs +++ b/crates/language/src/buffer_tests.rs @@ -3,6 +3,7 @@ use crate::Buffer; use clock::ReplicaId; use collections::BTreeMap; use futures::FutureExt as _; +use futures_lite::future::yield_now; use gpui::{App, AppContext as _, BorrowAppContext, Entity}; use gpui::{HighlightStyle, TestAppContext}; use indoc::indoc; @@ -559,7 +560,7 @@ async fn test_normalize_whitespace(cx: &mut gpui::TestAppContext) { // Spawn a task to format the buffer's whitespace. // Pause so that the formatting task starts running. let format = buffer.update(cx, |buffer, cx| buffer.remove_trailing_whitespace(cx)); - smol::future::yield_now().await; + yield_now().await; // Edit the buffer while the normalization task is running. let version_before_edit = buffer.update(cx, |buffer, _| buffer.version()); diff --git a/crates/language/src/language.rs b/crates/language/src/language.rs index 43bbe7a08c73e476a41aec8af015464aa3af853d..677ff347b547f6485085e18480f7f6b6394244ac 100644 --- a/crates/language/src/language.rs +++ b/crates/language/src/language.rs @@ -36,6 +36,7 @@ use http_client::HttpClient; pub use language_core::highlight_map::{HighlightId, HighlightMap}; +use futures::future::FutureExt as _; pub use language_core::{ BlockCommentConfig, BracketPair, BracketPairConfig, BracketPairContent, BracketsConfig, BracketsPatternConfig, CodeLabel, CodeLabelBuilder, DebugVariablesConfig, DebuggerTextObject, @@ -60,7 +61,6 @@ use regex::Regex; use semver::Version; use serde_json::Value; use settings::WorktreeId; -use smol::future::FutureExt as _; use std::{ ffi::OsStr, fmt::Debug, diff --git a/crates/language/src/language_registry.rs b/crates/language/src/language_registry.rs index 2ac6ef456d2ee17c8710ec1c37f22ff34a648e4d..729190e0d18cede363683bfe2bb22241cda7b5d2 100644 --- a/crates/language/src/language_registry.rs +++ b/crates/language/src/language_registry.rs @@ -33,7 +33,7 @@ use sum_tree::Bias; use text::{Point, Rope}; use theme::Theme; use unicase::UniCase; -use util::{ResultExt, maybe, post_inc}; +use util::{maybe, post_inc}; pub struct LanguageRegistry { state: RwLock, @@ -1092,18 +1092,6 @@ impl LanguageRegistry { ) -> mpsc::UnboundedReceiver<(LanguageServerName, BinaryStatus)> { self.lsp_binary_status_tx.subscribe() } - - pub async fn delete_server_container(&self, name: LanguageServerName) { - log::info!("deleting server container"); - let Some(dir) = self.language_server_download_dir(&name) else { - return; - }; - - smol::fs::remove_dir_all(dir) - .await - .context("server container removal") - .log_err(); - } } impl LanguageRegistryState { diff --git a/crates/language_model_core/Cargo.toml b/crates/language_model_core/Cargo.toml index 7a6de00f3e4a774537d93e2f77ea9107845a7c50..e9aa06400b6d3cf0f4afcae1e3bf005555efaa0d 100644 --- a/crates/language_model_core/Cargo.toml +++ b/crates/language_model_core/Cargo.toml @@ -14,6 +14,7 @@ doctest = false [dependencies] anyhow.workspace = true +async-lock.workspace = true cloud_llm_client.workspace = true futures.workspace = true gpui_shared_string.workspace = true @@ -22,6 +23,5 @@ partial-json-fixer.workspace = true schemars.workspace = true serde.workspace = true serde_json.workspace = true -smol.workspace = true strum.workspace = true thiserror.workspace = true diff --git a/crates/language_model_core/src/rate_limiter.rs b/crates/language_model_core/src/rate_limiter.rs index 790be05ac069b8f394e442cbcb6383f611326a69..28e92056f9de6e8e009be725bc6fb8f3455b7cc7 100644 --- a/crates/language_model_core/src/rate_limiter.rs +++ b/crates/language_model_core/src/rate_limiter.rs @@ -1,5 +1,5 @@ +use async_lock::{Semaphore, SemaphoreGuardArc}; use futures::Stream; -use smol::lock::{Semaphore, SemaphoreGuardArc}; use std::{ future::Future, pin::Pin, diff --git a/crates/language_models/Cargo.toml b/crates/language_models/Cargo.toml index 60670114529b07dca78202cc438ff5e243acaeee..f8c2fed98f72f1fb316edf630d65a9b1ee4c91d2 100644 --- a/crates/language_models/Cargo.toml +++ b/crates/language_models/Cargo.toml @@ -13,6 +13,7 @@ path = "src/language_models.rs" [dependencies] ai_onboarding.workspace = true +async-lock.workspace = true anthropic = { workspace = true, features = ["schemars"] } anyhow.workspace = true aws-config = { workspace = true, features = ["behavior-version-latest"] } @@ -55,7 +56,6 @@ schemars.workspace = true serde.workspace = true serde_json.workspace = true settings.workspace = true -smol.workspace = true strum.workspace = true tiktoken-rs.workspace = true tokio = { workspace = true, features = ["rt", "rt-multi-thread"] } diff --git a/crates/language_models/src/provider/bedrock.rs b/crates/language_models/src/provider/bedrock.rs index 80c758769cd990c00f5942433143bf6fb2216b7c..83c54f8f3439cacabbb25c8c2b90078ffc265deb 100644 --- a/crates/language_models/src/provider/bedrock.rs +++ b/crates/language_models/src/provider/bedrock.rs @@ -2,6 +2,7 @@ use std::pin::Pin; use std::sync::Arc; use anyhow::{Context as _, Result, anyhow}; +use async_lock::OnceCell; use aws_config::stalled_stream_protection::StalledStreamProtectionConfig; use aws_config::{BehaviorVersion, Region}; use aws_credential_types::{Credentials, Token}; @@ -40,7 +41,6 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use serde_json::Value; use settings::{BedrockAvailableModel as AvailableModel, Settings, SettingsStore}; -use smol::lock::OnceCell; use std::sync::LazyLock; use strum::{EnumIter, IntoEnumIterator, IntoStaticStr}; use ui::{ButtonLink, ConfiguredApiCard, Divider, List, ListBulletItem, prelude::*}; diff --git a/crates/language_models_cloud/Cargo.toml b/crates/language_models_cloud/Cargo.toml index b08acc5ecd5c2a718e936378c2dbfbc3d1c32df0..afe3e623af4b71597a4b6ec4ace4e49e40b0dc47 100644 --- a/crates/language_models_cloud/Cargo.toml +++ b/crates/language_models_cloud/Cargo.toml @@ -25,7 +25,6 @@ schemars.workspace = true semver.workspace = true serde.workspace = true serde_json.workspace = true -smol.workspace = true thiserror.workspace = true x_ai = { workspace = true, features = ["schemars"] } diff --git a/crates/language_models_cloud/src/language_models_cloud.rs b/crates/language_models_cloud/src/language_models_cloud.rs index 24c8ec87d5c672dbc18b20164f2fe28c9b46b2e1..b1a7b632d449a210225a1688c954f372b052f8c0 100644 --- a/crates/language_models_cloud/src/language_models_cloud.rs +++ b/crates/language_models_cloud/src/language_models_cloud.rs @@ -8,8 +8,9 @@ use cloud_llm_client::{ ZED_VERSION_HEADER_NAME, }; use futures::{ - AsyncBufReadExt, FutureExt, Stream, StreamExt, + AsyncBufReadExt, AsyncReadExt as _, FutureExt, Stream, StreamExt, future::BoxFuture, + io::BufReader, stream::{self, BoxStream}, }; use google_ai::GoogleModelMode; @@ -31,7 +32,6 @@ use language_model::{ use schemars::JsonSchema; use semver::Version; use serde::{Deserialize, Serialize, de::DeserializeOwned}; -use smol::io::{AsyncReadExt, BufReader}; use std::collections::VecDeque; use std::pin::Pin; use std::str::FromStr; diff --git a/crates/multi_buffer/Cargo.toml b/crates/multi_buffer/Cargo.toml index a06599999c8147dc464128ad8ab5e6bf5ad5755b..5dccddaba62735adf616fd5a02724d2c9b24bae6 100644 --- a/crates/multi_buffer/Cargo.toml +++ b/crates/multi_buffer/Cargo.toml @@ -26,6 +26,7 @@ anyhow.workspace = true clock.workspace = true collections.workspace = true ctor.workspace = true +futures-lite.workspace = true buffer_diff.workspace = true gpui.workspace = true itertools.workspace = true @@ -34,7 +35,6 @@ log.workspace = true parking_lot.workspace = true rand.workspace = true rope.workspace = true -smol.workspace = true settings.workspace = true serde.workspace = true smallvec.workspace = true diff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rs index 724f659e44e8153a9ef5b1a01b6b66529ab3a3e2..d3c87e0b6d10842de2071941f1e10c65260ee325 100644 --- a/crates/multi_buffer/src/multi_buffer.rs +++ b/crates/multi_buffer/src/multi_buffer.rs @@ -16,6 +16,7 @@ use buffer_diff::{ }; use clock::ReplicaId; use collections::{BTreeMap, Bound, HashMap, HashSet}; +use futures_lite::future::yield_now; use gpui::{App, Context, Entity, EventEmitter}; use itertools::Itertools; use language::{ @@ -33,7 +34,6 @@ use gpui::AppContext as _; use rope::DimensionPair; use settings::Settings; use smallvec::SmallVec; -use smol::future::yield_now; use std::{ any::type_name, borrow::Cow, diff --git a/crates/notifications/Cargo.toml b/crates/notifications/Cargo.toml index e0640c67cc55b3c2ba742e762d0e7a1e9d414c40..b03a658655fb47ac42be69e73daddfe5e0f20dba 100644 --- a/crates/notifications/Cargo.toml +++ b/crates/notifications/Cargo.toml @@ -24,8 +24,8 @@ test-support = [ anyhow.workspace = true channel.workspace = true client.workspace = true +futures-lite.workspace = true component.workspace = true -db.workspace = true gpui.workspace = true rpc.workspace = true sum_tree.workspace = true diff --git a/crates/notifications/src/notification_store.rs b/crates/notifications/src/notification_store.rs index f30a018811db822db49c9f05a2e5be3096ec0229..2e23b945a6f947af29fb0b6863f8700073032743 100644 --- a/crates/notifications/src/notification_store.rs +++ b/crates/notifications/src/notification_store.rs @@ -1,7 +1,7 @@ use anyhow::{Context as _, Result}; use channel::ChannelStore; use client::{ChannelId, Client, UserStore}; -use db::smol::stream::StreamExt; +use futures_lite::stream::StreamExt; use gpui::{App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, Global, Task}; use rpc::{Notification, TypedEnvelope, proto}; use std::{ops::Range, sync::Arc}; diff --git a/crates/outline/Cargo.toml b/crates/outline/Cargo.toml index 2ce031bd4605e6c5dfc32e7f76be7493924af825..84d596b761fea8e145653b6ca2598fa2b4b48db6 100644 --- a/crates/outline/Cargo.toml +++ b/crates/outline/Cargo.toml @@ -20,7 +20,6 @@ language.workspace = true ordered-float.workspace = true picker.workspace = true settings.workspace = true -smol.workspace = true theme.workspace = true theme_settings.workspace = true ui.workspace = true @@ -40,3 +39,4 @@ rope.workspace = true serde_json.workspace = true settings = { workspace = true, features = ["test-support"] } workspace = { workspace = true, features = ["test-support"] } +futures.workspace = true diff --git a/crates/outline/src/outline.rs b/crates/outline/src/outline.rs index af5671632fdac175e5d31ae15c5890d439b7860f..78c4d9c148eec3f38cbbded76bb8c31823216ee2 100644 --- a/crates/outline/src/outline.rs +++ b/crates/outline/src/outline.rs @@ -454,13 +454,13 @@ mod tests { use std::time::Duration; use super::*; + use futures::stream::StreamExt as _; use gpui::{TestAppContext, UpdateGlobal, VisualTestContext}; use indoc::indoc; use language::FakeLspAdapter; use project::{FakeFs, Project}; use serde_json::json; use settings::SettingsStore; - use smol::stream::StreamExt as _; use util::{path, rel_path::rel_path}; use workspace::{AppState, MultiWorkspace, Workspace}; diff --git a/crates/outline_panel/Cargo.toml b/crates/outline_panel/Cargo.toml index e88a0262907fcb22d1b954f25a5e74d8307bd174..a5bbf3f7ccc2d2cf38fc96fd164a2a099fe77f7b 100644 --- a/crates/outline_panel/Cargo.toml +++ b/crates/outline_panel/Cargo.toml @@ -14,11 +14,13 @@ doctest = false [dependencies] anyhow.workspace = true +async-channel.workspace = true collections.workspace = true db.workspace = true editor.workspace = true file_icons.workspace = true fuzzy.workspace = true +futures.workspace = true gpui.workspace = true itertools.workspace = true language.workspace = true @@ -31,7 +33,6 @@ serde.workspace = true serde_json.workspace = true settings.workspace = true smallvec.workspace = true -smol.workspace = true theme.workspace = true theme_settings.workspace = true ui.workspace = true diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rs index fa23b805cd48461dabaddbb7670155cdfe1ba8b0..fab8d1fe5b7a4ab2cc7777f719c40f3123378358 100644 --- a/crates/outline_panel/src/outline_panel.rs +++ b/crates/outline_panel/src/outline_panel.rs @@ -46,7 +46,6 @@ use project::{File, Fs, GitEntry, GitTraversal, Project, ProjectItem}; use search::{BufferSearchBar, ProjectSearchView}; use serde::{Deserialize, Serialize}; use settings::{Settings, SettingsStore}; -use smol::channel; use theme::SyntaxTheme; use theme_settings::ThemeSettings; use ui::{ @@ -155,7 +154,7 @@ struct SearchState { kind: SearchKind, query: String, matches: Vec<(Range, Arc>)>, - highlight_search_match_tx: channel::Sender, + highlight_search_match_tx: async_channel::Sender, _search_match_highlighter: Task<()>, _search_match_notify: Task<()>, } @@ -176,8 +175,8 @@ impl SearchState { window: &mut Window, cx: &mut Context, ) -> Self { - let (highlight_search_match_tx, highlight_search_match_rx) = channel::unbounded(); - let (notify_tx, notify_rx) = channel::unbounded::<()>(); + let (highlight_search_match_tx, highlight_search_match_rx) = async_channel::unbounded(); + let (notify_tx, notify_rx) = async_channel::unbounded::<()>(); Self { kind, query, @@ -5236,6 +5235,7 @@ impl GenerationState { #[cfg(test)] mod tests { use db::indoc; + use futures::stream::StreamExt as _; use gpui::{TestAppContext, UpdateGlobal, VisualTestContext, WindowHandle}; use language::{self, FakeLspAdapter, markdown_lang, rust_lang}; use pretty_assertions::assert_eq; @@ -5245,7 +5245,6 @@ mod tests { project_search::{self, perform_project_search}, }; use serde_json::json; - use smol::stream::StreamExt as _; use util::path; use workspace::{MultiWorkspace, OpenOptions, OpenVisible, ToolbarItemView}; diff --git a/crates/project/Cargo.toml b/crates/project/Cargo.toml index 628e979aab939a74bb4838477ae3e3657e2c91bc..3a27bf4de61249b59a9b1b7b1178812d5db48775 100644 --- a/crates/project/Cargo.toml +++ b/crates/project/Cargo.toml @@ -38,6 +38,7 @@ aho-corasick.workspace = true anyhow.workspace = true askpass.workspace = true async-trait.workspace = true +async-channel.workspace = true base64.workspace = true buffer_diff.workspace = true circular-buffer.workspace = true diff --git a/crates/project/src/buffer_store.rs b/crates/project/src/buffer_store.rs index d2f05a119a1883a1ec744b40d4cdb467074d3c83..a6d97abbb80927e640e0869547c51e08791d0d26 100644 --- a/crates/project/src/buffer_store.rs +++ b/crates/project/src/buffer_store.rs @@ -45,7 +45,7 @@ pub struct BufferStore { #[derive(Default)] struct RemoteProjectSearchState { // List of ongoing project search chunks from our remote host. Used by the side issuing a search RPC request. - chunks: HashMap>, + chunks: HashMap>, // Monotonously-increasing handle to hand out to remote host in order to identify the project search result chunk. next_id: u64, // Used by the side running the actual search for match candidates to potentially cancel the search prematurely. @@ -1709,8 +1709,8 @@ impl BufferStore { pub(crate) fn register_project_search_result_handle( &mut self, - ) -> (u64, smol::channel::Receiver) { - let (tx, rx) = smol::channel::unbounded(); + ) -> (u64, async_channel::Receiver) { + let (tx, rx) = async_channel::unbounded(); let handle = util::post_inc(&mut self.project_search.next_id); let _old_entry = self.project_search.chunks.insert(handle, tx); debug_assert!(_old_entry.is_none()); diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs index 7f24282dda619399701a740d335ece7c76b63683..57ed1b39f56af62816bd0096c5e20b24e6e6b089 100644 --- a/crates/project/src/git_store.rs +++ b/crates/project/src/git_store.rs @@ -307,7 +307,7 @@ pub struct JobInfo { struct GraphCommitDataHandler { _task: Task<()>, - commit_data_request: smol::channel::Sender, + commit_data_request: async_channel::Sender, } enum GraphCommitHandlerState { @@ -4727,7 +4727,7 @@ impl Repository { &mut self, log_source: LogSource, search_args: SearchCommitArgs, - request_tx: smol::channel::Sender, + request_tx: async_channel::Sender, cx: &mut Context, ) { let repository_state = self.repository_state.clone(); @@ -4827,7 +4827,7 @@ impl Repository { cx: &mut AsyncApp, ) -> Result<(), SharedString> { let (request_tx, request_rx) = - smol::channel::unbounded::>>(); + async_channel::unbounded::>>(); let task = cx.background_executor().spawn({ let log_source = log_source.clone(); @@ -4898,8 +4898,8 @@ impl Repository { self.graph_commit_data_handler = GraphCommitHandlerState::Starting; let state = self.repository_state.clone(); - let (result_tx, result_rx) = smol::channel::bounded::<(Oid, GraphCommitData)>(64); - let (request_tx, request_rx) = smol::channel::unbounded::(); + let (result_tx, result_rx) = async_channel::bounded::<(Oid, GraphCommitData)>(64); + let (request_tx, request_rx) = async_channel::unbounded::(); let foreground_task = cx.spawn(async move |this, cx| { while let Ok((sha, commit_data)) = result_rx.recv().await { diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index 1479f159138040681122bac46ace6e73ad62337b..0b466838dae8e924b8ad1edc798abda52e09be73 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -1178,7 +1178,7 @@ impl LocalLspStore { async move { let actions = params.actions.unwrap_or_default(); let message = params.message.clone(); - let (tx, rx) = smol::channel::bounded::(1); + let (tx, rx) = async_channel::bounded::(1); let level = match params.typ { lsp::MessageType::ERROR => PromptLevel::Critical, lsp::MessageType::WARNING => PromptLevel::Warning, @@ -1224,7 +1224,7 @@ impl LocalLspStore { let name = name.to_string(); let mut cx = cx.clone(); - let (tx, _) = smol::channel::bounded(1); + let (tx, _) = async_channel::bounded(1); let level = match params.typ { lsp::MessageType::ERROR => PromptLevel::Critical, lsp::MessageType::WARNING => PromptLevel::Warning, @@ -13817,7 +13817,7 @@ pub struct LanguageServerPromptRequest { pub message: String, pub actions: Vec, pub lsp_name: String, - pub(crate) response_channel: smol::channel::Sender, + pub(crate) response_channel: async_channel::Sender, } impl LanguageServerPromptRequest { @@ -13826,7 +13826,7 @@ impl LanguageServerPromptRequest { message: String, actions: Vec, lsp_name: String, - response_channel: smol::channel::Sender, + response_channel: async_channel::Sender, ) -> Self { let id = NEXT_PROMPT_REQUEST_ID.fetch_add(1, atomic::Ordering::AcqRel); LanguageServerPromptRequest { @@ -13853,7 +13853,7 @@ impl LanguageServerPromptRequest { actions: Vec, lsp_name: String, ) -> Self { - let (tx, _rx) = smol::channel::unbounded(); + let (tx, _rx) = async_channel::unbounded(); LanguageServerPromptRequest::new(level, message, actions, lsp_name, tx) } } diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 39e0cc9a0a00f4cd5861e60b1b100a8afef93eb8..a09ad34434b426098b2e5f95ab12db4c7af438a9 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -5193,7 +5193,7 @@ impl Project { envelope: TypedEnvelope, mut cx: AsyncApp, ) -> Result { - let (tx, rx) = smol::channel::bounded(1); + let (tx, rx) = async_channel::bounded(1); let actions: Vec<_> = envelope .payload .actions diff --git a/crates/project/src/project_search.rs b/crates/project/src/project_search.rs index 921ad7e26a454d97719310069d81dd423e9208ca..19614cc071ab9f66638d07ffe25733d44bf45c16 100644 --- a/crates/project/src/project_search.rs +++ b/crates/project/src/project_search.rs @@ -10,6 +10,7 @@ use std::{ }; use anyhow::Context; +use async_channel::{Receiver, Sender, bounded, unbounded}; use collections::HashSet; use fs::Fs; use futures::FutureExt as _; @@ -19,7 +20,6 @@ use language::{Buffer, BufferSnapshot}; use parking_lot::Mutex; use postage::oneshot; use rpc::{AnyProtoClient, proto}; -use smol::channel::{Receiver, Sender, bounded, unbounded}; use util::{ResultExt, maybe, paths::compare_rel_paths, rel_path::RelPath}; use worktree::{Entry, ProjectEntryId, Snapshot, Worktree, WorktreeSettings}; diff --git a/crates/project/src/terminals.rs b/crates/project/src/terminals.rs index 6efddcdf7726110a61f15666c68b963181181086..ac6bc969a59e800f95f6f2663b60a388dfbe88f2 100644 --- a/crates/project/src/terminals.rs +++ b/crates/project/src/terminals.rs @@ -2,12 +2,12 @@ use anyhow::Result; use collections::HashMap; use gpui::{App, AppContext as _, Context, Entity, Task, WeakEntity}; +use async_channel::bounded; use futures::{FutureExt, future::Shared}; use itertools::Itertools as _; use language::LanguageName; use remote::RemoteClient; use settings::{Settings, SettingsLocation}; -use smol::channel::bounded; use std::{ path::{Path, PathBuf}, sync::Arc, diff --git a/crates/recent_projects/Cargo.toml b/crates/recent_projects/Cargo.toml index a2aa9f78a2a5edaf13a4f23f52f3695de636850f..8ddd3ecd66a8204cfb834b3ad7a75613a4e72b27 100644 --- a/crates/recent_projects/Cargo.toml +++ b/crates/recent_projects/Cargo.toml @@ -44,7 +44,6 @@ semver.workspace = true serde.workspace = true serde_json.workspace = true settings.workspace = true -smol.workspace = true task.workspace = true telemetry.workspace = true ui.workspace = true diff --git a/crates/recent_projects/src/recent_projects.rs b/crates/recent_projects/src/recent_projects.rs index 9a6015ba843b06dfe678fee1b5de2fac38295849..3085686ecd6f3967f1d4217e8eedc36f28d75085 100644 --- a/crates/recent_projects/src/recent_projects.rs +++ b/crates/recent_projects/src/recent_projects.rs @@ -951,7 +951,7 @@ impl PickerDelegate for RecentProjectsDelegate { .map(|(id, folder)| StringMatchCandidate::new(id, folder.name.as_ref())) .collect(); - smol::block_on(fuzzy::match_strings( + gpui::block_on(fuzzy::match_strings( &candidates, query, smart_case, @@ -977,7 +977,7 @@ impl PickerDelegate for RecentProjectsDelegate { }) .collect(); - let mut project_group_matches = smol::block_on(fuzzy::match_strings( + let mut project_group_matches = gpui::block_on(fuzzy::match_strings( &project_group_candidates, query, smart_case, @@ -1009,7 +1009,7 @@ impl PickerDelegate for RecentProjectsDelegate { }) .collect(); - let mut recent_matches = smol::block_on(fuzzy::match_strings( + let mut recent_matches = gpui::block_on(fuzzy::match_strings( &recent_candidates, query, smart_case, diff --git a/crates/recent_projects/src/remote_servers.rs b/crates/recent_projects/src/remote_servers.rs index d360ba4233d036191617c89ffb92b9decced5002..1c5340236d56c437008bb010d1882be99d4eff33 100644 --- a/crates/recent_projects/src/remote_servers.rs +++ b/crates/recent_projects/src/remote_servers.rs @@ -12,7 +12,7 @@ use dev_container::{ use editor::Editor; use extension_host::ExtensionStore; -use futures::{FutureExt, channel::oneshot, future::Shared}; +use futures::{FutureExt, StreamExt as _, channel::oneshot, future::Shared}; use gpui::{ Action, AnyElement, App, ClickEvent, ClipboardItem, Context, DismissEvent, Entity, EventEmitter, FocusHandle, Focusable, PromptLevel, ScrollHandle, Subscription, Task, @@ -31,7 +31,6 @@ use settings::{ RemoteProject, RemoteSettingsContent, Settings as _, SettingsStore, update_settings_file, watch_config_file, }; -use smol::stream::StreamExt as _; use std::{ borrow::Cow, collections::BTreeSet, diff --git a/crates/recent_projects/src/sidebar_recent_projects.rs b/crates/recent_projects/src/sidebar_recent_projects.rs index 2c697de73fb6ad203ae6f85c89e73050a68fcbd0..fce864c42f6ac0e216467caafb54ae25c6df5d7f 100644 --- a/crates/recent_projects/src/sidebar_recent_projects.rs +++ b/crates/recent_projects/src/sidebar_recent_projects.rs @@ -235,7 +235,7 @@ impl PickerDelegate for SidebarRecentProjectsDelegate { }) .collect(); } else { - let mut matches = smol::block_on(fuzzy::match_strings( + let mut matches = gpui::block_on(fuzzy::match_strings( &candidates, query, smart_case, diff --git a/crates/recent_projects/src/wsl_picker.rs b/crates/recent_projects/src/wsl_picker.rs index c53dd7c3fb68bc087216764536506f85117ffb36..cb8ea873d2c9e56e0118838a3f7dc72af7bbd782 100644 --- a/crates/recent_projects/src/wsl_picker.rs +++ b/crates/recent_projects/src/wsl_picker.rs @@ -122,7 +122,7 @@ impl picker::PickerDelegate for WslPickerDelegate { let query = query.trim_start(); let smart_case = query.chars().any(|c| c.is_uppercase()); - self.matches = smol::block_on(fuzzy::match_strings( + self.matches = gpui::block_on(fuzzy::match_strings( candidates.as_slice(), query, smart_case, diff --git a/crates/remote_server/Cargo.toml b/crates/remote_server/Cargo.toml index c6ce45ba1ce28386d0776eb40299919f92aa8e53..48c047252fe1e4dda2a3ff3fd7ed66b5a425ef38 100644 --- a/crates/remote_server/Cargo.toml +++ b/crates/remote_server/Cargo.toml @@ -23,6 +23,7 @@ test-support = ["fs/test-support"] [dependencies] anyhow.workspace = true +async-channel.workspace = true askpass.workspace = true clap.workspace = true client.workspace = true diff --git a/crates/remote_server/src/server.rs b/crates/remote_server/src/server.rs index bc39e4635e96110f5e9179ba744afc6f93f8e341..c0a6d6de1993b4ff8fdcf86c58c1232d24f2d072 100644 --- a/crates/remote_server/src/server.rs +++ b/crates/remote_server/src/server.rs @@ -41,6 +41,7 @@ use rpc::proto::{self, Envelope, REMOTE_SERVER_PROJECT_ID}; use rpc::{AnyProtoClient, TypedEnvelope}; use settings::{Settings, SettingsStore, watch_config_file}; use smol::{ + Timer, channel::{Receiver, Sender}, io::AsyncReadExt, stream::StreamExt as _, @@ -181,7 +182,7 @@ fn init_logging_server(log_file_path: &Path) -> Result>> { .open(log_file_path) .context("Failed to open log file in append mode")?; - let (tx, rx) = smol::channel::unbounded(); + let (tx, rx) = async_channel::unbounded(); let target = Box::new(MultiWrite { file: log_file, @@ -472,6 +473,9 @@ pub fn execute_run( |task| { app.background_executor().spawn(task).detach(); }, + // we are running outside gpui + #[allow(clippy::disallowed_methods)] + |duration| FutureExt::map(Timer::after(duration), |_| ()), ); let log_rx = init_logging_server(&log_file)?; log::info!( @@ -727,6 +731,9 @@ pub(crate) fn execute_proxy( |task| { smol::spawn(task).detach(); }, + // we are running outside gpui + #[allow(clippy::disallowed_methods)] + |duration| FutureExt::map(Timer::after(duration), |_| ()), ); log::info!("starting proxy process. PID: {}", std::process::id()); @@ -755,7 +762,7 @@ pub(crate) fn execute_proxy( ); kill_running_server(pid, &server_paths)?; } - smol::block_on(spawn_server(&server_paths)).map_err(ExecuteProxyError::SpawnServer)?; + gpui::block_on(spawn_server(&server_paths)).map_err(ExecuteProxyError::SpawnServer)?; std::fs::read_to_string(&server_paths.pid_file) .and_then(|contents| { contents.parse::().map_err(|_| { @@ -826,7 +833,7 @@ pub(crate) fn execute_proxy( } }); - if let Err(forwarding_result) = smol::block_on(async move { + if let Err(forwarding_result) = gpui::block_on(async move { futures::select! { result = stdin_task.fuse() => result.map_err(ExecuteProxyError::StdinTask), result = stdout_task.fuse() => result.map_err(ExecuteProxyError::StdoutTask), @@ -834,7 +841,7 @@ pub(crate) fn execute_proxy( } }) { log::error!("encountered error while forwarding messages: {forwarding_result:#}",); - if !matches!(smol::block_on(check_server_running(server_pid)), Ok(true)) { + if !matches!(gpui::block_on(check_server_running(server_pid)), Ok(true)) { log::error!("server exited unexpectedly"); return Err(ExecuteProxyError::ServerNotRunning( ProxyLaunchError::ServerNotRunning, diff --git a/crates/search/Cargo.toml b/crates/search/Cargo.toml index 4213aa39a046e944cd34f9a1530bd15d1c442863..dac98f5245f11e16bcc325067cb37f36000712c6 100644 --- a/crates/search/Cargo.toml +++ b/crates/search/Cargo.toml @@ -27,6 +27,7 @@ bitflags.workspace = true collections.workspace = true editor.workspace = true fs.workspace = true +futures-lite.workspace = true futures.workspace = true gpui.workspace = true language.workspace = true @@ -36,7 +37,6 @@ project.workspace = true serde.workspace = true serde_json.workspace = true settings.workspace = true -smol.workspace = true theme.workspace = true theme_settings.workspace = true ui.workspace = true diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 3a5fbe3fcae6241495deb43930b83bb78ba81968..9773266f1392fa7a3b2012a420199d4fde7dc4b0 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -1907,10 +1907,10 @@ mod tests { DisplayPoint, Editor, MultiBuffer, PathKey, SearchSettings, SelectionEffects, display_map::DisplayRow, test::editor_test_context::EditorTestContext, }; + use futures::stream::StreamExt as _; use gpui::{Hsla, TestAppContext, UpdateGlobal, VisualTestContext}; use language::{Buffer, Point}; use settings::{SearchSettingsContent, SettingsStore}; - use smol::stream::StreamExt as _; use unindent::Unindent as _; use util_macros::perf; diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 7e7903674e3d883bfb98ac8d57b5f407237f66d1..afe910ba468d4d68a7e3dd2b3a26094004589bcc 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -467,7 +467,7 @@ impl ProjectSearch { while let Some(new_ranges) = new_ranges.next().await { // `new_ranges.next().await` likely never gets hit while still pending so `async_task` // will not reschedule, starving other front end tasks, insert a yield point for that here - smol::future::yield_now().await; + futures_lite::future::yield_now().await; project_search .update(cx, |project_search, cx| { project_search.match_ranges.extend(new_ranges); diff --git a/crates/sidebar/Cargo.toml b/crates/sidebar/Cargo.toml index e9ef4dea630e97732f050e6548392fde9ceedfc8..11f8ae88b1ee723033a6882cda8875bfc4f5c048 100644 --- a/crates/sidebar/Cargo.toml +++ b/crates/sidebar/Cargo.toml @@ -17,6 +17,7 @@ default = [] [dependencies] acp_thread.workspace = true action_log.workspace = true +async-channel.workspace = true agent.workspace = true agent-client-protocol.workspace = true agent_settings.workspace = true @@ -37,7 +38,6 @@ remote_connection.workspace = true serde.workspace = true serde_json.workspace = true settings.workspace = true -smol.workspace = true theme.workspace = true theme_settings.workspace = true ui.workspace = true diff --git a/crates/sidebar/src/sidebar.rs b/crates/sidebar/src/sidebar.rs index 9c126929a4705de4d3ffc9e6472332e86a07c2e8..37eafcee8ebac426a59b457639bb89e4a3e1d049 100644 --- a/crates/sidebar/src/sidebar.rs +++ b/crates/sidebar/src/sidebar.rs @@ -2912,7 +2912,7 @@ impl Sidebar { session_id: &acp::SessionId, neighbor: Option<&ThreadMetadata>, thread_folder_paths: Option<&PathList>, - in_flight_archive: Option<(Task<()>, smol::channel::Sender<()>)>, + in_flight_archive: Option<(Task<()>, async_channel::Sender<()>)>, window: &mut Window, cx: &mut Context, ) { @@ -2998,12 +2998,12 @@ impl Sidebar { session_id: &acp::SessionId, roots: Vec, cx: &mut Context, - ) -> Option<(Task<()>, smol::channel::Sender<()>)> { + ) -> Option<(Task<()>, async_channel::Sender<()>)> { if roots.is_empty() { return None; } - let (cancel_tx, cancel_rx) = smol::channel::bounded::<()>(1); + let (cancel_tx, cancel_rx) = async_channel::bounded::<()>(1); let session_id = session_id.clone(); let task = cx.spawn(async move |_this, cx| { match Self::archive_worktree_roots(roots, cancel_rx, cx).await { @@ -3031,7 +3031,7 @@ impl Sidebar { async fn archive_worktree_roots( roots: Vec, - cancel_rx: smol::channel::Receiver<()>, + cancel_rx: async_channel::Receiver<()>, cx: &mut gpui::AsyncApp, ) -> anyhow::Result { let mut completed_persists: Vec<(i64, thread_worktree_archive::RootPlan)> = Vec::new(); diff --git a/crates/sqlez/Cargo.toml b/crates/sqlez/Cargo.toml index 5f4a0bef67efe3cf021d9d113922ca14f269fe85..f5db6f96a0dfb6c7bbb67bf66036ded818988c64 100644 --- a/crates/sqlez/Cargo.toml +++ b/crates/sqlez/Cargo.toml @@ -16,7 +16,7 @@ indoc.workspace = true libsqlite3-sys.workspace = true log.workspace = true parking_lot.workspace = true -smol.workspace = true +pollster.workspace = true sqlformat.workspace = true thread_local = "1.1.4" util.workspace = true diff --git a/crates/sqlez/src/thread_safe_connection.rs b/crates/sqlez/src/thread_safe_connection.rs index 7b3630cdf65f900469e3d7544f3bd75b33250625..1de70a06636b8944ff6d6e574253405414349234 100644 --- a/crates/sqlez/src/thread_safe_connection.rs +++ b/crates/sqlez/src/thread_safe_connection.rs @@ -344,7 +344,7 @@ mod test { PRAGMA case_sensitive_like=TRUE; "}); - let _ = smol::block_on(builder.build()).unwrap().deref(); + let _ = pollster::block_on(builder.build()).unwrap().deref(); })); } diff --git a/crates/tab_switcher/Cargo.toml b/crates/tab_switcher/Cargo.toml index 8855c8869ab52260be668c45c20e5af7a869433f..82851568938855b76568da202111a3a07a495c5e 100644 --- a/crates/tab_switcher/Cargo.toml +++ b/crates/tab_switcher/Cargo.toml @@ -23,7 +23,6 @@ project.workspace = true schemars.workspace = true serde.workspace = true settings.workspace = true -smol.workspace = true ui.workspace = true util.workspace = true workspace.workspace = true diff --git a/crates/tab_switcher/src/tab_switcher.rs b/crates/tab_switcher/src/tab_switcher.rs index d1e19ea4faee8d8259d06e2c24875faac7a0117c..5beca566dced5ace002009a4e690a6032dec1b70 100644 --- a/crates/tab_switcher/src/tab_switcher.rs +++ b/crates/tab_switcher/src/tab_switcher.rs @@ -441,7 +441,7 @@ impl TabSwitcherDelegate { )) }) .collect::>(); - smol::block_on(fuzzy::match_strings( + gpui::block_on(fuzzy::match_strings( &candidates, &query, true, diff --git a/crates/terminal/Cargo.toml b/crates/terminal/Cargo.toml index 8a598c1d7730ef59c19085f73cc65bd955ad4e35..eaa2182871b2f7f8730ace8755ece601deecd056 100644 --- a/crates/terminal/Cargo.toml +++ b/crates/terminal/Cargo.toml @@ -20,10 +20,12 @@ path = "src/terminal.rs" doctest = false [dependencies] +async-channel.workspace = true alacritty_terminal.workspace = true anyhow.workspace = true collections.workspace = true futures.workspace = true +futures-lite.workspace = true gpui.workspace = true itertools.workspace = true libc.workspace = true @@ -34,7 +36,6 @@ schemars.workspace = true serde.workspace = true settings.workspace = true sysinfo.workspace = true -smol.workspace = true task.workspace = true theme.workspace = true theme_settings.workspace = true diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index b620f5f03c2debf19cdc4856da8c039fe690651f..c18188ea27a1b010adbe54215706a1b767659292 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -26,6 +26,7 @@ use alacritty_terminal::{ }, }; use anyhow::{Context as _, Result, bail}; +use futures_lite::future::yield_now; use log::trace; use futures::{ @@ -39,12 +40,12 @@ use mappings::mouse::{ scroll_report, }; +use async_channel::{Receiver, Sender}; use collections::{HashMap, VecDeque}; use futures::StreamExt; use pty_info::{ProcessIdGetter, PtyProcessInfo}; use serde::{Deserialize, Serialize}; use settings::Settings; -use smol::channel::{Receiver, Sender}; use task::{HideStrategy, Shell, SpawnInTerminal}; use terminal_hyperlinks::RegexSearches; use terminal_settings::{AlternateScroll, CursorShape, TerminalSettings}; @@ -736,7 +737,7 @@ impl TerminalBuilder { } if events.is_empty() && !wakeup { - smol::future::yield_now().await; + yield_now().await; break 'outer; } @@ -749,7 +750,7 @@ impl TerminalBuilder { this.process_event(event, cx); } })?; - smol::future::yield_now().await; + yield_now().await; } } anyhow::Ok(()) @@ -2564,6 +2565,7 @@ mod tests { index::{Column, Line, Point as AlacPoint}, term::cell::Cell, }; + use async_channel::Receiver; use collections::HashMap; use gpui::{ Entity, Modifiers, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Pixels, @@ -2571,7 +2573,6 @@ mod tests { }; use parking_lot::Mutex; use rand::{Rng, distr, rngs::StdRng}; - use smol::channel::Receiver; use task::{Shell, ShellBuilder}; #[cfg(not(target_os = "windows"))] @@ -2590,7 +2591,7 @@ mod tests { command: &str, args: &[&str], ) -> (Entity, Receiver>) { - let (completion_tx, completion_rx) = smol::channel::unbounded(); + let (completion_tx, completion_rx) = async_channel::unbounded(); let args: Vec = args.iter().map(|s| s.to_string()).collect(); let (program, args) = ShellBuilder::new(&Shell::System, false).build(Some(command.to_owned()), &args); @@ -2743,7 +2744,7 @@ mod tests { cx.executor().allow_parking(); - let (completion_tx, completion_rx) = smol::channel::unbounded(); + let (completion_tx, completion_rx) = async_channel::unbounded(); let builder = cx .update(|cx| { TerminalBuilder::new( @@ -2769,7 +2770,7 @@ mod tests { // Build an empty command, which will result in a tty shell spawned. let terminal = cx.new(|cx| builder.subscribe(cx)); - let (event_tx, event_rx) = smol::channel::unbounded::(); + let (event_tx, event_rx) = async_channel::unbounded::(); cx.update(|cx| { cx.subscribe(&terminal, move |_, e, _| { event_tx.send_blocking(e.clone()).unwrap(); @@ -2840,7 +2841,7 @@ mod tests { .unwrap(); let terminal = cx.new(|cx| builder.subscribe(cx)); - let (event_tx, event_rx) = smol::channel::unbounded::(); + let (event_tx, event_rx) = async_channel::unbounded::(); cx.update(|cx| { cx.subscribe(&terminal, move |_, e, _| { event_tx.send_blocking(e.clone()).unwrap(); @@ -2875,7 +2876,7 @@ mod tests { async fn test_terminal_no_exit_on_spawn_failure(cx: &mut TestAppContext) { cx.executor().allow_parking(); - let (completion_tx, completion_rx) = smol::channel::unbounded(); + let (completion_tx, completion_rx) = async_channel::unbounded(); let (program, args) = ShellBuilder::new(&Shell::System, false) .build(Some("asdasdasdasd".to_owned()), &["@@@@@".to_owned()]); let builder = cx diff --git a/crates/workspace/Cargo.toml b/crates/workspace/Cargo.toml index 42e64504f348a727d17d2538d06556497fba54df..f10de45b8dfc262b86b919202c9e8781d5b8d718 100644 --- a/crates/workspace/Cargo.toml +++ b/crates/workspace/Cargo.toml @@ -37,6 +37,7 @@ collections.workspace = true component.workspace = true db.workspace = true feature_flags.workspace = true +futures-lite.workspace = true fs.workspace = true futures.workspace = true git.workspace = true diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index d40b7abae0c036a5cdd227ec8a547bd3c10b262c..0beb887f8a3965c7fe86fd9b851142373a446f1a 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -17,7 +17,6 @@ mod persistence; pub mod searchable; mod security_modal; pub mod shared_screen; -use db::smol::future::yield_now; pub use shared_screen::SharedScreen; pub mod focus_follows_mouse; mod status_bar; @@ -3310,7 +3309,7 @@ impl Workspace { // Yield between synthetic keystrokes so deferred focus and // other effects can settle before dispatching the next key. - yield_now().await; + futures_lite::future::yield_now().await; } *keystrokes.borrow_mut() = Default::default(); diff --git a/crates/worktree/Cargo.toml b/crates/worktree/Cargo.toml index 6d8faad3dc495a02e054f3fa652f5815f301cf3f..5aac6f24173def4d801f12f1be66fa2c09cab206 100644 --- a/crates/worktree/Cargo.toml +++ b/crates/worktree/Cargo.toml @@ -31,6 +31,7 @@ test-support = [ [dependencies] anyhow.workspace = true +async-channel.workspace = true async-lock.workspace = true chardetng.workspace = true clock.workspace = true @@ -53,7 +54,6 @@ serde.workspace = true serde_json.workspace = true settings.workspace = true smallvec.workspace = true -smol.workspace = true sum_tree.workspace = true text.workspace = true tracing.workspace = true diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index ab8d448d793fb63a1c5bb5fe1c3bb05886c0866d..64320ece42439d4dc59a5a32560f9612db6a295c 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -32,6 +32,7 @@ use gpui::{ use ignore::IgnoreStack; use language::DiskState; +use async_channel::{self, Sender}; use parking_lot::Mutex; use paths::{local_settings_folder_name, local_vscode_folder_name}; use postage::{ @@ -46,7 +47,6 @@ use rpc::{ pub use settings::WorktreeId; use settings::{Settings, SettingsLocation, SettingsStore}; use smallvec::{SmallVec, smallvec}; -use smol::channel::{self, Sender}; use std::{ any::Any, borrow::Borrow as _, @@ -128,8 +128,8 @@ impl fmt::Debug for LoadedBinaryFile { pub struct LocalWorktree { snapshot: LocalSnapshot, - scan_requests_tx: channel::Sender, - path_prefixes_to_scan_tx: channel::Sender, + scan_requests_tx: async_channel::Sender, + path_prefixes_to_scan_tx: async_channel::Sender, is_scanning: (watch::Sender, watch::Receiver), snapshot_subscriptions: VecDeque<(usize, oneshot::Sender<()>)>, _background_scanner_tasks: Vec>, @@ -479,8 +479,8 @@ impl Worktree { .block_on(snapshot.insert_entry(entry, fs.as_ref())); } - let (scan_requests_tx, scan_requests_rx) = channel::unbounded(); - let (path_prefixes_to_scan_tx, path_prefixes_to_scan_rx) = channel::unbounded(); + let (scan_requests_tx, scan_requests_rx) = async_channel::unbounded(); + let (path_prefixes_to_scan_tx, path_prefixes_to_scan_rx) = async_channel::unbounded(); let mut worktree = LocalWorktree { share_private_files, next_entry_id, @@ -1101,8 +1101,8 @@ impl LocalWorktree { } fn restart_background_scanners(&mut self, cx: &Context) { - let (scan_requests_tx, scan_requests_rx) = channel::unbounded(); - let (path_prefixes_to_scan_tx, path_prefixes_to_scan_rx) = channel::unbounded(); + let (scan_requests_tx, scan_requests_rx) = async_channel::unbounded(); + let (path_prefixes_to_scan_tx, path_prefixes_to_scan_rx) = async_channel::unbounded(); self.scan_requests_tx = scan_requests_tx; self.path_prefixes_to_scan_tx = path_prefixes_to_scan_tx; @@ -1120,8 +1120,8 @@ impl LocalWorktree { fn start_background_scanner( &mut self, - scan_requests_rx: channel::Receiver, - path_prefixes_to_scan_rx: channel::Receiver, + scan_requests_rx: async_channel::Receiver, + path_prefixes_to_scan_rx: async_channel::Receiver, cx: &Context, ) { let snapshot = self.snapshot(); @@ -3903,8 +3903,8 @@ struct BackgroundScanner { fs_case_sensitive: bool, status_updates_tx: UnboundedSender, executor: BackgroundExecutor, - scan_requests_rx: channel::Receiver, - path_prefixes_to_scan_rx: channel::Receiver, + scan_requests_rx: async_channel::Receiver, + path_prefixes_to_scan_rx: async_channel::Receiver, next_entry_id: Arc, phase: BackgroundScannerPhase, watcher: Arc, @@ -4009,7 +4009,7 @@ impl BackgroundScanner { Box::pin(futures::stream::pending()) }; - let (scan_job_tx, scan_job_rx) = channel::unbounded(); + let (scan_job_tx, scan_job_rx) = async_channel::unbounded(); { let mut state = self.state.lock().await; state.snapshot.scan_id += 1; @@ -4417,7 +4417,7 @@ impl BackgroundScanner { self.state.lock().await.snapshot.scan_id += 1; - let (scan_job_tx, scan_job_rx) = channel::unbounded(); + let (scan_job_tx, scan_job_rx) = async_channel::unbounded(); log::debug!( "received fs events {:?}", relative_paths @@ -4482,7 +4482,7 @@ impl BackgroundScanner { .await; (state.snapshot.clone(), ignore_stack, abs_path) }; - let (scan_job_tx, scan_job_rx) = channel::unbounded(); + let (scan_job_tx, scan_job_rx) = async_channel::unbounded(); self.update_ignore_statuses_for_paths( scan_job_tx, prev_snapshot, @@ -4494,7 +4494,7 @@ impl BackgroundScanner { } async fn forcibly_load_paths(&self, paths: &[Arc]) -> bool { - let (scan_job_tx, scan_job_rx) = channel::unbounded(); + let (scan_job_tx, scan_job_rx) = async_channel::unbounded(); { let mut state = self.state.lock().await; let root_path = state.snapshot.abs_path.clone(); @@ -4529,7 +4529,7 @@ impl BackgroundScanner { async fn scan_dirs( &self, enable_progress_updates: bool, - scan_jobs_rx: channel::Receiver, + scan_jobs_rx: async_channel::Receiver, ) { if self .status_updates_tx @@ -5031,7 +5031,7 @@ impl BackgroundScanner { prev_snapshot: LocalSnapshot, ignores_to_update: Vec<(Arc, IgnoreStack)>, ) { - let (ignore_queue_tx, ignore_queue_rx) = channel::unbounded(); + let (ignore_queue_tx, ignore_queue_rx) = async_channel::unbounded(); { for (parent_abs_path, ignore_stack) in ignores_to_update { ignore_queue_tx diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 97caf14639ce23a8c85392aa630267f146902602..60eaa464c01e3fcf9f56bc828eea46990acfcc58 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -336,7 +336,7 @@ fn main() { session_id.clone(), KeyValueStore::from_app_db(&app_db), )); - + let background_executor = app.background_executor(); crashes::init( InitCrashHandler { session_id, @@ -357,6 +357,7 @@ fn main() { |task| { app.background_executor().spawn(task).detach(); }, + move |duration| background_executor.timer(duration), ); let (open_listener, mut open_rx) = OpenListener::new(); diff --git a/crates/zed/src/zed/open_listener.rs b/crates/zed/src/zed/open_listener.rs index 16d220c56093a2645db9f5bdc3114e16814138ac..7d248800a1b7eb9d082a0d86f518b614c12e91de 100644 --- a/crates/zed/src/zed/open_listener.rs +++ b/crates/zed/src/zed/open_listener.rs @@ -322,7 +322,7 @@ fn connect_to_cli( futures::channel::mpsc::channel::(16); thread::spawn(move || { while let Ok(cli_request) = request_rx.recv() { - if smol::block_on(async_request_tx.send(cli_request)).is_err() { + if gpui::block_on(async_request_tx.send(cli_request)).is_err() { break; } } diff --git a/crates/zed/src/zed/visual_tests.rs b/crates/zed/src/zed/visual_tests.rs index 982db08782207a9bfef96ec8f17c28c8abac41f3..610621f480f7bf365b63470db67defd25e3f1ba3 100644 --- a/crates/zed/src/zed/visual_tests.rs +++ b/crates/zed/src/zed/visual_tests.rs @@ -441,7 +441,7 @@ mod tests { let mut cx = VisualTestAppContext::new(gpui_platform::current_platform(false)); let app_state = init_visual_test(&mut cx); - smol::block_on(async { + gpui::block_on(async { app_state .fs .as_fake() @@ -456,7 +456,7 @@ mod tests { .await; }); - let workspace_result = smol::block_on(open_test_workspace(app_state, &mut cx)); + let workspace_result = gpui::block_on(open_test_workspace(app_state, &mut cx)); assert!( workspace_result.is_ok(), "Failed to open workspace: {:?}", @@ -482,7 +482,7 @@ mod tests { let mut cx = VisualTestAppContext::new(gpui_platform::current_platform(false)); let app_state = init_visual_test(&mut cx); - smol::block_on(async { + gpui::block_on(async { app_state .fs .as_fake() @@ -498,10 +498,10 @@ mod tests { .await; }); - let workspace = smol::block_on(open_test_workspace(app_state, &mut cx)) + let workspace = gpui::block_on(open_test_workspace(app_state, &mut cx)) .expect("Failed to open workspace"); - smol::block_on(async { + gpui::block_on(async { wait_for_ui_stabilization(&cx).await; let screenshot_result = cx.capture_screenshot(workspace.into());