(&self, session_id: &str, filename: &str)
| 2181 | } |
| 2182 | |
| 2183 | fn export_session_to_file(&self, session_id: &str, filename: &str) -> anyhow::Result<PathBuf> { |
| 2184 | let transcript = self.build_session_transcript(session_id).ok_or_else(|| { |
| 2185 | anyhow::anyhow!("No transcript available for session `{}`", session_id) |
| 2186 | })?; |
| 2187 | |
| 2188 | let mut path = PathBuf::from(filename.trim()); |
| 2189 | if path.as_os_str().is_empty() { |
| 2190 | anyhow::bail!("filename cannot be empty"); |
| 2191 | } |
| 2192 | if path.is_relative() { |
| 2193 | path = std::env::current_dir()?.join(path); |
| 2194 | } |
| 2195 | if let Some(parent) = path.parent() { |
| 2196 | if !parent.as_os_str().is_empty() { |
| 2197 | std::fs::create_dir_all(parent)?; |
| 2198 | } |
| 2199 | } |
| 2200 | std::fs::write(&path, transcript)?; |
| 2201 | Ok(path) |
| 2202 | } |
| 2203 | |
| 2204 | fn submit_prompt(&mut self) -> anyhow::Result<()> { |
| 2205 | let shell_mode = self.prompt.is_shell_mode(); |
no test coverage detected