TUI support for buffer experience (#29919)

This commit is contained in:
Eric Traut authored and GitHub committed 2026-06-24 19:50:50 -07:00
1 parent 3e51b46eba
commit 6801941cfe
18 files changed
+620 -3

No files matched your search

+31
View File
@@ -85,6 +85,37 @@ pub(crate) fn new_warning_event(message: String) -> PrefixedWrappedHistoryCell {
PrefixedWrappedHistoryCell::new(message.yellow(), "⚠ ".yellow(), " ")
}
#[derive(Debug)]
pub(crate) struct SafetyAccessBlockCell;
const SAFETY_ACCESS_BLOCK_TITLE: &str = "This content can't be shown";
const SAFETY_ACCESS_BLOCK_BODY: &str = "We've limited access to this content for safety reasons. This type of information may be used to benefit or to harm people.";
pub(crate) fn new_safety_access_block_event() -> SafetyAccessBlockCell {
SafetyAccessBlockCell
}
impl HistoryCell for SafetyAccessBlockCell {
fn display_lines(&self, width: u16) -> Vec<Line<'static>> {
let mut lines = vec![vec!["ⓘ ".cyan(), SAFETY_ACCESS_BLOCK_TITLE.bold()].into()];
let body = Line::from(vec![" ".into(), SAFETY_ACCESS_BLOCK_BODY.dim()]);
let wrap_width = width.saturating_sub(2).max(1) as usize;
let wrapped = adaptive_wrap_line(
&body,
RtOptions::new(wrap_width).subsequent_indent(" ".into()),
);
push_owned_lines(&wrapped, &mut lines);
lines
}
fn raw_lines(&self) -> Vec<Line<'static>> {
vec![
Line::from(SAFETY_ACCESS_BLOCK_TITLE),
Line::from(SAFETY_ACCESS_BLOCK_BODY),
]
}
}
const TRUSTED_ACCESS_FOR_CYBER_URL: &str = "https://chatgpt.com/cyber";
#[derive(Debug)]
@@ -0,0 +1,7 @@
---
source: tui/src/history_cell/tests.rs
expression: rendered
---
ⓘ This content can't be shown
We've limited access to this content for safety reasons. This type of
information may be used to benefit or to harm people.
+7
View File
@@ -699,6 +699,13 @@ fn cyber_policy_error_event_snapshot() {
insta::assert_snapshot!(rendered);
}
#[test]
fn safety_access_block_event_snapshot() {
let cell = new_safety_access_block_event();
let rendered = render_lines(&cell.display_lines(/*width*/ 80)).join("\n");
insta::assert_snapshot!(rendered);
}
#[test]
fn cyber_policy_error_event_narrow_snapshot() {
let cell = new_cyber_policy_error_event();