fix(canvas): extractMessageText uses only first direct text field #343

Closed
fullstack-engineer wants to merge 2 commits from fix/canvas-extractMessageText into staging

2 Commits

Author SHA1 Message Date
9279f9292b fix(canvas/test): Spinner tests use getAttribute for SVG className
Some checks failed
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 11s
sop-tier-check / tier-check (pull_request) Failing after 12s
audit-force-merge / audit (pull_request) Has been skipped
SVG elements in jsdom expose className as SVGAnimatedString (an object),
not a plain string. Calling toContain() on an object produces a confusing
"expected [] to include" error. Fix: use getAttribute("class") instead.

Also adds afterEach(cleanup) for DOM isolation between tests.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 21:22:44 +00:00
a832bd805c fix(canvas): extractMessageText uses only first direct text field
Some checks failed
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 8s
sop-tier-check / tier-check (pull_request) Failing after 12s
Bug: `extractMessageText` in ConversationTraceModal joined text from ALL
result.parts[].text + result.parts[].root.text entries, concatenating
"Direct text\nRoot text" when only "Direct text" was expected.

Fix: scan all parts for the first direct `text` field and return it.
Only fall back to `parts[0].root.text` when no direct text exists.
Subsequent parts' root.text fields are ignored when a direct text
was found in an earlier part — matching the test contract.

Fixes: ConversationTraceModal.test.tsx "prefers parts[].text over
parts[].root.text" (test was failing with concat output).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 21:18:55 +00:00