agentmux_srv/server/service/
workspace.rs1use crate::backend::service::{WebCallType, WebReturnType};
18use crate::backend::wcore;
19
20use super::super::AppState;
21use super::tab_lifecycle::{
22 handle_close_tab, handle_create_tab, handle_reorder_tab, handle_set_active_tab,
23 handle_update_tab_ids,
24};
25use super::tab_move::{
26 handle_move_block_to_tab, handle_move_tab_to_workspace, handle_promote_block_to_tab,
27 handle_restore_torn_off_tab,
28};
29use super::pin::{handle_pin_block_to_window, handle_unpin_block_from_window};
30use super::tear_off::{handle_redock_floating_pane, handle_tear_off_block, handle_tear_off_tab};
31use super::workspace_lifecycle::{
32 handle_create_workspace, handle_delete_workspace, handle_get_workspace,
33 handle_update_workspace,
34};
35
36pub(super) async fn handle_workspace_service(state: &AppState, call: &WebCallType) -> WebReturnType {
37 let store = &state.mstore;
38 match call.method.as_str() {
60 "CreateWorkspace" => handle_create_workspace(state, call).await,
61 "GetWorkspace" => handle_get_workspace(state, call).await,
62 "DeleteWorkspace" => handle_delete_workspace(state, call).await,
63 "ListWorkspaces" => match wcore::list_workspaces(store) {
64 Ok(list) => WebReturnType::success(serde_json::to_value(&list).unwrap_or_default()),
65 Err(e) => WebReturnType::error(e.to_string()),
66 },
67 "CreateTab" => handle_create_tab(state, call).await,
68 "SetActiveTab" => handle_set_active_tab(state, call).await,
69 "CloseTab" => handle_close_tab(state, call).await,
70 "UpdateWorkspace" => handle_update_workspace(state, call).await,
71 "UpdateTabIds" => handle_update_tab_ids(state, call).await,
72 "MoveBlockToTab" => handle_move_block_to_tab(state, call).await,
73 "PinBlockToWindow" => handle_pin_block_to_window(state, call).await,
74 "UnpinBlockFromWindow" => handle_unpin_block_from_window(state, call).await,
75 "PromoteBlockToTab" => handle_promote_block_to_tab(state, call).await,
76 "ReorderTab" => handle_reorder_tab(state, call).await,
77 "MoveTabToWorkspace" => handle_move_tab_to_workspace(state, call).await,
78 "RestoreTornOffTab" => handle_restore_torn_off_tab(state, call).await,
79 "TearOffBlock" => handle_tear_off_block(state, call).await,
80 "RedockFloatingPane" => handle_redock_floating_pane(state, call).await,
81 "TearOffTab" => handle_tear_off_tab(state, call).await,
82 "Flush" => super::user_workspace::handle_flush(state, call).await,
85 "RenameUserWorkspace" => super::user_workspace::handle_rename(state, call),
86 "ListUserWorkspaces" => super::user_workspace_switch::handle_list(state, call),
87 "CreateUserWorkspace" => super::user_workspace_switch::handle_create(state, call).await,
88 "SwitchUserWorkspace" => super::user_workspace_switch::handle_switch(state, call).await,
89 "DeleteUserWorkspace" => super::user_workspace_switch::handle_delete(state, call).await,
90 "UserWorkspaceAgents" => super::user_workspace_switch::handle_agents(state, call),
91 "ExportUserWorkspace" => super::user_workspace_files::handle_export(state, call).await,
92 "PreviewImport" => super::user_workspace_files::handle_preview(state, call).await,
93 "ImportUserWorkspace" => super::user_workspace_files::handle_import(state, call).await,
94 _ => WebReturnType::error(format!("unknown workspace method: {}", call.method)),
95 }
96}