From df26e733145fe002e2262c5bf1587da639dfddb9 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Fri, 6 Mar 2026 18:55:36 -0500 Subject: [PATCH] fix: Add missing parse_history_entries function to models.py --- src/models.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/models.py b/src/models.py index a546f08..ce89f37 100644 --- a/src/models.py +++ b/src/models.py @@ -31,6 +31,29 @@ AGENT_TOOL_NAMES = [ "py_get_hierarchy" ] +def parse_history_entries(history_strings: list[str], roles: list[str]) -> list[dict[str, Any]]: + """Parse stored history strings back to disc entry dicts.""" + import re + entries = [] + for raw in history_strings: + ts = "" + rest = raw + if rest.startswith("@"): + nl = rest.find("\n") + if nl != -1: + ts = rest[1:nl] + rest = rest[nl + 1:] + known = roles or ["User", "AI"] + role_pat = re.compile(r"^(" + "|".join(re.escape(r) for r in known) + r"):", re.IGNORECASE) + match = role_pat.match(rest) + role = match.group(1) if match else "User" + if match: + content = rest[match.end():].strip() + else: + content = rest + entries.append({"role": role, "content": content, "collapsed": False, "ts": ts}) + return entries + @dataclass class Ticket: """