From 15cab964f3494b77159caaea289e17e1596e0720 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Sat, 4 Jul 2026 15:31:14 +0300 Subject: feat: emit layout update events for runtime layout changes --- src/app/api/layouts.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/app/api/layouts.rs') diff --git a/src/app/api/layouts.rs b/src/app/api/layouts.rs index 044731a4..851221b4 100644 --- a/src/app/api/layouts.rs +++ b/src/app/api/layouts.rs @@ -207,6 +207,7 @@ impl App { }); } } + self.emit_layout_updated_event(ws_idx, new_tab_idx); let Some(layout) = self.layout_description(ws_idx, new_tab_idx) else { return encode_error(id, "layout_apply_failed", "new layout unavailable"); @@ -243,6 +244,7 @@ impl App { let Some(layout) = self.layout_description(ws_idx, tab_idx) else { return encode_error(id, "layout_not_found", "layout unavailable"); }; + self.emit_layout_updated_event(ws_idx, tab_idx); encode_success(id, ResponseResult::LayoutSplitRatioSet { layout }) } @@ -687,6 +689,12 @@ mod tests { panic!("expected split layout root"); }; assert!((ratio - 0.72).abs() < f32::EPSILON); + assert!(matches!( + &app.event_hub.events_after(0).last().expect("layout event").1.data, + EventData::LayoutUpdated { layout } + if layout.tab_id == app.public_tab_id(0, 0).unwrap() + && (layout.splits[0].ratio - 0.72).abs() < f32::EPSILON + )); } #[test] @@ -775,6 +783,12 @@ mod tests { second_pane.command, Some(vec!["sh".into(), "-c".into(), "true".into()]) ); + assert!(matches!( + &app.event_hub.events_after(0).last().expect("layout event").1.data, + EventData::LayoutUpdated { layout } + if layout.tab_id == app.public_tab_id(0, 0).unwrap() + && layout.panes.len() == 2 + )); shutdown_test_runtimes(&mut app); } -- cgit v1.2.3