From 774c888ca84b0f157211d402a55c241ac736dbaa Mon Sep 17 00:00:00 2001 From: Ahmed Allam Date: Wed, 9 Sep 2026 14:43:40 +0000 Subject: [PATCH] fix(tui): fingerprint report revisions by history length instead of second-resolution timestamp --- strix/interface/tui/runtime.py | 7 ++++++- tests/test_go_tui_runtime.py | 22 +++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/strix/interface/tui/runtime.py b/strix/interface/tui/runtime.py index 80e0f50f..a20960ce 100644 --- a/strix/interface/tui/runtime.py +++ b/strix/interface/tui/runtime.py @@ -49,6 +49,11 @@ if TYPE_CHECKING: logger = logging.getLogger(__name__) +def _revision_count(report: dict[str, Any]) -> int: + history = report.get("update_history") + return len(history) if isinstance(history, list) else 0 + + class GoTuiPreActivationError(RuntimeError): """A sidecar failure raised before the Go TUI activates.""" @@ -339,7 +344,7 @@ class GoTuiRuntime: if self.report_state is not None: usage = dict(self.report_state.get_total_llm_usage()) vulnerabilities = [ - (report.get("id", index), report.get("updated_at")) + (report.get("id", index), _revision_count(report)) if isinstance(report, dict) else index for index, report in enumerate(self.report_state.vulnerability_reports) diff --git a/tests/test_go_tui_runtime.py b/tests/test_go_tui_runtime.py index 3b27ef8a..afae99f1 100644 --- a/tests/test_go_tui_runtime.py +++ b/tests/test_go_tui_runtime.py @@ -1036,9 +1036,21 @@ def test_sync_fingerprint_tracks_report_revisions(tmp_path: Path) -> None: runtime.report_state.vulnerability_reports = [{"id": "vuln-0001", "title": "Old title"}] runtime.report_state.get_run_dir = lambda: tmp_path # type: ignore[method-assign] - before = runtime._runtime_sync_fingerprint() - runtime.report_state.vulnerability_reports[0].update( - {"title": "New title", "updated_at": "2026-09-09T10:00:00+00:00"} - ) + report = runtime.report_state.vulnerability_reports[0] + timestamp = "2026-09-09 10:00:00 UTC" - assert runtime._runtime_sync_fingerprint() != before + before = runtime._runtime_sync_fingerprint() + report.update( + { + "title": "New title", + "updated_at": timestamp, + "update_history": [{"timestamp": timestamp, "fields": ["title"]}], + } + ) + first_revision = runtime._runtime_sync_fingerprint() + assert first_revision != before + + report["title"] = "Newer title" + report["update_history"].append({"timestamp": timestamp, "fields": ["title"]}) + + assert runtime._runtime_sync_fingerprint() != first_revision