Keep map theme state aligned
This commit is contained in:
@@ -22,6 +22,8 @@
|
|||||||
coverage without changing migrations or enabling automatic refresh.
|
coverage without changing migrations or enabling automatic refresh.
|
||||||
- Fixed map theme ranking so a newer official observation always wins over an
|
- Fixed map theme ranking so a newer official observation always wins over an
|
||||||
older snapshot with a marginally larger feature count.
|
older snapshot with a marginally larger feature count.
|
||||||
|
- Restored the active map theme from the selected dataset when returning to the
|
||||||
|
Map workspace, keeping viewport queries, legends and zoom guidance aligned.
|
||||||
|
|
||||||
## Sprint 222 Official source edition probes (2026-07-16)
|
## Sprint 222 Official source edition probes (2026-07-16)
|
||||||
|
|
||||||
|
|||||||
@@ -258,3 +258,12 @@ def test_map_theme_ranking_prefers_newer_observation_over_feature_count() -> Non
|
|||||||
assert observed_sort < feature_tiebreaker
|
assert observed_sort < feature_tiebreaker
|
||||||
assert "new Date(right.observed_at ?? 0).getTime()" in workspace
|
assert "new Date(right.observed_at ?? 0).getTime()" in workspace
|
||||||
assert "if (observedAtDifference !== 0) return observedAtDifference" in workspace
|
assert "if (observedAtDifference !== 0) return observedAtDifference" in workspace
|
||||||
|
|
||||||
|
|
||||||
|
def test_map_workspace_restores_theme_from_selected_dataset() -> None:
|
||||||
|
root = Path(__file__).resolve().parents[2]
|
||||||
|
workspace = (root / "frontend" / "src" / "components" / "map" / "MapWorkspace.tsx").read_text(encoding="utf-8")
|
||||||
|
assert "function themeIdForDataset(" in workspace
|
||||||
|
assert "useState<DataThemeId>(() =>" in workspace
|
||||||
|
assert "return themeIdForDataset(selectedDataset) ?? 'buildings'" in workspace
|
||||||
|
assert "const matchingThemeId = themeIdForDataset(selectedMapDataset)" in workspace
|
||||||
|
|||||||
@@ -9365,7 +9365,7 @@ Boundaries:
|
|||||||
Validation so far:
|
Validation so far:
|
||||||
- Backend compile and frontend typecheck passed.
|
- Backend compile and frontend typecheck passed.
|
||||||
- Source-catalog plus governed-refresh focused suite passed: 20 tests.
|
- Source-catalog plus governed-refresh focused suite passed: 20 tests.
|
||||||
- Full `scripts/run_readiness_check.sh` passed: 780 backend tests, 110
|
- Full `scripts/run_readiness_check.sh` passed: 781 backend tests, 110
|
||||||
documented route contracts, one Alembic head, frontend typecheck/build and
|
documented route contracts, one Alembic head, frontend typecheck/build and
|
||||||
all packaged smoke checks.
|
all packaged smoke checks.
|
||||||
- Live Tower staging completed all 112 municipality/theme partitions for
|
- Live Tower staging completed all 112 municipality/theme partitions for
|
||||||
@@ -9379,6 +9379,10 @@ Validation so far:
|
|||||||
- Live browser validation exposed and fixed additive theme ranking where two
|
- Live browser validation exposed and fixed additive theme ranking where two
|
||||||
extra old water features could outweigh a newer observation date. Ranking is
|
extra old water features could outweigh a newer observation date. Ranking is
|
||||||
now priority, observation date, import date, then feature-count tie-breaker.
|
now priority, observation date, import date, then feature-count tie-breaker.
|
||||||
|
- Post-deploy browser validation also exposed a stale map-theme remount state:
|
||||||
|
returning from Status to Map could retain the Water legend while the viewport
|
||||||
|
query and zoom guidance reverted to Buildings. Map state now initializes from
|
||||||
|
the selected persisted dataset so all four signals remain aligned.
|
||||||
|
|
||||||
Next:
|
Next:
|
||||||
- Run the full release gate, deploy to Tower, execute a live read-only plan and
|
- Run the full release gate, deploy to Tower, execute a live read-only plan and
|
||||||
|
|||||||
@@ -308,6 +308,12 @@ function pickThemeDataset(
|
|||||||
return candidates[0] ?? null
|
return candidates[0] ?? null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function themeIdForDataset(dataset: DatasetCreateResponse | null): DataThemeId | null {
|
||||||
|
return dataset
|
||||||
|
? DATA_THEMES.find((theme) => datasetMatchesTheme(dataset, theme))?.id ?? null
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
|
||||||
function temporalSeriesLabel(items: DatasetCreateResponse[]): string {
|
function temporalSeriesLabel(items: DatasetCreateResponse[]): string {
|
||||||
const configuredLabel = items.find((item) => typeof item.source_metadata?.['temporal_series_label'] === 'string')
|
const configuredLabel = items.find((item) => typeof item.source_metadata?.['temporal_series_label'] === 'string')
|
||||||
?.source_metadata?.['temporal_series_label']
|
?.source_metadata?.['temporal_series_label']
|
||||||
@@ -774,7 +780,10 @@ export function MapWorkspace({
|
|||||||
onClearQualityEvidence,
|
onClearQualityEvidence,
|
||||||
}: MapWorkspaceProps): JSX.Element {
|
}: MapWorkspaceProps): JSX.Element {
|
||||||
const [advancedMode, setAdvancedMode] = useState(false)
|
const [advancedMode, setAdvancedMode] = useState(false)
|
||||||
const [activeThemeId, setActiveThemeId] = useState<DataThemeId>('buildings')
|
const [activeThemeId, setActiveThemeId] = useState<DataThemeId>(() => {
|
||||||
|
const selectedDataset = availableMapDatasets.find((dataset) => dataset.id === selectedMapDatasetId) ?? null
|
||||||
|
return themeIdForDataset(selectedDataset) ?? 'buildings'
|
||||||
|
})
|
||||||
const {
|
const {
|
||||||
themeInsights,
|
themeInsights,
|
||||||
themeInsightsLoading: themeResultsLoading,
|
themeInsightsLoading: themeResultsLoading,
|
||||||
@@ -1093,9 +1102,9 @@ export function MapWorkspace({
|
|||||||
if (!selectedMapDataset) {
|
if (!selectedMapDataset) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const matchingTheme = DATA_THEMES.find((theme) => datasetMatchesTheme(selectedMapDataset, theme))
|
const matchingThemeId = themeIdForDataset(selectedMapDataset)
|
||||||
if (matchingTheme) {
|
if (matchingThemeId) {
|
||||||
setActiveThemeId(matchingTheme.id)
|
setActiveThemeId(matchingThemeId)
|
||||||
}
|
}
|
||||||
}, [selectedMapDataset])
|
}, [selectedMapDataset])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user