fix(cli): avoid duplicate compaction error prefix

This commit is contained in:
Release Repro 2026-07-24 21:24:31 -04:00
parent 7eef7652d3
commit af647aba4b
No known key found for this signature in database
2 changed files with 22 additions and 2 deletions

View file

@ -1,6 +1,7 @@
use std::convert::TryFrom;
use chrono::{DateTime, Utc};
use fabro_agent::Error as AgentError;
use fabro_types::{BilledModelUsage, EventBody, RunEvent};
use fabro_util::error;
use fabro_workflow::event::RunNoticeLevel;
@ -433,8 +434,11 @@ pub(super) fn from_json_line(line: &str) -> Option<ProgressEvent> {
}
fn display_compaction_error(value: &Value) -> Option<String> {
let error = serde_json::from_value::<fabro_agent::Error>(value.clone()).ok()?;
matches!(&error, fabro_agent::Error::Compaction(_)).then(|| error.to_string())
let error = serde_json::from_value::<AgentError>(value.clone()).ok()?;
match error {
AgentError::Compaction(error) => Some(error.to_string()),
_ => None,
}
}
fn display_value(value: &Value) -> Option<String> {

View file

@ -712,6 +712,22 @@ mod tests {
assert!(ui.stage.active_stages["s1"].compaction_bar.is_none());
}
#[test]
fn plain_compaction_failure_snapshot() {
let (mut ui, buffer) = capture_ui(false);
emit(
&mut ui,
agent_event("s1", AgentEvent::Error {
error: fabro_agent::Error::Compaction(fabro_agent::CompactionError::EmptySummary {
summarized_turn_count: 14,
}),
}),
);
insta::assert_snapshot!(rendered(&buffer), @" ✗ compaction failed: generated summary was empty after trimming; refused to replace 14 turns and left history intact");
}
#[test]
fn handle_json_line_ignores_invalid_json() {
let (mut ui, buffer) = capture_ui(false);