Merge pull request #338 from dzivkovi/fix/windows-save-path-footer

fix(render): use forward slashes in save-path footer for Windows
This commit is contained in:
Trevin Chow
2026-05-17 00:25:45 -07:00
committed by GitHub
2 changed files with 27 additions and 2 deletions
+2 -2
View File
@@ -195,9 +195,9 @@ def compute_save_path_display(save_dir: str, topic: str, suffix: str, emit: str)
try: try:
home = _Path.home().resolve() home = _Path.home().resolve()
relative = raw.relative_to(home) relative = raw.relative_to(home)
return f"~/{relative}" return f"~/{relative.as_posix()}"
except ValueError: except ValueError:
return str(raw) return raw.as_posix()
def read_synthesis_file(path: str) -> str: def read_synthesis_file(path: str) -> str:
+25
View File
@@ -1,6 +1,7 @@
# ruff: noqa: E402 # ruff: noqa: E402
import json import json
import io import io
import shutil
import tempfile import tempfile
import subprocess import subprocess
import sys import sys
@@ -143,6 +144,30 @@ class CliV3Tests(unittest.TestCase):
_, kwargs = write_text.call_args _, kwargs = write_text.call_args
self.assertEqual("utf-8", kwargs.get("encoding")) self.assertEqual("utf-8", kwargs.get("encoding"))
def test_compute_save_path_display_uses_posix_slashes_under_home(self):
# Regression: f"~/{relative}" stringified pathlib.Path with the
# OS-native separator, producing "~/Documents\\Last30Days\\..." on
# Windows that no shell or File Explorer could open. The fix is
# f"~/{relative.as_posix()}" which forces forward slashes regardless
# of host OS. On POSIX hosts this asserts the contract for
# cross-platform safety; on Windows hosts it would fail without the fix.
real_home = Path.home()
tmp_under_home = Path(tempfile.mkdtemp(prefix="l30d_save_path_", dir=str(real_home)))
try:
save_dir = tmp_under_home / "Documents" / "Last30Days"
save_dir.mkdir(parents=True, exist_ok=True)
display = cli.compute_save_path_display(
str(save_dir), "british airways middle east", "v3", "compact"
)
self.assertTrue(display.startswith("~/"), f"Expected '~/' prefix, got: {display}")
self.assertNotIn("\\", display, f"Backslash leaked into display: {display}")
self.assertTrue(
display.endswith("british-airways-middle-east-raw-v3.md"),
f"Expected slug+suffix at end, got: {display}",
)
finally:
shutil.rmtree(tmp_under_home, ignore_errors=True)
def test_persist_report_updates_run_status_on_success_and_failure(self): def test_persist_report_updates_run_status_on_success_and_failure(self):
report = self.make_report() report = self.make_report()