Add a response target picker to /copy (#39997)

## What changed

- Open a picker for `/copy` with the whole response plus each fenced code block and blockquote from the latest response.
- Label code blocks by language, show content previews, and preserve source whitespace and nested quote Markdown when copying an individual target.
- Keep the picker from disturbing terminal scrollback or queued input, retain clipboard leases, and avoid writing copied content to the session log.

## Testing

- Add coverage for target extraction, picker navigation and cancellation, exact copied content, plan responses, queued input, scrollback preservation, clipboard failures, and session logging.

GitOrigin-RevId: 77a35bc99f4f45932d39914f9a709b30fe8cd7c2
This commit is contained in:
Benjamin Carlsson authored and copyberry committed 2026-08-21 19:23:26 +00:00
1 parent 950dd184a1
commit df6a54ee85
15 files changed
+766 -30

No files matched your search

+6 -2
View File
@@ -32,8 +32,10 @@ pub(super) struct TranscriptState {
pub(super) active_cell_revision: u64,
/// One bounded entry shared by layout and paint across unchanged active-cell frames.
pub(super) active_cell_layout: Cell<Option<ActiveCellLayoutCache>>,
/// Raw markdown of the most recently completed agent response.
/// Markdown of the most recently completed agent response for whole-response copying.
pub(super) last_agent_markdown: Option<String>,
/// Original source of that response, before display sanitization, for exact block copying.
pub(super) last_agent_source: Option<String>,
pub(super) last_completed_agent_message: Option<(String, String)>,
/// Raw markdown of the most recently completed proposed plan.
pub(super) latest_proposed_plan_markdown: Option<String>,
@@ -80,13 +82,15 @@ impl TranscriptState {
active_cell
}
pub(super) fn record_agent_markdown(&mut self, markdown: String) {
pub(super) fn record_agent_markdown(&mut self, markdown: String, source: String) {
self.last_agent_markdown = Some(markdown);
self.last_agent_source = Some(source);
self.saw_copy_source_this_turn = true;
}
pub(super) fn reset_copy_history(&mut self) {
self.last_agent_markdown = None;
self.last_agent_source = None;
self.saw_copy_source_this_turn = false;
}