Trace path: seed Compose from the route on screen, not the empty spec

The composer opened seeded from the stored spec, which is empty until a path
is first composed — so the very first Compose opened blank even though the
screen was already showing the auto-resolved route (the last stored walk, or
the device/history route in target mode). Seed the composer from the visible
route instead (the effective spec: the composed one if it stands, else the
auto plan), so opening Compose always resumes from what the user sees.

The adopt test still compares against the stored spec, so re-confirming an
auto plan verbatim just pins it — the same outcome as adopting it by hand.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Opus 4.8 committed 2026-07-14 03:07:46 -04:00
1 parent 53b7aa5724
commit 5a63574a9e
2 files changed
+36 -3

No files matched your search

+12 -3
View File
@@ -479,14 +479,18 @@ class TraceScreen(Screen):
elif key == "samples":
self._open_flow(self._pick_samples)
elif key == "compose":
self._open_flow(self._compose_path)
# Seed the composer with the route the screen is showing — the composed
# spec if one stands, else the auto-resolved plan — not the bare
# (empty on first open) stored spec, so opening Compose always resumes
# from the visible route.
self._open_flow(self._compose_path, seed=self._effective_spec()[0])
elif key == "explore" and self._explore is not None:
self._open_flow(self._explore)
elif key == "back":
self.cancel()
self.resolve(None)
def _open_flow(self, flow: PathFlow) -> None:
def _open_flow(self, flow: PathFlow, seed: Optional[str] = None) -> None:
"""Float a path-picking flow over the screen (one at a time, not mid-trace).
The composer, the scenario explorer, and the width picker all resolve the
@@ -496,6 +500,11 @@ class TraceScreen(Screen):
Args:
flow: The dialog flow to run with the current spec.
seed: The spec handed to the flow, when it should differ from the stored
one — the composer seeds from the *visible* route (the auto plan when
no spec stands), so it never opens blank over a shown route. The
adopt test still compares against the stored spec, so re-confirming an
auto plan verbatim simply pins it, exactly like adopting it by hand.
"""
if self._dialog_open or self._running:
return
@@ -503,7 +512,7 @@ class TraceScreen(Screen):
async def run() -> None:
try:
spec = await flow(self._path_spec)
spec = await flow(self._path_spec if seed is None else seed)
if spec is not None and spec.strip() != self._path_spec:
# A different spec is a different measurement: the aggregates,
# per-hop medians, and log all belong to the old route, so the
+24
View File
@@ -362,6 +362,30 @@ async def test_trace_screen_composer_updates_the_spec() -> None:
assert body.count("3d") >= 2
async def test_compose_seeds_from_the_visible_route_not_the_empty_spec() -> None:
"""Opening Compose resumes from the route on screen, not the stored spec.
On first open nothing has been composed, but the screen already shows the
auto-resolved plan; the composer must open seeded with that plan's hops so the
user edits the route they see rather than starting from a blank path.
"""
asked: list[str] = []
async def compose(current: str): # noqa: ANN001
asked.append(current)
return None # observe the seed only; leave the (auto) plan untouched
screen, _ = _trace_screen(
mode="path", compose_path=compose,
auto_spec=lambda: "3d,f2", auto_source="last walk",
)
screen._index = screen._actions.index("compose")
screen.handle("enter")
await asyncio.sleep(0)
assert asked == ["3d,f2"] # seeded from the visible auto plan, not ""
assert screen._path_spec == "" # None keeps the plan auto (nothing pinned)
async def test_trace_screen_explore_adopts_a_scenario_path() -> None:
"""Committing Explore paths runs the flow; adopting sets the spec, None keeps it."""