mirror of
https://github.com/openai/codex.git
synced 2026-11-18 23:02:23 +00:00
Expose plugin eligibility metadata in app-server summaries (#35837)
## What changed - Add nullable `disabledReason` and `eligiblePlanTypes` fields to v2 `PluginSummary` responses and generated schemas. - Preserve the remote catalog values across discovered, installed, and cached plugin summary paths while returning `null` for local plugins and older remote responses. - Treat unrecognized disabled reasons as `unknown` for forward compatibility. ## Testing - Cover protocol round trips, remote summary propagation, unknown disabled reasons, and app-server responses for admin-disabled and plan-ineligible plugins. GitOrigin-RevId: 657a7ea6f838a6ff8bd1769ebcca0f3432684437
This commit is contained in:
1 parent
c550cb3e01
commit
12b961d4c5
21 files changed
+472
-63
No files matched your search
@@ -150,6 +150,86 @@ fn installation_policy_source_is_preserved_across_remote_summary_paths() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn plan_eligibility_is_preserved_across_remote_summary_paths() {
|
||||
let mut directory_plugin = directory_plugin("plugin-gmail", "gmail");
|
||||
directory_plugin.installation_policy = PluginInstallPolicy::NotAvailable;
|
||||
directory_plugin.availability = PluginAvailability::DisabledByAdmin;
|
||||
directory_plugin.disabled_reason = Some(PluginDisabledReason::PlanNotEligible);
|
||||
directory_plugin.eligible_plan_types = Some(vec![
|
||||
"plus".to_string(),
|
||||
"pro".to_string(),
|
||||
"enterprise_cbp_automation".to_string(),
|
||||
]);
|
||||
let installed_plugin = RemotePluginInstalledItem {
|
||||
plugin: directory_plugin.clone(),
|
||||
enabled: false,
|
||||
disabled_skill_names: Vec::new(),
|
||||
};
|
||||
|
||||
let marketplace = build_remote_marketplace(
|
||||
REMOTE_GLOBAL_MARKETPLACE_NAME,
|
||||
REMOTE_GLOBAL_MARKETPLACE_DISPLAY_NAME,
|
||||
vec![directory_plugin],
|
||||
Vec::new(),
|
||||
/*include_installed_only*/ false,
|
||||
)
|
||||
.expect("marketplace should be valid")
|
||||
.expect("marketplace should not be empty");
|
||||
let expected = vec![(
|
||||
PluginAvailability::DisabledByAdmin,
|
||||
Some(PluginDisabledReason::PlanNotEligible),
|
||||
Some(vec![
|
||||
"plus".to_string(),
|
||||
"pro".to_string(),
|
||||
"enterprise_cbp_automation".to_string(),
|
||||
]),
|
||||
)];
|
||||
assert_eq!(
|
||||
marketplace
|
||||
.plugins
|
||||
.into_iter()
|
||||
.map(|plugin| (
|
||||
plugin.availability,
|
||||
plugin.disabled_reason,
|
||||
plugin.eligible_plan_types,
|
||||
))
|
||||
.collect::<Vec<_>>(),
|
||||
expected
|
||||
);
|
||||
|
||||
let installed_plugin = remote_installed_plugin_to_cache_entry(&installed_plugin)
|
||||
.expect("installed plugin should be valid");
|
||||
let marketplaces = group_remote_installed_plugins_by_marketplaces(
|
||||
&[installed_plugin],
|
||||
&[REMOTE_GLOBAL_MARKETPLACE_NAME],
|
||||
);
|
||||
assert_eq!(
|
||||
marketplaces
|
||||
.into_iter()
|
||||
.flat_map(|marketplace| marketplace.plugins)
|
||||
.map(|plugin| (
|
||||
plugin.availability,
|
||||
plugin.disabled_reason,
|
||||
plugin.eligible_plan_types,
|
||||
))
|
||||
.collect::<Vec<_>>(),
|
||||
expected
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_plugin_disabled_reason_preserves_remote_catalog_compatibility() {
|
||||
let plugin = directory_plugin("plugin-gmail", "gmail");
|
||||
let mut plugin_json = serde_json::to_value(plugin).expect("plugin should serialize");
|
||||
plugin_json["disabled_reason"] = serde_json::json!("future_disabled_reason");
|
||||
|
||||
let plugin: RemotePluginDirectoryItem =
|
||||
serde_json::from_value(plugin_json).expect("unknown reason should deserialize");
|
||||
|
||||
assert_eq!(plugin.disabled_reason, Some(PluginDisabledReason::Unknown));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn installation_interstitial_requirement_is_preserved_across_remote_summary_paths() {
|
||||
let mut directory_plugin = directory_plugin("plugin-linear", "linear");
|
||||
@@ -271,6 +351,8 @@ fn directory_plugin(id: &str, name: &str) -> RemotePluginDirectoryItem {
|
||||
must_show_installation_interstitial: None,
|
||||
authentication_policy: PluginAuthPolicy::OnUse,
|
||||
availability: PluginAvailability::Available,
|
||||
disabled_reason: None,
|
||||
eligible_plan_types: None,
|
||||
release: RemotePluginReleaseResponse {
|
||||
version: None,
|
||||
display_name: name.to_string(),
|
||||
|
||||
Reference in new issue
Block a user