split the map workspace into a view model and two views

MapWorkspace.tsx was 3.157 lines: a props interface, 1.200 lines of derived
state and handlers, and two complete render paths — the map-first explorer and
the advanced workbench behind it. It is now five modules, and the container is
nineteen lines that choose between the two.

The obstacle was the props signature. The explorer reads 97 derived values and
the workbench 40, so passing them individually would have produced a 97-field
interface — worse than the file it replaced. Extracting the derived state into
a hook that returns one object solves it: MapWorkspaceViewModel is
ReturnType<typeof useMapWorkspaceViewModel>, so the shape is derived from what
the hook actually produces and cannot drift from it. Each view then names two
typed objects, and the JSX moved unchanged.

The contract tests found the one place where widening a negative assertion is
wrong. "The map workspace performs no transport" was true of the old file and
false of the whole feature, because the hooks call the API by design. It is now
scoped to the presentational modules, which is what it always meant.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Jens
2026-08-22 22:38:25 +02:00
co-authored by Claude Opus 5
parent c4d873149b
commit c6837ec1b2
12 changed files with 3891 additions and 3263 deletions
@@ -1,4 +1,5 @@
from pathlib import Path
from tests.frontend_contract import read_feature
ROOT = Path(__file__).resolve().parents[2]
@@ -11,7 +12,7 @@ def read_text(relative_path: str) -> str:
def test_map_qa_result_exposes_quality_check_evidence_contract():
types = read_text("frontend/src/types.ts")
hook = read_text("frontend/src/hooks/useMapSelectionQa.ts")
workspace = read_text("frontend/src/components/map/MapWorkspace.tsx")
workspace = read_feature("map_workspace")
app = read_text("frontend/src/App.tsx")
assert "quality_check_id?: string" in types