Files
hermes-agent/apps
David Metcalfe aed18fdfbf fix(desktop): keep MEDIA attachments and prose when a turn also generated an image
stripGeneratedImageEchoes stripped EVERY markdown image and #media: link
from a final message whenever an image_generate tool result was present
in the same turn's parts. A completed response that carried a MEDIA:
directive for a different file lost its attachment link entirely, and a
message whose only content was such a directive rendered blank after the
empty text part was dropped by dedupeGeneratedImageEchoesInParts
(#80621).

Scope the strip to echoes of the actual generated source:
- markdown images are removed only when the src matches a source,
  with a lookahead so a longer path (a.png.bak) is not eaten by a
  prefix source (a.png)
- #media: links are removed only when the encoded path matches a
  source, anchored to the closing paren so prefix paths survive
- bare-path stripping no longer matches inside markdown link
  destinations, so [label](/tmp/a.png) is not corrupted to [label]()

Also wrap parseMarkdownIntoBlocksCached in a lexer-throw fallback so a
single pathological message cannot unwind through MessageRenderBoundary
to the root boundary and blank the whole transcript.

Closes #80621

Rebased onto current main: the strip keeps main's whitespace semantics — main deliberately stopped normalizing whole-document whitespace through media extraction (3e1b7af21b), so the same-file echo test now expects the two-space gap the removed image leaves instead of the old collapsed form. The scoped strip itself is unchanged.
2026-09-30 23:09:23 -05:00
..