MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / export_session_to_file

Method export_session_to_file

crates/opencode-tui/src/app/app.rs:2183–2202  ·  view source on GitHub ↗
(&self, session_id: &str, filename: &str)

Source from the content-addressed store, hash-verified

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();

Callers 1

handle_dialog_keyMethod · 0.80

Calls 2

is_emptyMethod · 0.80

Tested by

no test coverage detected