(
state: State<'_, AppState>,
request: QuickAnalyzeRequest,
)
| 102 | |
| 103 | #[tauri::command] |
| 104 | pub async fn get_work_state_summary( |
| 105 | state: State<'_, AppState>, |
| 106 | request: QuickAnalyzeRequest, |
| 107 | ) -> Result<WorkStateSummaryResponse, String> { |
| 108 | let agent = StartchatFunctionAgent::new(state.ai_client_factory.clone()); |
| 109 | |
| 110 | let language = request.language.unwrap_or(Language::Chinese); |
| 111 | |
| 112 | let analysis = agent |
| 113 | .quick_analyze(Path::new(&request.repo_path), language) |
| 114 | .await |
| 115 | .map_err(|e| { |
| 116 | error!( |
| 117 | "Failed to get work state summary: repo_path={}, error={}", |
| 118 | request.repo_path, e |
| 119 | ); |
| 120 | e.to_string() |
| 121 | })?; |
| 122 | |
| 123 | let (unstaged_files, unpushed_commits, has_git_changes) = |
| 124 | if let Some(ref git) = analysis.current_state.git_state { |
| 125 | ( |
| 126 | git.unstaged_files + git.staged_files, |
| 127 | git.unpushed_commits, |
| 128 | git.unstaged_files > 0 || git.staged_files > 0 || git.unpushed_commits > 0, |
| 129 | ) |
| 130 | } else { |
| 131 | (0, 0, false) |
| 132 | }; |
| 133 | |
| 134 | Ok(WorkStateSummaryResponse { |
| 135 | greeting_title: analysis.greeting.title, |
| 136 | current_state_summary: analysis.current_state.summary, |
| 137 | has_git_changes, |
| 138 | unstaged_files, |
| 139 | unpushed_commits, |
| 140 | predicted_actions_count: analysis.predicted_actions.len(), |
| 141 | }) |
| 142 | } |
nothing calls this directly
no test coverage detected