mcp: Fix source property showing up as undefined in settings (#43417)
Follow up to #39021. <img width="576" height="141" alt="image" src="https://github.com/user-attachments/assets/c89885a4-e664-4614-9bb0-86442dff34ee" /> - Add migration to remove `source` tag because `ContextServerSettings` is now untagged - Fix typos in context server modal - PR seems to have removed the `test_action_namespaces` test, which I brought back in this PR Release Notes: - Fixed an issue where the `source` property of MCP settings would show up as unrecognised
This commit is contained in:
@@ -122,7 +122,7 @@ impl ContextServerConfiguration {
|
||||
cx: &AsyncApp,
|
||||
) -> Option<Self> {
|
||||
match settings {
|
||||
ContextServerSettings::Custom {
|
||||
ContextServerSettings::Stdio {
|
||||
enabled: _,
|
||||
command,
|
||||
} => Some(ContextServerConfiguration::Custom { command }),
|
||||
@@ -1003,7 +1003,7 @@ mod tests {
|
||||
),
|
||||
(
|
||||
server_2_id.0.clone(),
|
||||
settings::ContextServerSettingsContent::Custom {
|
||||
settings::ContextServerSettingsContent::Stdio {
|
||||
enabled: true,
|
||||
command: ContextServerCommand {
|
||||
path: "somebinary".into(),
|
||||
@@ -1044,7 +1044,7 @@ mod tests {
|
||||
),
|
||||
(
|
||||
server_2_id.0.clone(),
|
||||
settings::ContextServerSettingsContent::Custom {
|
||||
settings::ContextServerSettingsContent::Stdio {
|
||||
enabled: true,
|
||||
command: ContextServerCommand {
|
||||
path: "somebinary".into(),
|
||||
@@ -1127,7 +1127,7 @@ mod tests {
|
||||
json!({"code.rs": ""}),
|
||||
vec![(
|
||||
SERVER_1_ID.into(),
|
||||
ContextServerSettings::Custom {
|
||||
ContextServerSettings::Stdio {
|
||||
enabled: true,
|
||||
command: ContextServerCommand {
|
||||
path: "somebinary".into(),
|
||||
@@ -1180,7 +1180,7 @@ mod tests {
|
||||
set_context_server_configuration(
|
||||
vec![(
|
||||
server_1_id.0.clone(),
|
||||
settings::ContextServerSettingsContent::Custom {
|
||||
settings::ContextServerSettingsContent::Stdio {
|
||||
enabled: false,
|
||||
command: ContextServerCommand {
|
||||
path: "somebinary".into(),
|
||||
@@ -1209,7 +1209,7 @@ mod tests {
|
||||
set_context_server_configuration(
|
||||
vec![(
|
||||
server_1_id.0.clone(),
|
||||
settings::ContextServerSettingsContent::Custom {
|
||||
settings::ContextServerSettingsContent::Stdio {
|
||||
enabled: true,
|
||||
command: ContextServerCommand {
|
||||
path: "somebinary".into(),
|
||||
@@ -1328,7 +1328,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn dummy_server_settings() -> ContextServerSettings {
|
||||
ContextServerSettings::Custom {
|
||||
ContextServerSettings::Stdio {
|
||||
enabled: true,
|
||||
command: ContextServerCommand {
|
||||
path: "somebinary".into(),
|
||||
|
||||
@@ -117,7 +117,7 @@ pub struct GlobalLspSettings {
|
||||
#[derive(Deserialize, Serialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
|
||||
#[serde(tag = "source", rename_all = "snake_case")]
|
||||
pub enum ContextServerSettings {
|
||||
Custom {
|
||||
Stdio {
|
||||
/// Whether the context server is enabled.
|
||||
#[serde(default = "default_true")]
|
||||
enabled: bool,
|
||||
@@ -125,16 +125,6 @@ pub enum ContextServerSettings {
|
||||
#[serde(flatten)]
|
||||
command: ContextServerCommand,
|
||||
},
|
||||
Extension {
|
||||
/// Whether the context server is enabled.
|
||||
#[serde(default = "default_true")]
|
||||
enabled: bool,
|
||||
/// The settings for this context server specified by the extension.
|
||||
///
|
||||
/// Consult the documentation for the context server to see what settings
|
||||
/// are supported.
|
||||
settings: serde_json::Value,
|
||||
},
|
||||
Http {
|
||||
/// Whether the context server is enabled.
|
||||
#[serde(default = "default_true")]
|
||||
@@ -145,13 +135,23 @@ pub enum ContextServerSettings {
|
||||
#[serde(skip_serializing_if = "HashMap::is_empty", default)]
|
||||
headers: HashMap<String, String>,
|
||||
},
|
||||
Extension {
|
||||
/// Whether the context server is enabled.
|
||||
#[serde(default = "default_true")]
|
||||
enabled: bool,
|
||||
/// The settings for this context server specified by the extension.
|
||||
///
|
||||
/// Consult the documentation for the context server to see what settings
|
||||
/// are supported.
|
||||
settings: serde_json::Value,
|
||||
},
|
||||
}
|
||||
|
||||
impl From<settings::ContextServerSettingsContent> for ContextServerSettings {
|
||||
fn from(value: settings::ContextServerSettingsContent) -> Self {
|
||||
match value {
|
||||
settings::ContextServerSettingsContent::Custom { enabled, command } => {
|
||||
ContextServerSettings::Custom { enabled, command }
|
||||
settings::ContextServerSettingsContent::Stdio { enabled, command } => {
|
||||
ContextServerSettings::Stdio { enabled, command }
|
||||
}
|
||||
settings::ContextServerSettingsContent::Extension { enabled, settings } => {
|
||||
ContextServerSettings::Extension { enabled, settings }
|
||||
@@ -171,8 +171,8 @@ impl From<settings::ContextServerSettingsContent> for ContextServerSettings {
|
||||
impl Into<settings::ContextServerSettingsContent> for ContextServerSettings {
|
||||
fn into(self) -> settings::ContextServerSettingsContent {
|
||||
match self {
|
||||
ContextServerSettings::Custom { enabled, command } => {
|
||||
settings::ContextServerSettingsContent::Custom { enabled, command }
|
||||
ContextServerSettings::Stdio { enabled, command } => {
|
||||
settings::ContextServerSettingsContent::Stdio { enabled, command }
|
||||
}
|
||||
ContextServerSettings::Extension { enabled, settings } => {
|
||||
settings::ContextServerSettingsContent::Extension { enabled, settings }
|
||||
@@ -200,17 +200,17 @@ impl ContextServerSettings {
|
||||
|
||||
pub fn enabled(&self) -> bool {
|
||||
match self {
|
||||
ContextServerSettings::Custom { enabled, .. } => *enabled,
|
||||
ContextServerSettings::Extension { enabled, .. } => *enabled,
|
||||
ContextServerSettings::Stdio { enabled, .. } => *enabled,
|
||||
ContextServerSettings::Http { enabled, .. } => *enabled,
|
||||
ContextServerSettings::Extension { enabled, .. } => *enabled,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_enabled(&mut self, enabled: bool) {
|
||||
match self {
|
||||
ContextServerSettings::Custom { enabled: e, .. } => *e = enabled,
|
||||
ContextServerSettings::Extension { enabled: e, .. } => *e = enabled,
|
||||
ContextServerSettings::Stdio { enabled: e, .. } => *e = enabled,
|
||||
ContextServerSettings::Http { enabled: e, .. } => *e = enabled,
|
||||
ContextServerSettings::Extension { enabled: e, .. } => *e = enabled,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user