From 2d136f1ff7084dfbf4cdb43ab33b8c375d8d5a32 Mon Sep 17 00:00:00 2001 From: Brian Krabach Date: Wed, 15 Apr 2026 21:25:13 -0700 Subject: [PATCH] feat: close flyout when targeted session disappears --- muxplex/frontend/app.js | 10 ++++++++++ muxplex/tests/test_frontend_js.py | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/muxplex/frontend/app.js b/muxplex/frontend/app.js index 6a5e010..46a18b8 100644 --- a/muxplex/frontend/app.js +++ b/muxplex/frontend/app.js @@ -1384,6 +1384,16 @@ function renderGrid(sessions) { var emptyState = $('empty-state'); var filterBar = $('filter-bar'); + // Close flyout if the targeted session no longer exists + if (_flyoutSessionKey) { + var flyoutStillExists = (sessions || []).some(function(s) { + return (s.sessionKey || s.name) === _flyoutSessionKey; + }); + if (!flyoutStillExists) { + closeFlyoutMenu(); + } + } + var visible = getVisibleSessions(sessions); if (visible.length === 0) { diff --git a/muxplex/tests/test_frontend_js.py b/muxplex/tests/test_frontend_js.py index 998df7c..e9ecd6b 100644 --- a/muxplex/tests/test_frontend_js.py +++ b/muxplex/tests/test_frontend_js.py @@ -3953,3 +3953,14 @@ def test_render_grid_has_add_sessions_affordance() -> None: assert "add-sessions" in fn_body.lower() or "openAddSessionsPanel" in fn_body, ( "renderGrid must render an 'Add Sessions' affordance for user views" ) + + +# ─── Task 12: Session death detection ──────────────────────────────────────── + + +def test_render_grid_closes_stale_flyout() -> None: + """renderGrid must close the flyout if the targeted session no longer exists.""" + fn_body = _JS.split("function renderGrid")[1].split("\nfunction ")[0] + assert "_flyoutSessionKey" in fn_body or "closeFlyoutMenu" in fn_body, ( + "renderGrid must check if the flyout's target session still exists and close if not" + )