From c62210b17871b6195b479ea52fe78b2924339e51 Mon Sep 17 00:00:00 2001 From: Smit Barmase Date: Fri, 14 Mar 2025 14:11:27 +0000 Subject: [PATCH] copilot: Handle sign out when copilot language server is not running (#26776) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When copilot is not being used as the edit prediction provider and you open a fresh Zed instance, we don’t run the copilot language server. This is because copilot chat is purely handled via oauth token and doesn’t require the language server. In this case, if you click sign out, instead of asking the language server to sign out (which isn’t running), we can manually clear the config directory, which contains the oauth tokens. We already watch this directory, and if the token is not found, we update the sign-in status. Release Notes: - N/A --- crates/copilot/src/copilot.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index fed19c77913527cc459a2cfaa1cc7039ac18a7f2..8896aa5ea2d3ba7edf116a1a354d2ca7086541b7 100644 --- a/crates/copilot/src/copilot.rs +++ b/crates/copilot/src/copilot.rs @@ -654,6 +654,10 @@ impl Copilot { anyhow::Ok(()) }) } + CopilotServer::Disabled => cx.background_spawn(async { + clear_copilot_config_dir().await; + anyhow::Ok(()) + }), _ => Task::ready(Err(anyhow!("copilot hasn't started yet"))), } } @@ -1047,6 +1051,10 @@ async fn clear_copilot_dir() { remove_matching(paths::copilot_dir(), |_| true).await } +async fn clear_copilot_config_dir() { + remove_matching(copilot_chat::copilot_chat_config_dir(), |_| true).await +} + async fn get_copilot_lsp(http: Arc) -> anyhow::Result { const SERVER_PATH: &str = "dist/language-server.js";