Add Markdown conversation export to the TUI (#37358)

## What changed

- Add `/export` with clipboard and file destinations, including a default filename prompt and support for an explicit path argument.
- Export the complete conversation history as structured Markdown, preserving user and assistant messages, plans, reasoning, activity, image labels, file changes, and MCP tool details while honoring reasoning visibility.
- Fall back to legacy history loading when pagination is unavailable, and use the visible transcript for ephemeral sessions.
- Resolve relative and home-relative paths without overwriting an existing file, and report export or copy results in the conversation.

## Testing

- Cover Markdown rendering, hidden review prompts, activity details, complete paginated and legacy history loading, destination prompts, status messages, path resolution, and overwrite protection.

GitOrigin-RevId: c2815fc2430d7a555da75d7038cc1ac08157b82e
This commit is contained in:
Eric Traut authored and copyberry committed 2026-08-07 02:45:35 +00:00
1 parent 4d7e3e90d9
commit 2801d12661
19 files changed
+795 -3

No files matched your search

@@ -1757,6 +1757,40 @@ async fn slash_copy_reports_when_no_agent_response_exists() {
);
}
#[tokio::test]
async fn slash_export_opens_destination_picker() {
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
chat.thread_id = Some(
ThreadId::from_string("00000000-0000-0000-0000-000000000123").expect("valid thread ID"),
);
handle_turn_started(&mut chat, "turn-1");
queue_composer_text_with_tab(&mut chat, "/export");
complete_turn_with_message(&mut chat, "turn-1", /*message*/ None);
let popup = render_bottom_popup(&chat, /*width*/ 80);
assert_chatwidget_snapshot!("slash_export_destination_picker", popup);
chat.show_transcript_export_file_prompt();
let popup = render_bottom_popup(&chat, /*width*/ 100);
assert_chatwidget_snapshot!("slash_export_filename_prompt", popup);
let statuses = "Saved conversation to conversation.md\nCopied conversation to clipboard";
for message in statuses.lines() {
chat.add_info_message(message.into(), /*hint*/ None);
}
chat.add_error_message("Copy failed: clipboard unavailable".to_string());
chat.add_error_message("Export failed: missing parent".to_string());
let cells = drain_insert_history(&mut rx);
assert_chatwidget_snapshot!(
"slash_export_completion_message",
cells
.iter()
.map(|cell| lines_to_single_string(cell).trim().to_string())
.collect::<Vec<_>>()
.join("\n"),
);
}
#[tokio::test]
async fn ctrl_o_copy_reports_when_no_agent_response_exists() {
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;