Allow /copy to copy status output and individual fields (#43055)

## Why

`/copy` only offered the last assistant response and its code blocks or quotes, leaving `/status` output unavailable in the copy picker.

## What changed

After `/status`, offer the whole status as plain text, the model, the full directory path, and the thread name and session ID when present. Preserve the displayed status fields across repeated copies and include refreshed rate limits in whole-status copies.

Return to assistant-response copying after a later user message, assistant response, or command other than `/copy`. Rename the picker to “Copy to clipboard”.

## Testing

Add snapshots and regression tests covering status text and field selection, missing fields, full directory paths, repeated copying, refreshed limits, and returning to response copying after subsequent turns and commands, including queued commands.

GitOrigin-RevId: 9424cdca9753c834971992ca29494161957b50c4
This commit is contained in:
Benjamin Carlsson
2026-09-05 16:43:40 +00:00
committed by copyberry
parent 89208f09f8
commit 52e73e3a54
12 changed files with 367 additions and 79 deletions
+10
View File
@@ -3,6 +3,7 @@
use super::HistoryCell;
use super::HistoryRenderMode;
use std::cell::Cell;
use std::sync::Arc;
/// Identifies the render state that determines an active cell's viewport height.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
@@ -25,6 +26,11 @@ pub(super) struct ActiveCellLayoutCache {
pub(super) rendered_height: Option<usize>,
}
pub(super) struct StatusCopySource {
pub(super) handle: crate::status::StatusHistoryHandle,
pub(super) fields: Vec<(String, Arc<str>)>,
}
#[derive(Default)]
pub(super) struct TranscriptState {
pub(super) active_cell: Option<Box<dyn HistoryCell>>,
@@ -36,6 +42,8 @@ pub(super) struct TranscriptState {
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>,
/// Latest `/status` card and fields, retained across copying until a later turn or command.
pub(super) last_status_copy_targets: Option<StatusCopySource>,
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>,
@@ -83,12 +91,14 @@ impl TranscriptState {
}
pub(super) fn record_agent_markdown(&mut self, markdown: String, source: String) {
self.last_status_copy_targets = None;
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_status_copy_targets = None;
self.last_agent_markdown = None;
self.last_agent_source = None;
self.saw_copy_source_this_turn = false;