mirror of
https://github.com/openai/codex.git
synced 2026-12-06 01:10:58 +00:00
## Why Rate limits and thread usage can arrive after `/status` is displayed. Updating a status card already in terminal scrollback required rewriting history and depended on where the card was rendered. ## What changed - Show the report in a scrollable modal with Overview, Configuration, and Session tabs. Apply rate limit and thread usage results to the open report without writing status output to the transcript or terminal scrollback. - Copy a selected field or the full report directly from the modal, and open usage settings from the same view. Remove status fields from the `/copy` picker. ## Testing Add coverage for overlapping refreshes, dismissal during account or thread changes, keyboard navigation and copying during an active turn, and scrolling in a narrow terminal. GitOrigin-RevId: 64961c4d013607e373d50a79182b74e3048c632f
104 lines
3.9 KiB
Rust
104 lines
3.9 KiB
Rust
//! Copy targets and bounded previews in the shared picker.
|
|
//!
|
|
//! Preview truncation never changes the source text or format sent to the clipboard.
|
|
|
|
use super::*;
|
|
use crate::clipboard_copy::CopyFormat;
|
|
use crate::text_formatting::truncate_text;
|
|
|
|
impl ChatWidget {
|
|
pub(super) fn show_copy_picker(&mut self) {
|
|
if self.local_settings.transcript_mode.is_owned() {
|
|
let guard = Arc::new(crate::copy_input_guard::CopyInputGuard(
|
|
self.app_event_tx.clone(),
|
|
));
|
|
self.input_queue.transcript_copy = Arc::downgrade(&guard);
|
|
self.app_event_tx
|
|
.send(AppEvent::SelectTranscriptCopy { guard });
|
|
return;
|
|
}
|
|
let mut choices = Vec::new();
|
|
if let Some(markdown) = self
|
|
.transcript
|
|
.last_agent_markdown
|
|
.as_deref()
|
|
.filter(|markdown| !markdown.is_empty())
|
|
{
|
|
choices.push((
|
|
"Whole response".to_string(),
|
|
Arc::<str>::from(markdown),
|
|
CopyFormat::Markdown,
|
|
));
|
|
let source = self
|
|
.transcript
|
|
.last_agent_source
|
|
.as_deref()
|
|
.unwrap_or(markdown);
|
|
choices.extend(
|
|
crate::markdown::extract_copy_targets(source)
|
|
.into_iter()
|
|
.filter_map(|target| match target {
|
|
crate::markdown::CopyTarget::Code { language, content } => Some((
|
|
language.map_or_else(
|
|
|| "Code block".to_string(),
|
|
|language| format!("{language} code"),
|
|
),
|
|
content,
|
|
CopyFormat::PlainText,
|
|
)),
|
|
crate::markdown::CopyTarget::Quote(content) => {
|
|
let content: String = content
|
|
.split_inclusive('\n')
|
|
.map(|line| {
|
|
crate::git_action_directives::strip_line_directives(line).0
|
|
})
|
|
.collect();
|
|
(!content.trim().is_empty()).then(|| {
|
|
(
|
|
"Blockquote".to_string(),
|
|
Arc::from(content),
|
|
CopyFormat::PlainText,
|
|
)
|
|
})
|
|
}
|
|
}),
|
|
);
|
|
}
|
|
if choices.is_empty() {
|
|
self.prepare_last_response_copy();
|
|
return;
|
|
}
|
|
|
|
let items = choices
|
|
.into_iter()
|
|
.map(|(label, text, format)| {
|
|
let description = text
|
|
.lines()
|
|
.find(|line| !line.trim().is_empty())
|
|
.map(|line| truncate_text(line.trim(), /*max_graphemes*/ 72));
|
|
SelectionItem {
|
|
name: label.clone(),
|
|
description,
|
|
actions: vec![Box::new(move |tx| {
|
|
tx.send(AppEvent::CopySelection {
|
|
text: Arc::clone(&text),
|
|
label: label.clone(),
|
|
format: format.clone(),
|
|
feedback: None,
|
|
});
|
|
})],
|
|
dismiss_on_select: true,
|
|
..Default::default()
|
|
}
|
|
})
|
|
.collect();
|
|
|
|
self.show_selection_view(SelectionViewParams {
|
|
title: Some("Copy to clipboard".into()),
|
|
items,
|
|
..SelectionViewParams::picker()
|
|
});
|
|
self.defer_input_until_settings_applied();
|
|
}
|
|
}
|