mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Style spoken prompts and link workspace files in voice transcripts (#43676)
## What changed - Render spoken user prompts with a bold red chevron, preserving its color during live transcript animation. Trim leading whitespace for display while retaining the raw transcript text. - Underline and link file references such as `src/lib.rs:42` in spoken assistant transcripts using terminal hyperlinks. Preserve existing links and support Windows-style relative separators. - Restrict generated file links to existing files with allowed extensions inside the workspace, rejecting hidden paths, traversal, and symlink escapes. ## Testing Add rendering and transcript tests for the spoken marker, raw text preservation, file links, Unicode column offsets, and Windows-style paths, plus validation tests for rejected file destinations. GitOrigin-RevId: 5fa180aa606acdc579a916441520602cb2bf3655
This commit is contained in:
1 parent
4e93cf9b4e
commit
3caf9f9586
21 files changed
+461
-20
No files matched your search
@@ -1500,20 +1500,12 @@ impl ChatWidget {
|
||||
|
||||
fn realtime_transcript_history_cell(&self, role: &str, text: &str) -> Box<dyn HistoryCell> {
|
||||
if role == "user" {
|
||||
Box::new(history_cell::new_user_prompt(
|
||||
text.to_string(),
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
))
|
||||
Box::new(history_cell::new_spoken_user_prompt(text.to_string()))
|
||||
} else {
|
||||
Box::new(
|
||||
history_cell::AgentMarkdownCell::new_with_inline_visualizations(
|
||||
text.to_string(),
|
||||
&self.config.cwd,
|
||||
/*inline_visualization_context*/ None,
|
||||
),
|
||||
)
|
||||
Box::new(history_cell::AgentMarkdownCell::new_spoken(
|
||||
text.to_string(),
|
||||
&self.config.cwd,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -196,7 +196,7 @@ impl SplitFlapTranscriptCell {
|
||||
text
|
||||
} else {
|
||||
if grapheme == "›" {
|
||||
style = style.fg(Color::Cyan);
|
||||
style = style.fg(span.style.fg.unwrap_or(Color::Cyan));
|
||||
} else if grapheme == "•" {
|
||||
style = style.fg(Color::Magenta);
|
||||
}
|
||||
|
||||
@@ -726,3 +726,33 @@ async fn live_voice_split_flap_animates_without_changing_final_history() {
|
||||
.any(|line| { line.to_string().contains("gate 73") })
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn spoken_user_transcript_preserves_red_chevron_and_canonical_history() {
|
||||
let (mut chat, _sender, mut events, _ops) = make_chatwidget_manual_with_sender().await;
|
||||
activate_voice(&mut chat);
|
||||
chat.on_realtime_transcript_delta("user".to_string(), "hello".to_string());
|
||||
let marker = chat
|
||||
.realtime_conversation
|
||||
.live_transcript_cell
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.display_lines(/*width*/ 32)
|
||||
.into_iter()
|
||||
.flat_map(|line| line.spans)
|
||||
.find(|span| span.content == "›")
|
||||
.expect("genuine spoken user marker");
|
||||
assert_eq!(marker.style.fg, Some(ratatui::style::Color::Red));
|
||||
assert!(
|
||||
marker
|
||||
.style
|
||||
.add_modifier
|
||||
.contains(ratatui::style::Modifier::BOLD)
|
||||
);
|
||||
chat.on_realtime_transcript_done("user".to_string(), "hello".to_string());
|
||||
let Ok(AppEvent::InsertHistoryCell(cell)) = events.try_recv() else {
|
||||
panic!("completed voice transcript should retain its ordinary history cell");
|
||||
};
|
||||
assert!(cell.as_any().is::<crate::history_cell::UserHistoryCell>());
|
||||
assert_eq!(cell.raw_lines()[0].to_string(), "hello");
|
||||
}
|
||||
Reference in new issue
Block a user