From 1a4e94e57e181379e2ed42d63a49fbc56ed1dba4 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Mon, 29 Jun 2026 18:09:25 +0300 Subject: refactor: route tui mutations through runtime authority --- src/api/schema/panes.rs | 10 +++++++++ src/api/schema/tabs.rs | 6 +++++ src/api/schema/tests.rs | 52 ++++++++++++++++++++++++++++++++++++++++++++ src/api/schema/workspaces.rs | 6 +++++ 4 files changed, 74 insertions(+) (limited to 'src/api/schema') 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 @@ -126,6 +126,16 @@ pub struct LayoutApplyParams { pub root: LayoutNode, } +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct LayoutSetSplitRatioParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub tab_id: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub pane_id: Option, + pub path: Vec, + pub ratio: f32, +} + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct LayoutDescription { pub workspace_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 @@ -30,6 +30,12 @@ pub struct TabRenameParams { pub label: String, } +#[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, 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 @@ -702,6 +702,58 @@ fn layout_export_apply_round_trip() { assert_eq!(restored, response); } +#[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 { 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 @@ -22,6 +22,12 @@ pub struct WorkspaceRenameParams { pub label: String, } +#[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, -- cgit v1.2.3