From a770f559cd68ba32c89177fdacabdfe30f3a1837 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Martineau Date: Wed, 22 Jul 2026 20:34:15 -0400 Subject: [PATCH] Node detail: make the Back row leave, like Esc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Committing the Back action resolved a bare "back" token, but the opener's action loop only breaks on CANCEL (or None) and has no "back" branch — so it fell through and simply re-showed the page. Back appeared inert while Esc worked. Resolve CANCEL for the Back row so it leaves the screen on the same path Esc does, back to the contact list. Co-Authored-By: Claude Opus 4.8 --- meshterm/ui/node_detail_screen.py | 5 ++++- tests/test_node_detail.py | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/meshterm/ui/node_detail_screen.py b/meshterm/ui/node_detail_screen.py index c9df375..ae32774 100644 --- a/meshterm/ui/node_detail_screen.py +++ b/meshterm/ui/node_detail_screen.py @@ -313,7 +313,10 @@ class NodeDetailScreen(Screen): kind, payload = focus[self._row_index % n] if kind == "action": assert isinstance(payload, _Action) - self.resolve(payload.key) + # Back leaves the page exactly as Esc does — it resolves the same + # CANCEL the opener's loop breaks on, not a "back" token the loop would + # ignore and re-show the page over. + self.resolve(CANCEL if payload.key == "back" else payload.key) # A route row is inert on Enter: selecting it (the highlight + graph) is the # whole interaction; the dedicated Trace row is what opens the trace flow. elif action in ("right", "tab"): diff --git a/tests/test_node_detail.py b/tests/test_node_detail.py index 638bb71..7b40ba0 100644 --- a/tests/test_node_detail.py +++ b/tests/test_node_detail.py @@ -411,6 +411,20 @@ def test_node_detail_screen_cursor_and_commit() -> None: assert resolved == ["timemachine", CANCEL] +def test_node_detail_back_row_leaves_like_escape() -> None: + """Committing the Back row resolves CANCEL — the same leave Esc does — not a stray token + the opener's loop would ignore and re-show the page over.""" + screen = _screen() + resolved: list = [] + screen.resolve = lambda value: resolved.append(value) # type: ignore[method-assign] + + screen.render_body(72) + screen.handle("down") # Trace -> Time machine + screen.handle("down") # Time machine -> Back + screen.handle("enter") + assert resolved == [CANCEL] + + def test_node_detail_screen_route_selection_arms_the_trace() -> None: """↑/↓ over the route rows moves the graph highlight and the spec a Trace would arm on.""" routes = _RoutesView(