aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/mod.rs4
-rw-r--r--src/api/schema.rs8
-rw-r--r--src/api/schema/panes.rs10
-rw-r--r--src/api/schema/tabs.rs6
-rw-r--r--src/api/schema/tests.rs52
-rw-r--r--src/api/schema/workspaces.rs6
-rw-r--r--src/api/server.rs4
7 files changed, 90 insertions, 0 deletions
diff --git a/src/api/mod.rs b/src/api/mod.rs
index 62247aa7..b285eb3d 100644
--- a/src/api/mod.rs
+++ b/src/api/mod.rs
@@ -27,6 +27,7 @@ pub(crate) fn request_changes_ui(request: &Request) -> bool {
| Method::WorkspaceCreate(_)
| Method::WorkspaceFocus(_)
| Method::WorkspaceRename(_)
+ | Method::WorkspaceMove(_)
| Method::WorkspaceClose(_)
| Method::WorktreeCreate(_)
| Method::WorktreeOpen(_)
@@ -34,8 +35,10 @@ pub(crate) fn request_changes_ui(request: &Request) -> bool {
| Method::TabCreate(_)
| Method::TabFocus(_)
| Method::TabRename(_)
+ | Method::TabMove(_)
| Method::TabClose(_)
| Method::LayoutApply(_)
+ | Method::LayoutSetSplitRatio(_)
| Method::AgentRename(_)
| Method::AgentFocus(_)
| Method::AgentStart(_)
@@ -45,6 +48,7 @@ pub(crate) fn request_changes_ui(request: &Request) -> bool {
| Method::PaneZoom(_)
| Method::PaneFocusDirection(_)
| Method::PaneResize(_)
+ | Method::PaneFocus(_)
| Method::PaneRename(_)
| Method::PaneReportAgent(_)
| Method::PaneReportAgentSession(_)
diff --git a/src/api/schema.rs b/src/api/schema.rs
index b2d6f62e..c3349c04 100644
--- a/src/api/schema.rs
+++ b/src/api/schema.rs
@@ -69,6 +69,8 @@ pub enum Method {
WorkspaceFocus(WorkspaceTarget),
#[serde(rename = "workspace.rename")]
WorkspaceRename(WorkspaceRenameParams),
+ #[serde(rename = "workspace.move")]
+ WorkspaceMove(WorkspaceMoveParams),
#[serde(rename = "workspace.close")]
WorkspaceClose(WorkspaceTarget),
#[serde(rename = "worktree.list")]
@@ -89,6 +91,8 @@ pub enum Method {
TabFocus(TabTarget),
#[serde(rename = "tab.rename")]
TabRename(TabRenameParams),
+ #[serde(rename = "tab.move")]
+ TabMove(TabMoveParams),
#[serde(rename = "tab.close")]
TabClose(TabTarget),
#[serde(rename = "agent.list")]
@@ -123,6 +127,8 @@ pub enum Method {
LayoutExport(LayoutExportParams),
#[serde(rename = "layout.apply")]
LayoutApply(LayoutApplyParams),
+ #[serde(rename = "layout.set_split_ratio")]
+ LayoutSetSplitRatio(LayoutSetSplitRatioParams),
#[serde(rename = "pane.neighbor")]
PaneNeighbor(PaneNeighborParams),
#[serde(rename = "pane.edges")]
@@ -137,6 +143,8 @@ pub enum Method {
PaneCurrent(PaneCurrentParams),
#[serde(rename = "pane.get")]
PaneGet(PaneTarget),
+ #[serde(rename = "pane.focus")]
+ PaneFocus(PaneTarget),
#[serde(rename = "pane.rename")]
PaneRename(PaneRenameParams),
#[serde(rename = "pane.send_text")]
diff --git a/src/api/schema/panes.rs b/src/api/schema/panes.rs
index 9bd8103d..55241131 100644
--- a/src/api/schema/panes.rs
+++ b/src/api/schema/panes.rs
@@ -127,6 +127,16 @@ pub struct LayoutApplyParams {
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+pub struct LayoutSetSplitRatioParams {
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub tab_id: Option<String>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub pane_id: Option<String>,
+ pub path: Vec<bool>,
+ pub ratio: f32,
+}
+
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct LayoutDescription {
pub workspace_id: String,
pub tab_id: String,
diff --git a/src/api/schema/tabs.rs b/src/api/schema/tabs.rs
index 4be94c3b..41af5c6b 100644
--- a/src/api/schema/tabs.rs
+++ b/src/api/schema/tabs.rs
@@ -31,6 +31,12 @@ pub struct TabRenameParams {
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
+pub struct TabMoveParams {
+ pub tab_id: String,
+ pub insert_index: usize,
+}
+
+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct TabInfo {
pub tab_id: String,
pub workspace_id: String,
diff --git a/src/api/schema/tests.rs b/src/api/schema/tests.rs
index c8c8adbb..d9ebe30b 100644
--- a/src/api/schema/tests.rs
+++ b/src/api/schema/tests.rs
@@ -703,6 +703,58 @@ fn layout_export_apply_round_trip() {
}
#[test]
+fn authority_mutation_requests_round_trip() {
+ let workspace_move = Request {
+ id: "move_ws".into(),
+ method: Method::WorkspaceMove(WorkspaceMoveParams {
+ workspace_id: "w1".into(),
+ insert_index: 2,
+ }),
+ };
+ let json = serde_json::to_value(&workspace_move).unwrap();
+ assert_eq!(json["method"], "workspace.move");
+ let restored: Request = serde_json::from_value(json).unwrap();
+ assert_eq!(restored, workspace_move);
+
+ let tab_move = Request {
+ id: "move_tab".into(),
+ method: Method::TabMove(TabMoveParams {
+ tab_id: "w1:1".into(),
+ insert_index: 1,
+ }),
+ };
+ let json = serde_json::to_value(&tab_move).unwrap();
+ assert_eq!(json["method"], "tab.move");
+ let restored: Request = serde_json::from_value(json).unwrap();
+ assert_eq!(restored, tab_move);
+
+ let pane_focus = Request {
+ id: "focus_pane".into(),
+ method: Method::PaneFocus(PaneTarget {
+ pane_id: "w1:1".into(),
+ }),
+ };
+ let json = serde_json::to_value(&pane_focus).unwrap();
+ assert_eq!(json["method"], "pane.focus");
+ let restored: Request = serde_json::from_value(json).unwrap();
+ assert_eq!(restored, pane_focus);
+
+ let split_ratio = Request {
+ id: "set_ratio".into(),
+ method: Method::LayoutSetSplitRatio(LayoutSetSplitRatioParams {
+ tab_id: Some("w1:1".into()),
+ pane_id: None,
+ path: vec![false, true],
+ ratio: 0.6,
+ }),
+ };
+ let json = serde_json::to_value(&split_ratio).unwrap();
+ assert_eq!(json["method"], "layout.set_split_ratio");
+ let restored: Request = serde_json::from_value(json).unwrap();
+ assert_eq!(restored, split_ratio);
+}
+
+#[test]
fn create_response_round_trips_with_root_pane() {
let response = SuccessResponse {
id: "req_2".into(),
diff --git a/src/api/schema/workspaces.rs b/src/api/schema/workspaces.rs
index d15cf09b..be5ef0b4 100644
--- a/src/api/schema/workspaces.rs
+++ b/src/api/schema/workspaces.rs
@@ -23,6 +23,12 @@ pub struct WorkspaceRenameParams {
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
+pub struct WorkspaceMoveParams {
+ pub workspace_id: String,
+ pub insert_index: usize,
+}
+
+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct WorkspaceInfo {
pub workspace_id: String,
pub number: usize,
diff --git a/src/api/server.rs b/src/api/server.rs
index e9e2b01b..039ede12 100644
--- a/src/api/server.rs
+++ b/src/api/server.rs
@@ -286,6 +286,7 @@ fn api_method_name(method: &Method) -> &'static str {
Method::WorkspaceGet(_) => "workspace.get",
Method::WorkspaceFocus(_) => "workspace.focus",
Method::WorkspaceRename(_) => "workspace.rename",
+ Method::WorkspaceMove(_) => "workspace.move",
Method::WorkspaceClose(_) => "workspace.close",
Method::WorktreeList(_) => "worktree.list",
Method::WorktreeCreate(_) => "worktree.create",
@@ -296,6 +297,7 @@ fn api_method_name(method: &Method) -> &'static str {
Method::TabGet(_) => "tab.get",
Method::TabFocus(_) => "tab.focus",
Method::TabRename(_) => "tab.rename",
+ Method::TabMove(_) => "tab.move",
Method::TabClose(_) => "tab.close",
Method::AgentList(_) => "agent.list",
Method::AgentGet(_) => "agent.get",
@@ -313,6 +315,7 @@ fn api_method_name(method: &Method) -> &'static str {
Method::PaneProcessInfo(_) => "pane.process_info",
Method::LayoutExport(_) => "layout.export",
Method::LayoutApply(_) => "layout.apply",
+ Method::LayoutSetSplitRatio(_) => "layout.set_split_ratio",
Method::PaneNeighbor(_) => "pane.neighbor",
Method::PaneEdges(_) => "pane.edges",
Method::PaneFocusDirection(_) => "pane.focus_direction",
@@ -320,6 +323,7 @@ fn api_method_name(method: &Method) -> &'static str {
Method::PaneList(_) => "pane.list",
Method::PaneCurrent(_) => "pane.current",
Method::PaneGet(_) => "pane.get",
+ Method::PaneFocus(_) => "pane.focus",
Method::PaneRename(_) => "pane.rename",
Method::PaneSendText(_) => "pane.send_text",
Method::PaneSendKeys(_) => "pane.send_keys",