diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-04 15:31:14 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-04 16:51:10 +0300 |
| commit | 15cab964f3494b77159caaea289e17e1596e0720 (patch) | |
| tree | d9614056c26b0d148771a464fc2eb0f0cabc60a2 /src/app/api/layouts.rs | |
| parent | b78a8a5c565e66e7e5ba9a06d9cb7f3a771fc4b0 (diff) | |
feat: emit layout update events for runtime layout changes
Diffstat (limited to 'src/app/api/layouts.rs')
| -rw-r--r-- | src/app/api/layouts.rs | 14 |
1 files changed, 14 insertions, 0 deletions
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); } |
