Conversation
split_continuous_references applied two sequential str.replace passes,
one for ', ' and one for ','. The first matching pass rewrote the
content substring, so the second pass found nothing: a tag mixing both
styles ('[a,b, c]') kept its earlier references merged on the streaming
chat path. Split on every comma with re.sub(r',\\s*', ...)' instead.
Red/green verified: the mixed-separator test fails against the old
implementation and passes with the fix.
🤖 Open Code ReviewTarget: PR #2418 ✅ OpenCodeReview: Review complete: 0 finding(s) across 2 selected item(s). Generated by cloud-assistant via Open Code Review. |
✅ Automated Test Results: PASSEDAll tests passed (5/5 executed). memos_python_core/changed-repo-python: 5/5. Duration: 9s [advisory, non-gating] AI-generated tests on branch test/auto-gen-ff4aba06e30b05df-20260928112516: 96/96 passed — these do NOT affect the PR verdict; review the branch manually. Branch: |
split_continuous_references rewrote ANY single bracketed comma list on the streaming chat path: mathematical or plain text like 'interval [x, y]' came out as 'interval [x][y]'. Restrict the split to content with the reference-tag shape (a numeric id before a colon in every element), which is the documented input format. Red/green verified: the new test fails against the old implementation ([x, y] rewritten to [x][y]) and passes with the fix. Signed-off-by: simpleqt <89645338+simpleqt@users.noreply.github.com>
|
Added a second commit (same theme): the split previously rewrote any bracketed comma list, so ordinary text like |
✅ Automated Test Results: PASSEDAll tests passed (6/6 executed). memos_python_core/changed-repo-python: 6/6. Duration: 8s [advisory, non-gating] AI-generated tests on branch test/auto-gen-5d9195458007c54b-20260928145304: 84/84 passed — these do NOT affect the PR verdict; review the branch manually. Branch: |
Description
Fixes #2417
split_continuous_referencesturned[1:aaa, 4:bbb]into[1:aaa][4:bbb]via two sequentialstr.replacepasses — one for", ", one for",". The first matching pass rewrote the content substring, so the second pass could no longer find the original: a tag mixing both styles kept its earlier references merged, and the streaming chat path (api/handlers/chat_handler.py→process_streaming_references_complete) then rendered them as literal text instead of reference tags.Implementation: split the bracket content with
re.sub(r",\\s*", "][", ...)in a single pass; the redundant innerimport reinprocess_streaming_references_completemoved to module level. No dependency changes.Type of change
How Has This Been Tested?
New
tests/mem_os/test_reference_utils.pycovers spaced, tight, and mixed separators, surrounding-text preservation, and the non-reference early returns. Red/green verified:test_mixed_separatorsfails against unpatchedmainand passes with the fix; the other four pin unchanged behavior.ruff checkandruff format --checkpass on both touched files.Checklist