MCPcopy Create free account
hub / github.com/GCWing/BitFun / compact_session

Function compact_session

src/apps/desktop/src/api/agentic_api.rs:877–922  ·  view source on GitHub ↗
(
    coordinator: State<'_, Arc<ConversationCoordinator>>,
    app_state: State<'_, AppState>,
    request: CompactSessionRequest,
)

Source from the content-addressed store, hash-verified

875
876#[tauri::command]
877pub async fn compact_session(
878 coordinator: State<'_, Arc<ConversationCoordinator>>,
879 app_state: State<'_, AppState>,
880 request: CompactSessionRequest,
881) -> Result<StartDialogTurnResponse, String> {
882 let session_id = request.session_id.trim();
883 if session_id.is_empty() {
884 return Err("session_id is required".to_string());
885 }
886
887 if coordinator
888 .get_session_manager()
889 .get_session(session_id)
890 .is_none()
891 {
892 let workspace_path = request
893 .workspace_path
894 .as_deref()
895 .map(str::trim)
896 .filter(|value| !value.is_empty())
897 .ok_or_else(|| {
898 "workspace_path is required when the session is not loaded".to_string()
899 })?;
900 let effective = desktop_effective_session_storage_path(
901 &app_state,
902 workspace_path,
903 request.remote_connection_id.as_deref(),
904 request.remote_ssh_host.as_deref(),
905 )
906 .await;
907 coordinator
908 .restore_session_from_storage_path(&effective, session_id)
909 .await
910 .map_err(|e| format!("Failed to restore session before compacting: {}", e))?;
911 }
912
913 coordinator
914 .compact_session_manually(session_id.to_string())
915 .await
916 .map_err(|e| format!("Failed to compact session: {}", e))?;
917
918 Ok(StartDialogTurnResponse {
919 success: true,
920 message: "Session compaction started".to_string(),
921 })
922}
923
924#[tauri::command]
925pub async fn activate_session_goal(

Callers

nothing calls this directly

Calls 7

trimMethod · 0.80
get_session_managerMethod · 0.80
is_emptyMethod · 0.45
get_sessionMethod · 0.45

Tested by

no test coverage detected