(
coordinator: State<'_, Arc<ConversationCoordinator>>,
app_state: State<'_, AppState>,
request: UpdateSessionTitleRequest,
)
| 731 | |
| 732 | #[tauri::command] |
| 733 | pub async fn update_session_title( |
| 734 | coordinator: State<'_, Arc<ConversationCoordinator>>, |
| 735 | app_state: State<'_, AppState>, |
| 736 | request: UpdateSessionTitleRequest, |
| 737 | ) -> Result<String, String> { |
| 738 | let session_id = request.session_id.trim(); |
| 739 | if session_id.is_empty() { |
| 740 | return Err("session_id is required".to_string()); |
| 741 | } |
| 742 | |
| 743 | if coordinator |
| 744 | .get_session_manager() |
| 745 | .get_session(session_id) |
| 746 | .is_none() |
| 747 | { |
| 748 | let workspace_path = request |
| 749 | .workspace_path |
| 750 | .as_deref() |
| 751 | .map(str::trim) |
| 752 | .filter(|value| !value.is_empty()) |
| 753 | .ok_or_else(|| { |
| 754 | "workspace_path is required when the session is not loaded".to_string() |
| 755 | })?; |
| 756 | |
| 757 | let effective = desktop_effective_session_storage_path( |
| 758 | &app_state, |
| 759 | workspace_path, |
| 760 | request.remote_connection_id.as_deref(), |
| 761 | request.remote_ssh_host.as_deref(), |
| 762 | ) |
| 763 | .await; |
| 764 | |
| 765 | coordinator |
| 766 | .restore_session_from_storage_path(&effective, session_id) |
| 767 | .await |
| 768 | .map_err(|e| format!("Failed to restore session before renaming: {}", e))?; |
| 769 | } |
| 770 | |
| 771 | coordinator |
| 772 | .update_session_title(session_id, &request.title) |
| 773 | .await |
| 774 | .map_err(|e| format!("Failed to update session title: {}", e)) |
| 775 | } |
| 776 | |
| 777 | /// Load the session into the coordinator process when it exists on disk but is not in memory. |
| 778 | /// Uses the same remote→local session path mapping as `restore_session`. |
nothing calls this directly
no test coverage detected