From 96156a84ed614effb30b439c9e90f44b1f10aba8 Mon Sep 17 00:00:00 2001 From: Jer Miller Date: Sun, 26 Jul 2026 20:28:25 -0600 Subject: [PATCH] fix(import): show current source names in the import list The import list now derives known source display names from SOURCE_METADATA at read time, so list rows use the current app copy instead of stale recorded labels. Unknown source types and records without a source type keep their recorded display value, and the stored import record is left intact. Detail views can still show the recorded provenance from the saved import metadata. Co-Authored-By: Claude Opus 5 (1M context) --- solstone/apps/import/routes.py | 11 ++++ solstone/apps/import/tests/test_routes.py | 72 +++++++++++++++++++++++ tests/baselines/api/import/list.json | 8 +-- 3 files changed, 87 insertions(+), 4 deletions(-) diff --git a/solstone/apps/import/routes.py b/solstone/apps/import/routes.py index dca9507cc..c959f5c6b 100644 --- a/solstone/apps/import/routes.py +++ b/solstone/apps/import/routes.py @@ -210,6 +210,14 @@ SOURCE_METADATA = [ ] +def _source_display_name(source_type: str | None) -> str | None: + """Return the current display name for a known source type, else None.""" + if not source_type: + return None + entry = next((s for s in SOURCE_METADATA if s["name"] == source_type), None) + return entry["display_name"] if entry else None + + def _source_metadata_payload(source: dict[str, Any]) -> dict[str, Any]: payload = dict(source) payload["icon_svg"] = lucide_svg(source["icon"]) @@ -811,6 +819,9 @@ def import_list() -> Any: journal_root=Path(state.journal_root), timestamp=timestamp, ) + display_name = _source_display_name(import_data.get("source_type")) + if display_name: + import_data["source_display"] = display_name # Calculate status based on processing state # Default status diff --git a/solstone/apps/import/tests/test_routes.py b/solstone/apps/import/tests/test_routes.py index dd716cbd3..ade4c5bd7 100644 --- a/solstone/apps/import/tests/test_routes.py +++ b/solstone/apps/import/tests/test_routes.py @@ -161,6 +161,15 @@ def client(tmp_path, monkeypatch): return app.test_client() +def _seed_imported_json(journal: Path, timestamp: str, payload: dict) -> None: + import_dir = journal / "imports" / timestamp + import_dir.mkdir(parents=True, exist_ok=True) + (import_dir / "imported.json").write_text( + json.dumps(payload) + "\n", + encoding="utf-8", + ) + + def test_import_index_serves_injected_spa_shell(client): response = client.get("/app/import/") @@ -212,6 +221,69 @@ def test_import_sources_emit_icon_svg_not_emoji(client): assert "