Skip to content

Commit b57a424

Browse files
committed
WIP
1 parent 7c634c8 commit b57a424

File tree

2 files changed

+261
-73
lines changed

2 files changed

+261
-73
lines changed

crates/copilot/src/copilot.rs

+36-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use language::{
2323
use lsp::{LanguageServer, LanguageServerBinary, LanguageServerId, LanguageServerName};
2424
use node_runtime::NodeRuntime;
2525
use parking_lot::Mutex;
26-
use request::StatusNotification;
26+
use request::{DidChangeStatus, WindowShowMessageRequest};
2727
use settings::SettingsStore;
2828
use sign_in::{reinstall_and_sign_in_within_workspace, sign_out_within_workspace};
2929
use std::{
@@ -500,7 +500,41 @@ impl Copilot {
500500
)?;
501501

502502
server
503-
.on_notification::<StatusNotification, _>(|_, _| { /* Silence the notification */ })
503+
.on_notification::<DidChangeStatus, _>({
504+
let this = this.clone();
505+
move |params, cx| {
506+
// Convert didChangeStatus to appropriate SignInStatus and update
507+
let sign_in_status = match params.kind.as_str() {
508+
"Error" => Some(request::SignInStatus::NotAuthorized {
509+
user: String::new(),
510+
}),
511+
"Normal" => Some(request::SignInStatus::AlreadySignedIn {
512+
user: String::new(),
513+
}),
514+
"Inactive" | "Warning" => None, // Don't change auth status for these
515+
_ => None,
516+
};
517+
518+
if let Some(status) = sign_in_status {
519+
this.update(cx, |this, cx| {
520+
this.update_sign_in_status(status, cx);
521+
})
522+
.ok();
523+
}
524+
}
525+
})
526+
.detach();
527+
528+
server
529+
.on_notification::<WindowShowMessageRequest, _>({
530+
let this = this.clone();
531+
move |params, cx| {
532+
// TODO: Display the message in Zed's UI
533+
534+
// Log the message
535+
log::info!("Copilot {}: {}", params.type_.as_str(), params.message);
536+
}
537+
})
504538
.detach();
505539

506540
let configuration = lsp::DidChangeConfigurationParams {

0 commit comments

Comments
 (0)