feat(cmd): use new effects to improve command behavior

Update various commands to utilize the new AbortChain and CleanEmptyRecords
effects.

- CommitAndAdvance now pushes a mode change effect when aborting.
- ToggleRecordsMode now cleans up empty records upon exiting.
- EnterAdvance now emits AbortChain when at the bottom-right corner.

Co-Authored-By: fiddlerwoaroof/git-smart-commit (gemma-4-26B-A4B-it-UD-Q5_K_XL.gguf)
This commit is contained in:
Edward Langley
2026-04-15 23:42:44 -07:00
parent 489e2805e8
commit a900f147b5
3 changed files with 59 additions and 5 deletions

View File

@ -132,7 +132,10 @@ mod tests {
let mut m = Workbook::new("Test");
m.add_category("Region").unwrap();
m.model.category_mut("Region").unwrap().add_item("East");
m.model.category_mut("_Measure").unwrap().add_item("Revenue");
m.model
.category_mut("_Measure")
.unwrap()
.add_item("Revenue");
m.model.category_mut("_Measure").unwrap().add_item("Cost");
m.model.set_cell(
CellKey::new(vec![
@ -148,7 +151,8 @@ mod tests {
]),
CellValue::Number(600.0),
);
m.model.add_formula(parse_formula("Profit = Revenue - Cost", "_Measure").unwrap());
m.model
.add_formula(parse_formula("Profit = Revenue - Cost", "_Measure").unwrap());
let layout = make_layout(&m);
let reg = make_registry();
@ -408,8 +412,15 @@ impl Cmd for ToggleRecordsMode {
let is_records = ctx.layout.is_records_mode();
if is_records {
// Navigate back to the previous view (restores original axes)
return vec![Box::new(effect::ViewBack), effect::set_status("Pivot mode")];
// Leaving records mode: clean up any records with empty CellKeys
// (produced by AddRecordRow when no page filters are set) before
// restoring the previous view. This is the inverse of `SortData`
// that runs on entry.
return vec![
Box::new(effect::CleanEmptyRecords),
Box::new(effect::ViewBack),
effect::set_status("Pivot mode"),
];
}
let mut effects: Vec<Box<dyn Effect>> = Vec::new();