Match the todo server's note title in dedup

The real server lists a new note as "<repo name> todos: <title>",
so the exact-title check never found the open task and a repeat
failure would have filed a duplicate. Seen while filing the one real
verification task. The fake server now titles notes the same way.

Todo: 85af719b

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Krzysztof Rudnicki 2026-11-22 17:12:58 +01:00
parent 9311405bc8
commit b29b708fb8
2 changed files with 25 additions and 3 deletions

View File

@ -142,10 +142,17 @@ def _parse(ctype: str, body: str) -> dict[str, Any]:
def _open_task(listing: str, title: str) -> str | None:
"""The id of an open task in *listing* titled exactly *title*."""
"""The id of an open task in *listing* titled *title*.
The server lists a new note as ``<repo name> todos: <title>``, so the
title matches exactly or as that suffix.
"""
for row in listing.splitlines():
parts = row.split("\t")
if len(parts) >= _COLUMNS and re.sub(r"^#+\s*", "", parts[4].strip()) == title:
if len(parts) < _COLUMNS:
continue
listed = re.sub(r"^#+\s*", "", parts[4].strip())
if listed == title or listed.endswith(f": {title}"):
return parts[0]
return None

View File

@ -42,8 +42,18 @@ class FakeTodo(ThreadingHTTPServer):
"""Answer one tool call the way the real server words it."""
self.calls.append(name)
if name == "list_tasks":
# The real server titles a new note "<repo name> todos: <title>".
rows = [
f"{t['id'][:8]}\ttodo\t{t['priority']}\t{t['repo']}\t{t['title']}\tclaude"
"\t".join(
(
t["id"][:8],
"todo",
t["priority"],
t["repo"],
_listed(t),
"claude",
)
)
for t in self.tasks
if t["repo"] == args.get("repo")
]
@ -55,6 +65,11 @@ class FakeTodo(ThreadingHTTPServer):
return f"added {task['id']}\n{task['id'][:8]}\ttodo\tmedium\t{task['repo']}"
def _listed(task: dict[str, Any]) -> str:
"""The title list_tasks shows for *task*, as the real server words it."""
return f"{task['repo'].split('/')[-1]} todos: {task['title']}"
class _Handler(BaseHTTPRequestHandler):
server: FakeTodo