diff options
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/mod.rs | 1 | ||||
| -rw-r--r-- | src/api/schema.rs | 2 | ||||
| -rw-r--r-- | src/api/schema/plugins.rs | 10 | ||||
| -rw-r--r-- | src/api/schema/tests.rs | 26 | ||||
| -rw-r--r-- | src/api/server.rs | 1 |
5 files changed, 37 insertions, 3 deletions
diff --git a/src/api/mod.rs b/src/api/mod.rs index b0d7caed..364d5fc8 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -64,6 +64,7 @@ pub(crate) fn request_changes_ui(request: &Request) -> bool { | Method::PaneClearAgentAuthority(_) | Method::PaneReleaseAgent(_) | Method::PaneClose(_) + | Method::PopupClose(_) | Method::PluginActionInvoke(_) | Method::PluginPaneOpen(_) | Method::PluginPaneFocus(_) diff --git a/src/api/schema.rs b/src/api/schema.rs index 4449b2d9..4f5df34f 100644 --- a/src/api/schema.rs +++ b/src/api/schema.rs @@ -191,6 +191,8 @@ pub enum Method { PaneReleaseAgent(PaneReleaseAgentParams), #[serde(rename = "pane.close")] PaneClose(PaneTarget), + #[serde(rename = "popup.close")] + PopupClose(EmptyParams), #[serde(rename = "events.subscribe")] EventsSubscribe(EventsSubscribeParams), #[serde(rename = "events.wait")] diff --git a/src/api/schema/plugins.rs b/src/api/schema/plugins.rs index 10e7d670..75b40f97 100644 --- a/src/api/schema/plugins.rs +++ b/src/api/schema/plugins.rs @@ -6,6 +6,7 @@ use super::common::AgentStatus; use super::common::SplitDirection; use super::panes::PaneInfo; use super::workspaces::WorkspaceWorktreeInfo; +use crate::popup_size::PopupSize; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)] pub struct PluginLinkParams { @@ -261,6 +262,10 @@ pub struct PluginManifestPane { pub platforms: Option<Vec<PluginPlatform>>, #[serde(default)] pub placement: PluginPanePlacement, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub width: Option<PopupSize>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub height: Option<PopupSize>, pub command: Vec<String>, } @@ -407,6 +412,10 @@ pub struct PluginPaneOpenParams { #[serde(default, skip_serializing_if = "Option::is_none")] pub placement: Option<PluginPanePlacement>, #[serde(default, skip_serializing_if = "Option::is_none")] + pub width: Option<PopupSize>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub height: Option<PopupSize>, + #[serde(default, skip_serializing_if = "Option::is_none")] pub workspace_id: Option<String>, #[serde(default, skip_serializing_if = "Option::is_none")] pub target_pane_id: Option<String>, @@ -427,6 +436,7 @@ pub struct PluginPaneOpenParams { pub enum PluginPanePlacement { #[default] Overlay, + Popup, Split, Tab, Zoomed, diff --git a/src/api/schema/tests.rs b/src/api/schema/tests.rs index adc7e61c..bc044ee9 100644 --- a/src/api/schema/tests.rs +++ b/src/api/schema/tests.rs @@ -814,6 +814,8 @@ fn plugin_link_list_unlink_round_trip() { description: None, platforms: None, placement: PluginPanePlacement::Overlay, + width: None, + height: None, command: vec!["bun".into(), "run".into(), "board.ts".into()], }], link_handlers: vec![PluginManifestLinkHandler { @@ -1152,10 +1154,12 @@ fn plugin_pane_open_request_round_trips() { method: Method::PluginPaneOpen(PluginPaneOpenParams { plugin_id: "example.board".into(), entrypoint: "board".into(), - placement: Some(PluginPanePlacement::Zoomed), + placement: Some(PluginPanePlacement::Popup), + width: Some(crate::popup_size::PopupSize::Cells(90)), + height: Some(crate::popup_size::PopupSize::Percent(80)), workspace_id: None, - target_pane_id: Some("1-1".into()), - direction: Some(SplitDirection::Right), + target_pane_id: None, + direction: None, cwd: Some("/tmp".into()), focus: true, env: [("HERDR_ROLE".to_string(), "board".to_string())].into(), @@ -1164,7 +1168,23 @@ fn plugin_pane_open_request_round_trips() { let json = serde_json::to_value(&request).unwrap(); assert_eq!(json["method"], "plugin.pane.open"); + assert_eq!(json["params"]["placement"], "popup"); + assert_eq!(json["params"]["width"], 90); + assert_eq!(json["params"]["height"], "80%"); assert_eq!(json["params"]["env"]["HERDR_ROLE"], "board"); let restored: Request = serde_json::from_value(json).unwrap(); assert_eq!(restored, request); } + +#[test] +fn popup_close_request_round_trips() { + let request = Request { + id: "popup-close".into(), + method: Method::PopupClose(EmptyParams::default()), + }; + + let json = serde_json::to_value(request).unwrap(); + + assert_eq!(json["method"], "popup.close"); + assert_eq!(json["params"], serde_json::json!({})); +} diff --git a/src/api/server.rs b/src/api/server.rs index aec7274d..c4c76703 100644 --- a/src/api/server.rs +++ b/src/api/server.rs @@ -406,6 +406,7 @@ fn api_method_name(method: &Method) -> &'static str { Method::PaneClearAgentAuthority(_) => "pane.clear_agent_authority", Method::PaneReleaseAgent(_) => "pane.release_agent", Method::PaneClose(_) => "pane.close", + Method::PopupClose(_) => "popup.close", Method::EventsSubscribe(_) => "events.subscribe", Method::EventsWait(_) => "events.wait", Method::PaneWaitForOutput(_) => "pane.wait_for_output", |
