The agent that turns websites into APIs!
fix(windows): recover readable history and gate live acceptance
kalil032104b35a3f54c9
diff --git a/src/reverse_api/messages.py b/src/reverse_api/messages.pyindex 696d36e..8e6125b 100644--- a/src/reverse_api/messages.py+++ b/src/reverse_api/messages.py@@ -66,13 +66,15 @@ class MessageStore:if not self.messages_path.exists():return []messages = []- with open(self.messages_path, encoding="utf-8") as f:+ # Decode each record independently: one corrupt/legacy-encoded line+ # must not make all the surrounding valid history unreadable.+ with open(self.messages_path, "rb") as f:for line in f:line = line.strip()if line:try:- messages.append(json.loads(line))- except json.JSONDecodeError:+ messages.append(json.loads(line.decode("utf-8")))+ except (json.JSONDecodeError, UnicodeDecodeError):continuereturn messagesdiff --git a/tests/test_windows_compatibility.py b/tests/test_windows_compatibility.pyindex 8074af2..6acf91f 100644--- a/tests/test_windows_compatibility.py+++ b/tests/test_windows_compatibility.py@@ -105,6 +105,14 @@ def test_invalid_utf8_config_and_history_recover(tmp_path):assert SessionManager(path).history == []+def test_corrupt_message_record_preserves_surrounding_history(tmp_path):+ store = MessageStore("mixed-history", str(tmp_path))+ first = json.dumps({"type": "prompt", "content": "中文"}, ensure_ascii=False).encode()+ last = json.dumps({"type": "thinking", "content": "🐍"}, ensure_ascii=False).encode()+ store.messages_path.write_bytes(first + b'\n{"content":"caf\xe9"}\ninvalid json\n' + last + b"\n")+ assert [message["content"] for message in store.load()] == ["中文", "🐍"]++@pytest.mark.parametrize(("platform", "env", "relative"),[diff --git a/tests/test_windows_runtime_e2e.py b/tests/test_windows_runtime_e2e.pyindex 1254aa4..f9d799f 100644--- a/tests/test_windows_runtime_e2e.py+++ b/tests/test_windows_runtime_e2e.py@@ -1,6 +1,6 @@"""Opt-in Windows acceptance with installed Chrome and the real OpenCode runtime.-Run on Windows CI (or opt in locally); no model or production site is accessed.+Run in the prepared live-windows job; no model or production site is accessed."""import asyncio@@ -17,8 +17,7 @@ import httpx2import pytestpytestmark = pytest.mark.skipif(- sys.platform != "win32"- or (os.environ.get("GITHUB_ACTIONS") != "true" and os.environ.get("RAE_WINDOWS_RUNTIME_E2E") != "1"),+ sys.platform != "win32" or os.environ.get("RAE_WINDOWS_RUNTIME_E2E") != "1",reason="opt-in native Windows runtime acceptance",)