From 75126a7eefca38cd068008ffa9cdf9aee93bbfbf Mon Sep 17 00:00:00 2001 From: eowca <4008965+eowca@users.noreply.github.com> Date: Thu, 26 Nov 2026 10:08:25 +0100 Subject: [PATCH 1/2] Read task handoffs as UTF-8 Architecture-Review: unchanged; task handoff reads match the writer without changing delivery interfaces. Co-Authored-By: Codex --- src/loopzero/worktree.py | 2 +- tests/test_cli.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/loopzero/worktree.py b/src/loopzero/worktree.py index 444c8d5e..755f8e79 100644 --- a/src/loopzero/worktree.py +++ b/src/loopzero/worktree.py @@ -244,7 +244,7 @@ def task_text(wt: Path) -> str: "or recreate the file using the handoff template at " "https://github.com/feder-positronics/loop-zero/blob/main/core/HANDOFF.md" ) - return task.read_text() + return task.read_text(encoding="utf-8") def base_sha(wt: Path) -> str: diff --git a/tests/test_cli.py b/tests/test_cli.py index 5c136d5d..d1140d03 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1049,12 +1049,12 @@ def test_pr_replaces_closed_never_merged_pr(wt: Path, gh: FakeGh, capsys) -> Non assert run(capsys, "pr") == (0, URL + "\n", "") -def test_pr_title_prefers_human_heading(wt: Path, gh: FakeGh, capsys) -> None: - task = wt / ".loopzero" / "task.md" - task.write_text("## Objective\nx\n\n# Add the feature flag\n") - assert cli._pr_title(wt, "lz/t1") == "Add the feature flag" - task.write_text("## Objective\nonly sections\n") - assert cli._pr_title(wt, "lz/t1") == "lz/t1" +@pytest.mark.parametrize("title", ["", "Zażółć gęślą jaźń"]) +def test_pr_title_prefers_human_heading(wt: Path, monkeypatch, title) -> None: + task, read_text = wt / ".loopzero" / "task.md", Path.read_text + monkeypatch.setattr(Path, "read_text", lambda path, encoding="ascii", **kw: read_text(path, encoding, **kw)) + task.write_text(f"## Objective\nZażółć gęślą jaźń\n\n# {title}\n", encoding="utf-8") + assert cli._pr_title(wt, "lz/t1") == (title or "lz/t1") @pytest.mark.parametrize("name,value", [ From 7adb2065e88c4ae7d6009f10c8bd0263f6d184e8 Mon Sep 17 00:00:00 2001 From: eowca <4008965+eowca@users.noreply.github.com> Date: Thu, 26 Nov 2026 10:12:40 +0100 Subject: [PATCH 2/2] Keep the fallback handoff fixture section-only Co-Authored-By: Codex --- tests/test_cli.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index d1140d03..95b38355 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1049,12 +1049,12 @@ def test_pr_replaces_closed_never_merged_pr(wt: Path, gh: FakeGh, capsys) -> Non assert run(capsys, "pr") == (0, URL + "\n", "") -@pytest.mark.parametrize("title", ["", "Zażółć gęślą jaźń"]) -def test_pr_title_prefers_human_heading(wt: Path, monkeypatch, title) -> None: +@pytest.mark.parametrize(("heading", "expected"), [("", "lz/t1"), ("\n# Zażółć gęślą jaźń\n", "Zażółć gęślą jaźń")]) +def test_pr_title_prefers_human_heading(wt: Path, monkeypatch, heading, expected) -> None: task, read_text = wt / ".loopzero" / "task.md", Path.read_text monkeypatch.setattr(Path, "read_text", lambda path, encoding="ascii", **kw: read_text(path, encoding, **kw)) - task.write_text(f"## Objective\nZażółć gęślą jaźń\n\n# {title}\n", encoding="utf-8") - assert cli._pr_title(wt, "lz/t1") == (title or "lz/t1") + task.write_text(f"## Objective\nZażółć gęślą jaźń\n{heading}", encoding="utf-8") + assert cli._pr_title(wt, "lz/t1") == expected @pytest.mark.parametrize("name,value", [