@@ -2,7 +2,9 @@ use super::*;
22use crate :: history_cell:: AgentMarkdownCell ;
33use crate :: history_cell:: HistoryCell ;
44use crate :: history_cell:: PlainHistoryCell ;
5+ use crate :: history_cell:: ReasoningSummaryCell ;
56use crate :: history_cell:: UserHistoryCell ;
7+ use crate :: history_cell:: new_proposed_plan;
68use crate :: history_cell:: raw_lines_from_source;
79use std:: path:: Path ;
810use std:: path:: PathBuf ;
@@ -14,8 +16,10 @@ const SECTION_MARKER_SUFFIX: &str = "-->";
1416#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
1517enum ImportSectionKind {
1618 User ,
17- Codex ,
18- Event ,
19+ Assistant ,
20+ Plan ,
21+ Reasoning ,
22+ Activity ,
1923}
2024
2125#[ derive( Debug ) ]
@@ -115,16 +119,30 @@ fn imported_section_cell(section: ImportSection, cwd: &Path) -> Arc<dyn HistoryC
115119 local_image_paths : Vec :: new ( ) ,
116120 remote_image_urls : Vec :: new ( ) ,
117121 } ) ,
118- ImportSectionKind :: Codex => Arc :: new ( AgentMarkdownCell :: new ( section. body , cwd) ) ,
119- ImportSectionKind :: Event => {
122+ ImportSectionKind :: Assistant => Arc :: new (
123+ AgentMarkdownCell :: new_with_inline_visualizations ( section. body , cwd, None ) ,
124+ ) ,
125+ ImportSectionKind :: Plan => Arc :: new ( new_proposed_plan ( section. body , cwd) ) ,
126+ ImportSectionKind :: Reasoning => Arc :: new ( ReasoningSummaryCell :: new (
127+ "Reasoning" . to_string ( ) ,
128+ section. body ,
129+ cwd,
130+ /*transcript_only*/ false ,
131+ ) ) ,
132+ ImportSectionKind :: Activity => {
120133 Arc :: new ( PlainHistoryCell :: new ( raw_lines_from_source ( & section. body ) ) )
121134 }
122135 }
123136}
124137
125138fn parse_exported_transcript ( markdown : & str ) -> Result < Vec < ImportSection > , String > {
126139 let body = markdown. strip_prefix ( '\u{feff}' ) . unwrap_or ( markdown) ;
127- let Some ( after_header) = body. strip_prefix ( super :: transcript_export:: EXPORT_HEADER ) else {
140+ let Some ( after_header) = [
141+ "# Codex conversation" ,
142+ super :: transcript_export:: EXPORT_HEADER ,
143+ ]
144+ . iter ( )
145+ . find_map ( |header| body. strip_prefix ( header) ) else {
128146 return Err ( "file is not a Codex chat export" . to_string ( ) ) ;
129147 } ;
130148
@@ -231,8 +249,10 @@ fn section_kind_from_heading(line: &str) -> Option<ImportSectionKind> {
231249fn section_kind_from_name ( name : & str ) -> Option < ImportSectionKind > {
232250 match name {
233251 "User" => Some ( ImportSectionKind :: User ) ,
234- "Codex" => Some ( ImportSectionKind :: Codex ) ,
235- "Event" => Some ( ImportSectionKind :: Event ) ,
252+ "Assistant" | "Codex" => Some ( ImportSectionKind :: Assistant ) ,
253+ "Plan" => Some ( ImportSectionKind :: Plan ) ,
254+ "Reasoning" => Some ( ImportSectionKind :: Reasoning ) ,
255+ "Activity" | "Event" => Some ( ImportSectionKind :: Activity ) ,
236256 _ => None ,
237257 }
238258}
0 commit comments