Render + write the export; never raises (export.tsx:67-82, ExportDialog.tsx:95-121 both wrap the write in a try/catch and report a failure message rather than throwing out of the command).
(
messages: Any,
fmt: ExportFormat,
filename: str,
cwd: str,
*,
preserve_markdown_extension: bool,
)
| 221 | |
| 222 | @staticmethod |
| 223 | def _write_export( |
| 224 | messages: Any, |
| 225 | fmt: ExportFormat, |
| 226 | filename: str, |
| 227 | cwd: str, |
| 228 | *, |
| 229 | preserve_markdown_extension: bool, |
| 230 | ) -> InteractiveOutcome: |
| 231 | """Render + write the export; never raises (export.tsx:67-82, |
| 232 | ExportDialog.tsx:95-121 both wrap the write in a try/catch and report a |
| 233 | failure message rather than throwing out of the command).""" |
| 234 | try: |
| 235 | content = render_messages_for_export(messages, format=fmt) |
| 236 | final_filename = ensure_export_filename_extension( |
| 237 | filename, |
| 238 | fmt, |
| 239 | preserve_markdown_extension=preserve_markdown_extension, |
| 240 | ) |
| 241 | filepath = resolve_export_filepath(cwd, final_filename) |
| 242 | with open(filepath, "w", encoding="utf-8") as fh: |
| 243 | fh.write(content) |
| 244 | return InteractiveOutcome( |
| 245 | message=f"Conversation exported to: {filepath}", display="system" |
| 246 | ) |
| 247 | except Exception as exc: # mirror TS catch-all (export.tsx:79) |
| 248 | return InteractiveOutcome( |
| 249 | message=f"Failed to export conversation: {exc}", display="system" |
| 250 | ) |
| 251 | |
| 252 | |
| 253 | EXPORT_COMMAND = ExportCommand( |
no test coverage detected