mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-07 20:39:04 +03:00
Copilot: handle "ok" status message when no user is set (#8116)
In #6954 a user has trouble using copilot. We haven't gotten to the
bottom of the problem, but one problem is that apparently sometimes (I'm
going to find out when) copilot sends an `"OK"` status message without a
username. This is from the user's logs:
2024-02-20T15:28:41-03:00 [ERROR] failed to deserialize response from
language server: missing field `user`. Response from language server:
"{\"status\":\"OK\"}"
The official `copilot.vim` plugin handles this as if the user is not
authenticated (!= authorized):
1a284014d2/autoload/copilot.vim (L574-L579)
So that's what I'm doing here too.
Release Notes:
- Fixed wrong handling of Copilot sign-in status in rare cases.
This commit is contained in:
parent
fd9823898f
commit
45e2c01773
@ -512,7 +512,7 @@ impl Copilot {
|
||||
.await?;
|
||||
match sign_in {
|
||||
request::SignInInitiateResult::AlreadySignedIn { user } => {
|
||||
Ok(request::SignInStatus::Ok { user })
|
||||
Ok(request::SignInStatus::Ok { user: Some(user) })
|
||||
}
|
||||
request::SignInInitiateResult::PromptUserDeviceFlow(flow) => {
|
||||
this.update(&mut cx, |this, cx| {
|
||||
@ -920,7 +920,7 @@ impl Copilot {
|
||||
|
||||
if let Ok(server) = self.server.as_running() {
|
||||
match lsp_status {
|
||||
request::SignInStatus::Ok { .. }
|
||||
request::SignInStatus::Ok { user: Some(_) }
|
||||
| request::SignInStatus::MaybeOk { .. }
|
||||
| request::SignInStatus::AlreadySignedIn { .. } => {
|
||||
server.sign_in_status = SignInStatus::Authorized;
|
||||
@ -936,7 +936,7 @@ impl Copilot {
|
||||
self.unregister_buffer(&buffer);
|
||||
}
|
||||
}
|
||||
request::SignInStatus::NotSignedIn => {
|
||||
request::SignInStatus::Ok { user: None } | request::SignInStatus::NotSignedIn => {
|
||||
server.sign_in_status = SignInStatus::SignedOut;
|
||||
for buffer in self.buffers.iter().cloned().collect::<Vec<_>>() {
|
||||
self.unregister_buffer(&buffer);
|
||||
|
@ -52,7 +52,7 @@ pub struct SignInConfirmParams {
|
||||
pub enum SignInStatus {
|
||||
#[serde(rename = "OK")]
|
||||
Ok {
|
||||
user: String,
|
||||
user: Option<String>,
|
||||
},
|
||||
MaybeOk {
|
||||
user: String,
|
||||
|
Loading…
Reference in New Issue
Block a user