copilot: Allow enterprise to sign in and use copilot (#32296)
This addresses: https://github.com/zed-industries/zed/pull/32248#issuecomment-2952060834. This PR address two main things one allowing enterprise users to use copilot chat and completion while also introducing the new way to handle copilot url specific their subscription. Simplifying the UX around the github copilot and removes the burden of users figuring out what url to use for their subscription. - [x] Pass enterprise_uri to copilot lsp so that it can redirect users to their enterprise server. Ref: https://github.com/github/copilot-language-server-release#configuration-management - [x] Remove the old ui and config language_models.copilot which allowed users to specify their copilot_chat specific endpoint. We now derive that automatically using token endpoint for copilot so that we can send the requests to specific copilot endpoint for depending upon the url returned by copilot server. - [x] Tested this for checking the both enterprise and non-enterprise flow work. Thanks to @theherk for the help to debug and test it. - [ ] Udpdate the zed.dev/docs to refelect how to setup enterprise copilot. What this doesn't do at the moment: * Currently zed doesn't allow to have two seperate accounts as the token used in chat is same as the one generated by lsp. After this changes also this behaviour remains same and users can't have both enterprise and personal copilot installed. P.S: Might need to do some bit of code cleanup and other things but overall I felt this PR was ready for atleast first pass of review to gather feedback around the implementation and code itself. Release Notes: - Add enterprise support for GitHub copilot --------- Signed-off-by: Umesh Yadav <git@umesh.dev>
This commit is contained in:
parent
c4355d2905
commit
b13144eb1f
8 changed files with 214 additions and 283 deletions
|
@ -288,6 +288,8 @@ pub struct CopilotSettings {
|
|||
pub proxy: Option<String>,
|
||||
/// Disable certificate verification for proxy (not recommended).
|
||||
pub proxy_no_verify: Option<bool>,
|
||||
/// Enterprise URI for Copilot.
|
||||
pub enterprise_uri: Option<String>,
|
||||
}
|
||||
|
||||
/// The settings for all languages.
|
||||
|
@ -607,6 +609,11 @@ pub struct CopilotSettingsContent {
|
|||
/// Default: false
|
||||
#[serde(default)]
|
||||
pub proxy_no_verify: Option<bool>,
|
||||
/// Enterprise URI for Copilot.
|
||||
///
|
||||
/// Default: none
|
||||
#[serde(default)]
|
||||
pub enterprise_uri: Option<String>,
|
||||
}
|
||||
|
||||
/// The settings for enabling/disabling features.
|
||||
|
@ -1228,10 +1235,10 @@ impl settings::Settings for AllLanguageSettings {
|
|||
let mut copilot_settings = default_value
|
||||
.edit_predictions
|
||||
.as_ref()
|
||||
.map(|settings| settings.copilot.clone())
|
||||
.map(|copilot| CopilotSettings {
|
||||
proxy: copilot.proxy,
|
||||
proxy_no_verify: copilot.proxy_no_verify,
|
||||
.map(|settings| CopilotSettings {
|
||||
proxy: settings.copilot.proxy.clone(),
|
||||
proxy_no_verify: settings.copilot.proxy_no_verify,
|
||||
enterprise_uri: settings.copilot.enterprise_uri.clone(),
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
|
@ -1287,6 +1294,14 @@ impl settings::Settings for AllLanguageSettings {
|
|||
copilot_settings.proxy_no_verify = Some(proxy_no_verify);
|
||||
}
|
||||
|
||||
if let Some(enterprise_uri) = user_settings
|
||||
.edit_predictions
|
||||
.as_ref()
|
||||
.and_then(|settings| settings.copilot.enterprise_uri.clone())
|
||||
{
|
||||
copilot_settings.enterprise_uri = Some(enterprise_uri);
|
||||
}
|
||||
|
||||
// A user's global settings override the default global settings and
|
||||
// all default language-specific settings.
|
||||
merge_settings(&mut defaults, &user_settings.defaults);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue