copilot: Fix references to uninitialized CopilotAuth global (#47954)

Closes: #46593 #32635 #47924

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
Co-authored-by: Cole Miller <cole@zed.dev>

Release Notes:

- Fixed issues with signing into Copilot via the Settings UI

---------

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
Co-authored-by: Cole Miller <cole@zed.dev>
Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com>
Co-authored-by: Anthony Eid <anthony@zed.dev>
This commit is contained in:
authored and GitHub committed 2026-01-29 15:47:04 -05:00
1 parent 67cc03938f
commit 832f7e50d9
8 files changed
+178 -110

No files matched your search

+6 -7
View File
@@ -271,27 +271,26 @@ impl GlobalCopilotAuth {
fs: Arc<dyn Fs>,
node_runtime: NodeRuntime,
cx: &mut App,
) {
) -> GlobalCopilotAuth {
let auth =
GlobalCopilotAuth(cx.new(|cx| Copilot::new(None, server_id, fs, node_runtime, cx)));
cx.set_global(auth);
cx.set_global(auth.clone());
auth
}
pub fn try_global(cx: &mut App) -> Option<&GlobalCopilotAuth> {
cx.try_global()
}
pub fn get_or_init(cx: &mut App) -> Option<GlobalCopilotAuth> {
pub fn get_or_init(app_state: Arc<AppState>, cx: &mut App) -> GlobalCopilotAuth {
if let Some(copilot) = cx.try_global::<Self>() {
Some(copilot.clone())
copilot.clone()
} else {
let app_state = AppState::global(cx).upgrade()?;
Self::set_global(
app_state.languages.next_language_server_id(),
app_state.fs.clone(),
app_state.node_runtime.clone(),
cx,
);
cx.try_global::<Self>().cloned()
)
}
}
}