Crash reports: keep component.activate in the journal (#5079) (#5121)

* claim: #5079

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Crash journal keeps component.activate (#5079)

Activating a component changes only the session's active component and
occurrence path, not the design, so the journal dropped the command and a
crash report's replay built later parts under the previously active
component. The journal now also keeps a command that changes either.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ahmetalpcelik
2026-10-23 15:35:54 +00:00
committed by GitHub
parent e5dffc7052
commit 4bdeaacde6
2 changed files with 34 additions and 0 deletions
+30
View File
@@ -75,6 +75,15 @@ fn child() {
"abort" => {
let _ = s.execute("diagnostics.crash_test", &json!({"mode": "abort"}));
}
// Back to the root between two components: only the session's active component changes.
"components" => {
s.execute("component.create", &json!({"name": "Tray"})).unwrap();
s.execute("solid.box", &json!({"length": 5, "width": 5, "height": 5})).unwrap();
s.execute("component.activate", &json!({"component": "root"})).unwrap();
s.execute("component.create", &json!({"name": "Bracket"})).unwrap();
s.execute("solid.box", &json!({"length": 4, "width": 4, "height": 4})).unwrap();
let _ = s.execute("diagnostics.crash_test", &json!({"mode": "abort"}));
}
_ => {}
}
end_session();
@@ -205,6 +214,27 @@ fn render_settings_survive_unclean_exit_and_journal_replay() {
let _ = fs::remove_dir_all(&d);
}
#[test]
fn activating_a_component_is_journaled_so_the_replay_builds_in_the_same_component() {
let d = fresh_dir("components");
assert!(!run_child(&d, "components").1);
assert!(run_child(&d, "none").1);
let (_, report) = only_report(&d);
let replay: Value = serde_json::from_slice(&fs::read(report["replay_path"].as_str().unwrap()).unwrap()).unwrap();
let commands = replay["commands"].as_array().unwrap();
assert_eq!(commands.iter().filter(|c| c["command"] == "component.activate").count(), 1, "{replay}");
let mut recovered = Session::default();
for command in commands {
let id = command["command"].as_str().unwrap();
if id != "diagnostics.crash_test" {
recovered.execute(id, &command["params"]).unwrap();
}
}
let bracket = recovered.doc.components.iter().find(|c| c.name == "Bracket").unwrap();
assert_eq!(bracket.parent, 0, "the Bracket was made under the root");
let _ = fs::remove_dir_all(&d);
}
#[test]
fn a_crash_while_starting_up_names_the_step_and_the_renderer() {
let d = fresh_dir("startup");
+4
View File
@@ -860,6 +860,8 @@ impl Session {
active_sketch: self.active_sketch,
pending_moves: self.pending_moves.clone(),
};
// Where new geometry goes: not in the design, but a replay needs it (component.activate).
let active_before = (self.active_component, self.active_occurrence_path.clone());
let null = Value::Object(Default::default());
let params = if params.is_null() { &null } else { params };
let given = params;
@@ -898,6 +900,8 @@ impl Session {
let changed = !Arc::ptr_eq(&self.doc, &before.doc)
|| self.active_sketch != before.active_sketch
|| self.pending_moves != before.pending_moves
|| self.active_component != active_before.0
|| self.active_occurrence_path != active_before.1
|| spec.id.starts_with("select.");
crash::command_done(self.crash_journal, changed, &before.doc, after, spec.id, given, failed.map_or(Ok(()), Err));
}