MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / build_session_transcript

Method build_session_transcript

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

Source from the content-addressed store, hash-verified

2147 }
2148
2149 fn build_session_transcript(&self, session_id: &str) -> Option<String> {
2150 let session_ctx = self.context.session.read();
2151 let session = session_ctx.sessions.get(session_id)?;
2152 let messages = session_ctx.messages.get(session_id)?;
2153
2154 let mut output = String::new();
2155 output.push_str(&format!("# {}\n\n", session.title));
2156 output.push_str(&format!("Session ID: `{}`\n", session.id));
2157 output.push_str(&format!("Created: {}\n", session.created_at.to_rfc3339()));
2158 output.push_str(&format!("Updated: {}\n\n", session.updated_at.to_rfc3339()));
2159
2160 if messages.is_empty() {
2161 output.push_str("_No messages_\n");
2162 return Some(output);
2163 }
2164
2165 for message in messages {
2166 let role = match message.role {
2167 MessageRole::User => "User",
2168 MessageRole::Assistant => "Assistant",
2169 MessageRole::System => "System",
2170 };
2171 output.push_str(&format!("## {}\n\n", role));
2172 if message.content.trim().is_empty() {
2173 output.push_str("_Empty message_\n\n");
2174 } else {
2175 output.push_str(&message.content);
2176 output.push_str("\n\n");
2177 }
2178 }
2179
2180 Some(output)
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(|| {

Callers 3

handle_dialog_keyMethod · 0.80
handle_copy_sessionMethod · 0.80

Calls 4

newFunction · 0.85
readMethod · 0.80
is_emptyMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected