feat: deprecation warning (#5825)

<img width="955" height="311" alt="Screenshot 2025-10-28 at 14 26 25"
src="https://github.com/user-attachments/assets/99729b3d-3bc9-4503-aab3-8dc919220ab4"
/>
This commit is contained in:
jif-oai
2025-10-29 12:29:28 +00:00
committed by GitHub
parent fa92cd92fa
commit 060637b4d4
12 changed files with 195 additions and 14 deletions

View File

@@ -1005,6 +1005,38 @@ pub(crate) fn new_warning_event(message: String) -> PlainHistoryCell {
}
}
#[derive(Debug)]
pub(crate) struct DeprecationNoticeCell {
summary: String,
details: Option<String>,
}
pub(crate) fn new_deprecation_notice(
summary: String,
details: Option<String>,
) -> DeprecationNoticeCell {
DeprecationNoticeCell { summary, details }
}
impl HistoryCell for DeprecationNoticeCell {
fn display_lines(&self, width: u16) -> Vec<Line<'static>> {
let mut lines: Vec<Line<'static>> = Vec::new();
lines.push(vec!["".red().bold(), self.summary.clone().red()].into());
let wrap_width = width.saturating_sub(4).max(1) as usize;
if let Some(details) = &self.details {
let line = textwrap::wrap(details, wrap_width)
.into_iter()
.map(|s| s.to_string().dim().into())
.collect::<Vec<_>>();
lines.extend(line);
}
lines
}
}
/// Render a summary of configured MCP servers from the current `Config`.
pub(crate) fn empty_mcp_output() -> PlainHistoryCell {
let lines: Vec<Line<'static>> = vec![
@@ -2259,4 +2291,21 @@ mod tests {
let rendered_transcript = render_transcript(cell.as_ref());
assert_eq!(rendered_transcript, vec!["• We should fix the bug next."]);
}
#[test]
fn deprecation_notice_renders_summary_with_details() {
let cell = new_deprecation_notice(
"Feature flag `foo`".to_string(),
Some("Use flag `bar` instead.".to_string()),
);
let lines = cell.display_lines(80);
let rendered = render_lines(&lines);
assert_eq!(
rendered,
vec![
"⚠ Feature flag `foo`".to_string(),
"Use flag `bar` instead.".to_string(),
]
);
}
}