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(